Debugging Multithreaded Applications |
12 |
![]() |
This chapter is organized into the following sections:
Basic Concepts
With dbx, you can examine stack traces of each thread, resume (cont) a specific thread or all threads, step or next a specific thread, and navigate between threads.
with -lpthread.
Understanding Multithreaded Debugging
When it detects a multithreaded program, dbx tries to dlopen libthread_db.so, a special system library for thread debugging located in /usr/lib. Thread Information
The following thread information is available:
thread [-info] [-hide] [-unhide] [-suspend] [-resume] tid |
To display the current thread:
thread |
thread tid |
Viewing the Threads List
The following are commands for viewing the threads list. The syntax is:
threads [-all} [-mode [all|filter] [auto|manual]] |
To print the list of all known threads:
threads |
To print threads normally not printed (zombies):
threads -all |
Resuming Execution
Use the cont command to resume program execution. Currently, threads use synchronous breakpoints so all threads resume execution.
Understanding LWP Information
Normally, you need not be aware of LWPs. There are times, however, when thread level queries cannot be completed. In this case, use the lwps command to show information about LWPs.
(dbx) lwps |
Print everything known about the given thread:
thread -info tid |
thread [-hide | -unhide] tid |
thread -unhide all |
Keep the given thread from ever running. A suspended thread shows up with an S in the threads list:
thread -suspend tid |
thread -suspend tid |
threads
Echoes the current modes:
threads -mode |
Control whether threads prints all threads or filters them by default:
threads -mode [all | filter] |
Thread and LWP States