Hopefully Simple Question on Debugging Kernel Modules
jhb at freebsd.org
Mon Feb 23 12:17:31 PST 2009
On Monday 23 February 2009 1:55:59 pm Scott Long wrote:
> Doug Barton wrote:
> > Scott Long wrote:
> >> Ah, I was still using 'CFLAGS+= -g". Thanks to you and Mr. Campbell for
> >> the tip.
> > IME in order to make sure I get debug symbols in everything (base and
> > ports) I need to include both of these:
> > CFLAGS+= -ggdb
> > DEBUG_FLAGS+= -ggdb
DEBUG_FLAGS alone should be sufficient. It is automatically added to CFLAGS
when building things in bsd.*.mk. It also has the side effect of disabling
strip if it is non-empty.
> > BTW, I've always used -ggdb out of habit, is using just -g preferable
> > for some reason?
> > hope this I helps,
> > Doug
> Never heard of -ggdb =-) One other tip is to compile with -O0 or
> -fno_inline so that kdb doesn't get fooled by all of the foolish
> auto-inlining that gcc wants to do. gdb is able to handle it, but
> I still find it a good practice to do.
gdb can choke on the inline stuff, too. Mostly it loses knowledge of function
parameters and local variables for either the inlined routine or the calling
routine (can't remember which) which is very annoying. I just
use 'DEBUG_FLAGS="-g -fno-inline"' when I run into that.
More information about the freebsd-current