Debugging threads with HP Wilde Beest
where, <pid> is the process identifier.
Miscellaneous notes on Advanced thread debugging feature in HP WDB
The following commands enable you to view extended information on threads, mutexes,
read-write locks and conditional variables in multi-threaded applications:
info thread [thread-id]
The info thread [thread-id] command displays a list of known threads. If you
provide a thread-id, the command displays extended information on the specified
thread.
Consider the following example:
(gdb) info thread
system thread 4189 0x7f666da8
in __pthread_create_system+0x3d8 () from /usr/lib/libpthread.1
2 system thread 4188 worker (wptr=0x40004640 " ) at quicksort.c:135
1 system thread 4184 0x7f66f728 in _lwp_create+0x10 () from /usr/lib/libpthread.1
info mutex [mutex-id]
The info mutex [mutex-id] command displays a list of known mutexes. If a
mutex-id is provided, the command displays extended information on the specified
mutex.
info condvar [condvar-id]
The info condvar [condvar-id] command displays a list of known condition
variables. If condvar-id is provided, the command displays extended information
on the specified condition variable.
info rwlock [rwlock-id]
The info rwlock [rwlock-id] command displays a list of known read-write locks.
If rwlock-id is provided, the command displays extended information on the specified
read-write lock.
Best Practices in Thread programming
The following are some of the best practices specific to Thread-programming:
• Ensure your program locks small segments or specific fields of a program segment
to increase concurrency in execution.
• Ensure that your locks always obtain synchronization control in an order that does
not cause race condition.
• Minimize locking instances so you can reduce the overhead that might result from
frequent synchronization efforts.
• Minimize critical sections that might result in longer waits for other threads.
• Reduce the number of nested function calls so you avoid errors resulting from
stack overflow.
44