2014-09-21 47 views
0

我有一個運行兩個線程的C++程序。線程A和線程B.有沒有一種方法可以逐步調試GDB中的兩個線程?步驟應該是這樣的:GDB一步一步調試兩個線程

  1. 停止線程&乙
  2. 切換到線程A繼續一步。
  3. 切換到線程B.繼續兩個步驟。
+0

您應該閱讀GDB手冊,特別是https://sourceware.org/gdb/current/onlinedocs/gdb/All_002dStop-Mode.html#All_002dStop-Mode和https://sourceware.org/gdb/current/ onlinedocs/gdb/Threads.html#線程 – Hasturkun 2014-09-21 14:05:13

+2

'將scheduler-locking'設置爲'on'或'step'可能有效。 AFAICT,你並不想單步執行所有的主題。 – Hasturkun 2014-09-21 14:12:00

回答

2

使用gdb命令「info threads」查看進程的所有線程,然後使用命令「thread thread-id」top切換到您想要的任何線程。