Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: GDB can't access kext code memory



Hi Garth,

Thanks for helping!  I really do need help with this.

> It sounds like you have a panic log but you want to view memory
> on the panicked machine. Is that right? 

No.  I have a panic log for a crash which I cannot duplicate.   The panic only happens on a Dual Processor G4.
I have been trying to find out which line of our code causes the panic. That's all.
Do I have to set up two-machine debugging for that?

The kexts are a driver, MacPortX, which depends on a shim, MacPortXEnetShim.

Here are the commands I used, following TN2063:

$su
% gdb /mach_kernel
(gdb)
(gdb) 
add-symbol-file /Users/joeman/Desktop/PANIC/com.twowire.MacPortXEnetShim.sym
(gdb) 
add-symbol-file /Users/joeman/Desktop/PANIC/com.twowire.MacPortX.sym
(gdb) set print asm-demangle on
(gdb) x/i 0x1558e900
0x1558e900 <com_twowire_MacPortX::probe(IOService *, long *)+148>:      Cannot access memory at address 0x1558e900
(gdb) x/i 0x1558eae0
0x1558eae0 <com_twowire_MacPortX::RegisterWithShim(void)+456>:  Cannot access memory at address 0x1558eae0

Those two addresses are right in the middle of the driver, which was loaded at the time.
I tried both kextload and installing the driver (into "extensions") and re-booting.
I generated the symbol files with kextload
The kexts do run on the debugging machne. 
Their addresses show up in kextstat, and match the addresses I tried to read with x/i.

If I "attach" gdb to another PID on this same machine, I can disassemble its memory. 
 I have not been able to find a way to disassemble a kext, however.

Do I have to set up two machines to follow the procedure in TN2063?   Since it does NOT include
a  "target remote-kdp" command,  I assumed that TN2063 used only one machine.

thanks for your help

Harland Harrison
2wire.com



-----Original Message-----
From: Garth Cummings [mailto:email@hidden]
Sent: Wed 2/9/2005 12:48 PM
To: Harland Harrison
Cc: 'email@hidden' USB
Subject: Re: GDB can't access kext code memory
 
Hi Harland,

> I know that gdb has to "attach" to a process to access its memory.
> I have tried the "attach" command with every PID listed in the PS  
> command.
> I have tried the "attach" command with the symbol file and the kext.
> How do you attach to a kext?

You don't, directly. You attach to the panicked machine from a second  
machine attached via Ethernet or FireWire.

It sounds like you have a panic log but you want to view memory on the  
panicked machine. Is that right? If so, you need to set up two-machine  
debugging. The documentation on this is pretty good. The best place to  
start is "Kernel Extension Concepts", especially the section titled  
"Hello Debugger":

<http://developer.apple.com/documentation/Darwin/Conceptual/ 
KEXTConcept/index.html>.

> HAS ANYONE EVER USED TN2063?

:-) I wrote it. And, yes, those techniques are being used every day by  
developers and Apple engineers.

> Please send anything which might help

If you're still stuck after reviewing the docs, how about posting the  
sequence of commands you've tried?

>
> thanks
>
> Harland Harrison
> 2wire.com

Regards,
--gc

>
>
> -----Original Message-----
> From: usb-bounces+hharrison=email@hidden on behalf of Jim  
> Wintermyre
> Sent: Tue 2/8/2005 4:43 PM
> To: email@hidden
> Subject: RE: GDB can't access kext code memory
>
>> The GDB tool always returns "Cannot access memory" for me, even on
>> valid addresses. I proved that with a panic.log from the same
>> machine and OS which is running GDB.
>>
>> Using an "assert()" in my kext, I generated a panic.log on the same
>> machine. Then I ran kextstat and checked that the addresses in this
>> panic.log fell within the ranges of the kexts involved. Then I tried
>> to read those addresses with the GDB tool. GDB still returned
>> "Cannot access memory" for valid addresses in my kext, and also for
>> addresses within the ranges of several "com.apple.X" kexts.
>
> If you're trying to access memory in your device's address space, you
> may need to use the kdp_read_io (mapped memory) and/or kdp_trans_off
> (phsical addresses) options.  Check here for more info:
>
> http://developer.apple.com/documentation/Darwin/Conceptual/ 
> KernelProgramming/build/chapter_18_section_5.html
>
> Also, I have heard that kdp_trans_off will affect lots of things in
> gdb, so its best to enable and then disable before attempting
> anything else.
>
> Jim
__________________________________________________________________
Garth Cummings				
Apple Developer Technical Support 	email@hidden

http://developer.apple.com/technicalsupport
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.