You can use the following commands to manipulate threads:
GDB Mode
:info threads
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
DBX Mode
show_thread_command
: show thread [ thread_id_list ] [ thread-state-filter ]
thread_id_list
: thread_id ,...
| *
thread_id
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 you omit a thread specification, the debugger displays information for all threads.
(idb) print $threadlevel
"openmp"
(idb) show thread
>* 1 initial thread 1024 (LWP 4097)
stopped at src/c_omp_os_omp.c:78 (0x8049780)
OpenMP team memberships: (134552576,0), (134549632,0)
2 unknown thread 2049 (LWP 4098)
stopped at 0x420e0037
OpenMP team memberships: <not available>
3 monitoring thread 1026 (LWP 4099)
stopped at 0x420b4b31
OpenMP team memberships: <not available>
4 openmp thread 2051 (LWP 4100)
stopped at src/c_omp_os_omp.c:71 (0x804970b)
OpenMP team memberships: (134552576,1)
5 openmp thread 3076 (LWP 4101)
stopped at 0x8048e60
OpenMP team memberships: (134552576,2)
6 foreign thread 4101 (LWP 4102)
stopped at 0x420b4b31
OpenMP team memberships: (134614144,0)
7 foreign thread 5126 (LWP 4103)
stopped at 0x420b4b31
OpenMP team memberships: (134639616,0)
(idb) set $threadlevel = "native"
(idb) show thread
Id State
>* 1 stopped
2 stopped
3 stopped
4 stopped
5 stopped
6 stopped
7 stopped
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.
: 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