Debugging a Program With dbx |
Debugging Multithreaded Applications
dbx
can debug multithreaded applications that use either Solaris threads or POSIX threads. Withdbx
, you can examine stack traces of each thread, resume all threads,step
ornext
a specific thread, and navigate between threads.
dbx
recognizes a multithreaded program by detecting whether it utilizeslibthread.so.
The program will uselibthread.so
either by explicitly being compiled with-lthread
or-mt
, or implicitly by being compiled with-lpthread.
This chapter describes how to find information about and debug threads using the
dbx
thread
commands.This chapter is organized into the following sections:
Understanding Multithreaded Debugging
When it detects a multithreaded program,
dbx
tries to loadlibthread_db.so
, a special system library for thread debugging located in/usr/lib
.
dbx
is synchronous; 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 in
dbx
:
Each line of information is composed of the following:
- The * (asterisk) indicates that an event requiring user attention has occurred in this thread. Usually this is a breakpoint.
- An 'o' instead of an asterisk indicates that a
dbx
internal event has occurred.- The > (arrow) denotes the current thread.
- t@num, the thread id, refers to a particular thread. The number is the
thread_t
value passed back bythr_create
.- b l@num or a l@num means the thread is bound to or active on the designated LWP, meaning the thread is actually runnable by the operating system.
- The "Start function" of the thread as passed to
thr_create
. A?()
means that the start function is not known.- The thread state (See TABLE 12-1 for descriptions of the thread states.)
- The function that the thread is currently executing.
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]
tidTo display the current thread, type:
threadTo switch to thread tid, type:
thread
tidFor more information on the
thread
command, see "thread Command" in the Using dbx Commands section of the Sun WorkShop online help.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, type:
threadsTo print threads normally not printed (zombies), type:
threads -allFor more information on the
threads
command, see "threads Command" in the Using dbx Commands section of the Sun WorkShop online help.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 these cases, use the
lwps
command to show information about LWPs.
(dbx)
lwps
l@1 running in main()
l@2 running in sigwait()
l@3 running in _lwp_sema_wait()
*>l@4 breakpoint in Queue_dequeue()
l@5 running in _thread_start()
(dbx)
Each line of the LWP list contains the following:
- The * (asterisk) indicates that an event requiring user attention has occurred in this LWP.
- The arrow denotes the current LWP.
- l@num refers to a particular LWP.
- The next item represents the LWP state.
- in func_name() identifies the function that the LWP is currently executing.
Sun Microsystems, Inc. Copyright information. All rights reserved. Feedback |
Library | Contents | Previous | Next | Index |