Re: Stack traces

Andi Kleen (ak@suse.de)
Tue, 8 Aug 2000 04:25:33 +0200


On Tue, Aug 08, 2000 at 11:36:31AM +1000, Dave Cecil wrote:
> I have a thread that appears to be hanging in my kernel module (or
> something called by it) and I want to determine where the problem is
> occurring. Unfortunately, printks change the timing of the system, and the
> problem no longer occurs.
>
> What I really want is to get a stack trace of the offending thread. I have
> used alt-sysrq-t to get some thread information, but it only provides the
> thread's saved PC (which isn't in my module, according to its address). Is
> there a way to get the thread's call stack? Are there any routines I could
> use or is there some documentation/code I could look at?
>
> How do others go about solving such problems? The only debugger I've found
> for 2.2.12 kernels that would fit the bill is SGI's kgdb, and there's
> obviously a bit of overhead involved in setting up the serial debugger.

kdb (no 'g') from SGI can do the same without a serial line. Then it is
as simple as btp <pid>

The other option is to compile a vmlinux with debugging symbols (-g),
do gdb vmlinux /proc/kcore (note that on 2.2 /proc/kcore is a.out so you
may need a gdb that can read a.out or a ELF kcore patch), use the appended
ps macro to find the task structure of your thread, display its tss.esp
member and backtrace from that.

-Andi

define ps
set $inittask = &(init_task_union.task)
set $t = $inittask->next_task
while $t != $inittask
output $t
output "\t"
output $t->pid
output "\t"
output $t->comm
echo
set $t = $t->next_task
end
end

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/