

Once we’ve got our VM installed, we need to install the Kernel Debug Kit. Generally it’s not a problem, but it’s annoying to roll back and much easier to use a VMware snapshot.
#MAC OS DEBUGGER MAC OS X#
So, the first step of the process is: install yourself a Mac OS X VM as per the VMware documentation.Įdit 13 July 2013: Once you’re done it’s probably a good idea to take a snapshot of your VM in case there are problems installing the debug kernel. VMware Fusion 4 introduced the ability to install Mac OS X 10.7 into a VM without any dodgy hacks, just by choosing the Install Mac OS X Lion.app bundle as the installation disc. Prior to this, only the “server” version of Mac OS X was allowed to be virtualised, and VMware ‘prevented’ the client version from being installed through some hardcoded logic in vmware-vmx (which some sneaky hackers patched). We don’t really want to use two physical machines for debugging, because who the hell uses physical boxes these days when VMs will do the job? With the release of Mac OS X 10.7 (Lion), Apple changed the EULA to allow running virtualised instances of Lion on top of an instance running on bare metal. Apple suggests in the Kernel Programming Guide that you are better off using gdb for most tasks, so that’s what we’ll do. ddb can be used to debug the running kernel from the target machine itself, but is pretty low-level and arcane. KDP is implemented in-kernel by an instance of IOKernelDebugger, and allows you to connect to the debug stub from an instance of gdb (Apple’s outdated fork only AFAIK) running on another machine connected via FireWire or Ethernet. Apple has long provided methods for kernel debugging via the Kernel Debugger Protocol (KDP), along with ddb, the in-kernel serial debugger.
#MAC OS DEBUGGER HOW TO#
printf()-debugging is the worst, and being in kernel-land, it might not be immediately obvious how to go about debugging your (or other people’s) code.

Tags: mac os x, kernel, debugging, vmware, gdbĮdit 13 July 2013: I’ve made a couple of updates to this post to clarify a couple of things and resolve issues people have had.įG! did a great write up here on how to set up two-machine debugging with VMware on Leopard a couple of years ago, but as a few things have changed since then and I will probably refer to this topic in future posts I thought it was worth revisiting.ĭebugging kernel extensions can be a bit of a pain. Debugging the Mac OS X kernel with VMware and GDB
