Kernel Utilities

Mac OS X includes various utilities that interact with the kernel. With these utilities, you can debug a running kernel, load and unload kernel modules or extensions, or set kernel variables.

ddb

The ddb utility can debug a running kernel. It is not included with the current version of Mac OS X. If you want to use ddb, you can find its source code in the xnu (Darwin kernel) source code (http://www.opensource.apple.com/darwinsource/).

ktrace

Use ktrace to perform kernel tracing (tracing system calls and other operations) on a process. To launch a program and generate a kernel trace (ktrace.out, which is not human-readable), use ktrace command, as in ktrace emacs. Kernel tracing ends when you exit the process or disable tracing with ktrace -cp pid. You can get human readable output from a ktrace file with kdump.

Kernel Module Utilities

The following list describes utilities for manipulating kernel modules. For more information, see the kernel extension tutorials available at http://www.opensource.apple.com/projects/documentation/howto. These utilities must be run with superuser privileges:

kextload

Loads an extension bundle.

kextunload

Unloads an extension bundle.

kextstat

Displays the status of currently loaded kernel extensions. Table 15-5 describes this utility’s output. Figure 15-6 shows sample output.

Table 15-5. Information displayed by kextstat

Item

number

Column

Description

1

Index

Index number of the loaded extension. Extensions are loaded ...

Get Mac OS X Panther for Unix Geeks, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.