Kext debugging using a virtual machine

Questions and Answers about all things *OS (macOS, iOS, tvOS, watchOS)

Kext debugging using a virtual machine

Postby bkdev » Fri Feb 12, 2016 9:28 pm

If I'm not mistaken, I believe that vol.2 of your upcoming book will have a section on how to debug a kext using a virtual machine.

I'm learning kext development and I would prefer to use a virtual machine (using VMWare Fusion) to load my kext in a virtual machine and use lldb from the host machine to debug it in order not to crash the host OS.

Until I can buy and read Vol.2 are there any resources that you would recommend to start debugging my kext using a virtual machine?

Thanks!
bkdev
 
Posts: 3
Joined: Fri Feb 12, 2016 9:21 pm

Re: Kext debugging using a virtual machine

Postby morpheus » Thu Feb 18, 2016 8:06 pm

Fusion is a bit problematic since it doesn't have full serial port emulation, only to a text file (i.e. write only, not read).

I suggest using VMWare workstation instead, where you get a full serial port to a windows named pipe, or linux pipe - in which case you can use lldb.

Option 2 is to use kdp. that's actually easier, and well documented (though outdated) in here:

https://reverse.put.as/2009/03/05/mac-o ... th-vmware/

And you definitely want the kernel debug kit (KDK) , downloadable from AAPL.
morpheus
Site Admin
 
Posts: 530
Joined: Thu Apr 11, 2013 6:24 pm

Re: Kext debugging using a virtual machine

Postby bkdev » Thu Feb 18, 2016 8:21 pm

Thank you for the reply!

Does this mean that I can not use LLDB and I have to use GDB?

Is there some other virtualization software for Mac that has full serial port emulation and that I can use?

Using VMWare workstation would mean using this on a Windows machine but I am using a Mac.

UPDATE: Just found this article that seems to mention Fusion:

http://ddeville.me/2015/08/kernel-debug ... re-fusion/

Still not sure how I would add the symbols for my kext source code and set breakpoints.
bkdev
 
Posts: 3
Joined: Fri Feb 12, 2016 9:21 pm

Re: Kext debugging using a virtual machine

Postby morpheus » Thu Feb 18, 2016 10:39 pm

So the link you have is essentially the same as Pedro's (reverse.put.as) but updated somewhat. But it's also over KDP

The trick is to add the debug symbols of both the kernel and your kernel extension (its dsym file) to lldb. LLDB and GDB operate in much the same way here.
morpheus
Site Admin
 
Posts: 530
Joined: Thu Apr 11, 2013 6:24 pm

Re: Kext debugging using a virtual machine

Postby TheDarkKnight » Tue Apr 05, 2016 3:03 pm

There's a good blog, similar to Pedro's here: https://objective-see.com/blog.html#blogEntry8

I found this useful too: http://ddeville.me/2015/08/kernel-debugging-with-lldb-and-vmware-fusion/

Still not sure how I would add the symbols for my kext source code and set breakpoints.


The symbols had me confused for quite some time. You need the symbols (.dsym) on both the host and target machines in a location that Spotlight will index. Once Spotlight is aware of them, they should automatically be picked up and available in lldb.
TheDarkKnight
 
Posts: 26
Joined: Wed Dec 16, 2015 10:30 am


Return to Questions and Answers

Who is online

Users browsing this forum: No registered users and 3 guests