Building and Debugging Kernels
This chapter is not about building kernel extensions (KEXTs). There are a number of good KEXT tutorials on Apple’s developer documentation site (http://developer.apple.com/documentation). This chapter is about adding new in-kernel modules (optional parts of the kernel), building kernels, and debugging kernel and kernel extension builds.
The discussion is divided into three sections. The first, “Adding New Files or Modules”, describes how to add new functionality into the kernel itself. You should only add files into the kernel when the use of a KEXT is not possible (for example, when adding certain low-level motherboard hardware support).
The second section, “Building Your First Kernel”, describes how to build a kernel, including how to build a kernel with debugger support, how to add new options, and how to obtain sources that are of similar vintage to those in a particular version of Mac OS X or Darwin.
The third section, “When Things Go Wrong: Debugging the Kernel”, tells how to debug a kernel or kernel module using
gdb. This is a must-read for anyone doing kernel development.