How to get anything useful out of kgdb?

Ryan Stone rysto32 at gmail.com
Fri May 15 17:57:04 UTC 2015


On Fri, May 15, 2015 at 1:07 PM, Sean Bruno <sbruno at ignoranthack.me> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
> Hrm, when I look at them directly in the crashdump, I don't see
> anything useful.
>
> (kgdb) tid 100058
> [Switching to thread 54 (Thread 100058)]#0  cpustop_handler () at
> /home/sbruno/bsd/em_mq/sys/x86/x86/mp_x86.c:987
> 987             CPU_SET_ATOMIC(cpu, &stopped_cpus);
> Current language:  auto; currently minimal
> (kgdb) whe
> #0  cpustop_handler () at /home/sbruno/bsd/em_mq/sys/x86/x86/mp_x86.c:98
> 7
> #1  0xffffffff80f76f7a in ipi_nmi_handler () at
> /home/sbruno/bsd/em_mq/sys/x86/x86/mp_x86.c:969
> #2  0xffffffff80e3657a in trap (frame=0xffffffff817eb910) at
> /home/sbruno/bsd/em_mq/sys/amd64/amd64/trap.c:188
> #3  0xffffffff80e1b273 in nmi_calltrap () at
> /home/sbruno/bsd/em_mq/sys/amd64/amd64/exception.S:509
> #4  0x0000000800841841 in ?? ()
> Previous frame inner to this frame (corrupt stack?)
>

*Sigh*,  kgdb isn't unwinding the trap frame properly.  You can try this to
figure out where it was running:

frame 2
info line *frame->tf_rip

That gives you the top of the callstack at the time that the core was
taken.  To get the rest of it, try:

define trace_stack
  set $frame_ptr=$arg0
  set $iters=0
  while $frame_ptr != 0 && $iters < $arg1
    set $ret_addr=((char*)$frame_ptr) + sizeof(void*)
    printf "frameptr=%p, ret_addr=%p\n", (void*)$frame_ptr,
*(void**)$ret_addr
    printf "    "
    info line **(void***)$ret_addr
    set $frame_ptr=*(void**)$frame_ptr
    set $iters=$iters+1
  end
end

trace_stack frame->tf_rbp 20


More information about the freebsd-hackers mailing list