Debugging a Program With dbx

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.

dbx is a synchronous dbx; when any thread or lightweight process (LWP) stops, all other threads and LWPs sympathetically stop. This behavior is sometimes referred to as the "stop the world" model.


Note -

For information on multithreaded programming and LWPs, see the Solaris Multithreaded Programming Guide.


Thread Information

The following thread information is available:


(dbx) threads
    t@1 a |@1  ?()  running   in main()
 	t@2      ?() asleep on 0xef751450  in_swtch()
 	t@3 b |@2  ?()  running in sigwait()
    t@4     consumer()  asleep on 0x22bb0 in _lwp_sema_wait()
 *>t@5 b |@4 consumer()  breakpoint     in Queue_dequeue()
	t@6 b |@5 producer()     running       in _thread_start()
(dbx)

Viewing the Context of Another Thread

To switch the viewing context to another thread, use the thread command. The syntax is:


thread [-info] [-hide] [-unhide] [-suspend] [-resume] tid

To display the current thread:


thread

To switch to thread tid:


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.