Debugging threads with HP Wilde Beest

if ((ret_val = pthread_mutex_lock(&job_lock)) != 0)
fatal_error(ret_val, "p mtx_lock failed");
for (int i = 0; i < 100; i++)
more_stack[i] = i;
for (int i = 0; i < 1000; i++);
/* Release the associated mutex */
if ((ret_val = pthread_mutex_unlock(&job_lock)) != 0)
fatal_error(ret_val, "mtx_unlock failed");
my_thread();
}
#define check_error(return_val, msg) { \
if (return_val != 0) \
fatal_error(return_val, msg); \
}
main()
{
pthread_t tid;
int ret_val;
/* Create two threads to do the work */
ret_val = pthread_create(&tid, (pthread_attr_t *)NULL,
(void *(*)())my_thread, (void *) NULL);
check_error(ret_val, "pthread_create 2 failed");
/* Wait for the threads to finish */
ret_val = pthread_join(tid, (void **)NULL);
check_error(ret_val, "pthread_join: tid");
exit(0);
}
void
fatal_error(int err_num, char *function)
{
char *err_string;
err_string = strerror(err_num);
fprintf(stderr, "%s error: %s\n", function, err_string);
exit(-1);
}
The set thread-check stack-util[num] command checks if any thread has
used more than the specified percentage[num] of the stack allocation.
The debugger transfers the execution control to the user and displays a warning message
when this condition is detected.
36