Skip site navigation (1)Skip section navigation (2)
Date:      14 Aug 2001 20:36:19 +0100
From:      Rolf Neugebauer <neugebar@dcs.gla.ac.uk>
To:        volf@oasis.IAEhv.nl (Frank Volf)
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: how to debug a kld module?
Message-ID:  <ysqae12wi18.fsf@therese.dcs.gla.ac.uk>
In-Reply-To: volf@oasis.IAEhv.nl's message of "Mon, 13 Aug 2001 22:30:47 %2B0200 (CEST)"
References:  <20010813203047.C9E2F3E07@drawbridge.oasis.IAEhv.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
volf@oasis.IAEhv.nl (Frank Volf) writes:

> Rolf Neugebauer wrote:
> > > My system panics with a page fault in one of my kernel loadable modules. I
> > > want to debug this, but I can't find a way to load that module and its
> > > symbol table into gdb.
> > > 
> > > The steps that I have taken are 
> > > 
> > > 	gdb -k /sys/compile/DRAWBRIDGE/kernel.debug vmcore.11
> > > 
> > > which gives me a normal kenel with debug symbols that I can debug? But, how
> > > can I load the offending kld module symbol table as well? Or can I only
> > > properly debug this, when I compile the module into the kernel?
> > 
> > Try following the steps in the developers handbook:
> > 
> > http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/kerneldebug.html
> > 
> > In particular the section 11.6 Debugging Loadable Modules Using GDB:
> > http://www.freebsd.org/doc/en_US.ISO8859-1/books/developers-handbook/x4290.html
> 
> Thanks, this is very usefull information, so I feel rather stupid to ask the
> next question. How exactly do I walk the linker_files structure as described
> in the developers handbook:
> 
> gdb -k /sys/compile/DRAWBRIDGE/kernel.debug vmcore.13
> GNU gdb 4.18
> Copyright 1998 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i386-unknown-freebsd"...
> IdlePTD 3633152
> initial pcb at 2e6600
> panicstr: page fault
> ....
> 
> (kgdb) print linker_files
> $1 = -1067722752
> (kgdb) print *linker_files
> $2 = 5
> (kgdb) print linker_files->tqh_first
> Attempt to extract a component of a value that is not a structure pointer.
> (kgdb) whatis linker_files
> type = <data variable, no debug info>
> 
> What am I doing wrong?

Something doesn't look right here :(

Disclainer: I have never done debugging with dumps, I normally use
serial line remote debugging.

I suspect you don't have debugging symbols in your kernel.debug.

Have compiled the kernel with -g? I use:
makeoptions	DEBUG=-g
in my kernel config. You can also specify it as an argument to config.

With this gdb should know what type 'linker_files' is. e.g, if I do:
gdb -k kernel.debug
[snip]
(kgdb) tar rem /dev/cuaa1
[snip]
(kgdb) print linker_files
$1 = {tqh_first = 0xc05ae800, tqh_last = 0xc1bc840c}
This is on 4.3-STABLE.

If I use gdb without debugging kernel, I get similar results as you do:
gdb -k kernel
[snip]
(kgdb) tar rem /dev/cuaa1
[snip]
(kgdb) p linker_files
$1 = -1067784192
(kgdb) p *linker_files
$2 = 3


NB.: the /sys/modules/vinum directory contains some handy gdb init
scripts for module debugging. in particular .gdbinit.vinum.paths which
walks the list of loaded modules for you and loads the symbols.

Rolf

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ysqae12wi18.fsf>