DDB(4) BSD Kernel Interfaces Manual DDB(4)
ddb -- interactive kernel debugger
In order to enable kernel debugging facilities include:
To prevent activation of the debugger on kernel panic(9):
In order to print a stack trace of the current thread on the console for a panic:
To print the numerical value of symbols in addition to the symbolic representation, define:
To enable the gdb(1) backend, so that remote debugging with kgdb(1) is possible, include:
The ddb kernel debugger is an interactive debugger with a syntax inspired by gdb(1). If linked into the running kernel, it can be invoked
locally with the 'debug' keymap(5) action. The debugger is also invoked on kernel panic(9) if the debug.debugger_on_panic sysctl(8) MIB
variable is set non-zero, which is the default unless the KDB_UNATTENDED option is specified.
The current location is called dot. The dot is displayed with a hexadecimal format at a prompt. The commands examine and write update dot
to the address of the last line examined or the last location modified, and set next to the address of the next location to be examined or
changed. Other commands do not change dot, and set next to be the same as dot.
The general command syntax is: command[/modifier] address[,count]
A blank line repeats the previous command from the address next with count 1 and no modifiers. Specifying address sets dot to the address.
Omitting address uses dot. A missing count is taken to be 1 for printing commands or infinity for stack traces.
The ddb debugger has a pager feature (like the more(1) command) for the output. If an output line exceeds the number set in the lines vari-
able, it displays ``--More--'' and waits for a response. The valid responses for it are:
SPC one more page
RET one more line
q abort the current command, and return to the command input mode
Finally, ddb provides a small (currently 10 items) command history, and offers simple emacs-style command line editing capabilities. In
addition to the emacs control keys, the usual ANSI arrow keys may be used to browse through the history buffer, and move the cursor within
the current line.
x Display the addressed locations according to the formats in the modifier. Multiple modifier formats display multiple locations. If
no format is specified, the last format specified for this command is used.
The format characters are:
b look at by bytes (8 bits)
h look at by half words (16 bits)
l look at by long words (32 bits)
a print the location being displayed
A print the location with a line number if possible
x display in unsigned hex
z display in signed hex
o display in unsigned octal
d display in signed decimal
u display in unsigned decimal
r display in current radix, signed
c display low 8 bits as a character. Non-printing characters are displayed as an octal escape code (e.g., '