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 [EMAIL PROTECTED] for PGP public key
See complete headers for address and phone numbers


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to