How to debug panic()s in device_attach function of kernel module?

Chuck Tuffli chuck_tuffli at agilent.com
Fri Apr 18 05:59:06 PDT 2003


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


More information about the freebsd-hackers mailing list