The
dbx command provides four subcommands—
condition,
mutex,
readwritelock,
and
thread—for examining thread-related
objects. To check on the status of all threads in your application,
enter the
thread subcommand with no operands.
The following example shows a sample output of the
thread subcommand:
(dbx) thread
thread thread_id state substate held exit_status
>$t1 0x03567d9000000001 activ no 0x00000000
$t2 0x0356831000000002 activ cv_wait no 0x00000000
$t3 0x035688a000000003 activ mu_wait no 0x00000000
$t4 0x03568e2000000004 activ cv_wait no 0x00000000
$t5 0x035693b000000005 activ jn_wait no 0x00000000
$t6 0x0356993800000006 activ cv_wait no 0x00000000
(dbx)
The
> (greater than) sign in the left
margin marks the
current thread, which is the thread last notified
of an event. A
dbx internal name such as
$t1 is
assigned to each thread for easy reference. Also, a data structure
type is associated with the thread object for referring to individual
elements of the thread object. For an example that uses the
dbx
whatis subcommand to display the data structure for
an individual thread, see
Examining the status of individual threads.
Note: Thread internal names change
as the program executes and the debugger automatically updates thread
names. For example, if you have three threads—$t1, $t2, and $t3—and
$t2 finishes running, the remaining two threads are renumbered to
$t1 and $t2. You should keep this in mind when using the dbx subcommands
that refer to thread names. Break and trace points that refer to thread
names are automatically updated to their new names when necessary.
The thread_id column lists a constant hexadecimal
value that is assigned to the thread when it is created.
The
state column indicates the execution status
of a thread. Possible states include:
- activ
- The thread is currently executing, or it is executing in a wait
state. The substate field indicates if the thread
is waiting: cv_wait for a thread waiting for a condition
variable, mu_wait for a thread waiting for a mutex,
and jn_wait for a thread waiting for a pthread_join call
to return.
- async
- The thread is not currently executing on a task. For example,
if the BPXPRMxx PARMLIB member MAXTHREADS is set to 1000, but MAXTHREADTASKS
is set to 50, there can be only 50 threads in the activ state.
If a program creates more than 50 threads, the ones greater than 50
will have a state of async.
- dead
- The thread has finished processing. The exit_status field
contains data about the exit status of the thread when it finished
processing.
- pcanc
- The thread is pending cancellation by either explicitly disabling
cancellation or waiting for controlled cancellation at a specified
cancellation point.
The held field indicates whether a thread is being
held by dbx. The thread will not execute
until it is released, allowing you to focus attention on other threads.
For example, if a variable changes, you can be certain that it was
not changed by the held thread.