From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 18 05:59:06 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6509937B40A for ; Fri, 18 Apr 2003 05:59:06 -0700 (PDT) Received: from msgbas1x.cos.agilent.com (msgbas1x.cos.agilent.com [192.25.240.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id AA9BE43FE1 for ; Fri, 18 Apr 2003 05:59:05 -0700 (PDT) (envelope-from ctuffli@rose.agilent.com) Received: from relcos1.cos.agilent.com (relcos1.cos.agilent.com [130.29.152.239]) by msgbas1x.cos.agilent.com (Postfix) with ESMTP id 5AA2F16FC2 for ; Fri, 18 Apr 2003 06:59:05 -0600 (MDT) Received: from rtl.rose.agilent.com (rtl.rose.agilent.com [130.30.179.189]) by relcos1.cos.agilent.com (Postfix) with ESMTP id E9AC85ED for ; Fri, 18 Apr 2003 06:59:04 -0600 (MDT) Received: from mail.rose.agilent.com (mailsrv@bellhop [130.30.179.19]) ESMTP id FAA19727 for ; Fri, 18 Apr 2003 05:59:03 -0700 (PDT) Received: from thegrail (anu.rose.agilent.com [156.140.225.186]) by mail.rose.agilent.com (Netscape Messaging Server 3.6) with ESMTP id AAA69A4; Fri, 18 Apr 2003 05:59:00 -0700 Received: by thegrail (Postfix, from userid 1001) id A204384BDF; Fri, 18 Apr 2003 04:52:49 -0700 (PDT) Date: Fri, 18 Apr 2003 04:52:49 -0700 From: Chuck Tuffli To: Yuriy Tsibizov Message-ID: <20030418115248.GA169@thegrail.rose.agilent.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i cc: freebsd-hackers@FreeBSD.ORG Subject: Re: How to debug panic()s in device_attach function of kernel module? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Apr 2003 12:59:06 -0000 On Fri, Apr 18, 2003 at 10:52:41AM +0400, Yuriy Tsibizov wrote: > > I'm trying to debug panic()s in one of my drivers (I can compile it > only as module now), but I can't find a way to get address where it > was loaded by kldload. I can't run kldstat (as recommended by > developers' handbook, 17.6) because it panic()s during kldloading > (after LOR of ZONE_LOCKs after malloc(0) somewhere in device_attach > of my driver). Can I get this address inside kdb? You were in the right section of the handbook. Take a look at the paragraph after the kldstat suggestion. You can walk the linker_files structure to see where modules are loaded. I use gbd for debugging and define the following function in my .gdbinit file to walk this list define lm set $linker = (struct linker_file *)linker_files->tqh_first while $linker != 0 printf "found %s at %#x\n", $linker->filename, $linker->address set $linker = $linker.link.tqe_next end end You can manually follow the above approach using kdb as well. Hope that helps. -- Chuck Tuffli Agilent Technologies, Storage and Networking