DDB(4) MidnightBSD Kernel Interfaces Manual DDB(4)


ddb — interactive kernel debugger


options KDB
options DDB




The ddb kernel debugger has most of the features of the old kdb, but with a more rational 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. Examine and write commands 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’.


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 feature like the more(1) command for the output. If an output line exceeds the number set in the $lines variable, it displays ‘‘--db_more--’’ and waits for a response. The valid responses for it are:


one more page


one more line


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 might be used to browse through the history buffer, and move the cursor within the current line.



Display the addressed locations according to the formats in the modifier. Multiple modifier formats display multiple locations. If no format is specified, the last formats specified for this command is used.

The format characters are:


look at by bytes (8 bits)


look at by half words (16 bits)


look at by long words (32 bits)


print the location being displayed


print the location with a line number if possible


display in unsigned hex


display in signed hex


display in unsigned octal


display in signed decimal


display in unsigned decimal


display in current radix, signed








display as an instruction


display as an instruction with possible alternate formats depending on the machine:


Show the registers of the instruction.


No alternate format.


No alternate format.


No alternate format.


No alternate format.


No alternate format.


Examine forward: Execute an examine command with the last specified parameters to it except that the next address displayed by it is used as the start address.




Print addrs according to the modifier character (as described above for examine). Valid formats are: a, x, z, o, d, u, r, and c. If no modifier is specified, the last one specified to it is used. addr can be a string, in which case it is printed as it is. For example:


will print like:

eax = xxxxxx
ecx = yyyyyy


Write the expressions specified after addr on the command line at succeeding locations starting with addr The write unit size can be specified in the modifier with a letter b (byte), h (half word) or l (long word) respectively. If omitted, long word is assumed.


set $variable [=] expr



Set a break point at addr. If count is supplied, continues count - 1 times before stopping at the break point. If the break point is set, a break point number is printed with ‘#’. This number can be used in deleting the break point or adding conditions to it.

If the u modifier is specified, this command sets a break point in user space address. Without the u option, the address is considered in the kernel space, and wrong space address is rejected with an error message. This modifier can be used only if it is supported by machine dependent routines.


delete addr

delete #number

Delete the break point. The target break point can be specified by a break point number with #, or by using the same addr specified in the original break command.


Single step count times (the comma is a mandatory part of the syntax). If the p modifier is specified, print each instruction at each step. Otherwise, only print the last instruction.










trace[/u] [frame] [,count]

Stack trace. The u option traces user space; if omitted, trace only traces kernel space. count is the number of frames to be traced. If count is omitted, all frames are printed.



Search memory for value. This command might fail in interesting ways if it does not find the searched-for value. This is because ddb does not always recover from touching bad memory. The optional count argument limits the search.

show all procs[/m]



show registers[/u]

Display the register set. If the u option is specified, it displays user registers instead of kernel or currently saved one.


show map[/f] addr


show object[/f] addr


show watches

Displays all watchpoints.


Hard reset the system.

watch addr,size



hwatch addr,size



dhwatch addr,size

Delete specified hardware watchpoint.




Print a short summary of the available commands and command abbreviations.


The debugger accesses registers and variables as $name. Register names are as in the ‘‘show registers’’ command. Some variables are suffixed with numbers, and may have some modifier following a colon immediately after the variable name. For example, register variables can have a u modifier to indicate user register (e.g., $eax:u).

Built-in variables currently supported are:


Input and output radix


Addresses are printed as ’symbol’+offset unless offset is greater than maxoff.


The width of the displayed line.


The number of lines. It is used by ‘‘more’’ feature.


Tab stop width.


Work variable. xx can be 0 to 31.





filename: ]func:lineno, [
: ]variable, and [
: ]lineno can be accepted as a symbol.


Radix is determined by the first two letters: 0x: hex, 0o: octal, 0t: decimal; otherwise, follow current radix.






address of the start of the last line examined. Unlike ‘dot’ or ‘next’, this is only changed by ‘‘examine’’ or ‘‘write’’ command.

last address explicitly specified.


Translated to the value of the specified variable. It may be followed by a : and modifiers as described above.




indirection. It may be followed by a ‘’: and modifiers as described above.






The ddb debugger was developed for Mach, and ported to 386BSD 0.1. This manual page translated from −man macros by Garrett Wollman.

MidnightBSD 0.3 February 27, 2006 MidnightBSD 0.3