]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - share/man/man4/ddb.4
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / share / man / man4 / ddb.4
1 .\"
2 .\" Mach Operating System
3 .\" Copyright (c) 1991,1990 Carnegie Mellon University
4 .\" Copyright (c) 2007 Robert N. M. Watson
5 .\" All Rights Reserved.
6 .\"
7 .\" Permission to use, copy, modify and distribute this software and its
8 .\" documentation is hereby granted, provided that both the copyright
9 .\" notice and this permission notice appear in all copies of the
10 .\" software, derivative works or modified versions, and any portions
11 .\" thereof, and that both notices appear in supporting documentation.
12 .\"
13 .\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 .\" CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
15 .\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 .\"
17 .\" Carnegie Mellon requests users of this software to return to
18 .\"
19 .\"  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
20 .\"  School of Computer Science
21 .\"  Carnegie Mellon University
22 .\"  Pittsburgh PA 15213-3890
23 .\"
24 .\" any improvements or extensions that they make and grant Carnegie Mellon
25 .\" the rights to redistribute these changes.
26 .\"
27 .\" changed a \# to #, since groff choked on it.
28 .\"
29 .\" HISTORY
30 .\" ddb.4,v
31 .\" Revision 1.1  1993/07/15  18:41:02  brezak
32 .\" Man page for DDB
33 .\"
34 .\" Revision 2.6  92/04/08  08:52:57  rpd
35 .\"     Changes from OSF.
36 .\"     [92/01/17  14:19:22  jsb]
37 .\"     Changes for OSF debugger modifications.
38 .\"     [91/12/12            tak]
39 .\"
40 .\" Revision 2.5  91/06/25  13:50:22  rpd
41 .\"     Added some watchpoint explanation.
42 .\"     [91/06/25            rpd]
43 .\"
44 .\" Revision 2.4  91/06/17  15:47:31  jsb
45 .\"     Added documentation for continue/c, match, search, and watchpoints.
46 .\"     I've not actually explained what a watchpoint is; maybe Rich can
47 .\"     do that (hint, hint).
48 .\"     [91/06/17  10:58:08  jsb]
49 .\"
50 .\" Revision 2.3  91/05/14  17:04:23  mrt
51 .\"     Correcting copyright
52 .\"
53 .\" Revision 2.2  91/02/14  14:10:06  mrt
54 .\"     Changed to new Mach copyright
55 .\"     [91/02/12  18:10:12  mrt]
56 .\"
57 .\" Revision 2.2  90/08/30  14:23:15  dbg
58 .\"     Created.
59 .\"     [90/08/30            dbg]
60 .\"
61 .\" $FreeBSD$
62 .\"
63 .Dd November 29, 2008
64 .Dt DDB 4
65 .Os
66 .Sh NAME
67 .Nm ddb
68 .Nd interactive kernel debugger
69 .Sh SYNOPSIS
70 .Cd options KDB
71 .Cd options DDB
72 .Pp
73 To prevent activation of the debugger on kernel
74 .Xr panic 9 :
75 .Cd options KDB_UNATTENDED
76 .Sh DESCRIPTION
77 The
78 .Nm
79 kernel debugger has most of the features of the old
80 .Nm kdb ,
81 but with a more rational syntax
82 inspired by
83 .Xr gdb 1 .
84 If linked into the running kernel,
85 it can be invoked locally with the
86 .Ql debug
87 .Xr keymap 5
88 action.
89 The debugger is also invoked on kernel
90 .Xr panic 9
91 if the
92 .Va debug.debugger_on_panic
93 .Xr sysctl 8
94 MIB variable is set non-zero,
95 which is the default
96 unless the
97 .Dv KDB_UNATTENDED
98 option is specified.
99 .Pp
100 The current location is called
101 .Va dot .
102 The
103 .Va dot
104 is displayed with
105 a hexadecimal format at a prompt.
106 The commands
107 .Ic examine
108 and
109 .Ic write
110 update
111 .Va dot
112 to the address of the last line
113 examined or the last location modified, and set
114 .Va next
115 to the address of
116 the next location to be examined or changed.
117 Other commands do not change
118 .Va dot ,
119 and set
120 .Va next
121 to be the same as
122 .Va dot .
123 .Pp
124 The general command syntax is:
125 .Ar command Ns Op Li / Ns Ar modifier
126 .Ar address Ns Op Li , Ns Ar count
127 .Pp
128 A blank line repeats the previous command from the address
129 .Va next
130 with
131 count 1 and no modifiers.
132 Specifying
133 .Ar address
134 sets
135 .Va dot
136 to the address.
137 Omitting
138 .Ar address
139 uses
140 .Va dot .
141 A missing
142 .Ar count
143 is taken
144 to be 1 for printing commands or infinity for stack traces.
145 .Pp
146 The
147 .Nm
148 debugger has a pager feature (like the
149 .Xr more 1
150 command)
151 for the output.
152 If an output line exceeds the number set in the
153 .Va lines
154 variable, it displays
155 .Dq Li --More--
156 and waits for a response.
157 The valid responses for it are:
158 .Pp
159 .Bl -tag -compact -width ".Li SPC"
160 .It Li SPC
161 one more page
162 .It Li RET
163 one more line
164 .It Li q
165 abort the current command, and return to the command input mode
166 .El
167 .Pp
168 Finally,
169 .Nm
170 provides a small (currently 10 items) command history, and offers
171 simple
172 .Nm emacs Ns -style
173 command line editing capabilities.
174 In addition to
175 the
176 .Nm emacs
177 control keys, the usual
178 .Tn ANSI
179 arrow keys might be used to
180 browse through the history buffer, and move the cursor within the
181 current line.
182 .Sh COMMANDS
183 .Bl -tag -width indent -compact
184 .It Ic examine
185 .It Ic x
186 Display the addressed locations according to the formats in the modifier.
187 Multiple modifier formats display multiple locations.
188 If no format is specified, the last format specified for this command
189 is used.
190 .Pp
191 The format characters are:
192 .Bl -tag -compact -width indent
193 .It Cm b
194 look at by bytes (8 bits)
195 .It Cm h
196 look at by half words (16 bits)
197 .It Cm l
198 look at by long words (32 bits)
199 .It Cm a
200 print the location being displayed
201 .It Cm A
202 print the location with a line number if possible
203 .It Cm x
204 display in unsigned hex
205 .It Cm z
206 display in signed hex
207 .It Cm o
208 display in unsigned octal
209 .It Cm d
210 display in signed decimal
211 .It Cm u
212 display in unsigned decimal
213 .It Cm r
214 display in current radix, signed
215 .It Cm c
216 display low 8 bits as a character.
217 Non-printing characters are displayed as an octal escape code (e.g.,
218 .Ql \e000 ) .
219 .It Cm s
220 display the null-terminated string at the location.
221 Non-printing characters are displayed as octal escapes.
222 .It Cm m
223 display in unsigned hex with character dump at the end of each line.
224 The location is also displayed in hex at the beginning of each line.
225 .It Cm i
226 display as an instruction
227 .It Cm I
228 display as an instruction with possible alternate formats depending on the
229 machine:
230 .Bl -tag -width ".Tn powerpc" -compact
231 .It Tn alpha
232 Show the registers of the instruction.
233 .It Tn amd64
234 No alternate format.
235 .It Tn i386
236 No alternate format.
237 .It Tn ia64
238 No alternate format.
239 .It Tn powerpc
240 No alternate format.
241 .It Tn sparc64
242 No alternate format.
243 .El
244 .It Cm S
245 display a symbol name for the pointer stored at the address
246 .El
247 .Pp
248 .It Ic xf
249 Examine forward:
250 execute an
251 .Ic examine
252 command with the last specified parameters to it
253 except that the next address displayed by it is used as the start address.
254 .Pp
255 .It Ic xb
256 Examine backward:
257 execute an
258 .Ic examine
259 command with the last specified parameters to it
260 except that the last start address subtracted by the size displayed by it
261 is used as the start address.
262 .Pp
263 .It Ic print Ns Op Li / Ns Cm acdoruxz
264 .It Ic p Ns Op Li / Ns Cm acdoruxz
265 Print
266 .Ar addr Ns s
267 according to the modifier character (as described above for
268 .Cm examine ) .
269 Valid formats are:
270 .Cm a , x , z , o , d , u , r ,
271 and
272 .Cm c .
273 If no modifier is specified, the last one specified to it is used.
274 The argument
275 .Ar addr
276 can be a string, in which case it is printed as it is.
277 For example:
278 .Bd -literal -offset indent
279 print/x "eax = " $eax "\enecx = " $ecx "\en"
280 .Ed
281 .Pp
282 will print like:
283 .Bd -literal -offset indent
284 eax = xxxxxx
285 ecx = yyyyyy
286 .Ed
287 .Pp
288 .It Xo
289 .Ic write Ns Op Li / Ns Cm bhl
290 .Ar addr expr1 Op Ar expr2 ...
291 .Xc
292 .It Xo
293 .Ic w Ns Op Li / Ns Cm bhl
294 .Ar addr expr1 Op Ar expr2 ...
295 .Xc
296 Write the expressions specified after
297 .Ar addr
298 on the command line at succeeding locations starting with
299 .Ar addr .
300 The write unit size can be specified in the modifier with a letter
301 .Cm b
302 (byte),
303 .Cm h
304 (half word) or
305 .Cm l
306 (long word) respectively.
307 If omitted,
308 long word is assumed.
309 .Pp
310 .Sy Warning :
311 since there is no delimiter between expressions, strange
312 things may happen.
313 It is best to enclose each expression in parentheses.
314 .Pp
315 .It Ic set Li $ Ns Ar variable Oo Li = Oc Ar expr
316 Set the named variable or register with the value of
317 .Ar expr .
318 Valid variable names are described below.
319 .Pp
320 .It Ic break Ns Op Li / Ns Cm u
321 .It Ic b Ns Op Li / Ns Cm u
322 Set a break point at
323 .Ar addr .
324 If
325 .Ar count
326 is supplied, continues
327 .Ar count
328 \- 1 times before stopping at the
329 break point.
330 If the break point is set, a break point number is
331 printed with
332 .Ql # .
333 This number can be used in deleting the break point
334 or adding conditions to it.
335 .Pp
336 If the
337 .Cm u
338 modifier is specified, this command sets a break point in user space
339 address.
340 Without the
341 .Cm u
342 option, the address is considered in the kernel
343 space, and wrong space address is rejected with an error message.
344 This modifier can be used only if it is supported by machine dependent
345 routines.
346 .Pp
347 .Sy Warning :
348 If a user text is shadowed by a normal user space debugger,
349 user space break points may not work correctly.
350 Setting a break
351 point at the low-level code paths may also cause strange behavior.
352 .Pp
353 .It Ic delete Ar addr
354 .It Ic d Ar addr
355 .It Ic delete Li # Ns Ar number
356 .It Ic d Li # Ns Ar number
357 Delete the break point.
358 The target break point can be specified by a
359 break point number with
360 .Ql # ,
361 or by using the same
362 .Ar addr
363 specified in the original
364 .Ic break
365 command.
366 .Pp
367 .It Ic watch Ar addr Ns Li , Ns Ar size
368 Set a watchpoint for a region.
369 Execution stops when an attempt to modify the region occurs.
370 The
371 .Ar size
372 argument defaults to 4.
373 If you specify a wrong space address, the request is rejected
374 with an error message.
375 .Pp
376 .Sy Warning :
377 Attempts to watch wired kernel memory
378 may cause unrecoverable error in some systems such as i386.
379 Watchpoints on user addresses work best.
380 .Pp
381 .It Ic hwatch Ar addr Ns Li , Ns Ar size
382 Set a hardware watchpoint for a region if supported by the
383 architecture.
384 Execution stops when an attempt to modify the region occurs.
385 The
386 .Ar size
387 argument defaults to 4.
388 .Pp
389 .Sy Warning :
390 The hardware debug facilities do not have a concept of separate
391 address spaces like the watch command does.
392 Use
393 .Ic hwatch
394 for setting watchpoints on kernel address locations only, and avoid
395 its use on user mode address spaces.
396 .Pp
397 .It Ic dhwatch Ar addr Ns Li , Ns Ar size
398 Delete specified hardware watchpoint.
399 .Pp
400 .It Ic step Ns Op Li / Ns Cm p
401 .It Ic s Ns Op Li / Ns Cm p
402 Single step
403 .Ar count
404 times (the comma is a mandatory part of the syntax).
405 If the
406 .Cm p
407 modifier is specified, print each instruction at each step.
408 Otherwise, only print the last instruction.
409 .Pp
410 .Sy Warning :
411 depending on machine type, it may not be possible to
412 single-step through some low-level code paths or user space code.
413 On machines with software-emulated single-stepping (e.g., pmax),
414 stepping through code executed by interrupt handlers will probably
415 do the wrong thing.
416 .Pp
417 .It Ic continue Ns Op Li / Ns Cm c
418 .It Ic c Ns Op Li / Ns Cm c
419 Continue execution until a breakpoint or watchpoint.
420 If the
421 .Cm c
422 modifier is specified, count instructions while executing.
423 Some machines (e.g., pmax) also count loads and stores.
424 .Pp
425 .Sy Warning :
426 when counting, the debugger is really silently single-stepping.
427 This means that single-stepping on low-level code may cause strange
428 behavior.
429 .Pp
430 .It Ic until Ns Op Li / Ns Cm p
431 Stop at the next call or return instruction.
432 If the
433 .Cm p
434 modifier is specified, print the call nesting depth and the
435 cumulative instruction count at each call or return.
436 Otherwise,
437 only print when the matching return is hit.
438 .Pp
439 .It Ic next Ns Op Li / Ns Cm p
440 .It Ic match Ns Op Li / Ns Cm p
441 Stop at the matching return instruction.
442 If the
443 .Cm p
444 modifier is specified, print the call nesting depth and the
445 cumulative instruction count at each call or return.
446 Otherwise, only print when the matching return is hit.
447 .Pp
448 .It Xo
449 .Ic trace Ns Op Li / Ns Cm u
450 .Op Ar pid | tid
451 .Op Li , Ns Ar count
452 .Xc
453 .It Xo
454 .Ic t Ns Op Li / Ns Cm u
455 .Op Ar pid | tid
456 .Op Li , Ns Ar count
457 .Xc
458 .It Xo
459 .Ic where Ns Op Li / Ns Cm u
460 .Op Ar pid | tid
461 .Op Li , Ns Ar count
462 .Xc
463 .It Xo
464 .Ic bt Ns Op Li / Ns Cm u
465 .Op Ar pid | tid
466 .Op Li , Ns Ar count
467 .Xc
468 Stack trace.
469 The
470 .Cm u
471 option traces user space; if omitted,
472 .Ic trace
473 only traces
474 kernel space.
475 The optional argument
476 .Ar count
477 is the number of frames to be traced.
478 If
479 .Ar count
480 is omitted, all frames are printed.
481 .Pp
482 .Sy Warning :
483 User space stack trace is valid
484 only if the machine dependent code supports it.
485 .Pp
486 .It Xo
487 .Ic search Ns Op Li / Ns Cm bhl
488 .Ar addr
489 .Ar value
490 .Op Ar mask
491 .Op Li , Ns Ar count
492 .Xc
493 Search memory for
494 .Ar value .
495 This command might fail in interesting
496 ways if it does not find the searched-for value.
497 This is because
498 .Nm
499 does not always recover from touching bad memory.
500 The optional
501 .Ar count
502 argument limits the search.
503 .Pp
504 .It Ic show Cm all procs Ns Op Li / Ns Cm m
505 .It Ic ps Ns Op Li / Ns Cm m
506 Display all process information.
507 The process information may not be shown if it is not
508 supported in the machine, or the bottom of the stack of the
509 target process is not in the main memory at that time.
510 The
511 .Cm m
512 modifier will alter the display to show VM map
513 addresses for the process and not show other info.
514 .Pp
515 .It Ic show Cm registers Ns Op Li / Ns Cm u
516 Display the register set.
517 If the
518 .Cm u
519 modifier is specified, it displays user registers instead of
520 kernel or currently saved one.
521 .Pp
522 .Sy Warning :
523 The support of the
524 .Cm u
525 modifier depends on the machine.
526 If not supported, incorrect information will be displayed.
527 .Pp
528 .It Ic show Cm sysregs
529 Show system registers (e.g.,
530 .Li cr0-4
531 on i386.)
532 Not present on some platforms.
533 .Pp
534 .It Ic show Cm geom Op Ar addr
535 If the
536 .Ar addr
537 argument is not given, displays the entire GEOM topology.
538 If the
539 .Ar addr
540 is given, displays details about the given GEOM object (class, geom, provider
541 or consumer).
542 .\"
543 .Pp
544 .It Ic show Cm jails
545 Show the list of
546 .Xr jail 8
547 instances.
548 In addition to what
549 .Xr jls 8
550 shows, also list kernel internal details.
551 .\"
552 .Pp
553 .It Ic show Cm map Ns Oo Li / Ns Cm f Oc Ar addr
554 Prints the VM map at
555 .Ar addr .
556 If the
557 .Cm f
558 modifier is specified the
559 complete map is printed.
560 .Pp
561 .It Ic show Cm object Ns Oo Li / Ns Cm f Oc Ar addr
562 Prints the VM object at
563 .Ar addr .
564 If the
565 .Cm f
566 option is specified the
567 complete object is printed.
568 .Pp
569 .It Ic show Cm vnode Ar addr
570 Displays details about the given vnode.
571 .Pp
572 .It Ic show Cm watches
573 Displays all watchpoints.
574 .Pp
575 .It Ic gdb
576 Toggles between remote GDB and DDB mode.
577 In remote GDB mode, another machine is required that runs
578 .Xr gdb 1
579 using the remote debug feature, with a connection to the serial
580 console port on the target machine.
581 Currently only available on the
582 i386
583 architecture.
584 .Pp
585 .It Ic halt
586 Halt the system.
587 .Pp
588 .It Ic kill Ar sig pid
589 Send signal
590 .Ar sig
591 to process
592 .Ar pid .
593 The signal is acted on upon returning from the debugger.
594 This command can be used to kill a process causing resource contention
595 in the case of a hung system.
596 See
597 .Xr signal 3
598 for a list of signals.
599 Note that the arguments are reversed relative to
600 .Xr kill 2 .
601 .Pp
602 .It Ic reboot
603 .It Ic reset
604 Hard reset the system.
605 .Pp
606 .It Ic help
607 Print a short summary of the available commands and command
608 abbreviations.
609 .Pp
610 .It Ic capture on
611 .It Ic capture off
612 .It Ic capture reset
613 .It Ic capture status
614 .Nm
615 supports a basic output capture facility, which can be used to retrieve the
616 results of debugging commands from userpsace using
617 .Xr sysctl 2 .
618 .Ic capture on
619 enables output capture;
620 .Ic capture off
621 disables capture.
622 .Ic capture reset
623 will clear the capture buffer and disable capture.
624 .Ic capture status
625 will report current buffer use, buffer size, and disposition of output
626 capture.
627 .Pp
628 Userspace processes may inspect and manage
629 .Nm
630 capture state using
631 .Xr sysctl 8 :
632 .Pp
633 .Dv debug.ddb.capture.bufsize
634 may be used to query or set the current capture buffer size.
635 .Pp
636 .Dv debug.ddb.capture.maxbufsize
637 may be used to query the compile-time limit on the capture buffer size.
638 .Pp
639 .Dv debug.ddb.capture.bytes
640 may be used to query the number of bytes of output currently in the capture
641 buffer.
642 .Pp
643 .Dv debug.ddb.capture.data
644 returns the contents of the buffer as a string to an appropriately privileged
645 process.
646 .Pp
647 This facility is particularly useful in concert with the scripting and
648 .Xr textdump 4
649 facilities, allowing scripted debugging output to be captured and
650 committed to disk as part of a textdump for later analysis.
651 The contents of the capture buffer may also be inspected in a kernel core dump
652 using
653 .Xr kgdb 1 .
654 .Pp
655 .It Ic run
656 .It Ic script
657 .It Ic scripts
658 .It Ic unscript
659 Run, define, list, and delete scripts.
660 See the
661 .Sx SCRIPTING
662 section for more information on the scripting facility.
663 .Pp
664 .It Ic textdump set
665 .It Ic textdump status
666 .It Ic textdump unset
667 The
668 .Ic textdump set
669 command may be used to force the next kernel core dump to be a textdump
670 rather than a traditional memory dump or minidump.
671 .Ic textdump status
672 reports whether a textdump has been scheduled.
673 .Ic textdump unset
674 cancels a request to perform a textdump as the next kernel core dump.
675 More information may be found in
676 .Xr textdump 4 .
677 .El
678 .Sh VARIABLES
679 The debugger accesses registers and variables as
680 .Li $ Ns Ar name .
681 Register names are as in the
682 .Dq Ic show Cm registers
683 command.
684 Some variables are suffixed with numbers, and may have some modifier
685 following a colon immediately after the variable name.
686 For example, register variables can have a
687 .Cm u
688 modifier to indicate user register (e.g.,
689 .Dq Li $eax:u ) .
690 .Pp
691 Built-in variables currently supported are:
692 .Pp
693 .Bl -tag -width ".Va tabstops" -compact
694 .It Va radix
695 Input and output radix.
696 .It Va maxoff
697 Addresses are printed as
698 .Dq Ar symbol Ns Li + Ns Ar offset
699 unless
700 .Ar offset
701 is greater than
702 .Va maxoff .
703 .It Va maxwidth
704 The width of the displayed line.
705 .It Va lines
706 The number of lines.
707 It is used by the built-in pager.
708 .It Va tabstops
709 Tab stop width.
710 .It Va work Ns Ar xx
711 Work variable;
712 .Ar xx
713 can take values from 0 to 31.
714 .El
715 .Sh EXPRESSIONS
716 Most expression operators in C are supported except
717 .Ql ~ ,
718 .Ql ^ ,
719 and unary
720 .Ql & .
721 Special rules in
722 .Nm
723 are:
724 .Bl -tag -width ".No Identifiers"
725 .It Identifiers
726 The name of a symbol is translated to the value of the symbol, which
727 is the address of the corresponding object.
728 .Ql \&.
729 and
730 .Ql \&:
731 can be used in the identifier.
732 If supported by an object format dependent routine,
733 .Sm off
734 .Oo Ar filename : Oc Ar func : lineno ,
735 .Sm on
736 .Oo Ar filename : Oc Ns Ar variable ,
737 and
738 .Oo Ar filename : Oc Ns Ar lineno
739 can be accepted as a symbol.
740 .It Numbers
741 Radix is determined by the first two letters:
742 .Ql 0x :
743 hex,
744 .Ql 0o :
745 octal,
746 .Ql 0t :
747 decimal; otherwise, follow current radix.
748 .It Li \&.
749 .Va dot
750 .It Li +
751 .Va next
752 .It Li ..
753 address of the start of the last line examined.
754 Unlike
755 .Va dot
756 or
757 .Va next ,
758 this is only changed by
759 .Ic examine
760 or
761 .Ic write
762 command.
763 .It Li '
764 last address explicitly specified.
765 .It Li $ Ns Ar variable
766 Translated to the value of the specified variable.
767 It may be followed by a
768 .Ql \&:
769 and modifiers as described above.
770 .It Ar a Ns Li # Ns Ar b
771 A binary operator which rounds up the left hand side to the next
772 multiple of right hand side.
773 .It Li * Ns Ar expr
774 Indirection.
775 It may be followed by a
776 .Ql \&:
777 and modifiers as described above.
778 .El
779 .Sh SCRIPTING
780 .Nm
781 supports a basic scripting facility to allow automating tasks or responses to
782 specific events.
783 Each script consists of a list of DDB commands to be executed sequentially,
784 and is assigned a unique name.
785 Certain script names have special meaning, and will be automatically run on
786 various
787 .Nm
788 events if scripts by those names have been defined.
789 .Pp
790 The
791 .Ic script
792 command may be used to define a script by name.
793 Scripts consist of a series of
794 .Nm
795 commands separated with the
796 .Ic ;
797 character.
798 For example:
799 .Bd -literal -offset indent
800 script kdb.enter.panic=bt; show pcpu
801 script lockinfo=show alllocks; show lockedvnods
802 .Ed
803 .Pp
804 The
805 .Ic scripts
806 command lists currently defined scripts.
807 .Pp
808 The
809 .Ic run
810 command execute a script by name.
811 For example:
812 .Bd -literal -offset indent
813 run lockinfo
814 .Ed
815 .Pp
816 The
817 .Ic unscript
818 command may be used to delete a script by name.
819 For example:
820 .Bd -literal -offset indent
821 unscript kdb.enter.panic
822 .Ed
823 .Pp
824 These functions may also be performed from userspace using the
825 .Xr ddb 8
826 command.
827 .Pp
828 Certain scripts are run automatically, if defined, for specific
829 .Nm
830 events.
831 The follow scripts are run when various events occur:
832 .Bl -tag -width kdb.enter.powerfail
833 .It Dv kdb.enter.acpi
834 The kernel debugger was entered as a result of an
835 .Xr acpi 4
836 event.
837 .It Dv kdb.enter.bootflags
838 The kernel debugger was entered at boot as a result of the debugger boot
839 flag being set.
840 .It Dv kdb.enter.break
841 The kernel debugger was entered as a result of a serial or console break.
842 .It Dv kdb.enter.cam
843 The kernel debugger was entered as a result of a
844 .Xr CAM 4
845 event.
846 .It Dv kdb.enter.mac
847 The kernel debugger was entered as a result of an assertion failure in the
848 .Xr mac_test 4
849 module of the
850 TrustedBSD MAC Framework.
851 .It Dv kdb.enter.ndis
852 The kernel debugger was entered as a result of an
853 .Xr ndis 4
854 breakpoint event.
855 .It Dv kdb.enter.netgraph
856 The kernel debugger was entered as a result of a
857 .Xr netgraph 4
858 event.
859 .It Dv kdb.enter.panic
860 .Xr panic 9
861 was called.
862 .It Dv kdb.enter.powerfail
863 The kernel debugger was entered as a result of a powerfail NMI on the sparc64
864 platform.
865 .It Dv kdb.enter.powerpc
866 The kernel debugger was entered as a result of an unimplemented interrupt
867 type on the powerpc platform.
868 .It Dv kdb.enter.sysctl
869 The kernel debugger was entered as a result of the
870 .Dv debug.kdb.enter
871 sysctl being set.
872 .It Dv kdb.enter.trapsig
873 The kernel debugger was entered as a result of a trapsig event on the sparc64
874 or sun4v platform.
875 .It Dv kdb.enter.unionfs
876 The kernel debugger was entered as a result of an assertion failure in the
877 union file system.
878 .It Dv kdb.enter.unknown
879 The kernel debugger was entered, but no reason has been set.
880 .It Dv kdb.enter.vfslock
881 The kernel debugger was entered as a result of a VFS lock violation.
882 .It Dv kdb.enter.watchdog
883 The kernel debugger was entered as a result of a watchdog firing.
884 .It Dv kdb.enter.witness
885 The kernel debugger was entered as a result of a
886 .Xr witness 4
887 violation.
888 .El
889 .Pp
890 In the event that none of these scripts is found,
891 .Nm
892 will attempt to execute a default script:
893 .Bl -tag -width kdb.enter.powerfail
894 .It Dv kdb.enter.default
895 The kernel debugger was entered, but a script exactly matching the reason for
896 entering was not defined.
897 This can be used as a catch-all to handle cases not specifically of interest;
898 for example,
899 .Dv kdb.enter.witness
900 might be defined to have special handling, and
901 .Dv kdb.enter.default
902 might be defined to simply panic and reboot.
903 .El
904 .Sh HINTS
905 On machines with an ISA expansion bus, a simple NMI generation card can be
906 constructed by connecting a push button between the A01 and B01 (CHCHK# and
907 GND) card fingers.
908 Momentarily shorting these two fingers together may cause the bridge chipset to
909 generate an NMI, which causes the kernel to pass control to
910 .Nm .
911 Some bridge chipsets do not generate a NMI on CHCHK#, so your mileage may vary.
912 The NMI allows one to break into the debugger on a wedged machine to
913 diagnose problems.
914 Other bus' bridge chipsets may be able to generate NMI using bus specific
915 methods.
916 .Sh SEE ALSO
917 .Xr gdb 1 ,
918 .Xr kgdb 1 ,
919 .Xr acpi 4 ,
920 .Xr CAM 4 ,
921 .Xr mac_text 4 ,
922 .Xr ndis 4 ,
923 .Xr netgraph 4 ,
924 .Xr textdump 4 ,
925 .Xr witness 4 ,
926 .Xr ddb 8 ,
927 .Xr sysctl 8 ,
928 .Xr panic 9
929 .Sh HISTORY
930 The
931 .Nm
932 debugger was developed for Mach, and ported to
933 .Bx 386 0.1 .
934 This manual page translated from
935 .Xr man 7
936 macros by
937 .An Garrett Wollman .
938 .Pp
939 .An Robert N. M. Watson
940 added support for
941 .Nm
942 output capture,
943 .Xr textdump 4
944 and scripting in
945 .Fx 7.1 .