2 .\" Mach Operating System
3 .\" Copyright (c) 1991,1990 Carnegie Mellon University
4 .\" All Rights Reserved.
6 .\" Permission to use, copy, modify and distribute this software and its
7 .\" documentation is hereby granted, provided that both the copyright
8 .\" notice and this permission notice appear in all copies of the
9 .\" software, derivative works or modified versions, and any portions
10 .\" thereof, and that both notices appear in supporting documentation.
12 .\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 .\" CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 .\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 .\" Carnegie Mellon requests users of this software to return to
18 .\" Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 .\" School of Computer Science
20 .\" Carnegie Mellon University
21 .\" Pittsburgh PA 15213-3890
23 .\" any improvements or extensions that they make and grant Carnegie Mellon
24 .\" the rights to redistribute these changes.
26 .\" changed a \# to #, since groff choked on it.
30 .\" Revision 1.1 1993/07/15 18:41:02 brezak
33 .\" Revision 2.6 92/04/08 08:52:57 rpd
35 .\" [92/01/17 14:19:22 jsb]
36 .\" Changes for OSF debugger modifications.
39 .\" Revision 2.5 91/06/25 13:50:22 rpd
40 .\" Added some watchpoint explanation.
43 .\" Revision 2.4 91/06/17 15:47:31 jsb
44 .\" Added documentation for continue/c, match, search, and watchpoints.
45 .\" I've not actually explained what a watchpoint is; maybe Rich can
46 .\" do that (hint, hint).
47 .\" [91/06/17 10:58:08 jsb]
49 .\" Revision 2.3 91/05/14 17:04:23 mrt
50 .\" Correcting copyright
52 .\" Revision 2.2 91/02/14 14:10:06 mrt
53 .\" Changed to new Mach copyright
54 .\" [91/02/12 18:10:12 mrt]
56 .\" Revision 2.2 90/08/30 14:23:15 dbg
66 .Nd interactive kernel debugger
71 To prevent activation of the debugger on kernel
73 .Cd options KDB_UNATTENDED
77 kernel debugger has most of the features of the old kdb,
78 but with a more rational syntax
81 If linked into the running kernel,
82 it can be invoked locally with the
86 The debugger is also invoked on kernel
89 .Va debug.debugger_on_panic
91 MIB variable is set non-zero,
97 The current location is called `dot'.
98 The `dot' is displayed with
99 a hexadecimal format at a prompt.
100 Examine and write commands update `dot' to the address of the last line
101 examined or the last location modified, and set `next' to the address of
102 the next location to be examined or changed.
103 Other commands do not change `dot', and set `next' to be the same as `dot'.
105 The general command syntax is:
106 .Cm command Ns Op Li \&/ Ns Ar modifier
107 .Ar address Ns Op Li , Ns Ar count
109 A blank line repeats the previous command from the address `next' with
110 count 1 and no modifiers.
121 to be 1 for printing commands or infinity for stack traces.
125 debugger has a feature like the
129 If an output line exceeds the number set in the
131 variable, it displays
133 and waits for a response.
134 The valid responses for it are:
136 .Bl -tag -compact -width ".Li SPC"
142 abort the current command, and return to the command input mode
147 provides a small (currently 10 items) command history, and offers
148 simple emacs-style command line editing capabilities.
150 the emacs control keys, the usual ANSI arrow keys might be used to
151 browse through the history buffer, and move the cursor within the
157 Display the addressed locations according to the formats in the modifier.
158 Multiple modifier formats display multiple locations.
159 If no format is specified, the last formats specified for this command
162 The format characters are:
163 .Bl -tag -compact -width indent
165 look at by bytes (8 bits)
167 look at by half words (16 bits)
169 look at by long words (32 bits)
171 print the location being displayed
173 print the location with a line number if possible
175 display in unsigned hex
177 display in signed hex
179 display in unsigned octal
181 display in signed decimal
183 display in unsigned decimal
185 display in current radix, signed
187 display low 8 bits as a character.
188 Non-printing characters are displayed as an octal escape code (e.g., `\e000').
190 display the null-terminated string at the location.
191 Non-printing characters are displayed as octal escapes.
193 display in unsigned hex with character dump at the end of each line.
194 The location is also displayed in hex at the beginning of each line.
196 display as an instruction
198 display as an instruction with possible alternate formats depending on the
200 .Bl -tag -width ".Tn powerpc" -compact
202 Show the registers of the instruction.
217 Execute an examine command with the last specified parameters to it
218 except that the next address displayed by it is used as the start address.
221 Execute an examine command with the last specified parameters to it
222 except that the last start address subtracted by the size displayed by it
223 is used as the start address.
224 .It Cm print Ns Op Cm /acdoruxz
227 according to the modifier character (as described above for
239 If no modifier is specified, the last one specified to it is used.
241 can be a string, in which case it is printed as it is.
243 .Bd -literal -offset indent
244 print/x \&"eax = \&" $eax \&"\enecx = \&" $ecx \&"\en\&"
248 .Bd -literal -offset indent
253 .Cm write Ns Op Cm /bhl
254 .Ar addr Ar expr1 Op Ar "expr2 ..."
256 Write the expressions specified after
258 on the command line at succeeding locations starting with
260 The write unit size can be specified in the modifier with a letter
266 (long word) respectively.
268 long word is assumed.
271 since there is no delimiter between expressions, strange
273 It is best to enclose each expression in parentheses.
276 .Li \&$ Ns Ar variable
280 Set the named variable or register with the value of
282 Valid variable names are described below.
283 .It Cm break Ns Op Cm /u
288 is supplied, continues
290 - 1 times before stopping at the
292 If the break point is set, a break point number is
295 This number can be used in deleting the break point
296 or adding conditions to it.
300 modifier is specified, this command sets a break point in user space
304 option, the address is considered in the kernel
305 space, and wrong space address is rejected with an error message.
306 This modifier can be used only if it is supported by machine dependent
310 If a user text is shadowed by a normal user space debugger,
311 user space break points may not work correctly.
313 point at the low-level code paths may also cause strange behavior.
314 .It Cm delete Ar addr
315 .It Cm delete Li \&# Ns Ar number
316 Delete the break point.
317 The target break point can be specified by a
318 break point number with
322 specified in the original
325 .It Cm step Ns Op Cm /p
328 times (the comma is a mandatory part of the syntax).
331 modifier is specified, print each instruction at each step.
332 Otherwise, only print the last instruction.
335 depending on machine type, it may not be possible to
336 single-step through some low-level code paths or user space code.
337 On machines with software-emulated single-stepping (e.g., pmax),
338 stepping through code executed by interrupt handlers will probably
340 .It Cm continue Ns Op Cm /c
341 Continue execution until a breakpoint or watchpoint.
344 modifier is specified, count instructions while executing.
345 Some machines (e.g., pmax) also count loads and stores.
348 when counting, the debugger is really silently single-stepping.
349 This means that single-stepping on low-level code may cause strange
351 .It Cm until Ns Op Cm /p
352 Stop at the next call or return instruction.
355 modifier is specified, print the call nesting depth and the
356 cumulative instruction count at each call or return.
358 only print when the matching return is hit.
359 .It Cm next Ns Op Cm /p
360 .It Cm match Ns Op Cm /p
361 Stop at the matching return instruction.
364 modifier is specified, print the call nesting depth and the
365 cumulative instruction count at each call or return.
366 Otherwise, only print when the matching return is hit.
368 .Cm trace Ns Op Cm /u
375 option traces user space; if omitted,
380 is the number of frames to be traced.
383 is omitted, all frames are printed.
386 User space stack trace is valid
387 only if the machine dependent code supports it.
389 .Cm search Ns Op Cm /bhl
397 This command might fail in interesting
398 ways if it does not find the searched-for value.
399 This is because ddb does not always recover from touching bad memory.
402 argument limits the search.
403 .It Cm show all procs Ns Op Cm /m
404 .It Cm ps Ns Op Cm /m
405 Display all process information.
406 The process information may not be shown if it is not
407 supported in the machine, or the bottom of the stack of the
408 target process is not in the main memory at that time.
411 modifier will alter the display to show VM map
412 addresses for the process and not show other info.
413 .It Cm show registers Ns Op Cm /u
414 Display the register set.
417 option is specified, it displays user registers instead of
418 kernel or currently saved one.
423 modifier depends on the machine.
424 If not supported, incorrect information will be displayed.
426 .Cm show map Ns Op Cm /f
433 modifier is specified the
434 complete map is printed.
436 .Cm show object Ns Op Cm /f
439 Prints the VM object at
443 option is specified the
444 complete object is printed.
445 .It Cm "show watches"
446 Displays all watchpoints.
448 Hard reset the system.
451 .Ar addr Ns Li \&, Ns Ar size
453 Set a watchpoint for a region.
454 Execution stops when an attempt to modify the region occurs.
457 argument defaults to 4.
458 If you specify a wrong space address, the request is rejected
459 with an error message.
462 Attempts to watch wired kernel memory
463 may cause unrecoverable error in some systems such as i386.
464 Watchpoints on user addresses work best.
467 .Ar addr Ns Li \&, Ns Ar size
469 Set a hardware watchpoint for a region if supported by the
471 Execution stops when an attempt to modify the region occurs.
474 argument defaults to 4.
477 The hardware debug facilities do not have a concept of separate
478 address spaces like the watch command does.
481 for setting watchpoints on kernel address locations only, and avoid
482 its use on user mode address spaces.
485 .Ar addr Ns Li \&, Ns Ar size
487 Delete specified hardware watchpoint.
489 Toggles between remote GDB and DDB mode.
490 In remote GDB mode, another machine is required that runs
492 using the remote debug feature, with a connection to the serial
493 console port on the target machine.
494 Currently only available on the
498 Print a short summary of the available commands and command
502 The debugger accesses registers and variables as
504 Register names are as in the
505 .Dq Cm show registers
507 Some variables are suffixed with numbers, and may have some modifier
508 following a colon immediately after the variable name.
509 For example, register variables can have a
511 modifier to indicate user register (e.g.,
514 Built-in variables currently supported are:
515 .Bl -tag -width ".Li tabstops" -compact
517 Input and output radix
519 Addresses are printed as 'symbol'+offset unless offset is greater than maxoff.
521 The width of the displayed line.
535 Almost all expression operators in C are supported except
543 .Bl -tag -width ".Em Identifiers"
545 The name of a symbol is translated to the value of the symbol, which
546 is the address of the corresponding object.
550 can be used in the identifier.
551 If supported by an object format dependent routine,
553 .Oo Em filename : Oc Em func : lineno ,
555 .Oo Em filename : Oc Ns Em variable ,
557 .Oo Em filename : Oc Ns Em lineno
558 can be accepted as a symbol.
560 Radix is determined by the first two letters:
566 decimal; otherwise, follow current radix.
572 address of the start of the last line examined.
573 Unlike `dot' or `next', this is only changed by
579 last address explicitly specified.
580 .It Li \&$ Ns Em variable
581 Translated to the value of the specified variable.
582 It may be followed by a
584 and modifiers as described above.
585 .It Em a Ns Li \&# Ns Em b
586 a binary operator which rounds up the left hand side to the next
587 multiple of right hand side.
588 .It Li \&* Ns Em expr
590 It may be followed by a
592 and modifiers as described above.
595 On machines with an ISA expansion bus, a simple NMI generation card can be
596 constructed by connecting a push button between the A01 and B01 (CHCHK# and
598 Momentarily shorting these two fingers together may cause the bridge chipset to
599 generate an NMI, which causes the kernel to pass control to
601 Some bridge chipsets do not generate a NMI on CHCHK#, so your mileage may vary.
602 The NMI allows one to break into the debugger on a wedged machine to
604 Other bus' bridge chipsets may be able to generate NMI using bus specific
611 debugger was developed for Mach, and ported to
613 This manual page translated from
615 macros by Garrett Wollman.