我用-finstrument-functions
來產生進入和我的每個函數調用的退出信息,並使用點繪製它只是像上面。但是,我發現一個問題,在我的main
函數中,我創建了兩個線程,一個名爲driver_TASL,另一個是keyBoard_TASK。但在我生成的圖片中,看起來好像我的keyBoard_TASK
被driver_TASK
調用。它應該像這兩個任務由main
備註叫:我不能上傳圖片,所以我形容它下面:
我生成函數調用之後,它應該是這樣的:
main
通話driver_TASK
main
呼叫keyBoard_TASK
然而,就變成
main
呼叫driver_TASK
driver_TASK
呼叫keyboard_TASK
爲什麼keyBoard_TASK
被driver_TASK
叫什麼名字?應該由main
叫我認爲
在我的源代碼,我寫了他們喜歡(我刪除了一些代碼打印功能):
int main(/*@ unused @*/int argc, /*@ unused @*/char *argv[]) //comment for lint
{
int res;
pthread_t driver_thread, keyBoard_thread;
void *thread_result;
res = pthread_create(&driver_thread, NULL, driver_TASK, (void *)&_gDriverStatus);
if(res != 0)
{
perror("Thread Creation Failed");
exit(EXIT_FAILURE);
}
sleep(1);
res = pthread_create(&keyBoard_thread, NULL, keyBoard_TASK, (void *)&_gKeyStatus);
if(res != 0)
{
perror("Thread Creation Failed");
exit(EXIT_FAILURE);
}
res = pthread_join(driver_thread, &thread_result);
if(res != 0)
{
perror("Thread Join Failed");
exit(EXIT_FAILURE);
}
res = pthread_join(keyBoard_thread, &thread_result);
if(res != 0)
{
perror("Thread Join Failed");
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
我還附上我的自動點文件時,函數調用流程圖是由pvtace自動生成的
digraph DEMO {
main [shape=rectangle]
driver_TASK [shape=rectangle]
DDI_DRIVER_Probe [shape=rectangle]
_Driver_Clear [shape=ellipse]
_Driver [shape=ellipse]
DRIVER_Probe_Demo [shape=ellipse]
DDI_DRIVER_Init [shape=rectangle]
DRIVER_Init_Demo [shape=rectangle]
_DRIVER_Init_Demo [shape=ellipse]
DDI_DRIVER_Running [shape=rectangle]
DRIVER_Running_Demo [shape=rectangle]
_DRIVER_Running_Demo [shape=ellipse]
keyBoard_TASK [shape=rectangle]
main -> DBG_PrintColor [label="2 calls" fontsize="10"]
main -> driver_TASK [label="1 calls" fontsize="10"] //this is correct
driver_TASK -> DBG_PrintColor [label="6 calls" fontsize="10"]
driver_TASK -> DDI_DRIVER_Probe [label="1 calls" fontsize="10"]
driver_TASK -> DDI_DRIVER_Init [label="1 calls" fontsize="10"]
driver_TASK -> DDI_DRIVER_Running [label="1 calls" fontsize="10"]
driver_TASK -> keyBoard_TASK [label="1 calls" fontsize="10"] //this is not correct
DDI_DRIVER_Probe -> _Driver_Clear [label="1 calls" fontsize="10"]
DDI_DRIVER_Probe -> _Driver [label="1 calls" fontsize="10"]
DDI_DRIVER_Probe -> DRIVER_Probe_Demo [label="1 calls" fontsize="10"]
DDI_DRIVER_Init -> _Driver [label="1 calls" fontsize="10"]
DDI_DRIVER_Init -> DRIVER_Init_Demo [label="1 calls" fontsize="10"]
DRIVER_Init_Demo -> _DRIVER_Init_Demo [label="1 calls" fontsize="10"]
DDI_DRIVER_Running -> _Driver [label="1 calls" fontsize="10"]
DDI_DRIVER_Running -> DRIVER_Running_Demo [label="1 calls" fontsize="10"]
DRIVER_Running_Demo -> _DRIVER_Running_Demo [label="1 calls" fontsize="10"]
keyBoard_TASK -> DBG_PrintColor [label="6 calls" fontsize="10"]
}
你的問題到底是什麼? –
對不起,我不能上傳圖片... –
我的問題是爲什麼函數跟蹤器告訴我,'driver_TASK'調用的'keyBoard_TASK' –