Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Apr 2003 04:52:49 -0700
From:      Chuck Tuffli <chuck_tuffli@agilent.com>
To:        Yuriy Tsibizov <Yuriy.Tsibizov@gfk.ru>
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: How to debug panic()s in device_attach function of kernel module?
Message-ID:  <20030418115248.GA169@thegrail.rose.agilent.com>
In-Reply-To: <C192C8912E798F4399668791C8965190674E2F@mx.hhp.local>
References:  <C192C8912E798F4399668791C8965190674E2F@mx.hhp.local>

next in thread | previous in thread | raw e-mail | index | archive | help
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    <chuck_tuffli AT NO_SPAM agilent DOT com>
Agilent Technologies, Storage and Networking



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