Looking at the Threads. Simple Debugging

In a multithreaded application, you can obtain information about the thread that stopped or about all the threads, and you can then change the context to look more closely at a different thread. Note that a right bracket (>) marks the current thread. And the asterisk (*) marks the thread with return status.

DBX Mode

 

(idb) thread

  Thread Name                      State           Substate    Policy       Pri

  ------ ------------------------- --------------- ----------- ------------ ---

>*     1 default thread            running VP 3                SCHED_OTHER  19

(idb) show thread

  Thread Name                      State           Substate    Policy       Pri

  ------ ------------------------- --------------- ----------- ------------ ---

>*     1 default thread            running VP 3                SCHED_OTHER  19

      -1 manager thread            blk SCS                     SCHED_RR     19

      -2 null thread for slot 0    running VP 1                null thread  -1

      -3 null thread for slot 1    ready VP 3                  null thread  -1

      -4 null thread for slot 2    new             new         null thread  -1

      -5 null thread for slot 3    new             new         null thread  -1

       2 threads(0x140000798)      blocked         cond 3      SCHED_OTHER  19

       3 threads+8(0x1400007a0)    blocked         cond 3      SCHED_OTHER  19

       4 threads+16(0x1400007a8)   blocked         cond 3      SCHED_OTHER  19

       5 threads+24(0x1400007b0)   blocked         cond 3      SCHED_OTHER  19

       6 threads+32(0x1400007b8)   blocked         cond 3      SCHED_OTHER  19

 

You can select any thread to be the focus of commands that show things. For example:

 

(idb) thread 2

  Thread Name                      State           Substate    Policy       Pri

  ------ ------------------------- --------------- ----------- ------------ ---

>      2 threads(0x140000798)      blocked         cond 3      SCHED_OTHER  19

 

GDB Mode

 

Within the GDB mode, you can have a look at a particular thread by specifying the internal debugger thread number. The asterisk (*) marks the current thread. Or you can observe all threads while your program is running:

 

(idb) thread

   ID           State

>* 8            stopped

(idb) show thread

   ID           State

   1            stopped

   2            stopped

   3            stopped

   4            stopped

   5            stopped

   6            stopped

   7            stopped

>* 8            stopped

 

This command provides the following information about known threads:

You can select any thread to be the focus of commands that show things. For example:

 

(idb) thread 2

   ID           State

>  2            stopped