From owner-freebsd-hackers Mon Nov 1 12:31:51 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from apollo.sitaranetworks.com (apollo.sitaranetworks.com [199.103.141.105]) by hub.freebsd.org (Postfix) with ESMTP id BAFA315305; Mon, 1 Nov 1999 12:30:57 -0800 (PST) (envelope-from grog@lemis.com) Message-ID: <19991029142543.26735@mojave.worldwide.lemis.com> Date: Fri, 29 Oct 1999 14:25:43 -0400 From: Greg Lehey To: Robert Watson , FreeBSD Hackers , committers@mojave.worldwide.lemis.com Subject: Re: gdb and kld symbols -- how to (and handbook is outdated) References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii In-Reply-To: ; from Robert Watson on Fri, Oct 29, 1999 at 09:05:15AM -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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