How to get stack from every thread when doing crash dump?

Ed Maste emaste at
Mon Jul 4 23:14:02 GMT 2005

On Thu, Jun 23, 2005 at 06:15:43PM -0700, Peter Wemm wrote:
> But I wonder if what you're running into is possibly a result of gdb not 
> parsing the stack frames from exception.s?  We do not emit any dwarf2 
> call frame information for any assembler code, and gdb6 is dwarf2 
> based.   And since it is dwarf2 based, during the last cleanups the gdb 
> developers did, they removed (or moved) the places that we used to 
> insert stack frame sniffers to cope with crossing the nonstandard 
> assembler stack frames.  As a result, we don't generally show traces 
> that cross exceptions any more.

It seems worse than that -- the gdb backtrace might show unknown or
completely bogus frames as a result.  For example, we've run across
the tty locking issue (discussed on -stable), and backtraces often
look like:

#6  0xa0723d8a in calltrap () at /usr/src/sys/i386/i386/exception.s:202
#7  0xc7f10018 in ?? ()
#8  0xa05b0010 in power_profile_set_state (state=0)
    at /usr/src/sys/kern/subr_power.c:110
#9  0xa05c942c in ttwakeup (tp=0xa23fdc00) at /usr/src/sys/kern/tty.c:2370
#10 0xa05c7d71 in ttymodem (tp=0xa23fdc00, flag=0)
    at /usr/src/sys/kern/tty.c:1625

when in reality frames 7 and 8 should actually be a single frame in

> If that is the problem you're seeing, then the fix is that somebody 
> needs to annotate the *.s and *.S files with .cfa_* pseudo-ops so that 
> dwarf2 frame descriptors are emitted for a -g kernel.  This is 
> non-trivial though.

I assume you meant .cfi_* -- .cfi_startproc, .cfi_offset etc?  I had a
quick look and it doesn't seem like it should be difficult.  I ran into
one issue though -- these get written to the .eh_frame section.  The
data emitted by gcc goes in .debug_frame, but the two have the same

I tried changing the linker script to put both in the .debug_frame
section, but ld faild ("Not enough room for program headers").  The 
.eh_frame section is marked loadable, so it seems ld still tries to
create a phdr entry for it.  Once I can figure out how to address
that I'll test out adding the .cfi_ pseudo-ops to exception.s.

Ed Maste, Sandvine Incorporated

More information about the freebsd-arch mailing list