2 .\" Mach Operating System
3 .\" Copyright (c) 1991,1990 Carnegie Mellon University
4 .\" Copyright (c) 2007 Robert N. M. Watson
5 .\" All Rights Reserved.
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.
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.
17 .\" Carnegie Mellon requests users of this software to return to
19 .\" Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
20 .\" School of Computer Science
21 .\" Carnegie Mellon University
22 .\" Pittsburgh PA 15213-3890
24 .\" any improvements or extensions that they make and grant Carnegie Mellon
25 .\" the rights to redistribute these changes.
34 .Nd interactive kernel debugger
36 In order to enable kernel debugging facilities include:
37 .Bd -ragged -offset indent
42 To prevent activation of the debugger on kernel
44 .Bd -ragged -offset indent
45 .Cd options KDB_UNATTENDED
48 In order to print a stack trace of the current thread on the console
50 .Bd -ragged -offset indent
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
62 backend, so that remote debugging with
63 .Xr kgdb 1 Pq Pa ports/devel/gdb
65 .Bd -ragged -offset indent
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
77 action, usually mapped to Ctrl+Alt+Esc, or by setting the
80 The debugger is also invoked on kernel
83 .Va debug.debugger_on_panic
85 MIB variable is set non-zero,
91 .Va debug.debugger_on_recursive_panic
94 then the debugger will be invoked on a recursive kernel panic.
95 This variable has a default value of
98 .Va debug.debugger_on_panic
99 is already set non-zero.
101 The current location is called
106 a hexadecimal format at a prompt.
113 to the address of the last line
114 examined or the last location modified, and set
117 the next location to be examined or changed.
118 Other commands do not change
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
129 A blank line repeats the previous command from the address
132 count 1 and no modifiers.
145 to be 1 for printing commands or infinity for stack traces.
148 of -1 is equivalent to a missing
150 Options that are supplied but not supported by the given
156 debugger has a pager feature (like the
160 If an output line exceeds the number set in the
162 variable, it displays
164 and waits for a response.
165 The valid responses for it are:
167 .Bl -tag -compact -width ".Li SPC"
173 abort the current command, and return to the command input mode
178 provides a small (currently 10 items) command history, and offers
181 command line editing capabilities.
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.
188 .Ss COMMON DEBUGGER COMMANDS
189 .Bl -tag -width indent -compact
191 Print a short summary of the available commands and command
195 .Ic examine Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
196 .Oo Ar addr Oc Ns Op , Ns Ar count
199 .Ic x Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
200 .Oo Ar addr Oc Ns Op , Ns Ar count
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
207 The format characters are:
208 .Bl -tag -compact -width indent
210 look at by bytes (8 bits)
212 look at by half words (16 bits)
214 look at by long words (32 bits)
216 look at by quad words (64 bits)
218 print the location being displayed
220 print the location with a line number if possible
222 display in unsigned hex
224 display in signed hex
226 display in unsigned octal
228 display in signed decimal
230 display in unsigned decimal
232 display in current radix, signed
234 display low 8 bits as a character.
235 Non-printing characters are displayed as an octal escape code (e.g.,
238 display the null-terminated string at the location.
239 Non-printing characters are displayed as octal escapes.
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.
244 display as a disassembled instruction
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).
251 display a symbol name for the pointer stored at the address
258 command with the last specified parameters to it
259 except that the next address displayed by it is used as the start address.
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.
269 .It Ic print Ns Op Li / Ns Cm acdoruxz
270 .It Ic p Ns Op Li / Ns Cm acdoruxz
273 according to the modifier character (as described above for
276 .Cm a , x , z , o , d , u , r ,
279 If no modifier is specified, the last one specified to it is used.
282 can be a string, in which case it is printed as it is.
284 .Bd -literal -offset indent
285 print/x "eax = " $eax "\enecx = " $ecx "\en"
289 .Bd -literal -offset indent
295 .Ic write Ns Op Li / Ns Cm bhl
296 .Ar addr expr1 Op Ar expr2 ...
299 .Ic w Ns Op Li / Ns Cm bhl
300 .Ar addr expr1 Op Ar expr2 ...
302 Write the expressions specified after
304 on the command line at succeeding locations starting with
306 The write unit size can be specified in the modifier with a letter
312 (long word) respectively.
314 long word is assumed.
317 since there is no delimiter between expressions, strange
319 It is best to enclose each expression in parentheses.
321 .It Ic set Li $ Ns Ar variable Oo Li = Oc Ar expr
322 Set the named variable or register with the value of
324 Valid variable names are described below.
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
334 command will not stop at this break point on the first
336 \- 1 times that it is hit.
337 If the break point is set, a break point number is
340 This number can be used in deleting the break point
341 or adding conditions to it.
345 modifier is specified, this command sets a break point in user
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
355 If a user text is shadowed by a normal user space debugger,
356 user space break points may not work correctly.
358 point at the low-level code paths may also cause strange behavior.
360 .It Ic delete 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
370 specified in the original
372 command, or by omitting
374 to get the default address of
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.
385 argument defaults to 4.
386 If you specify a wrong space address, the request is rejected
387 with an error message.
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.
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
397 Execution stops when an attempt to modify the region occurs.
400 argument defaults to 4.
403 The hardware debug facilities do not have a concept of separate
404 address spaces like the watch command does.
407 for setting watchpoints on kernel address locations only, and avoid
408 its use on user mode address spaces.
410 .It Ic dhwatch Oo Ar addr Oc Ns Op , Ns Ar size
411 Delete specified hardware watchpoint.
413 .It Ic kill Ar sig 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.
423 for a list of signals.
424 Note that the arguments are reversed relative to
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
434 modifier is specified, print each instruction at each step.
435 Otherwise, only print the last instruction.
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
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.
449 modifier is specified, count instructions while executing.
450 Some machines (e.g., pmax) also count loads and stores.
453 when counting, the debugger is really silently single-stepping.
454 This means that single-stepping on low-level code may cause strange
457 .It Ic until Ns Op Li / Ns Cm p
458 Stop at the next call or return instruction.
461 modifier is specified, print the call nesting depth and the
462 cumulative instruction count at each call or return.
464 only print when the matching return is hit.
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.
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.
476 .Ic trace Ns Op Li / Ns Cm u
481 .Ic t Ns Op Li / Ns Cm u
486 .Ic where Ns Op Li / Ns Cm u
491 .Ic bt Ns Op Li / Ns Cm u
498 option traces user space; if omitted,
502 The optional argument
504 is the number of frames to be traced.
507 is omitted, all frames are printed.
510 User space stack trace is valid
511 only if the machine dependent code supports it.
514 .Ic search Ns Op Li / Ns Cm bhl
524 argument limits the search.
528 .Ic Ic reboot Ns Op Li / Ns Cm s
532 .Ic Ic reset Ns Op Li / Ns Cm s
535 Hard reset the system.
536 If the optional argument
538 is given, the debugger will wait for this long, at most a week,
542 modifier is given, the command will skip running any registered shutdown
543 handlers and attempt the most basic reset.
545 .It Ic thread Ar addr | tid
546 Switch the debugger to the thread with ID
548 if the argument is a decimal number, or address
552 .It Ic watchdog Op Ar exp
558 If no argument is provided, the watchdog timer is disabled.
560 .Ss SPECIALIZED HELPER COMMANDS
561 .Bl -tag -width indent -compact
566 Prints the address of the thread whose kernel-mode stack contains
570 .It Ic show Cm active trace
572 Show a stack trace for every thread running on a CPU.
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.
582 modifier will print command line arguments for each process.
585 .It Ic show Cm all trace
587 Show a stack trace for every thread in the system.
589 .It Ic show Cm all ttys
590 Show all TTY's within the system.
593 but also includes the address of the TTY structure.
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.
601 .It Ic show Cm allchains
602 Show the same information like "show lockchain" does, but
603 for every thread in the system.
606 .It Ic show Cm alllocks
607 Show all locks that are currently held.
608 This command is only available if
610 is included in the kernel.
613 .It Ic show Cm allpcpu
614 The same as "show pcpu", but for every CPU present in the system.
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.
624 Dump data about APIC IDT vector mappings.
627 .It Ic show Cm badstacks
630 graph and print any lock-order violations.
631 This command is only available if
633 is included in the kernel.
636 .It Ic show Cm breaks
637 Show breakpoints set with the "break" command.
640 .It Ic show Cm bio Ar addr
641 Show information about the bio structure
649 for more details on the exact meaning of the structure fields.
652 .It Ic show Cm buffer Ar addr
653 Show information about the buf structure
659 header file for more details on the exact meaning of the structure fields.
662 .It Ic show Cm callout Ar addr
663 Show information about the callout structure
669 .It Ic show Cm cdev Op Ar addr
670 Show the internal devfs state of the cdev structure located at
672 If no argument is provided, show the list of all created cdevs, consisting of
673 the devfs node name and the
678 .It Ic show Cm conifhk
679 Lists hooks currently waiting for completion in
680 .Fn run_interrupt_driven_config_hooks .
683 .It Ic show Cm cpusets
684 Print numbered root and assigned CPU affinity sets.
690 .It Ic show Cm cyrixreg
691 Show registers specific to the Cyrix processor.
694 .It Ic show Cm devmap
695 Prints the contents of the static device mapping table.
696 Currently only available on the
701 .It Ic show Cm domain Ar addr
702 Print protocol domain structure
708 header file for more details on the exact meaning of the structure fields.
711 .It Ic show Cm ffs Op Ar addr
712 Show brief information about ffs mount at the address
714 if argument is given.
715 Otherwise, provides the summary about each ffs mount.
718 .It Ic show Cm file Ar addr
719 Show information about the file structure
726 Show information about every file structure in the system.
729 .It Ic show Cm freepages
730 Show the number of physical pages in each of the free lists.
733 .It Ic show Cm geom Op Ar addr
736 argument is not given, displays the entire GEOM topology.
739 is given, displays details about the given GEOM object (class, geom,
740 provider or consumer).
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.
750 .It Ic show Cm igi_list Ar addr
751 Show information about the IGMP structure
752 .Vt struct igmp_ifsoftc
757 .It Ic show Cm iosched Ar addr
758 Show information about the I/O scheduler
759 .Vt struct cam_iosched_softc
764 .It Ic show Cm inodedeps Op Ar addr
765 Show brief information about each inodedep structure.
768 is given, only inodedeps belonging to the fs located at the
769 supplied address are shown.
772 .It Ic show Cm inpcb Ar addr
773 Show information on IP Control Block
780 Dump information about interrupt handlers.
783 .It Ic show Cm intrcnt
784 Dump the interrupt statistics.
788 Show interrupt lines and their respective kernel threads.
791 .It Ic show Cm ktr Ns Op Li / Ns Cm a Ns Cm v Ns Cm V
792 Print the contents of the
797 modifier will request fully verbose output, causing the file, line number, and
798 timestamp to be printed for each trace entry.
801 modifier will request only the timestamps to be printed.
804 modifier will request that the output be unpaginated.
808 Show information from the local APIC registers for this CPU.
811 .It Ic show Cm lock Ar addr
813 The output format is as follows:
814 .Bl -tag -width "flags"
817 Possible types include
825 Flags passed to the lock initialization function.
827 values are lock class specific.
829 Current state of a lock.
831 values are lock class specific.
837 .It Ic show Cm lockchain Ar addr
838 Show all threads a particular thread at address
840 is waiting on based on non-spin locks.
843 .It Ic show Cm lockedbufs
844 Show the same information as "show buf", but for every locked
849 .It Ic show Cm lockedvnods
850 List all locked vnodes in the system.
854 Prints all locks that are currently acquired.
855 This command is only available if
857 is included in the kernel.
860 .It Ic show Cm locktree
863 .It Ic show Cm malloc Ns Op Li / Ns Cm i
866 memory allocator statistics.
869 modifier is specified, format output as machine-parseable comma-separated
871 The output columns are as follows:
873 .Bl -tag -compact -offset indent -width "Requests"
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 .
880 Number of memory allocations of the given type, for which
882 has not been called yet.
884 Total memory consumed by the given allocation type.
886 Number of memory allocation requests for the given
890 The same information can be gathered in userspace with
894 .It Ic show Cm map Ns Oo Li / Ns Cm f Oc Ar addr
899 modifier is specified the
900 complete map is printed.
903 .It Ic show Cm msgbuf
904 Print the system's message buffer.
905 It is the same output as in the
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
913 .It Ic show Cm mount Op Ar addr
914 Displays details about the mount point located at
919 displays short info about all currently mounted file systems.
922 .It Ic show Cm object Ns Oo Li / Ns Cm f Oc Ar addr
923 Prints the VM object at
927 option is specified the
928 complete object is printed.
932 Print the panic message if set.
936 Show statistics on VM pages.
940 Show statistics on VM page queues.
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 .
950 Print current processor state.
951 The output format is as follows:
953 .Bl -tag -compact -offset indent -width "spin locks held:"
955 Processor identifier.
957 Thread pointer, process identifier and the name of the process.
959 Control block pointer.
965 CPU identifier coming from APIC.
968 .It Ic spin locks held
969 Names of spin locks held.
973 .It Ic show Cm pgrpdump
974 Dump process groups present within the system.
977 .It Ic show Cm prison Op Ar addr
978 Show the prison structure located at
982 argument is specified, show information about all prisons in the system.
985 .It Ic show Cm proc Op Ar addr
986 Show information about the process structure located at address
988 or the current process if no argument is specified.
991 .It Ic show Cm procvm Op Ar addr
992 Show process virtual memory layout for the process located at
994 or the current process if no argument is specified.
997 .It Ic show Cm protosw Ar addr
998 Print protocol switch structure
1004 .It Ic show Cm registers Ns Op Li / Ns Cm u
1005 Display the register set.
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.
1013 .It Ic show Cm rman Ar addr
1014 Show resource manager object
1018 Addresses of particular pointers can be gathered with "show allrman"
1022 .It Ic show Cm route Ar addr
1023 Show route table result for destination
1025 At this time, INET and INET6 formatted addresses are supported.
1028 .It Ic show Cm routetable Oo Ar af Oc
1029 Show full route table or tables.
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.
1037 Show real time clock value.
1038 Useful for long debugging sessions.
1041 .It Ic show Cm sleepchain
1044 .Ic show Cm lockchain .
1047 .It Ic show Cm sleepq Ar addr
1048 .It Ic show Cm sleepqueue Ar addr
1051 structure located at
1055 .It Ic show Cm sockbuf Ar addr
1056 Show the socket buffer
1062 .It Ic show Cm socket Ar addr
1063 Show the socket object
1069 .It Ic show Cm sysregs
1070 Show system registers (e.g.,
1073 Not present on some platforms.
1076 .It Ic show Cm tcpcb Ar addr
1077 Print TCP control block
1081 For exact interpretation of output, visit
1086 .It Ic show Cm thread Op Ar addr | tid
1091 is specified, show detailed information about current thread.
1092 Otherwise, print information about the thread with ID
1096 (If the argument is a decimal number, it is assumed to be a tid.)
1099 .It Ic show Cm threads
1100 Show all threads within the system.
1101 Output format is as follows:
1103 .Bl -tag -compact -offset indent -width "Second column"
1105 Thread identifier (TID)
1106 .It Ic Second column
1107 Thread structure address
1113 .It Ic show Cm tty Ar addr
1114 Display the contents of a TTY structure in a readable form.
1117 .It Ic show Cm turnstile Ar addr
1119 .Vt struct turnstile
1120 structure at address
1122 Turnstiles are structures used within the
1125 synchronization primitives which, while holding a specific type of lock, cannot
1126 sleep or context switch to another thread.
1127 Currently, those are:
1133 .It Ic show Cm uma Ns Op Li / Ns Cm i
1134 Show UMA allocator statistics.
1137 modifier is specified, format output as machine-parseable comma-separated
1139 The output contains the following columns:
1141 .Bl -tag -compact -offset indent -width "Total Mem"
1143 Name of the UMA zone.
1144 The same string that was passed to
1146 as a first argument.
1148 Size of a given memory object (slab).
1150 Number of slabs being currently used.
1152 Number of free slabs within the UMA zone.
1154 Number of allocations requests to the given zone.
1156 Total memory in use (either allocated or free) by a zone, in bytes.
1158 Number of free slabs within the UMA zone that were freed on a different NUMA
1159 domain than allocated.
1162 column is inclusive of
1166 The same information might be gathered in the userspace
1168 .Dq Nm vmstat Fl z .
1171 .It Ic show Cm unpcb Ar addr
1172 Shows UNIX domain socket private control block
1174 present at the address
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.
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.
1188 .It Ic show Cm vnet Ar addr
1189 Prints virtualized network stack
1191 structure present at the address
1195 .It Ic show Cm vnode Ar addr
1200 For the exact interpretation of the output, look at the
1205 .It Ic show Cm vnodebufs Ar addr
1206 Shows clean/dirty buffer lists of the vnode located at
1210 .It Ic show Cm vpath Ar addr
1211 Walk the namecache to lookup the pathname of the vnode located at
1215 .It Ic show Cm watches
1216 Displays all watchpoints.
1217 Shows watchpoints set with "watch" command.
1220 .It Ic show Cm witness
1221 Shows information about lock acquisition coming from the
1225 .Ss OFFLINE DEBUGGING COMMANDS
1226 .Bl -tag -width indent -compact
1228 Initiate a kernel core dump to the device(s) configured by
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.
1238 .It Ic netdump Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1241 with the provided parameters, and immediately perform a netdump.
1243 There are some known limitations.
1246 only supports IPv4 at this time.
1247 The address arguments to the
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.
1255 command does not provide any way to configure compression or encryption.
1257 .It Ic netgdb Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1260 session with the provided parameters.
1263 has identical limitations to
1268 .It Ic capture reset
1269 .It Ic capture status
1271 supports a basic output capture facility, which can be used to retrieve the
1272 results of debugging commands from userspace using
1275 enables output capture;
1279 will clear the capture buffer and disable capture.
1281 will report current buffer use, buffer size, and disposition of output
1284 Userspace processes may inspect and manage
1289 .Va debug.ddb.capture.bufsize
1290 may be used to query or set the current capture buffer size.
1292 .Va debug.ddb.capture.maxbufsize
1293 may be used to query the compile-time limit on the capture buffer size.
1295 .Va debug.ddb.capture.bytes
1296 may be used to query the number of bytes of output currently in the capture
1299 .Va debug.ddb.capture.data
1300 returns the contents of the buffer as a string to an appropriately privileged
1303 This facility is particularly useful in concert with the scripting and
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
1309 .Xr kgdb 1 Pq Pa ports/devel/gdb .
1315 Run, define, list, and delete scripts.
1318 section for more information on the scripting facility.
1320 .It Ic textdump dump
1322 .It Ic textdump status
1323 .It Ic textdump unset
1326 command to immediately perform a textdump.
1327 More information may be found in
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.
1334 reports whether a textdump has been scheduled.
1336 cancels a request to perform a textdump as the next kernel core dump.
1339 The debugger accesses registers and variables as
1341 Register names are as in the
1342 .Dq Ic show Cm registers
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
1348 modifier to indicate user register (e.g.,
1351 Built-in variables currently supported are:
1353 .Bl -tag -width ".Va tabstops" -compact
1355 Input and output radix.
1357 Addresses are printed as
1358 .Dq Ar symbol Ns Li + Ns Ar offset
1364 The width of the displayed line.
1366 The number of lines.
1367 It is used by the built-in pager.
1368 Setting it to 0 disables paging.
1371 .It Va work Ns Ar xx
1374 can take values from 0 to 31.
1377 Most expression operators in C are supported except
1385 .Bl -tag -width ".No Identifiers"
1387 The name of a symbol is translated to the value of the symbol, which
1388 is the address of the corresponding object.
1392 can be used in the identifier.
1393 If supported by an object format dependent routine,
1395 .Oo Ar filename : Oc Ar func : lineno ,
1397 .Oo Ar filename : Oc Ns Ar variable ,
1399 .Oo Ar filename : Oc Ns Ar lineno
1400 can be accepted as a symbol.
1402 Radix is determined by the first two letters:
1408 decimal; otherwise, follow current radix.
1414 address of the start of the last line examined.
1419 this is only changed by
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
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.
1436 It may be followed by a
1438 and modifiers as described above.
1442 supports a basic scripting facility to allow automating tasks or responses to
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
1449 events if scripts by those names have been defined.
1453 command may be used to define a script by name.
1454 Scripts consist of a series of
1456 commands separated with the
1460 .Bd -literal -offset indent
1461 script kdb.enter.panic=bt; show pcpu
1462 script lockinfo=show alllocks; show lockedvnods
1467 command lists currently defined scripts.
1471 command execute a script by name.
1473 .Bd -literal -offset indent
1479 command may be used to delete a script by name.
1481 .Bd -literal -offset indent
1482 unscript kdb.enter.panic
1485 These functions may also be performed from userspace using the
1489 Certain scripts are run automatically, if defined, for specific
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
1498 .It Va kdb.enter.bootflags
1499 The kernel debugger was entered at boot as a result of the debugger boot
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
1507 .It Va kdb.enter.mac
1508 The kernel debugger was entered as a result of an assertion failure in the
1511 TrustedBSD MAC Framework.
1512 .It Va kdb.enter.netgraph
1513 The kernel debugger was entered as a result of a
1516 .It Va kdb.enter.panic
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
1526 .It Va kdb.enter.unionfs
1527 The kernel debugger was entered as a result of an assertion failure in the
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
1541 In the event that none of these scripts is found,
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;
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.
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
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
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
1565 Other bus' bridge chipsets may be able to generate NMI using bus specific
1567 There are many PCI and PCIe add-in cards which can generate NMI for
1569 Modern server systems typically use IPMI to generate signals to enter the
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
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
1599 The break-to-debugger behavior can be enabled by setting
1601 .Va debug.kdb.break_to_debugger
1603 The alt-break-to-debugger behavior can be enabled by setting
1605 .Va debug.kdb.alt_break_to_debugger
1607 The debugger can be entered by setting
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
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
1621 .Va debug.ddb.prioritize_control_input ,
1622 which defaults to 1.
1623 The input buffer size is 512 bytes.
1625 Header files mentioned in this manual page can be found below
1635 .Pa netinet/in_pcb.h
1642 .Xr gdb 1 Pq Pa ports/devel/gdb ,
1643 .Xr kgdb 1 Pq Pa ports/devel/gdb ,
1658 debugger was developed for Mach, and ported to
1660 This manual page translated from
1663 .An Garrett Wollman .
1665 .An Robert N. M. Watson