Julian Elischer <[EMAIL PROTECTED]> writes:
> Marcel Moolenaar wrote:
> > BTW: Do we have handy functions for use in the remote debugger, such
> > as show_proc, show_vm or whatever, that dump important information
> > in a readable form?
> Matt has a cool set of macros as does Grog.
I have a couple of macros I've used for debugging KLDs, which may
serve as templates or inspiration for someone to write e.g. a "ps"
macro (it shouldn't be too different from the "kldstat" macro, just
walk the process table and print formatted info for every process)
define kldstat
set $kld = linker_files.tqh_first
printf "Id Refs Address Size Name\n"
while ($kld != 0)
printf "%2d %4d 0x%08x %-8x %s\n", \
$kld->id, $kld->refs, $kld->address, $kld->size, $kld->filename
set $kld = $kld->link.tqe_next
end
end
document kldstat
Lists the modules that were loaded when the kernel crashed.
end
define kldstat-v
set $kld = linker_files.tqh_first
printf "Id Refs Address Size Name\n"
while ($kld != 0)
printf "%2d %4d 0x%08x %-8x %s\n", \
$kld->id, $kld->refs, $kld->address, $kld->size, $kld->filename
printf " Contains modules:\n"
printf " Id Name\n"
set $module = $kld->modules.tqh_first
while ($module != 0)
printf " %2d %s\n", $module->id, $module->name
set $module = $module->link.tqe_next
end
set $kld = $kld->link.tqe_next
end
end
document kldstat-v
Lists modules with full information.
end
define kldload
set $kld = linker_files.tqh_first
set $done = 0
while ($kld != 0 && $done == 0)
if ($kld->filename == $arg0)
set $done = 1
else
set $kld = $kld->link.tqe_next
end
end
if ($done == 1)
shell /usr/bin/objdump -h $arg0 | \
awk '/ .text/ { print "set \$offset = 0x" $6 }' > .kgdb.temp
source .kgdb.temp
add-symbol-file $arg0 $kld->address + $offset
end
end
document kldload
Loads a module. Arguments are module name and offset of text section.
end
DES
--
Dag-Erling Smorgrav - [EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message