From owner-freebsd-hackers Tue Jan 2 17:41:33 2001 From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 2 17:41:31 2001 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from wantadilla.lemis.com (wantadilla.lemis.com [192.109.197.80]) by hub.freebsd.org (Postfix) with ESMTP id AA35B37B400 for ; Tue, 2 Jan 2001 17:41:29 -0800 (PST) Received: by wantadilla.lemis.com (Postfix, from userid 1004) id EFC636A911; Wed, 3 Jan 2001 12:11:15 +1030 (CST) Date: Wed, 3 Jan 2001 12:11:15 +1030 From: Greg Lehey To: Doug White Cc: Zhiui Zhang , freebsd-hackers@FreeBSD.ORG Subject: Re: kernel debugging suggestion needed Message-ID: <20010103121115.D15003@wantadilla.lemis.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from dwhite@resnet.uoregon.edu on Tue, Jan 02, 2001 at 02:03:16PM -0800 Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.lemis.com/~grog X-PGP-Fingerprint: 6B 7B C3 8C 61 CD 54 AF 13 24 52 F8 6D A4 95 EF Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tuesday, 2 January 2001 at 14:03:16 -0800, Doug White wrote: > On Tue, 2 Jan 2001, Zhiui Zhang wrote: > >> >> I have written a KLD and am debugging it. The program often hangs after >> runs for a while (I guess it enters into some dead loop). Is there a way >> to attach to the process and somehow find out which code it is executing >> (with remote debugging or ddb)? > > kld debugging is a bit tricky. Take a look at the debugging macros and > bits that Greg Lehey put together for vinum for a starting point. You have > to calculate the appropriate offset to get to the KLD code in gdb. Doug Rabson has described an alternative to me, but I never got it to work. My hack walks down the list of klds looking for a name starting with 'v'; you can change this to something which identifies your kld, and you'll need to change the name of the kld itself, of course. I also have a number of other macros in files in /usr/src/sys/modules/vinum. Here's the macro: 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 sys/modules/vinum/vinum.ko | grep ' .text' | awk '{print "add-symbol-file sys/modules/vinum/vinum.ko \$file->address+0x" $4}' > .asf source .asf end Greg -- 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