]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/ddb.4
MFV: xz 5.4.4.
[FreeBSD/FreeBSD.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 .\" $FreeBSD$
28 .\"
29 .Dd November 10, 2022
30 .Dt DDB 4
31 .Os
32 .Sh NAME
33 .Nm ddb
34 .Nd interactive kernel debugger
35 .Sh SYNOPSIS
36 In order to enable kernel debugging facilities include:
37 .Bd -ragged -offset indent
38 .Cd options KDB
39 .Cd options DDB
40 .Ed
41 .Pp
42 To prevent activation of the debugger on kernel
43 .Xr panic 9 :
44 .Bd -ragged -offset indent
45 .Cd options KDB_UNATTENDED
46 .Ed
47 .Pp
48 In order to print a stack trace of the current thread on the console
49 for a panic:
50 .Bd -ragged -offset indent
51 .Cd options KDB_TRACE
52 .Ed
53 .Pp
54 To print the numerical value of symbols in addition to the symbolic
55 representation, define:
56 .Bd -ragged -offset indent
57 .Cd options DDB_NUMSYM
58 .Ed
59 .Pp
60 To enable the
61 .Xr gdb 4
62 backend, so that remote debugging with
63 .Xr kgdb 1 Pq Pa ports/devel/gdb
64 is possible, include:
65 .Bd -ragged -offset indent
66 .Cd options GDB
67 .Ed
68 .Sh DESCRIPTION
69 The
70 .Nm
71 kernel debugger is an interactive debugger with a syntax inspired by
72 .Xr gdb 1 Pq Pa ports/devel/gdb .
73 If linked into the running kernel,
74 it can be invoked locally with the
75 .Ql debug
76 .Xr keymap 5
77 action, usually mapped to Ctrl+Alt+Esc, or by setting the
78 .Va debug.kdb.enter
79 sysctl to 1.
80 The debugger is also invoked on kernel
81 .Xr panic 9
82 if the
83 .Va debug.debugger_on_panic
84 .Xr sysctl 8
85 MIB variable is set non-zero,
86 which is the default
87 unless the
88 .Dv KDB_UNATTENDED
89 option is specified.
90 Similarly, if the
91 .Va debug.debugger_on_recursive_panic
92 variable is set to
93 .Dv 1 ,
94 then the debugger will be invoked on a recursive kernel panic.
95 This variable has a default value of
96 .Dv 0 ,
97 and has no effect if
98 .Va debug.debugger_on_panic
99 is already set non-zero.
100 .Pp
101 The current location is called
102 .Va dot .
103 The
104 .Va dot
105 is displayed with
106 a hexadecimal format at a prompt.
107 The commands
108 .Ic examine
109 and
110 .Ic write
111 update
112 .Va dot
113 to the address of the last line
114 examined or the last location modified, and set
115 .Va next
116 to the address of
117 the next location to be examined or changed.
118 Other commands do not change
119 .Va dot ,
120 and set
121 .Va next
122 to be the same as
123 .Va dot .
124 .Pp
125 The general command syntax is:
126 .Ar command Ns Op Li / Ns Ar modifier
127 .Oo Ar addr Oc Ns Op , Ns Ar count
128 .Pp
129 A blank line repeats the previous command from the address
130 .Va next
131 with
132 count 1 and no modifiers.
133 Specifying
134 .Ar addr
135 sets
136 .Va dot
137 to the address.
138 Omitting
139 .Ar addr
140 uses
141 .Va dot .
142 A missing
143 .Ar count
144 is taken
145 to be 1 for printing commands or infinity for stack traces.
146 A
147 .Ar count
148 of -1 is equivalent to a missing
149 .Ar count .
150 Options that are supplied but not supported by the given
151 .Ar command
152 are usually ignored.
153 .Pp
154 The
155 .Nm
156 debugger has a pager feature (like the
157 .Xr more 1
158 command)
159 for the output.
160 If an output line exceeds the number set in the
161 .Va lines
162 variable, it displays
163 .Dq Li --More--
164 and waits for a response.
165 The valid responses for it are:
166 .Pp
167 .Bl -tag -compact -width ".Li SPC"
168 .It Li SPC
169 one more page
170 .It Li RET
171 one more line
172 .It Li q
173 abort the current command, and return to the command input mode
174 .El
175 .Pp
176 Finally,
177 .Nm
178 provides a small (currently 10 items) command history, and offers
179 simple
180 .Nm emacs Ns -style
181 command line editing capabilities.
182 In addition to
183 the
184 .Nm emacs
185 control keys, the usual ANSI arrow keys may be used to browse through the
186 history buffer, and move the cursor within the current line.
187 .Sh COMMANDS
188 .Ss COMMON DEBUGGER COMMANDS
189 .Bl -tag -width indent -compact
190 .It Ic help
191 Print a short summary of the available commands and command
192 abbreviations.
193 .Pp
194 .It Xo
195 .Ic examine Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
196 .Oo Ar addr Oc Ns Op , Ns Ar count
197 .Xc
198 .It Xo
199 .Ic x       Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
200 .Oo Ar addr Oc Ns Op , Ns Ar count
201 .Xc
202 Display the addressed locations according to the formats in the modifier.
203 Multiple modifier formats display multiple locations.
204 If no format is specified, the last format specified for this command
205 is used.
206 .Pp
207 The format characters are:
208 .Bl -tag -compact -width indent
209 .It Cm b
210 look at by bytes (8 bits)
211 .It Cm h
212 look at by half words (16 bits)
213 .It Cm l
214 look at by long words (32 bits)
215 .It Cm g
216 look at by quad words (64 bits)
217 .It Cm a
218 print the location being displayed
219 .It Cm A
220 print the location with a line number if possible
221 .It Cm x
222 display in unsigned hex
223 .It Cm z
224 display in signed hex
225 .It Cm o
226 display in unsigned octal
227 .It Cm d
228 display in signed decimal
229 .It Cm u
230 display in unsigned decimal
231 .It Cm r
232 display in current radix, signed
233 .It Cm c
234 display low 8 bits as a character.
235 Non-printing characters are displayed as an octal escape code (e.g.,
236 .Ql \e000 ) .
237 .It Cm s
238 display the null-terminated string at the location.
239 Non-printing characters are displayed as octal escapes.
240 .It Cm m
241 display in unsigned hex with character dump at the end of each line.
242 The location is also displayed in hex at the beginning of each line.
243 .It Cm i
244 display as a disassembled instruction
245 .It Cm I
246 display as a disassembled instruction with possible alternate formats
247 depending on the machine.
248 On i386, this selects the alternate format for the instruction decoding
249 (16 bits in a 32-bit code segment and vice versa).
250 .It Cm S
251 display a symbol name for the pointer stored at the address
252 .El
253 .Pp
254 .It Ic xf
255 Examine forward:
256 execute an
257 .Ic examine
258 command with the last specified parameters to it
259 except that the next address displayed by it is used as the start address.
260 .Pp
261 .It Ic xb
262 Examine backward:
263 execute an
264 .Ic examine
265 command with the last specified parameters to it
266 except that the last start address subtracted by the size displayed by it
267 is used as the start address.
268 .Pp
269 .It Ic print Ns Op Li / Ns Cm acdoruxz
270 .It Ic p Ns Op Li / Ns Cm acdoruxz
271 Print
272 .Ar addr Ns s
273 according to the modifier character (as described above for
274 .Cm examine ) .
275 Valid formats are:
276 .Cm a , x , z , o , d , u , r ,
277 and
278 .Cm c .
279 If no modifier is specified, the last one specified to it is used.
280 The argument
281 .Ar addr
282 can be a string, in which case it is printed as it is.
283 For example:
284 .Bd -literal -offset indent
285 print/x "eax = " $eax "\enecx = " $ecx "\en"
286 .Ed
287 .Pp
288 will print like:
289 .Bd -literal -offset indent
290 eax = xxxxxx
291 ecx = yyyyyy
292 .Ed
293 .Pp
294 .It Xo
295 .Ic write Ns Op Li / Ns Cm bhl
296 .Ar addr expr1 Op Ar expr2 ...
297 .Xc
298 .It Xo
299 .Ic w Ns Op Li / Ns Cm bhl
300 .Ar addr expr1 Op Ar expr2 ...
301 .Xc
302 Write the expressions specified after
303 .Ar addr
304 on the command line at succeeding locations starting with
305 .Ar addr .
306 The write unit size can be specified in the modifier with a letter
307 .Cm b
308 (byte),
309 .Cm h
310 (half word) or
311 .Cm l
312 (long word) respectively.
313 If omitted,
314 long word is assumed.
315 .Pp
316 .Sy Warning :
317 since there is no delimiter between expressions, strange
318 things may happen.
319 It is best to enclose each expression in parentheses.
320 .Pp
321 .It Ic set Li $ Ns Ar variable Oo Li = Oc Ar expr
322 Set the named variable or register with the value of
323 .Ar expr .
324 Valid variable names are described below.
325 .Pp
326 .It Ic break Ns Oo Li / Ns Cm u Oc Oo Ar addr Oc Ns Op , Ns Ar count
327 .It Ic b     Ns Oo Li / Ns Cm u Oc Oo Ar addr Oc Ns Op , Ns Ar count
328 Set a break point at
329 .Ar addr .
330 If
331 .Ar count
332 is supplied, the
333 .Ic continue
334 command will not stop at this break point on the first
335 .Ar count
336 \- 1 times that it is hit.
337 If the break point is set, a break point number is
338 printed with
339 .Ql # .
340 This number can be used in deleting the break point
341 or adding conditions to it.
342 .Pp
343 If the
344 .Cm u
345 modifier is specified, this command sets a break point in user
346 address space.
347 Without the
348 .Cm u
349 option, the address is considered to be in the kernel
350 space, and a wrong space address is rejected with an error message.
351 This modifier can be used only if it is supported by machine dependent
352 routines.
353 .Pp
354 .Sy Warning :
355 If a user text is shadowed by a normal user space debugger,
356 user space break points may not work correctly.
357 Setting a break
358 point at the low-level code paths may also cause strange behavior.
359 .Pp
360 .It Ic delete Op Ar addr
361 .It Ic d      Op Ar addr
362 .It Ic delete Li # Ns Ar number
363 .It Ic d      Li # Ns Ar number
364 Delete the specified break point.
365 The break point can be specified by a
366 break point number with
367 .Ql # ,
368 or by using the same
369 .Ar addr
370 specified in the original
371 .Ic break
372 command, or by omitting
373 .Ar addr
374 to get the default address of
375 .Va dot .
376 .Pp
377 .It Ic halt
378 Halt the system.
379 .Pp
380 .It Ic watch Oo Ar addr Oc Ns Op , Ns Ar size
381 Set a watchpoint for a region.
382 Execution stops when an attempt to modify the region occurs.
383 The
384 .Ar size
385 argument defaults to 4.
386 If you specify a wrong space address, the request is rejected
387 with an error message.
388 .Pp
389 .Sy Warning :
390 Attempts to watch wired kernel memory
391 may cause unrecoverable error in some systems such as i386.
392 Watchpoints on user addresses work best.
393 .Pp
394 .It Ic hwatch Oo Ar addr Oc Ns Op , Ns Ar size
395 Set a hardware watchpoint for a region if supported by the
396 architecture.
397 Execution stops when an attempt to modify the region occurs.
398 The
399 .Ar size
400 argument defaults to 4.
401 .Pp
402 .Sy Warning :
403 The hardware debug facilities do not have a concept of separate
404 address spaces like the watch command does.
405 Use
406 .Ic hwatch
407 for setting watchpoints on kernel address locations only, and avoid
408 its use on user mode address spaces.
409 .Pp
410 .It Ic dhwatch Oo Ar addr Oc Ns Op , Ns Ar size
411 Delete specified hardware watchpoint.
412 .Pp
413 .It Ic kill Ar sig pid
414 Send signal
415 .Ar sig
416 to process
417 .Ar pid .
418 The signal is acted on upon returning from the debugger.
419 This command can be used to kill a process causing resource contention
420 in the case of a hung system.
421 See
422 .Xr signal 3
423 for a list of signals.
424 Note that the arguments are reversed relative to
425 .Xr kill 2 .
426 .Pp
427 .It Ic step Ns Oo Li / Ns Cm p Oc Ns Op , Ns Ar count
428 .It Ic s    Ns Oo Li / Ns Cm p Oc Ns Op , Ns Ar count
429 Single step
430 .Ar count
431 times.
432 If the
433 .Cm p
434 modifier is specified, print each instruction at each step.
435 Otherwise, only print the last instruction.
436 .Pp
437 .Sy Warning :
438 depending on machine type, it may not be possible to
439 single-step through some low-level code paths or user space code.
440 On machines with software-emulated single-stepping (e.g., pmax),
441 stepping through code executed by interrupt handlers will probably
442 do the wrong thing.
443 .Pp
444 .It Ic continue Ns Op Li / Ns Cm c
445 .It Ic c Ns Op Li / Ns Cm c
446 Continue execution until a breakpoint or watchpoint.
447 If the
448 .Cm c
449 modifier is specified, count instructions while executing.
450 Some machines (e.g., pmax) also count loads and stores.
451 .Pp
452 .Sy Warning :
453 when counting, the debugger is really silently single-stepping.
454 This means that single-stepping on low-level code may cause strange
455 behavior.
456 .Pp
457 .It Ic until Ns Op Li / Ns Cm p
458 Stop at the next call or return instruction.
459 If the
460 .Cm p
461 modifier is specified, print the call nesting depth and the
462 cumulative instruction count at each call or return.
463 Otherwise,
464 only print when the matching return is hit.
465 .Pp
466 .It Ic next Ns Op Li / Ns Cm p
467 .It Ic match Ns Op Li / Ns Cm p
468 Stop at the matching return instruction.
469 If the
470 .Cm p
471 modifier is specified, print the call nesting depth and the
472 cumulative instruction count at each call or return.
473 Otherwise, only print when the matching return is hit.
474 .Pp
475 .It Xo
476 .Ic trace Ns Op Li / Ns Cm u
477 .Op Ar pid | tid Ns
478 .Op , Ns Ar count
479 .Xc
480 .It Xo
481 .Ic t Ns Op Li / Ns Cm u
482 .Op Ar pid | tid Ns
483 .Op , Ns Ar count
484 .Xc
485 .It Xo
486 .Ic where Ns Op Li / Ns Cm u
487 .Op Ar pid | tid Ns
488 .Op , Ns Ar count
489 .Xc
490 .It Xo
491 .Ic bt Ns Op Li / Ns Cm u
492 .Op Ar pid | tid Ns
493 .Op , Ns Ar count
494 .Xc
495 Stack trace.
496 The
497 .Cm u
498 option traces user space; if omitted,
499 .Ic trace
500 only traces
501 kernel space.
502 The optional argument
503 .Ar count
504 is the number of frames to be traced.
505 If
506 .Ar count
507 is omitted, all frames are printed.
508 .Pp
509 .Sy Warning :
510 User space stack trace is valid
511 only if the machine dependent code supports it.
512 .Pp
513 .It Xo
514 .Ic search Ns Op Li / Ns Cm bhl
515 .Ar addr
516 .Ar value
517 .Op Ar mask Ns
518 .Op , Ns Ar count
519 .Xc
520 Search memory for
521 .Ar value .
522 The optional
523 .Ar count
524 argument limits the search.
525 .\"
526 .Pp
527 .It Xo
528 .Ic Ic reboot Ns Op Li / Ns Cm s
529 .Op Ar seconds
530 .Xc
531 .It Xo
532 .Ic Ic reset Ns Op Li / Ns Cm s
533 .Op Ar seconds
534 .Xc
535 Hard reset the system.
536 If the optional argument
537 .Ar seconds
538 is given, the debugger will wait for this long, at most a week,
539 before rebooting.
540 When the
541 .Cm s
542 modifier is given, the command will skip running any registered shutdown
543 handlers and attempt the most basic reset.
544 .Pp
545 .It Ic thread Ar addr | tid
546 Switch the debugger to the thread with ID
547 .Ar tid ,
548 if the argument is a decimal number, or address
549 .Ar addr ,
550 otherwise.
551 .Pp
552 .It Ic watchdog Op Ar exp
553 Program the
554 .Xr watchdog 4
555 timer to fire in
556 .Pf 2^ Ar exp
557 seconds.
558 If no argument is provided, the watchdog timer is disabled.
559 .El
560 .Ss SPECIALIZED HELPER COMMANDS
561 .Bl -tag -width indent -compact
562 .It Xo
563 .Ic findstack
564 .Ar addr
565 .Xc
566 Prints the address of the thread whose kernel-mode stack contains
567 .Ar addr ,
568 if any.
569 .Pp
570 .It Ic show Cm active trace
571 .It acttrace
572 Show a stack trace for every thread running on a CPU.
573 .Pp
574 .It Ic show Cm all procs Ns Op Li / Ns Cm a
575 .It Ic ps Ns Op Li / Ns Cm a
576 Display all process information.
577 The process information may not be shown if it is not
578 supported in the machine, or the bottom of the stack of the
579 target process is not in the main memory at that time.
580 The
581 .Cm a
582 modifier will print command line arguments for each process.
583 .\"
584 .Pp
585 .It Ic show Cm all trace
586 .It Ic alltrace
587 Show a stack trace for every thread in the system.
588 .Pp
589 .It Ic show Cm all ttys
590 Show all TTY's within the system.
591 Output is similar to
592 .Xr pstat 8 ,
593 but also includes the address of the TTY structure.
594 .\"
595 .Pp
596 .It Ic show Cm all vnets
597 Show the same output as "show vnet" does, but lists all
598 virtualized network stacks within the system.
599 .\"
600 .Pp
601 .It Ic show Cm allchains
602 Show the same information like "show lockchain" does, but
603 for every thread in the system.
604 .\"
605 .Pp
606 .It Ic show Cm alllocks
607 Show all locks that are currently held.
608 This command is only available if
609 .Xr witness 4
610 is included in the kernel.
611 .\"
612 .Pp
613 .It Ic show Cm allpcpu
614 The same as "show pcpu", but for every CPU present in the system.
615 .\"
616 .Pp
617 .It Ic show Cm allrman
618 Show information related with resource management, including
619 interrupt request lines, DMA request lines, I/O ports, I/O memory
620 addresses, and Resource IDs.
621 .\"
622 .Pp
623 .It Ic show Cm apic
624 Dump data about APIC IDT vector mappings.
625 .\"
626 .Pp
627 .It Ic show Cm badstacks
628 Walk the
629 .Xr witness 4
630 graph and print any lock-order violations.
631 This command is only available if
632 .Xr witness 4
633 is included in the kernel.
634 .\"
635 .Pp
636 .It Ic show Cm breaks
637 Show breakpoints set with the "break" command.
638 .\"
639 .Pp
640 .It Ic show Cm bio Ar addr
641 Show information about the bio structure
642 .Vt struct bio
643 present at
644 .Ar addr .
645 See the
646 .Pa sys/bio.h
647 header file and
648 .Xr g_bio 9
649 for more details on the exact meaning of the structure fields.
650 .\"
651 .Pp
652 .It Ic show Cm buffer Ar addr
653 Show information about the buf structure
654 .Vt struct buf
655 present at
656 .Ar addr .
657 See the
658 .Pa sys/buf.h
659 header file for more details on the exact meaning of the structure fields.
660 .\"
661 .Pp
662 .It Ic show Cm callout Ar addr
663 Show information about the callout structure
664 .Vt struct callout
665 present at
666 .Ar addr .
667 .\"
668 .Pp
669 .It Ic show Cm cdev Op Ar addr
670 Show the internal devfs state of the cdev structure located at
671 .Ar addr .
672 If no argument is provided, show the list of all created cdevs, consisting of
673 the devfs node name and the
674 .Vt struct cdev
675 address.
676 .\"
677 .Pp
678 .It Ic show Cm conifhk
679 Lists hooks currently waiting for completion in
680 .Fn run_interrupt_driven_config_hooks .
681 .\"
682 .Pp
683 .It Ic show Cm cpusets
684 Print numbered root and assigned CPU affinity sets.
685 See
686 .Xr cpuset 2
687 for more details.
688 .\"
689 .Pp
690 .It Ic show Cm cyrixreg
691 Show registers specific to the Cyrix processor.
692 .\"
693 .Pp
694 .It Ic show Cm devmap
695 Prints the contents of the static device mapping table.
696 Currently only available on the
697 ARM
698 architecture.
699 .\"
700 .Pp
701 .It Ic show Cm domain Ar addr
702 Print protocol domain structure
703 .Vt struct domain
704 at address
705 .Ar addr .
706 See the
707 .Pa sys/domain.h
708 header file for more details on the exact meaning of the structure fields.
709 .\"
710 .Pp
711 .It Ic show Cm ffs Op Ar addr
712 Show brief information about ffs mount at the address
713 .Ar addr ,
714 if argument is given.
715 Otherwise, provides the summary about each ffs mount.
716 .\"
717 .Pp
718 .It Ic show Cm file Ar addr
719 Show information about the file structure
720 .Vt struct file
721 present at address
722 .Ar addr .
723 .\"
724 .Pp
725 .It Ic show Cm files
726 Show information about every file structure in the system.
727 .\"
728 .Pp
729 .It Ic show Cm freepages
730 Show the number of physical pages in each of the free lists.
731 .\"
732 .Pp
733 .It Ic show Cm geom Op Ar addr
734 If the
735 .Ar addr
736 argument is not given, displays the entire GEOM topology.
737 If
738 .Ar addr
739 is given, displays details about the given GEOM object (class, geom,
740 provider or consumer).
741 .\"
742 .Pp
743 .It Ic show Cm idt
744 Show IDT layout.
745 The first column specifies the IDT vector.
746 The second one is the name of the interrupt/trap handler.
747 Those functions are machine dependent.
748 .\"
749 .Pp
750 .It Ic show Cm igi_list Ar addr
751 Show information about the IGMP structure
752 .Vt struct igmp_ifsoftc
753 present at
754 .Ar addr .
755 .\"
756 .Pp
757 .It Ic show Cm iosched Ar addr
758 Show information about the I/O scheduler
759 .Vt struct cam_iosched_softc
760 located at
761 .Ar addr .
762 .\"
763 .Pp
764 .It Ic show Cm inodedeps Op Ar addr
765 Show brief information about each inodedep structure.
766 If
767 .Ar addr
768 is given, only inodedeps belonging to the fs located at the
769 supplied address are shown.
770 .\"
771 .Pp
772 .It Ic show Cm inpcb Ar addr
773 Show information on IP Control Block
774 .Vt struct in_pcb
775 present at
776 .Ar addr .
777 .\"
778 .Pp
779 .It Ic show Cm intr
780 Dump information about interrupt handlers.
781 .\"
782 .Pp
783 .It Ic show Cm intrcnt
784 Dump the interrupt statistics.
785 .\"
786 .Pp
787 .It Ic show Cm irqs
788 Show interrupt lines and their respective kernel threads.
789 .\"
790 .Pp
791 .It Ic show Cm ktr Ns Op Li / Ns Cm a Ns Cm v Ns Cm V
792 Print the contents of the
793 .Xr ktr 4
794 trace buffer.
795 The
796 .Cm v
797 modifier will request fully verbose output, causing the file, line number, and
798 timestamp to be printed for each trace entry.
799 The
800 .Cm V
801 modifier will request only the timestamps to be printed.
802 The
803 .Cm a
804 modifier will request that the output be unpaginated.
805 .\"
806 .Pp
807 .It Ic show Cm lapic
808 Show information from the local APIC registers for this CPU.
809 .\"
810 .Pp
811 .It Ic show Cm lock Ar addr
812 Show lock structure.
813 The output format is as follows:
814 .Bl -tag -width "flags"
815 .It Ic class :
816 Class of the lock.
817 Possible types include
818 .Xr mutex 9 ,
819 .Xr rmlock 9 ,
820 .Xr rwlock 9 ,
821 .Xr sx 9 .
822 .It Ic name :
823 Name of the lock.
824 .It Ic flags :
825 Flags passed to the lock initialization function.
826 .Em flags
827 values are lock class specific.
828 .It Ic state :
829 Current state of a lock.
830 .Em state
831 values are lock class specific.
832 .It Ic owner :
833 Lock owner.
834 .El
835 .\"
836 .Pp
837 .It Ic show Cm lockchain Ar addr
838 Show all threads a particular thread at address
839 .Ar addr
840 is waiting on based on non-spin locks.
841 .\"
842 .Pp
843 .It Ic show Cm lockedbufs
844 Show the same information as "show buf", but for every locked
845 .Vt struct buf
846 object.
847 .\"
848 .Pp
849 .It Ic show Cm lockedvnods
850 List all locked vnodes in the system.
851 .\"
852 .Pp
853 .It Ic show Cm locks
854 Prints all locks that are currently acquired.
855 This command is only available if
856 .Xr witness 4
857 is included in the kernel.
858 .\"
859 .Pp
860 .It Ic show Cm locktree
861 .\"
862 .Pp
863 .It Ic show Cm malloc Ns Op Li / Ns Cm i
864 Prints
865 .Xr malloc 9
866 memory allocator statistics.
867 If the
868 .Cm i
869 modifier is specified, format output as machine-parseable comma-separated
870 values ("CSV").
871 The output columns are as follows:
872 .Pp
873 .Bl -tag -compact -offset indent -width "Requests"
874 .It Ic Type
875 Specifies a type of memory.
876 It is the same as a description string used while defining the
877 given memory type with
878 .Xr MALLOC_DECLARE 9 .
879 .It Ic InUse
880 Number of memory allocations of the given type, for which
881 .Xr free 9
882 has not been called yet.
883 .It Ic MemUse
884 Total memory consumed by the given allocation type.
885 .It Ic Requests
886 Number of memory allocation requests for the given
887 memory type.
888 .El
889 .Pp
890 The same information can be gathered in userspace with
891 .Dq Nm vmstat Fl m .
892 .\"
893 .Pp
894 .It Ic show Cm map Ns Oo Li / Ns Cm f Oc Ar addr
895 Prints the VM map at
896 .Ar addr .
897 If the
898 .Cm f
899 modifier is specified the
900 complete map is printed.
901 .\"
902 .Pp
903 .It Ic show Cm msgbuf
904 Print the system's message buffer.
905 It is the same output as in the
906 .Dq Nm dmesg
907 case.
908 It is useful if you got a kernel panic, attached a serial cable
909 to the machine and want to get the boot messages from before the
910 system hang.
911 .\"
912 .Pp
913 .It Ic show Cm mount Op Ar addr
914 Displays details about the mount point located at
915 .Ar addr .
916 If no
917 .Ar addr
918 is specified,
919 displays short info about all currently mounted file systems.
920 .\"
921 .Pp
922 .It Ic show Cm object Ns Oo Li / Ns Cm f Oc Ar addr
923 Prints the VM object at
924 .Ar addr .
925 If the
926 .Cm f
927 option is specified the
928 complete object is printed.
929 .\"
930 .Pp
931 .It Ic show Cm panic
932 Print the panic message if set.
933 .\"
934 .Pp
935 .It Ic show Cm page
936 Show statistics on VM pages.
937 .\"
938 .Pp
939 .It Ic show Cm pageq
940 Show statistics on VM page queues.
941 .\"
942 .Pp
943 .It Ic show Cm pciregs
944 Print PCI bus registers.
945 The same information can be gathered in userspace by running
946 .Dq Nm pciconf Fl lv .
947 .\"
948 .Pp
949 .It Ic show Cm pcpu
950 Print current processor state.
951 The output format is as follows:
952 .Pp
953 .Bl -tag -compact -offset indent -width "spin locks held:"
954 .It Ic cpuid
955 Processor identifier.
956 .It Ic curthread
957 Thread pointer, process identifier and the name of the process.
958 .It Ic curpcb
959 Control block pointer.
960 .It Ic fpcurthread
961 FPU thread pointer.
962 .It Ic idlethread
963 Idle thread pointer.
964 .It Ic APIC ID
965 CPU identifier coming from APIC.
966 .It Ic currentldt
967 LDT pointer.
968 .It Ic spin locks held
969 Names of spin locks held.
970 .El
971 .\"
972 .Pp
973 .It Ic show Cm pgrpdump
974 Dump process groups present within the system.
975 .\"
976 .Pp
977 .It Ic show Cm prison Op Ar addr
978 Show the prison structure located at
979 .Ar addr .
980 If no
981 .Ar addr
982 argument is specified, show information about all prisons in the system.
983 .\"
984 .Pp
985 .It Ic show Cm proc Op Ar addr
986 Show information about the process structure located at address
987 .Ar addr ,
988 or the current process if no argument is specified.
989 .\"
990 .Pp
991 .It Ic show Cm procvm Op Ar addr
992 Show process virtual memory layout for the process located at
993 .Ar addr ,
994 or the current process if no argument is specified.
995 .\"
996 .Pp
997 .It Ic show Cm protosw Ar addr
998 Print protocol switch structure
999 .Vt struct protosw
1000 at address
1001 .Ar addr .
1002 .\"
1003 .Pp
1004 .It Ic show Cm registers Ns Op Li / Ns Cm u
1005 Display the register set.
1006 If the
1007 .Cm u
1008 modifier is specified, the register contents of the thread's previous
1009 trapframe are displayed instead.
1010 Usually, this corresponds to the saved state from userspace.
1011 .\"
1012 .Pp
1013 .It Ic show Cm rman Ar addr
1014 Show resource manager object
1015 .Vt struct rman
1016 at address
1017 .Ar addr .
1018 Addresses of particular pointers can be gathered with "show allrman"
1019 command.
1020 .\"
1021 .Pp
1022 .It Ic show Cm route Ar addr
1023 Show route table result for destination
1024 .Ar addr .
1025 At this time, INET and INET6 formatted addresses are supported.
1026 .\"
1027 .Pp
1028 .It Ic show Cm routetable Oo Ar af Oc
1029 Show full route table or tables.
1030 If
1031 .Ar af
1032 is specified, show only routes for the given numeric address family.
1033 If no argument is specified, dump the route table for all address families.
1034 .\"
1035 .Pp
1036 .It Ic show Cm rtc
1037 Show real time clock value.
1038 Useful for long debugging sessions.
1039 .\"
1040 .Pp
1041 .It Ic show Cm sleepchain
1042 Deprecated.
1043 Now an alias for
1044 .Ic show Cm lockchain .
1045 .\"
1046 .Pp
1047 .It Ic show Cm sleepq Ar addr
1048 .It Ic show Cm sleepqueue Ar addr
1049 Show the
1050 .Xr sleepqueue 9
1051 structure located at
1052 .Ar addr .
1053 .\"
1054 .Pp
1055 .It Ic show Cm sockbuf Ar addr
1056 Show the socket buffer
1057 .Va struct sockbuf
1058 located at
1059 .Ar addr .
1060 .\"
1061 .Pp
1062 .It Ic show Cm socket Ar addr
1063 Show the socket object
1064 .Vt struct socket
1065 located at
1066 .Ar addr .
1067 .\"
1068 .Pp
1069 .It Ic show Cm sysregs
1070 Show system registers (e.g.,
1071 .Li cr0-4
1072 on i386.)
1073 Not present on some platforms.
1074 .\"
1075 .Pp
1076 .It Ic show Cm tcpcb Ar addr
1077 Print TCP control block
1078 .Vt struct tcpcb
1079 lying at address
1080 .Ar addr .
1081 For exact interpretation of output, visit
1082 .Pa netinet/tcp.h
1083 header file.
1084 .\"
1085 .Pp
1086 .It Ic show Cm thread Op Ar addr | tid
1087 If no
1088 .Ar addr
1089 or
1090 .Ar tid
1091 is specified, show detailed information about current thread.
1092 Otherwise, print information about the thread with ID
1093 .Ar tid
1094 or kernel address
1095 .Ar addr .
1096 (If the argument is a decimal number, it is assumed to be a tid.)
1097 .\"
1098 .Pp
1099 .It Ic show Cm threads
1100 Show all threads within the system.
1101 Output format is as follows:
1102 .Pp
1103 .Bl -tag -compact -offset indent -width "Second column"
1104 .It Ic First column
1105 Thread identifier (TID)
1106 .It Ic Second column
1107 Thread structure address
1108 .It Ic Third column
1109 Backtrace.
1110 .El
1111 .\"
1112 .Pp
1113 .It Ic show Cm tty Ar addr
1114 Display the contents of a TTY structure in a readable form.
1115 .\"
1116 .Pp
1117 .It Ic show Cm turnstile Ar addr
1118 Show turnstile
1119 .Vt struct turnstile
1120 structure at address
1121 .Ar addr .
1122 Turnstiles are structures used within the
1123 .Fx
1124 kernel to implement
1125 synchronization primitives which, while holding a specific type of lock, cannot
1126 sleep or context switch to another thread.
1127 Currently, those are:
1128 .Xr mutex 9 ,
1129 .Xr rwlock 9 ,
1130 .Xr rmlock 9 .
1131 .\"
1132 .Pp
1133 .It Ic show Cm uma Ns Op Li / Ns Cm i
1134 Show UMA allocator statistics.
1135 If the
1136 .Cm i
1137 modifier is specified, format output as machine-parseable comma-separated
1138 values ("CSV").
1139 The output contains the following columns:
1140 .Pp
1141 .Bl -tag -compact -offset indent -width "Total Mem"
1142 .It Cm "Zone"
1143 Name of the UMA zone.
1144 The same string that was passed to
1145 .Xr uma_zcreate 9
1146 as a first argument.
1147 .It Cm "Size"
1148 Size of a given memory object (slab).
1149 .It Cm "Used"
1150 Number of slabs being currently used.
1151 .It Cm "Free"
1152 Number of free slabs within the UMA zone.
1153 .It Cm "Requests"
1154 Number of allocations requests to the given zone.
1155 .It Cm "Total Mem"
1156 Total memory in use (either allocated or free) by a zone, in bytes.
1157 .It Cm "XFree"
1158 Number of free slabs within the UMA zone that were freed on a different NUMA
1159 domain than allocated.
1160 (The count in the
1161 .Cm "Free"
1162 column is inclusive of
1163 .Cm "XFree" . )
1164 .El
1165 .Pp
1166 The same information might be gathered in the userspace
1167 with the help of
1168 .Dq Nm vmstat Fl z .
1169 .\"
1170 .Pp
1171 .It Ic show Cm unpcb Ar addr
1172 Shows UNIX domain socket private control block
1173 .Vt struct unpcb
1174 present at the address
1175 .Ar addr .
1176 .\"
1177 .Pp
1178 .It Ic show Cm vmochk
1179 Prints, whether the internal VM objects are in a map somewhere
1180 and none have zero ref counts.
1181 .\"
1182 .Pp
1183 .It Ic show Cm vmopag
1184 Walk the list of VM objects in the system, printing the indices and physical
1185 addresses of the VM pages belonging to each object.
1186 .\"
1187 .Pp
1188 .It Ic show Cm vnet Ar addr
1189 Prints virtualized network stack
1190 .Vt struct vnet
1191 structure present at the address
1192 .Ar addr .
1193 .\"
1194 .Pp
1195 .It Ic show Cm vnode Ar addr
1196 Prints vnode
1197 .Vt struct vnode
1198 structure lying at
1199 .Ar addr .
1200 For the exact interpretation of the output, look at the
1201 .Pa sys/vnode.h
1202 header file.
1203 .\"
1204 .Pp
1205 .It Ic show Cm vnodebufs Ar addr
1206 Shows clean/dirty buffer lists of the vnode located at
1207 .Ar addr .
1208 .\"
1209 .Pp
1210 .It Ic show Cm vpath Ar addr
1211 Walk the namecache to lookup the pathname of the vnode located at
1212 .Ar addr .
1213 .\"
1214 .Pp
1215 .It Ic show Cm watches
1216 Displays all watchpoints.
1217 Shows watchpoints set with "watch" command.
1218 .\"
1219 .Pp
1220 .It Ic show Cm witness
1221 Shows information about lock acquisition coming from the
1222 .Xr witness 4
1223 subsystem.
1224 .El
1225 .Ss OFFLINE DEBUGGING COMMANDS
1226 .Bl -tag -width indent -compact
1227 .It Ic dump
1228 Initiate a kernel core dump to the device(s) configured by
1229 .Xr dumpon 8 .
1230 .Pp
1231 .It Ic gdb
1232 Switches to remote GDB mode.
1233 In remote GDB mode, another machine is required that runs
1234 .Xr gdb 1 Pq Pa ports/devel/gdb
1235 using the remote debug feature, with a connection to the serial
1236 console port on the target machine.
1237 .Pp
1238 .It Ic netdump Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1239 Configure
1240 .Xr netdump 4
1241 with the provided parameters, and immediately perform a netdump.
1242 .Pp
1243 There are some known limitations.
1244 Principally,
1245 .Xr netdump 4
1246 only supports IPv4 at this time.
1247 The address arguments to the
1248 .Ic netdump
1249 command must be dotted decimal IPv4 addresses.
1250 (Hostnames are not supported.)
1251 At present, the command only works if the machine is in a panic state.
1252 Finally, the
1253 .Nm
1254 .Ic netdump
1255 command does not provide any way to configure compression or encryption.
1256 .Pp
1257 .It Ic netgdb Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1258 Initiate a
1259 .Xr netgdb 4
1260 session with the provided parameters.
1261 .Pp
1262 .Ic netgdb
1263 has identical limitations to
1264 .Ic netdump .
1265 .Pp
1266 .It Ic capture on
1267 .It Ic capture off
1268 .It Ic capture reset
1269 .It Ic capture status
1270 .Nm
1271 supports a basic output capture facility, which can be used to retrieve the
1272 results of debugging commands from userspace using
1273 .Xr sysctl 3 .
1274 .Ic capture on
1275 enables output capture;
1276 .Ic capture off
1277 disables capture.
1278 .Ic capture reset
1279 will clear the capture buffer and disable capture.
1280 .Ic capture status
1281 will report current buffer use, buffer size, and disposition of output
1282 capture.
1283 .Pp
1284 Userspace processes may inspect and manage
1285 .Nm
1286 capture state using
1287 .Xr sysctl 8 :
1288 .Pp
1289 .Va debug.ddb.capture.bufsize
1290 may be used to query or set the current capture buffer size.
1291 .Pp
1292 .Va debug.ddb.capture.maxbufsize
1293 may be used to query the compile-time limit on the capture buffer size.
1294 .Pp
1295 .Va debug.ddb.capture.bytes
1296 may be used to query the number of bytes of output currently in the capture
1297 buffer.
1298 .Pp
1299 .Va debug.ddb.capture.data
1300 returns the contents of the buffer as a string to an appropriately privileged
1301 process.
1302 .Pp
1303 This facility is particularly useful in concert with the scripting and
1304 .Xr textdump 4
1305 facilities, allowing scripted debugging output to be captured and
1306 committed to disk as part of a textdump for later analysis.
1307 The contents of the capture buffer may also be inspected in a kernel core dump
1308 using
1309 .Xr kgdb 1 Pq Pa ports/devel/gdb .
1310 .Pp
1311 .It Ic run
1312 .It Ic script
1313 .It Ic scripts
1314 .It Ic unscript
1315 Run, define, list, and delete scripts.
1316 See the
1317 .Sx SCRIPTING
1318 section for more information on the scripting facility.
1319 .Pp
1320 .It Ic textdump dump
1321 .It Ic textdump set
1322 .It Ic textdump status
1323 .It Ic textdump unset
1324 Use the
1325 .Ic textdump dump
1326 command to immediately perform a textdump.
1327 More information may be found in
1328 .Xr textdump 4 .
1329 The
1330 .Ic textdump set
1331 command may be used to force the next kernel core dump to be a textdump
1332 rather than a traditional memory dump or minidump.
1333 .Ic textdump status
1334 reports whether a textdump has been scheduled.
1335 .Ic textdump unset
1336 cancels a request to perform a textdump as the next kernel core dump.
1337 .El
1338 .Sh VARIABLES
1339 The debugger accesses registers and variables as
1340 .Li $ Ns Ar name .
1341 Register names are as in the
1342 .Dq Ic show Cm registers
1343 command.
1344 Some variables are suffixed with numbers, and may have some modifier
1345 following a colon immediately after the variable name.
1346 For example, register variables can have a
1347 .Cm u
1348 modifier to indicate user register (e.g.,
1349 .Dq Li $eax:u ) .
1350 .Pp
1351 Built-in variables currently supported are:
1352 .Pp
1353 .Bl -tag -width ".Va tabstops" -compact
1354 .It Va radix
1355 Input and output radix.
1356 .It Va maxoff
1357 Addresses are printed as
1358 .Dq Ar symbol Ns Li + Ns Ar offset
1359 unless
1360 .Ar offset
1361 is greater than
1362 .Va maxoff .
1363 .It Va maxwidth
1364 The width of the displayed line.
1365 .It Va lines
1366 The number of lines.
1367 It is used by the built-in pager.
1368 Setting it to 0 disables paging.
1369 .It Va tabstops
1370 Tab stop width.
1371 .It Va work Ns Ar xx
1372 Work variable;
1373 .Ar xx
1374 can take values from 0 to 31.
1375 .El
1376 .Sh EXPRESSIONS
1377 Most expression operators in C are supported except
1378 .Ql ~ ,
1379 .Ql ^ ,
1380 and unary
1381 .Ql & .
1382 Special rules in
1383 .Nm
1384 are:
1385 .Bl -tag -width ".No Identifiers"
1386 .It Identifiers
1387 The name of a symbol is translated to the value of the symbol, which
1388 is the address of the corresponding object.
1389 .Ql \&.
1390 and
1391 .Ql \&:
1392 can be used in the identifier.
1393 If supported by an object format dependent routine,
1394 .Sm off
1395 .Oo Ar filename : Oc Ar func : lineno ,
1396 .Sm on
1397 .Oo Ar filename : Oc Ns Ar variable ,
1398 and
1399 .Oo Ar filename : Oc Ns Ar lineno
1400 can be accepted as a symbol.
1401 .It Numbers
1402 Radix is determined by the first two letters:
1403 .Ql 0x :
1404 hex,
1405 .Ql 0o :
1406 octal,
1407 .Ql 0t :
1408 decimal; otherwise, follow current radix.
1409 .It Li \&.
1410 .Va dot
1411 .It Li +
1412 .Va next
1413 .It Li ..
1414 address of the start of the last line examined.
1415 Unlike
1416 .Va dot
1417 or
1418 .Va next ,
1419 this is only changed by
1420 .Ic examine
1421 or
1422 .Ic write
1423 command.
1424 .It Li '
1425 last address explicitly specified.
1426 .It Li $ Ns Ar variable
1427 Translated to the value of the specified variable.
1428 It may be followed by a
1429 .Ql \&:
1430 and modifiers as described above.
1431 .It Ar a Ns Li # Ns Ar b
1432 A binary operator which rounds up the left hand side to the next
1433 multiple of right hand side.
1434 .It Li * Ns Ar expr
1435 Indirection.
1436 It may be followed by a
1437 .Ql \&:
1438 and modifiers as described above.
1439 .El
1440 .Sh SCRIPTING
1441 .Nm
1442 supports a basic scripting facility to allow automating tasks or responses to
1443 specific events.
1444 Each script consists of a list of DDB commands to be executed sequentially,
1445 and is assigned a unique name.
1446 Certain script names have special meaning, and will be automatically run on
1447 various
1448 .Nm
1449 events if scripts by those names have been defined.
1450 .Pp
1451 The
1452 .Ic script
1453 command may be used to define a script by name.
1454 Scripts consist of a series of
1455 .Nm
1456 commands separated with the
1457 .Ql \&;
1458 character.
1459 For example:
1460 .Bd -literal -offset indent
1461 script kdb.enter.panic=bt; show pcpu
1462 script lockinfo=show alllocks; show lockedvnods
1463 .Ed
1464 .Pp
1465 The
1466 .Ic scripts
1467 command lists currently defined scripts.
1468 .Pp
1469 The
1470 .Ic run
1471 command execute a script by name.
1472 For example:
1473 .Bd -literal -offset indent
1474 run lockinfo
1475 .Ed
1476 .Pp
1477 The
1478 .Ic unscript
1479 command may be used to delete a script by name.
1480 For example:
1481 .Bd -literal -offset indent
1482 unscript kdb.enter.panic
1483 .Ed
1484 .Pp
1485 These functions may also be performed from userspace using the
1486 .Xr ddb 8
1487 command.
1488 .Pp
1489 Certain scripts are run automatically, if defined, for specific
1490 .Nm
1491 events.
1492 The follow scripts are run when various events occur:
1493 .Bl -tag -width kdb.enter.powerfail
1494 .It Va kdb.enter.acpi
1495 The kernel debugger was entered as a result of an
1496 .Xr acpi 4
1497 event.
1498 .It Va kdb.enter.bootflags
1499 The kernel debugger was entered at boot as a result of the debugger boot
1500 flag being set.
1501 .It Va kdb.enter.break
1502 The kernel debugger was entered as a result of a serial or console break.
1503 .It Va kdb.enter.cam
1504 The kernel debugger was entered as a result of a
1505 .Xr CAM 4
1506 event.
1507 .It Va kdb.enter.mac
1508 The kernel debugger was entered as a result of an assertion failure in the
1509 .Xr mac_test 4
1510 module of the
1511 TrustedBSD MAC Framework.
1512 .It Va kdb.enter.netgraph
1513 The kernel debugger was entered as a result of a
1514 .Xr netgraph 4
1515 event.
1516 .It Va kdb.enter.panic
1517 .Xr panic 9
1518 was called.
1519 .It Va kdb.enter.powerpc
1520 The kernel debugger was entered as a result of an unimplemented interrupt
1521 type on the powerpc platform.
1522 .It Va kdb.enter.sysctl
1523 The kernel debugger was entered as a result of the
1524 .Va debug.kdb.enter
1525 sysctl being set.
1526 .It Va kdb.enter.unionfs
1527 The kernel debugger was entered as a result of an assertion failure in the
1528 union file system.
1529 .It Va kdb.enter.unknown
1530 The kernel debugger was entered, but no reason has been set.
1531 .It Va kdb.enter.vfslock
1532 The kernel debugger was entered as a result of a VFS lock violation.
1533 .It Va kdb.enter.watchdog
1534 The kernel debugger was entered as a result of a watchdog firing.
1535 .It Va kdb.enter.witness
1536 The kernel debugger was entered as a result of a
1537 .Xr witness 4
1538 violation.
1539 .El
1540 .Pp
1541 In the event that none of these scripts is found,
1542 .Nm
1543 will attempt to execute a default script:
1544 .Bl -tag -width kdb.enter.powerfail
1545 .It Va kdb.enter.default
1546 The kernel debugger was entered, but a script exactly matching the reason for
1547 entering was not defined.
1548 This can be used as a catch-all to handle cases not specifically of interest;
1549 for example,
1550 .Va kdb.enter.witness
1551 might be defined to have special handling, and
1552 .Va kdb.enter.default
1553 might be defined to simply panic and reboot.
1554 .El
1555 .Sh HINTS
1556 On machines with an ISA expansion bus, a simple NMI generation card can be
1557 constructed by connecting a push button between the A01 and B01 (CHCHK# and
1558 GND) card fingers.
1559 Momentarily shorting these two fingers together may cause the bridge chipset to
1560 generate an NMI, which causes the kernel to pass control to
1561 .Nm .
1562 Some bridge chipsets do not generate a NMI on CHCHK#, so your mileage may vary.
1563 The NMI allows one to break into the debugger on a wedged machine to
1564 diagnose problems.
1565 Other bus' bridge chipsets may be able to generate NMI using bus specific
1566 methods.
1567 There are many PCI and PCIe add-in cards which can generate NMI for
1568 debugging.
1569 Modern server systems typically use IPMI to generate signals to enter the
1570 debugger.
1571 The
1572 .Va devel/ipmitool
1573 port can be used to send the
1574 .Cd chassis power diag
1575 command which delivers an NMI to the processor.
1576 Embedded systems often use JTAG for debugging, but rarely use it in
1577 combination with
1578 .Nm .
1579 .Pp
1580 Serial consoles can break to the debugger by sending a BREAK
1581 condition on the serial line.
1582 This requires a kernel built with
1583 .Cd options BREAK_TO_DEBUGGER
1584 is specified in the kernel.
1585 Most terminal emulation programs can send a break sequence with a
1586 special key sequence or menu selection.
1587 Sending the break can be difficult or even happen spuriously in some setups.
1588 An alternative method is to build a kernel with
1589 .Cd options ALT_BREAK_TO_DEBUGGER
1590 then the sequence of CR TILDE CTRL-B enters the debugger;
1591 CR TILDE CTRL-P causes a panic; and
1592 CR TILDE CTRL-R causes an immediate reboot.
1593 In all these sequences, CR represents Carriage Return and is usually
1594 sent by pressing the Enter or Return key.
1595 TILDE is the ASCII tilde character (~).
1596 CTRL-x is Control x, sent by pressing the Control key, then x, then releasing
1597 both.
1598 .Pp
1599 The break-to-debugger behavior can be enabled by setting
1600 .Xr sysctl 8
1601 .Va debug.kdb.break_to_debugger
1602 to 1.
1603 The alt-break-to-debugger behavior can be enabled by setting
1604 .Xr sysctl 8
1605 .Va debug.kdb.alt_break_to_debugger
1606 to 1.
1607 The debugger can be entered by setting
1608 .Xr sysctl 8
1609 .Va debug.kdb.enter
1610 to 1.
1611 .Pp
1612 Output can be interrupted, paused, and resumed with the control
1613 characters CTRL-C, CTRL-S, and CTRL-Q.
1614 Because these control characters are received as in-band data from the
1615 console, there is an input buffer, and once that buffer fills
1616 .Nm
1617 must either stop responding to control characters or drop additional
1618 input while continuing to search for control characters.
1619 This behavior is controlled by the tunable
1620 .Xr sysctl 8
1621 .Va debug.ddb.prioritize_control_input ,
1622 which defaults to 1.
1623 The input buffer size is 512 bytes.
1624 .Sh FILES
1625 Header files mentioned in this manual page can be found below
1626 .Pa /usr/include
1627 directory.
1628 .Pp
1629 .Bl -dash -compact
1630 .It
1631 .Pa sys/buf.h
1632 .It
1633 .Pa sys/domain.h
1634 .It
1635 .Pa netinet/in_pcb.h
1636 .It
1637 .Pa sys/socket.h
1638 .It
1639 .Pa sys/vnode.h
1640 .El
1641 .Sh SEE ALSO
1642 .Xr gdb 1 Pq Pa ports/devel/gdb ,
1643 .Xr kgdb 1 Pq Pa ports/devel/gdb ,
1644 .Xr acpi 4 ,
1645 .Xr CAM 4 ,
1646 .Xr gdb 4 ,
1647 .Xr mac_ddb 4 ,
1648 .Xr mac_test 4 ,
1649 .Xr netgraph 4 ,
1650 .Xr textdump 4 ,
1651 .Xr witness 4 ,
1652 .Xr ddb 8 ,
1653 .Xr sysctl 8 ,
1654 .Xr panic 9
1655 .Sh HISTORY
1656 The
1657 .Nm
1658 debugger was developed for Mach, and ported to
1659 .Bx 386 0.1 .
1660 This manual page translated from
1661 .Xr man 7
1662 macros by
1663 .An Garrett Wollman .
1664 .Pp
1665 .An Robert N. M. Watson
1666 added support for
1667 .Nm
1668 output capture,
1669 .Xr textdump 4
1670 and scripting in
1671 .Fx 7.1 .