SHORE Thread Debugging

This is out of date It is here to remind me to make something more up-to-date.

This document contains some hints to debugging threads. Specifically, it focusses on the issue of getting stack traces from all blocked threads in gdb. Simply setting the stack pointer register in gdb is not sufficient, at least on sparcs (where register windows seem to be a problem).

Ultimately we'd like some combination of gdb macro and thread functions allow us to arbitrarily switch stacks and run the gdb "where" command.

Dan had the idea of setting a break point just before context switching is complete and then calling the context switch function with parameters for the specific thread to switch to.

We discovered that:

The place to set the break point is:

    sthread_core_switch at stcore.c:741

    break stcore.c:741

This is the last line of sthread_core_switch.

Next, use the output of:
    call dumpthreads()
too find the address of the sthread_t structure for the
thread you want to switch to.  Assume the address is 0xZZZZZZZZ
Then run:
   call sthread_core_switch(&me()->_core, &((sthread_t*)0xZZZZZZZZ)->_core, 0) 

   call sthread_core_switch(&me()->_core, &((sthread_t*)0x829ac50)->_core, 0) 

This switched from "me" to the 0xZZZZZZZZ thread. You can now run "where".

At this point you can call sthread_core_switch() again for a different thread and run where again.


Bolo's Notes
Bolo's Home Page
Last Modified: Thu Nov 22 23:43:52 CST 2007
Bolo (Josef Burger) <bolo@cs.wisc.edu>