Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Oct 1999 14:25:43 -0400
From:      Greg Lehey <grog@lemis.com>
To:        Robert Watson <robert+freebsd@cyrus.watson.org>, FreeBSD Hackers <hackers@FreeBSD.ORG>, committers@mojave.worldwide.lemis.com
Subject:   Re: gdb and kld symbols -- how to (and handbook is outdated)
Message-ID:  <19991029142543.26735@mojave.worldwide.lemis.com>
In-Reply-To: <Pine.BSF.3.96.991029090302.35544A-100000@fledge.watson.org>; from Robert Watson on Fri, Oct 29, 1999 at 09:05:15AM -0400
References:  <Pine.BSF.3.96.991029090302.35544A-100000@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, 29 October 1999 at  9:05:15 -0400, Robert Watson wrote:
>
> I've mostly debugged kernel modules running as lkm's, but decided to start
> up my debugger on code in a kld a couple of days, and needless to say the
> procedure is different :-).  And unfortunately, also not documented in the
> handbook online, which still talks about lkms.  Any suggestions?  It is
> presumably still add-symbol-file, but with a different offset?
>
> Also, it might be desirable to either extend the handbook to also talk
> about klds, or to replace it with a kld page.

This questions qualifies as "in-depth technical", so I'm moving it to
-hackers.  If you're not signed up there, you should be.  I'm also
copying -committers because it's probably of interest there.

The object you need is in /modules.  For example, to debug the Linux
kld, you need to load the symbols from /modules/linux.ko.  That's the
easy part.

The difficult part is to find the base address.  I have this in
/usr/src/sys/modules/vinum/.gdbinit.vinum.paths:

define asf
   set $file = linker_files.tqh_first
   set $found = 0
   while ($found == 0)
     if (*$file->filename == 'v')
	set $found = 1
     else
       set $file = $file->link.tqe_next
     end
   end
   shell /usr/bin/objdump --section-headers /modules/vinum.ko | grep ' .text' | awk '{print "add-symbol-file /modules/vinum.ko \$file->address+0x" $4}' > .asf
   source .asf
end

This goes through an internal kernel list and looks for a module name
which begins with 'v'; you'll need to change the first "if" statement
to something which uniquely matches your kld.  The rest (modulo file
names, which I have omitted here) should stay the same.  There's also
more information in vinum(4).

Greg
--
When replying to this message, please copy the original recipients.
For more information, see http://www.lemis.com/questions.html
Finger grog@lemis.com for PGP public key
See complete headers for address and phone numbers


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?19991029142543.26735>