This is an officially unsupported two-box setup, suitable for real kernel (and sometimes kext) development.
Make sure the box has plenty, but not too much, ram, unless you enjoy wasting time doing either virtual or actual paging.
-
Install OSX by dragging the
Install OS X *.app
onto VMware Fusion new VM wizard dialog. -
Install the
Kernel Debug Kit (KDK)
of this box'es kernel. -
Run the following to change from release to development kernel: NOTE: debug flag 0x001 pauses bootup until the host debugger attaches
# 10.10+
sudo cp /Library/Developer/KDKs/*/System/Library/Kernels/kernel.development /System/Library/Kernels/
sudo nvram boot-args="pmuflags=1 debug=0x166 kext-dev-mode=1 kcsuffix=development -v" sudo kextcache -invalidate / sudo reboot
-
If debugging the kernel with the debug flag 0x001, verbose mode should now show when the host's llvm debugger connects:
ip address: (TARGET_BOX_IP_ADDR) Waiting for remote debugger connection.
-
Install
Xcode
andXcode CLT
. -
Install the same KDK of the target box'es kernel.
-
Append or create the following to
~/.lldbinit-lldb
settings set target.load-script-from-symbol-file true
-
Run this to start the remote debugger:
# 10.10+ TARGET : use development kernel instead of release lldb /Library/Developer/KDKs/*/System/Library/Kernels/kernel.development # <= 10.9 TARGET: use release kernel, DEBUG might be too slow # lldb /Library/Developer/KDKs/*/mach_kernel
-
At the '(lldb)' prompt, run:
(lldb) kdp-remote TARGET_BOX_IP_ADDR
-
This should boot the kernel, and the target box should now say:
Connected to remote debugger.
-
To boot the box "normally", just run this:
(lldb) continue
- /Library/Developer/KDKs/*.kdk/ReadMe.html
- LLDB Quick Start Guide
- Apple's GDB -> LLDB command map
- kernel debug flags