How to produce debugging symbols?

Mike Meyer mwm-dated-1049163332.c238ec at
Thu Mar 27 02:15:38 PST 2003

In <20030326222553.GA38860 at>, Dan Nelson <dnelson at> typed:
> In the last episode (Mar 26), taxman said:
> > On Wednesday 26 March 2003 03:11 pm, Dan Nelson wrote:
> > > If it's your program, recompile and link with the -g commandline
> > > switch added.  If it's a base FreeBSD program (or port), edit the
> > > Makefile and add a line reading "DEBUG_FLAGS=-g" (this will compile
> > > with -g and also no strip the debugging symbols when the binary
> > > gets installed).
> > Does this work for the kernel?  I'd read that the kernel strips
> > symbols anyway.  If i put makeoptions DEBUG=-g in my kernel config
> > (as shown in LINT) will I still get the symbols?  Thats for 4.x, what
> > about 5.0 is that different?
> It still works in 5.0.  What ends up happenning is a debugging kernel
> gets built as kernel.debug, but the stripped version is still installed
> into /boot/kernel/ (most likely to conserve space on /).  When you
> panic and coredump, copy kernel.debug out of the source tree into
> /var/crash and use that to debug.

That's  the difficult way to do this. You can debug the core and
kernel dumps in /sys/crash, and use the gdb symbol-file command to
load the symbols from kernel.debug. This is all documented in the
kernel debugging section of the developer's handbook link at <URL: >.

Mike Meyer <mwm at>
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

More information about the freebsd-questions mailing list