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
65 .Bd -ragged -offset indent
71 kernel debugger is an interactive debugger with a syntax inspired by
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 The current location is called
96 a hexadecimal format at a prompt.
103 to the address of the last line
104 examined or the last location modified, and set
107 the next location to be examined or changed.
108 Other commands do not change
115 The general command syntax is:
116 .Ar command Ns Op Li / Ns Ar modifier
117 .Oo Ar addr Oc Ns Op , Ns Ar count
119 A blank line repeats the previous command from the address
122 count 1 and no modifiers.
135 to be 1 for printing commands or infinity for stack traces.
138 of -1 is equivalent to a missing
140 Options that are supplied but not supported by the given
146 debugger has a pager feature (like the
150 If an output line exceeds the number set in the
152 variable, it displays
154 and waits for a response.
155 The valid responses for it are:
157 .Bl -tag -compact -width ".Li SPC"
163 abort the current command, and return to the command input mode
168 provides a small (currently 10 items) command history, and offers
171 command line editing capabilities.
175 control keys, the usual
177 arrow keys may be used to
178 browse through the history buffer, and move the cursor within the
181 .Ss COMMON DEBUGGER COMMANDS
182 .Bl -tag -width indent -compact
184 Print a short summary of the available commands and command
188 .Ic examine Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
189 .Oo Ar addr Oc Ns Op , Ns Ar count
192 .Ic x Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
193 .Oo Ar addr Oc Ns Op , Ns Ar count
195 Display the addressed locations according to the formats in the modifier.
196 Multiple modifier formats display multiple locations.
197 If no format is specified, the last format specified for this command
200 The format characters are:
201 .Bl -tag -compact -width indent
203 look at by bytes (8 bits)
205 look at by half words (16 bits)
207 look at by long words (32 bits)
209 look at by quad words (64 bits)
211 print the location being displayed
213 print the location with a line number if possible
215 display in unsigned hex
217 display in signed hex
219 display in unsigned octal
221 display in signed decimal
223 display in unsigned decimal
225 display in current radix, signed
227 display low 8 bits as a character.
228 Non-printing characters are displayed as an octal escape code (e.g.,
231 display the null-terminated string at the location.
232 Non-printing characters are displayed as octal escapes.
234 display in unsigned hex with character dump at the end of each line.
235 The location is also displayed in hex at the beginning of each line.
237 display as a disassembled instruction
239 display as an disassembled instruction with possible alternate formats depending on the
241 On i386, this selects the alternate format for the instruction decoding
242 (16 bits in a 32-bit code segment and vice versa).
244 display a symbol name for the pointer stored at the address
251 command with the last specified parameters to it
252 except that the next address displayed by it is used as the start address.
258 command with the last specified parameters to it
259 except that the last start address subtracted by the size displayed by it
260 is used as the start address.
262 .It Ic print Ns Op Li / Ns Cm acdoruxz
263 .It Ic p Ns Op Li / Ns Cm acdoruxz
266 according to the modifier character (as described above for
269 .Cm a , x , z , o , d , u , r ,
272 If no modifier is specified, the last one specified to it is used.
275 can be a string, in which case it is printed as it is.
277 .Bd -literal -offset indent
278 print/x "eax = " $eax "\enecx = " $ecx "\en"
282 .Bd -literal -offset indent
288 .Ic write Ns Op Li / Ns Cm bhl
289 .Ar addr expr1 Op Ar expr2 ...
292 .Ic w Ns Op Li / Ns Cm bhl
293 .Ar addr expr1 Op Ar expr2 ...
295 Write the expressions specified after
297 on the command line at succeeding locations starting with
299 The write unit size can be specified in the modifier with a letter
305 (long word) respectively.
307 long word is assumed.
310 since there is no delimiter between expressions, strange
312 It is best to enclose each expression in parentheses.
314 .It Ic set Li $ Ns Ar variable Oo Li = Oc Ar expr
315 Set the named variable or register with the value of
317 Valid variable names are described below.
319 .It Ic break Ns Oo Li / Ns Cm u Oc Oo Ar addr Oc Ns Op , Ns Ar count
320 .It Ic b Ns Oo Li / Ns Cm u Oc Oo Ar addr Oc Ns Op , Ns Ar count
327 command will not stop at this break point on the first
329 \- 1 times that it is hit.
330 If the break point is set, a break point number is
333 This number can be used in deleting the break point
334 or adding conditions to it.
338 modifier is specified, this command sets a break point in user
342 option, the address is considered to be in the kernel
343 space, and a wrong space address is rejected with an error message.
344 This modifier can be used only if it is supported by machine dependent
348 If a user text is shadowed by a normal user space debugger,
349 user space break points may not work correctly.
351 point at the low-level code paths may also cause strange behavior.
353 .It Ic delete Op Ar addr
355 .It Ic delete Li # Ns Ar number
356 .It Ic d Li # Ns Ar number
357 Delete the specified break point.
358 The break point can be specified by a
359 break point number with
363 specified in the original
365 command, or by omitting
367 to get the default address of
373 .It Ic watch Oo Ar addr Oc Ns Op , Ns Ar size
374 Set a watchpoint for a region.
375 Execution stops when an attempt to modify the region occurs.
378 argument defaults to 4.
379 If you specify a wrong space address, the request is rejected
380 with an error message.
383 Attempts to watch wired kernel memory
384 may cause unrecoverable error in some systems such as i386.
385 Watchpoints on user addresses work best.
387 .It Ic hwatch Oo Ar addr Oc Ns Op , Ns Ar size
388 Set a hardware watchpoint for a region if supported by the
390 Execution stops when an attempt to modify the region occurs.
393 argument defaults to 4.
396 The hardware debug facilities do not have a concept of separate
397 address spaces like the watch command does.
400 for setting watchpoints on kernel address locations only, and avoid
401 its use on user mode address spaces.
403 .It Ic dhwatch Oo Ar addr Oc Ns Op , Ns Ar size
404 Delete specified hardware watchpoint.
406 .It Ic kill Ar sig pid
411 The signal is acted on upon returning from the debugger.
412 This command can be used to kill a process causing resource contention
413 in the case of a hung system.
416 for a list of signals.
417 Note that the arguments are reversed relative to
420 .It Ic step Ns Oo Li / Ns Cm p Oc Ns Op , Ns Ar count
421 .It Ic s Ns Oo Li / Ns Cm p Oc Ns Op , Ns Ar count
427 modifier is specified, print each instruction at each step.
428 Otherwise, only print the last instruction.
431 depending on machine type, it may not be possible to
432 single-step through some low-level code paths or user space code.
433 On machines with software-emulated single-stepping (e.g., pmax),
434 stepping through code executed by interrupt handlers will probably
437 .It Ic continue Ns Op Li / Ns Cm c
438 .It Ic c Ns Op Li / Ns Cm c
439 Continue execution until a breakpoint or watchpoint.
442 modifier is specified, count instructions while executing.
443 Some machines (e.g., pmax) also count loads and stores.
446 when counting, the debugger is really silently single-stepping.
447 This means that single-stepping on low-level code may cause strange
450 .It Ic until Ns Op Li / Ns Cm p
451 Stop at the next call or return instruction.
454 modifier is specified, print the call nesting depth and the
455 cumulative instruction count at each call or return.
457 only print when the matching return is hit.
459 .It Ic next Ns Op Li / Ns Cm p
460 .It Ic match Ns Op Li / Ns Cm p
461 Stop at the matching return instruction.
464 modifier is specified, print the call nesting depth and the
465 cumulative instruction count at each call or return.
466 Otherwise, only print when the matching return is hit.
469 .Ic trace Ns Op Li / Ns Cm u
474 .Ic t Ns Op Li / Ns Cm u
479 .Ic where Ns Op Li / Ns Cm u
484 .Ic bt Ns Op Li / Ns Cm u
491 option traces user space; if omitted,
495 The optional argument
497 is the number of frames to be traced.
500 is omitted, all frames are printed.
503 User space stack trace is valid
504 only if the machine dependent code supports it.
507 .Ic search Ns Op Li / Ns Cm bhl
517 argument limits the search.
520 .It Ic reboot Op Ar seconds
521 .It Ic reset Op Ar seconds
522 Hard reset the system.
523 If the optional argument
525 is given, the debugger will wait for this long, at most a week,
528 .It Ic thread Ar addr | tid
529 Switch the debugger to the thread with ID
531 if the argument is a decimal number, or address
536 .Ss SPECIALIZED HELPER COMMANDS
538 .Bl -tag -width indent -compact
543 Prints the thread address for a thread kernel-mode stack of which contains the
545 If the thread is not found, search the thread stack cache and prints the
546 cached stack address.
547 Otherwise, prints nothing.
549 .It Ic show Cm all procs Ns Op Li / Ns Cm a
550 .It Ic ps Ns Op Li / Ns Cm a
551 Display all process information.
552 The process information may not be shown if it is not
553 supported in the machine, or the bottom of the stack of the
554 target process is not in the main memory at that time.
557 modifier will print command line arguments for each process.
560 .It Ic show Cm all trace
562 Show a stack trace for every thread in the system.
564 .It Ic show Cm all ttys
565 Show all TTY's within the system.
568 but also includes the address of the TTY structure.
571 .It Ic show Cm all vnets
572 Show the same output as "show vnet" does, but lists all
573 virtualized network stacks within the system.
576 .It Ic show Cm allchains
577 Show the same information like "show lockchain" does, but
578 for every thread in the system.
581 .It Ic show Cm alllocks
582 Show all locks that are currently held.
583 This command is only available if
585 is included in the kernel.
588 .It Ic show Cm allpcpu
589 The same as "show pcpu", but for every CPU present in the system.
592 .It Ic show Cm allrman
593 Show information related with resource management, including
594 interrupt request lines, DMA request lines, I/O ports, I/O memory
595 addresses, and Resource IDs.
599 Dump data about APIC IDT vector mappings.
602 .It Ic show Cm breaks
603 Show breakpoints set with the "break" command.
606 .It Ic show Cm bio Ar addr
607 Show information about the bio structure
615 for more details on the exact meaning of the structure fields.
618 .It Ic show Cm buffer Ar addr
619 Show information about the buf structure
625 header file for more details on the exact meaning of the structure fields.
628 .It Ic show Cm callout Ar addr
629 Show information about the callout structure
635 .It Ic show Cm cbstat
636 Show brief information about the TTY subsystem.
640 Without argument, show the list of all created cdev's, consisting of devfs
641 node name and struct cdev address.
642 When address of cdev is supplied, show some internal devfs state of the cdev.
645 .It Ic show Cm conifhk
646 Lists hooks currently waiting for completion in
647 run_interrupt_driven_config_hooks().
650 .It Ic show Cm cpusets
651 Print numbered root and assigned CPU affinity sets.
657 .It Ic show Cm cyrixreg
658 Show registers specific to the Cyrix processor.
661 .It Ic show Cm devmap
662 Prints the contents of the static device mapping table.
663 Currently only available on the
668 .It Ic show Cm domain Ar addr
669 Print protocol domain structure
675 header file for more details on the exact meaning of the structure fields.
678 .It Ic show Cm ffs Op Ar addr
679 Show brief information about ffs mount at the address
681 if argument is given.
682 Otherwise, provides the summary about each ffs mount.
685 .It Ic show Cm file Ar addr
686 Show information about the file structure
693 Show information about every file structure in the system.
696 .It Ic show Cm freepages
697 Show the number of physical pages in each of the free lists.
700 .It Ic show Cm geom Op Ar addr
703 argument is not given, displays the entire GEOM topology.
706 is given, displays details about the given GEOM object (class, geom,
707 provider or consumer).
712 The first column specifies the IDT vector.
713 The second one is the name of the interrupt/trap handler.
714 Those functions are machine dependent.
717 .It Ic show Cm igi_list Ar addr
718 Show information about the IGMP structure
719 .Vt struct igmp_ifsoftc
724 .It Ic show Cm inodedeps Op Ar addr
725 Show brief information about each inodedep structure.
728 is given, only inodedeps belonging to the fs located at the
729 supplied address are shown.
732 .It Ic show Cm inpcb Ar addr
733 Show information on IP Control Block
740 Dump information about interrupt handlers.
743 .It Ic show Cm intrcnt
744 Dump the interrupt statistics.
748 Show interrupt lines and their respective kernel threads.
757 shows, also list kernel internal details.
761 Show information from the local APIC registers for this CPU.
764 .It Ic show Cm lock Ar addr
766 The output format is as follows:
767 .Bl -tag -width "flags"
770 Possible types include
778 Flags passed to the lock initialization function.
780 values are lock class specific.
782 Current state of a lock.
784 values are lock class specific.
790 .It Ic show Cm lockchain Ar addr
791 Show all threads a particular thread at address
793 is waiting on based on non-spin locks.
796 .It Ic show Cm lockedbufs
797 Show the same information as "show buf", but for every locked
802 .It Ic show Cm lockedvnods
803 List all locked vnodes in the system.
807 Prints all locks that are currently acquired.
808 This command is only available if
810 is included in the kernel.
813 .It Ic show Cm locktree
816 .It Ic show Cm malloc Ns Op Li / Ns Cm i
819 memory allocator statistics.
822 modifier is specified, format output as machine-parseable comma-separated
824 The output columns are as follows:
826 .Bl -tag -compact -offset indent -width "Requests"
828 Specifies a type of memory.
829 It is the same as a description string used while defining the
830 given memory type with
831 .Xr MALLOC_DECLARE 9 .
833 Number of memory allocations of the given type, for which
835 has not been called yet.
837 Total memory consumed by the given allocation type.
839 Number of memory allocation requests for the given
843 The same information can be gathered in userspace with
847 .It Ic show Cm map Ns Oo Li / Ns Cm f Oc Ar addr
852 modifier is specified the
853 complete map is printed.
856 .It Ic show Cm msgbuf
857 Print the system's message buffer.
858 It is the same output as in the
861 It is useful if you got a kernel panic, attached a serial cable
862 to the machine and want to get the boot messages from before the
866 Displays short info about all currently mounted file systems.
868 .It Ic show Cm mount Ar addr
869 Displays details about the given mount point.
872 .It Ic show Cm object Ns Oo Li / Ns Cm f Oc Ar addr
873 Prints the VM object at
877 option is specified the
878 complete object is printed.
882 Print the panic message if set.
886 Show statistics on VM pages.
890 Show statistics on VM page queues.
893 .It Ic show Cm pciregs
894 Print PCI bus registers.
895 The same information can be gathered in userspace by running
896 .Dq Nm pciconf Fl lv .
900 Print current processor state.
901 The output format is as follows:
903 .Bl -tag -compact -offset indent -width "spin locks held:"
905 Processor identifier.
907 Thread pointer, process identifier and the name of the process.
909 Control block pointer.
915 CPU identifier coming from APIC.
918 .It Ic spin locks held
919 Names of spin locks held.
923 .It Ic show Cm pgrpdump
924 Dump process groups present within the system.
927 .It Ic show Cm proc Op Ar addr
930 is specified, print information about the current process.
931 Otherwise, show information about the process at address
935 .It Ic show Cm procvm
936 Show process virtual memory layout.
939 .It Ic show Cm protosw Ar addr
940 Print protocol switch structure
946 .It Ic show Cm registers Ns Op Li / Ns Cm u
947 Display the register set.
950 modifier is specified, it displays user registers instead of
951 kernel registers or the currently saved one.
956 modifier depends on the machine.
957 If not supported, incorrect information will be displayed.
960 .It Ic show Cm rman Ar addr
961 Show resource manager object
965 Addresses of particular pointers can be gathered with "show allrman"
969 .It Ic show Cm route Ar addr
970 Show route table result for destination
972 At this time, INET and INET6 formatted addresses are supported.
975 .It Ic show Cm routetable Oo Ar af Oc
976 Show full route table or tables.
979 is specified, show only routes for the given numeric address family.
980 If no argument is specified, dump the route table for all address families.
984 Show real time clock value.
985 Useful for long debugging sessions.
988 .It Ic show Cm sleepchain
991 .Ic show Cm lockchain .
994 .It Ic show Cm sleepq
995 .It Ic show Cm sleepqueue
996 Both commands provide the same functionality.
998 .Vt struct sleepqueue
1000 Sleepqueues are used within the
1002 kernel to implement sleepable
1003 synchronization primitives (thread holding a lock might sleep or
1004 be context switched), which at the time of writing are:
1012 .It Ic show Cm sockbuf Ar addr
1013 .It Ic show Cm socket Ar addr
1014 Those commands print
1020 Output consists of all values present in structures mentioned.
1021 For exact interpretation and more details, visit
1026 .It Ic show Cm sysregs
1027 Show system registers (e.g.,
1030 Not present on some platforms.
1033 .It Ic show Cm tcpcb Ar addr
1034 Print TCP control block
1038 For exact interpretation of output, visit
1043 .It Ic show Cm thread Op Ar addr | tid
1048 is specified, show detailed information about current thread.
1049 Otherwise, print information about the thread with ID
1053 (If the argument is a decimal number, it is assumed to be a tid.)
1056 .It Ic show Cm threads
1057 Show all threads within the system.
1058 Output format is as follows:
1060 .Bl -tag -compact -offset indent -width "Second column"
1062 Thread identifier (TID)
1063 .It Ic Second column
1064 Thread structure address
1070 .It Ic show Cm tty Ar addr
1071 Display the contents of a TTY structure in a readable form.
1074 .It Ic show Cm turnstile Ar addr
1076 .Vt struct turnstile
1077 structure at address
1079 Turnstiles are structures used within the
1082 synchronization primitives which, while holding a specific type of lock, cannot
1083 sleep or context switch to another thread.
1084 Currently, those are:
1090 .It Ic show Cm uma Ns Op Li / Ns Cm i
1091 Show UMA allocator statistics.
1094 modifier is specified, format output as machine-parseable comma-separated
1096 The output contains the following columns:
1098 .Bl -tag -compact -offset indent -width "Total Mem"
1100 Name of the UMA zone.
1101 The same string that was passed to
1103 as a first argument.
1105 Size of a given memory object (slab).
1107 Number of slabs being currently used.
1109 Number of free slabs within the UMA zone.
1111 Number of allocations requests to the given zone.
1113 Total memory in use (either allocated or free) by a zone, in bytes.
1115 Number of free slabs within the UMA zone that were freed on a different NUMA
1116 domain than allocated.
1119 column is inclusive of
1123 The same information might be gathered in the userspace
1125 .Dq Nm vmstat Fl z .
1128 .It Ic show Cm unpcb Ar addr
1129 Shows UNIX domain socket private control block
1131 present at the address
1135 .It Ic show Cm vmochk
1136 Prints, whether the internal VM objects are in a map somewhere
1137 and none have zero ref counts.
1140 .It Ic show Cm vmopag
1141 This is supposed to show physical addresses consumed by a
1143 Currently, it is not possible to use this command when
1145 is compiled in the kernel.
1148 .It Ic show Cm vnet Ar addr
1149 Prints virtualized network stack
1151 structure present at the address
1155 .It Ic show Cm vnode Op Ar addr
1160 For the exact interpretation of the output, look at the
1165 .It Ic show Cm vnodebufs Ar addr
1166 Shows clean/dirty buffer lists of the vnode located at
1170 .It Ic show Cm vpath Ar addr
1171 Walk the namecache to lookup the pathname of the vnode located at
1175 .It Ic show Cm watches
1176 Displays all watchpoints.
1177 Shows watchpoints set with "watch" command.
1180 .It Ic show Cm witness
1181 Shows information about lock acquisition coming from the
1186 .Ss OFFLINE DEBUGGING COMMANDS
1187 .Bl -tag -width indent -compact
1189 Switches to remote GDB mode.
1190 In remote GDB mode, another machine is required that runs
1192 using the remote debug feature, with a connection to the serial
1193 console port on the target machine.
1195 .It Ic netdump Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1198 with the provided parameters, and immediately perform a netdump.
1200 There are some known limitations.
1203 only supports IPv4 at this time.
1204 The address arguments to the
1206 command must be dotted decimal IPv4 addresses.
1207 (Hostnames are not supported.)
1208 At present, the command only works if the machine is in a panic state.
1212 command does not provide any way to configure compression or encryption.
1214 .It Ic netgdb Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1217 session with the provided parameters.
1220 has identical limitations to
1225 .It Ic capture reset
1226 .It Ic capture status
1228 supports a basic output capture facility, which can be used to retrieve the
1229 results of debugging commands from userspace using
1232 enables output capture;
1236 will clear the capture buffer and disable capture.
1238 will report current buffer use, buffer size, and disposition of output
1241 Userspace processes may inspect and manage
1246 .Va debug.ddb.capture.bufsize
1247 may be used to query or set the current capture buffer size.
1249 .Va debug.ddb.capture.maxbufsize
1250 may be used to query the compile-time limit on the capture buffer size.
1252 .Va debug.ddb.capture.bytes
1253 may be used to query the number of bytes of output currently in the capture
1256 .Va debug.ddb.capture.data
1257 returns the contents of the buffer as a string to an appropriately privileged
1260 This facility is particularly useful in concert with the scripting and
1262 facilities, allowing scripted debugging output to be captured and
1263 committed to disk as part of a textdump for later analysis.
1264 The contents of the capture buffer may also be inspected in a kernel core dump
1272 Run, define, list, and delete scripts.
1275 section for more information on the scripting facility.
1277 .It Ic textdump dump
1279 .It Ic textdump status
1280 .It Ic textdump unset
1283 command to immediately perform a textdump.
1284 More information may be found in
1288 command may be used to force the next kernel core dump to be a textdump
1289 rather than a traditional memory dump or minidump.
1291 reports whether a textdump has been scheduled.
1293 cancels a request to perform a textdump as the next kernel core dump.
1296 The debugger accesses registers and variables as
1298 Register names are as in the
1299 .Dq Ic show Cm registers
1301 Some variables are suffixed with numbers, and may have some modifier
1302 following a colon immediately after the variable name.
1303 For example, register variables can have a
1305 modifier to indicate user register (e.g.,
1308 Built-in variables currently supported are:
1310 .Bl -tag -width ".Va tabstops" -compact
1312 Input and output radix.
1314 Addresses are printed as
1315 .Dq Ar symbol Ns Li + Ns Ar offset
1321 The width of the displayed line.
1323 The number of lines.
1324 It is used by the built-in pager.
1325 Setting it to 0 disables paging.
1328 .It Va work Ns Ar xx
1331 can take values from 0 to 31.
1334 Most expression operators in C are supported except
1342 .Bl -tag -width ".No Identifiers"
1344 The name of a symbol is translated to the value of the symbol, which
1345 is the address of the corresponding object.
1349 can be used in the identifier.
1350 If supported by an object format dependent routine,
1352 .Oo Ar filename : Oc Ar func : lineno ,
1354 .Oo Ar filename : Oc Ns Ar variable ,
1356 .Oo Ar filename : Oc Ns Ar lineno
1357 can be accepted as a symbol.
1359 Radix is determined by the first two letters:
1365 decimal; otherwise, follow current radix.
1371 address of the start of the last line examined.
1376 this is only changed by
1382 last address explicitly specified.
1383 .It Li $ Ns Ar variable
1384 Translated to the value of the specified variable.
1385 It may be followed by a
1387 and modifiers as described above.
1388 .It Ar a Ns Li # Ns Ar b
1389 A binary operator which rounds up the left hand side to the next
1390 multiple of right hand side.
1393 It may be followed by a
1395 and modifiers as described above.
1399 supports a basic scripting facility to allow automating tasks or responses to
1401 Each script consists of a list of DDB commands to be executed sequentially,
1402 and is assigned a unique name.
1403 Certain script names have special meaning, and will be automatically run on
1406 events if scripts by those names have been defined.
1410 command may be used to define a script by name.
1411 Scripts consist of a series of
1413 commands separated with the
1417 .Bd -literal -offset indent
1418 script kdb.enter.panic=bt; show pcpu
1419 script lockinfo=show alllocks; show lockedvnods
1424 command lists currently defined scripts.
1428 command execute a script by name.
1430 .Bd -literal -offset indent
1436 command may be used to delete a script by name.
1438 .Bd -literal -offset indent
1439 unscript kdb.enter.panic
1442 These functions may also be performed from userspace using the
1446 Certain scripts are run automatically, if defined, for specific
1449 The follow scripts are run when various events occur:
1450 .Bl -tag -width kdb.enter.powerfail
1451 .It Va kdb.enter.acpi
1452 The kernel debugger was entered as a result of an
1455 .It Va kdb.enter.bootflags
1456 The kernel debugger was entered at boot as a result of the debugger boot
1458 .It Va kdb.enter.break
1459 The kernel debugger was entered as a result of a serial or console break.
1460 .It Va kdb.enter.cam
1461 The kernel debugger was entered as a result of a
1464 .It Va kdb.enter.mac
1465 The kernel debugger was entered as a result of an assertion failure in the
1468 TrustedBSD MAC Framework.
1469 .It Va kdb.enter.ndis
1470 The kernel debugger was entered as a result of an
1473 .It Va kdb.enter.netgraph
1474 The kernel debugger was entered as a result of a
1477 .It Va kdb.enter.panic
1480 .It Va kdb.enter.powerfail
1481 The kernel debugger was entered as a result of a powerfail NMI on the sparc64
1483 .It Va kdb.enter.powerpc
1484 The kernel debugger was entered as a result of an unimplemented interrupt
1485 type on the powerpc platform.
1486 .It Va kdb.enter.sysctl
1487 The kernel debugger was entered as a result of the
1490 .It Va kdb.enter.trapsig
1491 The kernel debugger was entered as a result of a trapsig event on the sparc64
1493 .It Va kdb.enter.unionfs
1494 The kernel debugger was entered as a result of an assertion failure in the
1496 .It Va kdb.enter.unknown
1497 The kernel debugger was entered, but no reason has been set.
1498 .It Va kdb.enter.vfslock
1499 The kernel debugger was entered as a result of a VFS lock violation.
1500 .It Va kdb.enter.watchdog
1501 The kernel debugger was entered as a result of a watchdog firing.
1502 .It Va kdb.enter.witness
1503 The kernel debugger was entered as a result of a
1508 In the event that none of these scripts is found,
1510 will attempt to execute a default script:
1511 .Bl -tag -width kdb.enter.powerfail
1512 .It Va kdb.enter.default
1513 The kernel debugger was entered, but a script exactly matching the reason for
1514 entering was not defined.
1515 This can be used as a catch-all to handle cases not specifically of interest;
1517 .Va kdb.enter.witness
1518 might be defined to have special handling, and
1519 .Va kdb.enter.default
1520 might be defined to simply panic and reboot.
1523 On machines with an ISA expansion bus, a simple NMI generation card can be
1524 constructed by connecting a push button between the A01 and B01 (CHCHK# and
1526 Momentarily shorting these two fingers together may cause the bridge chipset to
1527 generate an NMI, which causes the kernel to pass control to
1529 Some bridge chipsets do not generate a NMI on CHCHK#, so your mileage may vary.
1530 The NMI allows one to break into the debugger on a wedged machine to
1532 Other bus' bridge chipsets may be able to generate NMI using bus specific
1534 There are many PCI and PCIe add-in cards which can generate NMI for
1536 Modern server systems typically use IPMI to generate signals to enter the
1540 port can be used to send the
1541 .Cd chassis power diag
1542 command which delivers an NMI to the processor.
1543 Embedded systems often use JTAG for debugging, but rarely use it in
1547 For serial consoles, you can enter the debugger by sending a BREAK
1548 condition on the serial line if
1549 .Cd options BREAK_TO_DEBUGGER
1550 is specified in the kernel.
1551 Most terminal emulation programs can send a break sequence with a
1552 special key sequence or via a menu item.
1553 However, in some setups, sending the break can be difficult to arrange
1554 or happens spuriously, so if the kernel contains
1555 .Cd options ALT_BREAK_TO_DEBUGGER
1556 then the sequence of CR TILDE CTRL-B enters the debugger;
1557 CR TILDE CTRL-P causes a panic instead of entering the
1559 CR TILDE CTRL-R causes an immediate reboot.
1560 In all the above sequences, CR is a Carriage Return and is usually
1561 sent by hitting the Enter or Return key.
1562 TILDE is the ASCII tilde character (~).
1563 CTRL-x is Control x created by hitting the control key and then x
1564 and then releasing both.
1566 The break to enter the debugger behavior may be enabled at run-time
1569 .Va debug.kdb.break_to_debugger
1571 The alternate sequence to enter the debugger behavior may be enabled
1572 at run-time by setting the
1574 .Va debug.kdb.alt_break_to_debugger
1576 The debugger may be entered by setting the
1581 Header files mentioned in this manual page can be found below
1591 .Pa netinet/in_pcb.h
1613 debugger was developed for Mach, and ported to
1615 This manual page translated from
1618 .An Garrett Wollman .
1620 .An Robert N. M. Watson