Re: Hopefully Simple Question on Debugging Kernel Modules

From: John Baldwin <jhb_at_freebsd.org>
Date: Mon, 23 Feb 2009 16:17:53 -0500
On Monday 23 February 2009 3:51:18 pm David Christensen wrote:
> > > > Just use gdb on bce.ko (built with debug symbols):
> > > >
> > > > gdb /path/to/if_bce.ko
> > > > (gdb) l *bce_intr+0x8df
> > > >
> > > > If you get a crashdump you can run kgdb on it and just walk up to
> > the
> > relevant
> > > > stack frame and use 'l' there to get a listing.
> > > >
> > >
> > > One thing that I've never figured out is how debugging symbols are
> > > handled in module builds these days.  If I go to /sys/modules/bce and
> > > do 'make', it generates a .ko and explicitly strips it.  I wind up
> > > having to re-run the link command by hand so I get symbols.  What is
> > > the correct way to do this?  Note that I'm not interested in answers
> > > that involve "go to /usr/src and run make buildkernel" =-)
> > 
> > make DEBUG_FLAGS=-g is what I use.  The same thing works for userland
> > tools
> > and the kernel (usually we put 'makeoptions DEBUG_FLAGS=-g' in a kernel
> > config so it is "automatic" for kernels though).
> 
> So is the use of COPTS=-g mentioned in the Developer's Handbook
> 
(http://www.freebsd.org/doc/en/books/developers-handbook/kerneldebug-kld.html)
> deprecated?  I wasn't able to build with symbols until I used 
DEBUG_FLAGS='g.

Yes.  kgdb is now also smarter in that it should automatically load symbols 
for kld's.  There's no need to use add-symbol-file to add symbols by hand 
anymore.

-- 
John Baldwin
Received on Mon Feb 23 2009 - 20:18:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:42 UTC