Debugging threads with HP Wilde Beest

4. Invoke the executable that you want to debug:
(gdb) file <Complete path of the executable or name of the executable>
5. Enable thread check along with the specific option as required.
(gdb) set thread-check [option][on|off]
6. Execute the file with the following command:
(gdb) run <Name of the executable>
The thread-check command
The advanced thread debugging features can be enabled only if the set
thread-check[on] command is enabled. The following advanced thread debugging
options are available for the set thread-check command:
recursive-relock [on|off]
unlock-not-own [on|off]
mixed-sched-policy [on|off]
cv-multiple-mxs [on|off]
cv-wait-no-mx [on|off]
thread-exit-own-mutex [on|off]
thread-exit-no-join-detach [on|off]
stack-util [num]
num-waiters [num]
NOTE: By default all these options are turned on if you set the command set
thread-check on.
Debugging common thread-programming problems
Problem: The thread attempts to acquire a non-recursive mutex that it currently has control.
Consider the following scenario:
Function 1 locks a non-recursive mutex and calls Function 2 without releasing the lock
object. If Function 2 also attempts to acquire the same non-recursive mutex, the scenario
results in a deadlock. In effect, the program does not proceed with the execution.
Consider the following example enh_thr_mx_relock.c
#include pthread.h
#include string.h
#include stdio.h
#include errno.h
pthread_mutex_t r_mtx; /* recursive mutex */
pthread_mutex_t n_mtx; /* normal mutex */
extern void fatal_error(int err, char *func);
Modes of Thread debugging in HP WDB 19