Re: kext debugging in Lion broken?
Re: kext debugging in Lion broken?
- Subject: Re: kext debugging in Lion broken?
- From: Jason Molenda <email@hidden>
- Date: Tue, 16 Aug 2011 18:55:25 -0700
Hi Gary, gdb is in bug-fix maintenance mode except for the kext debugging features I mentioned earlier. I just reviewed the changes we made over the last year and I don't see anything else except the new "add-all-kexts" command.
We're putting our energy into our new debugger, LLDB (v. http://lldb.llvm.org/ or see the video from this year's WWDC, session 321, "Migrating from GDB to LLDB"). lldb can't yet do kernel debugging so it isn't of interest to many people on this list -- and which is why we added these new commands to gdb -- but eventually we'll have kernel debugging support added to lldb.
FWIW the "add-all-kexts" command in gdb gets the list of kexts currently loaded and search for the .kext and .kext.dSYM bundles on your local system. The .dSYM and .kext bundles must be next to each other in a directory; gdb searches for the dSYM and assumes that the .kext bundle will be a sibling. gdb will look with a Spotlight search, if it's in a Spotlight-indexed location on your computer (e.g. a .kext and .kext.dSYM in /tmp probably aren't going to be found by Spotlight) or you can specify a directory where gdb should look for these bundles on your system by a dwrite in Terminal
% defaults write com.apple.DebugSymbols DBGSearchPaths -string /Volumes/workdir/kexts/are/here
If you're working with multiple kexts you may want to set this and use add-all-kexts to load all of them instead of doing "add-kext" on each one individually. You can check which kexts have been loaded into gdb by doing
(gdb) info shared
after any of the above commands. I haven't tried using add-all-kexts with a small number of kexts - you may get warning messages from gdb about all of the system kexts it couldn't locate.
J
On Aug 16, 2011, at 6:27 PM, Gary Kratkin wrote:
> Jason, can you tell us what else has changed in the new gdb?
>
> On Aug 16, 2011, at 10:18 PM, Jason Molenda wrote:
>
>> David, as far as I know Ethernet kext debugging works correctly with Lion.
>>
>> If you are running Xcode 4.1's gdb on your debugger machine, you don't need to generate a .sym file with kextload -s. Instead you can target remote-kdp in gdb (on your "remote computer") and do
>>
>> (gdb) add-kext ~/XXXX.kext
>>
>> and gdb will get the addresses of where your kext was loaded directly from the kernel of the Lion system that's in kdp mode. (the kextload -s command that was used previously was the old way of telling gdb where everything got loaded)
>>
>>
>> Note that you must be building your kext with DWARF debug info (not stabs) - but I don't think you can build something with stabs in Xcode 4.1 any more. We changed our debug info format from stabs to DWARF 3-4 years ago.
>>
>> There is an additional "maintenance" command in gdb which will list all kexts currently loaded in the system that's in kdp mode,
>>
>> (gdb) maint list-kexts
>>
>> Note that gdb will enforce a check of the binary's UUID (the Mach-O LC_UUID load command contents) -- you must be "add-kext"'ing the exact same binary that is running on the system that is in kdp mode or gdb will reject the add-kext command.
>>
>> The intention is to make kext debugging a little bit easier than it used to be, we've gotten some positive feedback from kernel developers internally -- try this new arrangement, I think you'll like it.
>>
>> J
>>
>>
>> On Aug 15, 2011, at 10:06 PM, David Tay wrote:
>>
>>>
>>>
>>> Previously (Panther - Snow Leopard), I would do the following (ethernet based connection)
>>> 1. load the kext on the target machine kextload -l -s ~/ XXXX.kext
>>> 2. start gdb on the remote machine.
>>> 3. target remote kdp on the remote machine,
>>> 4. add-symbol-file YYYY copied from the target machine.
>>> 5. set break points in the code.
>>> 6. kextstat to make sure the kext was still loaded on the target machine.
>>> 7. Command -Power on target machine
>>> 8. connect <IP addr> from remote machine gdb session.
>>> 9. continue in gdb.
>>> 10. kextload -m on target machine.
>>>
>>> On Lion, none of the breakpoints (eg start, stop) are reached and the driver continues running. I'm using the Lion A511 kernel debug kit.
>>>
>>>
>>> What could be happening?
>>>
>>> Thanks,
>>>
>>> David _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Darwin-kernel mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Darwin-kernel mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden