Subject: Re: kernel stack traces for other processes?
To: None <jtk@atria.com>
From: Charles M. Hannum <mycroft@gnu.ai.mit.edu>
List: port-i386
Date: 09/26/1994 17:52:13
   Is there a way in ddb (preferable) or gdb (OK) to get a stack trace of
   some process other than the current process?

It's a bit complicated to do with DDB at the moment (though I plan to
change that).  What I do is something like:

1) Use the DDB `ps' command to see where the `struct proc' is.  This
is the address in the `proc' field.

2) If it's listed as having a wchan, force a wakeup on that channel by
`call wakeup(whatever-address)'.

3) Set a breakpoint in tsleep to catch the switch() return.  `break
bpendtsleep'.

4) `c' until curproc is the address recorded in #1.

Really, DDB ought to have some sort of `switch' command.  There are
some issues about interrupt handlers to consider when implementing
this, however.  The simplest approach seems like it would be to simply
wake up the process, put it at a high priority (which should get reset
on the next scheduler scan), and register an AST in the current
process to force a switch.  Then have a trap in cpu_switch() itself to
reenter the debugger.

Unfortunately, that only allows you to do a stack trace if the kernel
is in good enough shape to actually do a switch.  In other
circumstances, something more elaborate is needed.