關於gdb的細節是什麼,調試代碼時是否保存一個線程? 我在主線程中設置了退出標誌,並且在打印標誌之前我已經加入了其他線程。當我與參數「-g」 compling運行後用gdb調試版本,它看起來:有關gdb的細節是什麼,它是否擁有一個線程?
[Thread debugging using libthread_db enabled]
Input number of threads:5
Main thread id: 0xb7fda6c0,
[New Thread 0xb7fd9b70 (LWP 9276)]
[New Thread 0xb75d8b70 (LWP 9277)]
[New Thread 0xb6bd7b70 (LWP 9278)]
[New Thread 0xb61d6b70 (LWP 9279)]
[New Thread 0xb57d5b70 (LWP 9280)]
I am thread 0xb6bd7b70, myorder 2, thread_exit.
I am thread 0xb61d6b70, myorder 3, thread_exit.
I am thread 0xb7fd9b70, myorder 0, thread_exit.
I am thread 0xb57d5b70, myorder 4, thread_exit.
I am thread 0xb75d8b70, myorder 1, thread_exit.
[Thread 0xb61d6b70 (LWP 9279) exited]
[Thread 0xb6bd7b70 (LWP 9278) exited]
[Thread 0xb75d8b70 (LWP 9277) exited]
[Thread 0xb7fd9b70 (LWP 9276) exited]
Main: completed join with thread 0xb7fd9b70 having a status of 0
Main: completed join with thread 0xb75d8b70 having a status of 1
Main: completed join with thread 0xb6bd7b70 having a status of 2
Main: completed join with thread 0xb61d6b70 having a status of 3
Main: completed join with thread 0xb57d5b70 having a status of 4
Main: lock will be destroy
Main: 9273, tlist will be free
Main exit.
[Thread 0xb57d5b70 (LWP 9280) exited]
Program exited normally.
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.7.el6.i686 libgcc-4.4.4-13.el6.i686
GDB必須提供有關「創造」和線程的「退出」許多信息。但總是有一個線程在調用pthread_join()並在主線程中打印「Main exit」後退出。爲什麼? gdb使用的線程是什麼? 運行發行版,沒有什麼特別的:
Input number of threads:5
Main thread id: 0xb77176c0,
I am thread 0xb5913b70, myorder 3, thread_exit.
I am thread 0xb4f12b70, myorder 4, thread_exit.
I am thread 0xb6314b70, myorder 2, thread_exit.
I am thread 0xb6d15b70, myorder 1, thread_exit.
I am thread 0xb7716b70, myorder 0, thread_exit.
Main: completed join with thread 0xb7716b70 having a status of 0
Main: completed join with thread 0xb6d15b70 having a status of 1
Main: completed join with thread 0xb6314b70 having a status of 2
Main: completed join with thread 0xb5913b70 having a status of 3
Main: completed join with thread 0xb4f12b70 having a status of 4
Main: lock will be destroy
Main: tdata list will be free
Main exit.
如果您從您的第一個上市的GDB的消息,輸出的是幾乎相同的(區別僅在分配的地址/ ID和'myorder'價值,我認爲是不determinisitic因爲它可能取決於訂單線程調度)。你怎麼知道最後一個線程退出並沒有在非調試器運行中被阻止,因爲在這種情況下線程退出何時完成沒有任何信息?對於所有你知道它可能會發生在其他線程以及... – 2012-07-13 05:38:53
我已經運行了很多次,每次只有一個線程後,「主要出口」。主要出口。 [線程0xb57d5b70(LWP 9280)退出]'。如果它是隨機的,它應該是兩個,也許三個線程,但事實並非如此。 – 2012-07-13 13:08:20