f78
Debugging programs with multiple threads
Warning:
Whenever GDB detects a new thread in your program, it displays the target
system’s identification for the thread with a message in the form ‘
For debugging purposes, GDB associates its own thread number—always a single
integer—with each thread in your program.
An asterisk ‘
thread threadno
Whenever GDB stops your program, due to a breakpoint or a signal, it
automatically selects the thread where that breakpoint or signal happened. GDB alerts
you to the context switch with a message of the form ‘
See
See
automatic notification of new threads
‘
‘
‘
thread-specific breakpoints
These facilities are not yet available on every GDB configuration where the
operating system supports threads. If your GDB does not support threads, these
commands have no effect. For instance, a system without thread support shows no
output from ‘
(gdb) thread 1
Thread ID 1 not known. Use the "info threads" command to see the IDs of
currently known threads.
Display a summary of all threads currently in your program. GDB displays for
each thread (in the following order):
3 process 35 thread 27 0x34e5 in sigpause ()
2 process 35 thread 23 0x34e5 in sigpause ()
* 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
at threadtest.c:68
Make thread number threadno the current thread. The command argument, threadno, is the internal GDB thread number, as shown in the first field of the ‘info threads’ display. GDB responds by displaying the system identifier of the thread you
selected, and its current stack frame summary:
[Switching to process 35 thread 23]
0x34e5 in sigpause ()
The thread apply command allows you to apply a command to one or more threads.
Specify the numbers of the threads that you want affected with the command
argument threadno. threadno is the internal GDB thread number, as shown in the first field of the ‘info threads’ display. To apply a command to all threads, use thread apply all args.