Thread Display Commands

You can use the following commands to display threads:

DBX Mode

 

show_thread_command

        : show thread [ thread_id_list ] [ thread-state-filter ]

 

thread_id_list

        : thread_id ,...

        | *

 

thread_id

        : expression

 

thread_state_filter

        : with state eq thread_state

 

eq

        : ==               (for C and C++)

        | .eq.             (for Fortran)

 

thread_state

        : ready

        | running

        | terminated

        | blocked

 

Use the show thread command without parameters to list all the threads known to the debugger.

If you specify one or more thread identifiers, the debugger displays information about the threads you specify, if the thread matches what you specified in the list. If you omit a thread specification, the debugger displays information for all threads.

Use the show thread commands to list threads that have specific characteristics, such as threads that are currently blocked. For example:

 

(idb) print $threadlevel

"pthreads"

(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

(idb) set $threadlevel = "pthreads"

(idb) print $threadlevel

"pthreads"

(idb) show thread

   Id                  State

*  0x9                 stopped

*  0x9                 unstarted

   0x3                 unstarted

   0x7                 unstarted

GDB Mode

 

info_threads_command

        : info threads

thread

        : expression

 

Use the info threads command to list all the threads known to the debugger.

 

(idb) info threads

  0 Thread 1024 (LWP 19513)  0x804f8f6 in __sigsuspend from /tmp/pthread_manythreads

  1 Thread 2049 (LWP 19514)  0x805a42a in __clone from /tmp/pthread_manythreads

* 2 Thread 1026 (LWP 19515)  0x804f8f6 in __sigsuspend from /tmp/pthread_manythreads

  3 Thread 2051 (LWP 19516)  0x804f8f6 in __sigsuspend from /tmp/pthread_manythreads

  4 Thread 3076 (LWP 19517)  0x804f8f6 in __sigsuspend from /tmp/pthread_manythreads

  5 Thread 4101 (LWP 19518)  0x8048288 in prime_search at pthread_manythreads.c:79

Note:

In the output, the right bracket indicator (>) marks the current thread, whereas the asterisk (*) indicator marks the thread with the event that stopped the application.

You can switch to a different thread as the current thread. The debugger variable $curthread contains the thread identifier of the current thread.

 

switch_thread_command

          : thread [ thread_id ]

 

The $curthread value is updated when program execution stops or completes. You can modify the current thread by assigning $curthread a valid thread identifier. This is equivalent to issuing the thread thread_id command. When there is no process or program, $curthread is set to 0.

Use the thread command without a thread identifier to identify the current thread. Supply a thread identifier to make another thread the current thread.

GDB Mode

 

(idb) thread 2

* 2 Thread 1026 (LWP 19515)  0x804f8f6 in __sigsuspend from /tmp/pthread_manythreads