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 .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
187 arrow keys may be used to
188 browse through the history buffer, and move the cursor within the
191 .Ss COMMON DEBUGGER COMMANDS
192 .Bl -tag -width indent -compact
194 Print a short summary of the available commands and command
198 .Ic examine Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
199 .Oo Ar addr Oc Ns Op , Ns Ar count
202 .Ic x Ns Op Li / Ns Cm AISabcdghilmorsuxz ...
203 .Oo Ar addr Oc Ns Op , Ns Ar count
205 Display the addressed locations according to the formats in the modifier.
206 Multiple modifier formats display multiple locations.
207 If no format is specified, the last format specified for this command
210 The format characters are:
211 .Bl -tag -compact -width indent
213 look at by bytes (8 bits)
215 look at by half words (16 bits)
217 look at by long words (32 bits)
219 look at by quad words (64 bits)
221 print the location being displayed
223 print the location with a line number if possible
225 display in unsigned hex
227 display in signed hex
229 display in unsigned octal
231 display in signed decimal
233 display in unsigned decimal
235 display in current radix, signed
237 display low 8 bits as a character.
238 Non-printing characters are displayed as an octal escape code (e.g.,
241 display the null-terminated string at the location.
242 Non-printing characters are displayed as octal escapes.
244 display in unsigned hex with character dump at the end of each line.
245 The location is also displayed in hex at the beginning of each line.
247 display as a disassembled instruction
249 display as an disassembled instruction with possible alternate formats depending on the
251 On i386, this selects the alternate format for the instruction decoding
252 (16 bits in a 32-bit code segment and vice versa).
254 display a symbol name for the pointer stored at the address
261 command with the last specified parameters to it
262 except that the next address displayed by it is used as the start address.
268 command with the last specified parameters to it
269 except that the last start address subtracted by the size displayed by it
270 is used as the start address.
272 .It Ic print Ns Op Li / Ns Cm acdoruxz
273 .It Ic p Ns Op Li / Ns Cm acdoruxz
276 according to the modifier character (as described above for
279 .Cm a , x , z , o , d , u , r ,
282 If no modifier is specified, the last one specified to it is used.
285 can be a string, in which case it is printed as it is.
287 .Bd -literal -offset indent
288 print/x "eax = " $eax "\enecx = " $ecx "\en"
292 .Bd -literal -offset indent
298 .Ic write Ns Op Li / Ns Cm bhl
299 .Ar addr expr1 Op Ar expr2 ...
302 .Ic w Ns Op Li / Ns Cm bhl
303 .Ar addr expr1 Op Ar expr2 ...
305 Write the expressions specified after
307 on the command line at succeeding locations starting with
309 The write unit size can be specified in the modifier with a letter
315 (long word) respectively.
317 long word is assumed.
320 since there is no delimiter between expressions, strange
322 It is best to enclose each expression in parentheses.
324 .It Ic set Li $ Ns Ar variable Oo Li = Oc Ar expr
325 Set the named variable or register with the value of
327 Valid variable names are described below.
329 .It Ic break Ns Oo Li / Ns Cm u Oc Oo Ar addr Oc Ns Op , Ns Ar count
330 .It Ic b Ns Oo Li / Ns Cm u Oc Oo Ar addr Oc Ns Op , Ns Ar count
337 command will not stop at this break point on the first
339 \- 1 times that it is hit.
340 If the break point is set, a break point number is
343 This number can be used in deleting the break point
344 or adding conditions to it.
348 modifier is specified, this command sets a break point in user
352 option, the address is considered to be in the kernel
353 space, and a wrong space address is rejected with an error message.
354 This modifier can be used only if it is supported by machine dependent
358 If a user text is shadowed by a normal user space debugger,
359 user space break points may not work correctly.
361 point at the low-level code paths may also cause strange behavior.
363 .It Ic delete Op Ar addr
365 .It Ic delete Li # Ns Ar number
366 .It Ic d Li # Ns Ar number
367 Delete the specified break point.
368 The break point can be specified by a
369 break point number with
373 specified in the original
375 command, or by omitting
377 to get the default address of
383 .It Ic watch Oo Ar addr Oc Ns Op , Ns Ar size
384 Set a watchpoint for a region.
385 Execution stops when an attempt to modify the region occurs.
388 argument defaults to 4.
389 If you specify a wrong space address, the request is rejected
390 with an error message.
393 Attempts to watch wired kernel memory
394 may cause unrecoverable error in some systems such as i386.
395 Watchpoints on user addresses work best.
397 .It Ic hwatch Oo Ar addr Oc Ns Op , Ns Ar size
398 Set a hardware watchpoint for a region if supported by the
400 Execution stops when an attempt to modify the region occurs.
403 argument defaults to 4.
406 The hardware debug facilities do not have a concept of separate
407 address spaces like the watch command does.
410 for setting watchpoints on kernel address locations only, and avoid
411 its use on user mode address spaces.
413 .It Ic dhwatch Oo Ar addr Oc Ns Op , Ns Ar size
414 Delete specified hardware watchpoint.
416 .It Ic kill Ar sig pid
421 The signal is acted on upon returning from the debugger.
422 This command can be used to kill a process causing resource contention
423 in the case of a hung system.
426 for a list of signals.
427 Note that the arguments are reversed relative to
430 .It Ic step Ns Oo Li / Ns Cm p Oc Ns Op , Ns Ar count
431 .It Ic s Ns Oo Li / Ns Cm p Oc Ns Op , Ns Ar count
437 modifier is specified, print each instruction at each step.
438 Otherwise, only print the last instruction.
441 depending on machine type, it may not be possible to
442 single-step through some low-level code paths or user space code.
443 On machines with software-emulated single-stepping (e.g., pmax),
444 stepping through code executed by interrupt handlers will probably
447 .It Ic continue Ns Op Li / Ns Cm c
448 .It Ic c Ns Op Li / Ns Cm c
449 Continue execution until a breakpoint or watchpoint.
452 modifier is specified, count instructions while executing.
453 Some machines (e.g., pmax) also count loads and stores.
456 when counting, the debugger is really silently single-stepping.
457 This means that single-stepping on low-level code may cause strange
460 .It Ic until Ns Op Li / Ns Cm p
461 Stop at the next call or return instruction.
464 modifier is specified, print the call nesting depth and the
465 cumulative instruction count at each call or return.
467 only print when the matching return is hit.
469 .It Ic next Ns Op Li / Ns Cm p
470 .It Ic match Ns Op Li / Ns Cm p
471 Stop at the matching return instruction.
474 modifier is specified, print the call nesting depth and the
475 cumulative instruction count at each call or return.
476 Otherwise, only print when the matching return is hit.
479 .Ic trace Ns Op Li / Ns Cm u
484 .Ic t Ns Op Li / Ns Cm u
489 .Ic where Ns Op Li / Ns Cm u
494 .Ic bt Ns Op Li / Ns Cm u
501 option traces user space; if omitted,
505 The optional argument
507 is the number of frames to be traced.
510 is omitted, all frames are printed.
513 User space stack trace is valid
514 only if the machine dependent code supports it.
517 .Ic search Ns Op Li / Ns Cm bhl
527 argument limits the search.
530 .It Ic reboot Op Ar seconds
531 .It Ic reset Op Ar seconds
532 Hard reset the system.
533 If the optional argument
535 is given, the debugger will wait for this long, at most a week,
538 .It Ic thread Ar addr | tid
539 Switch the debugger to the thread with ID
541 if the argument is a decimal number, or address
545 .Ss SPECIALIZED HELPER COMMANDS
546 .Bl -tag -width indent -compact
551 Prints the thread address for a thread kernel-mode stack of which contains the
553 If the thread is not found, search the thread stack cache and prints the
554 cached stack address.
555 Otherwise, prints nothing.
557 .It Ic show Cm all procs Ns Op Li / Ns Cm a
558 .It Ic ps Ns Op Li / Ns Cm a
559 Display all process information.
560 The process information may not be shown if it is not
561 supported in the machine, or the bottom of the stack of the
562 target process is not in the main memory at that time.
565 modifier will print command line arguments for each process.
568 .It Ic show Cm all trace
570 Show a stack trace for every thread in the system.
572 .It Ic show Cm all ttys
573 Show all TTY's within the system.
576 but also includes the address of the TTY structure.
579 .It Ic show Cm all vnets
580 Show the same output as "show vnet" does, but lists all
581 virtualized network stacks within the system.
584 .It Ic show Cm allchains
585 Show the same information like "show lockchain" does, but
586 for every thread in the system.
589 .It Ic show Cm alllocks
590 Show all locks that are currently held.
591 This command is only available if
593 is included in the kernel.
596 .It Ic show Cm allpcpu
597 The same as "show pcpu", but for every CPU present in the system.
600 .It Ic show Cm allrman
601 Show information related with resource management, including
602 interrupt request lines, DMA request lines, I/O ports, I/O memory
603 addresses, and Resource IDs.
607 Dump data about APIC IDT vector mappings.
610 .It Ic show Cm breaks
611 Show breakpoints set with the "break" command.
614 .It Ic show Cm bio Ar addr
615 Show information about the bio structure
623 for more details on the exact meaning of the structure fields.
626 .It Ic show Cm buffer Ar addr
627 Show information about the buf structure
633 header file for more details on the exact meaning of the structure fields.
636 .It Ic show Cm callout Ar addr
637 Show information about the callout structure
643 .It Ic show Cm cbstat
644 Show brief information about the TTY subsystem.
648 Without argument, show the list of all created cdev's, consisting of devfs
649 node name and struct cdev address.
650 When address of cdev is supplied, show some internal devfs state of the cdev.
653 .It Ic show Cm conifhk
654 Lists hooks currently waiting for completion in
655 run_interrupt_driven_config_hooks().
658 .It Ic show Cm cpusets
659 Print numbered root and assigned CPU affinity sets.
665 .It Ic show Cm cyrixreg
666 Show registers specific to the Cyrix processor.
669 .It Ic show Cm devmap
670 Prints the contents of the static device mapping table.
671 Currently only available on the
676 .It Ic show Cm domain Ar addr
677 Print protocol domain structure
683 header file for more details on the exact meaning of the structure fields.
686 .It Ic show Cm ffs Op Ar addr
687 Show brief information about ffs mount at the address
689 if argument is given.
690 Otherwise, provides the summary about each ffs mount.
693 .It Ic show Cm file Ar addr
694 Show information about the file structure
701 Show information about every file structure in the system.
704 .It Ic show Cm freepages
705 Show the number of physical pages in each of the free lists.
708 .It Ic show Cm geom Op Ar addr
711 argument is not given, displays the entire GEOM topology.
714 is given, displays details about the given GEOM object (class, geom,
715 provider or consumer).
720 The first column specifies the IDT vector.
721 The second one is the name of the interrupt/trap handler.
722 Those functions are machine dependent.
725 .It Ic show Cm igi_list Ar addr
726 Show information about the IGMP structure
727 .Vt struct igmp_ifsoftc
732 .It Ic show Cm inodedeps Op Ar addr
733 Show brief information about each inodedep structure.
736 is given, only inodedeps belonging to the fs located at the
737 supplied address are shown.
740 .It Ic show Cm inpcb Ar addr
741 Show information on IP Control Block
748 Dump information about interrupt handlers.
751 .It Ic show Cm intrcnt
752 Dump the interrupt statistics.
756 Show interrupt lines and their respective kernel threads.
765 shows, also list kernel internal details.
769 Show information from the local APIC registers for this CPU.
772 .It Ic show Cm lock Ar addr
774 The output format is as follows:
775 .Bl -tag -width "flags"
778 Possible types include
786 Flags passed to the lock initialization function.
788 values are lock class specific.
790 Current state of a lock.
792 values are lock class specific.
798 .It Ic show Cm lockchain Ar addr
799 Show all threads a particular thread at address
801 is waiting on based on non-spin locks.
804 .It Ic show Cm lockedbufs
805 Show the same information as "show buf", but for every locked
810 .It Ic show Cm lockedvnods
811 List all locked vnodes in the system.
815 Prints all locks that are currently acquired.
816 This command is only available if
818 is included in the kernel.
821 .It Ic show Cm locktree
824 .It Ic show Cm malloc Ns Op Li / Ns Cm i
827 memory allocator statistics.
830 modifier is specified, format output as machine-parseable comma-separated
832 The output columns are as follows:
834 .Bl -tag -compact -offset indent -width "Requests"
836 Specifies a type of memory.
837 It is the same as a description string used while defining the
838 given memory type with
839 .Xr MALLOC_DECLARE 9 .
841 Number of memory allocations of the given type, for which
843 has not been called yet.
845 Total memory consumed by the given allocation type.
847 Number of memory allocation requests for the given
851 The same information can be gathered in userspace with
855 .It Ic show Cm map Ns Oo Li / Ns Cm f Oc Ar addr
860 modifier is specified the
861 complete map is printed.
864 .It Ic show Cm msgbuf
865 Print the system's message buffer.
866 It is the same output as in the
869 It is useful if you got a kernel panic, attached a serial cable
870 to the machine and want to get the boot messages from before the
874 Displays short info about all currently mounted file systems.
876 .It Ic show Cm mount Ar addr
877 Displays details about the given mount point.
880 .It Ic show Cm object Ns Oo Li / Ns Cm f Oc Ar addr
881 Prints the VM object at
885 option is specified the
886 complete object is printed.
890 Print the panic message if set.
894 Show statistics on VM pages.
898 Show statistics on VM page queues.
901 .It Ic show Cm pciregs
902 Print PCI bus registers.
903 The same information can be gathered in userspace by running
904 .Dq Nm pciconf Fl lv .
908 Print current processor state.
909 The output format is as follows:
911 .Bl -tag -compact -offset indent -width "spin locks held:"
913 Processor identifier.
915 Thread pointer, process identifier and the name of the process.
917 Control block pointer.
923 CPU identifier coming from APIC.
926 .It Ic spin locks held
927 Names of spin locks held.
931 .It Ic show Cm pgrpdump
932 Dump process groups present within the system.
935 .It Ic show Cm proc Op Ar addr
938 is specified, print information about the current process.
939 Otherwise, show information about the process at address
943 .It Ic show Cm procvm
944 Show process virtual memory layout.
947 .It Ic show Cm protosw Ar addr
948 Print protocol switch structure
954 .It Ic show Cm registers Ns Op Li / Ns Cm u
955 Display the register set.
958 modifier is specified, the register contents of the thread's previous
959 trapframe are displayed instead.
960 Usually, this corresponds to the saved state from userspace.
964 .It Ic show Cm rman Ar addr
965 Show resource manager object
969 Addresses of particular pointers can be gathered with "show allrman"
973 .It Ic show Cm route Ar addr
974 Show route table result for destination
976 At this time, INET and INET6 formatted addresses are supported.
979 .It Ic show Cm routetable Oo Ar af Oc
980 Show full route table or tables.
983 is specified, show only routes for the given numeric address family.
984 If no argument is specified, dump the route table for all address families.
988 Show real time clock value.
989 Useful for long debugging sessions.
992 .It Ic show Cm sleepchain
995 .Ic show Cm lockchain .
998 .It Ic show Cm sleepq
999 .It Ic show Cm sleepqueue
1000 Both commands provide the same functionality.
1001 They show sleepqueue
1002 .Vt struct sleepqueue
1004 Sleepqueues are used within the
1006 kernel to implement sleepable
1007 synchronization primitives (thread holding a lock might sleep or
1008 be context switched), which at the time of writing are:
1016 .It Ic show Cm sockbuf Ar addr
1017 .It Ic show Cm socket Ar addr
1018 Those commands print
1024 Output consists of all values present in structures mentioned.
1025 For exact interpretation and more details, visit
1030 .It Ic show Cm sysregs
1031 Show system registers (e.g.,
1034 Not present on some platforms.
1037 .It Ic show Cm tcpcb Ar addr
1038 Print TCP control block
1042 For exact interpretation of output, visit
1047 .It Ic show Cm thread Op Ar addr | tid
1052 is specified, show detailed information about current thread.
1053 Otherwise, print information about the thread with ID
1057 (If the argument is a decimal number, it is assumed to be a tid.)
1060 .It Ic show Cm threads
1061 Show all threads within the system.
1062 Output format is as follows:
1064 .Bl -tag -compact -offset indent -width "Second column"
1066 Thread identifier (TID)
1067 .It Ic Second column
1068 Thread structure address
1074 .It Ic show Cm tty Ar addr
1075 Display the contents of a TTY structure in a readable form.
1078 .It Ic show Cm turnstile Ar addr
1080 .Vt struct turnstile
1081 structure at address
1083 Turnstiles are structures used within the
1086 synchronization primitives which, while holding a specific type of lock, cannot
1087 sleep or context switch to another thread.
1088 Currently, those are:
1094 .It Ic show Cm uma Ns Op Li / Ns Cm i
1095 Show UMA allocator statistics.
1098 modifier is specified, format output as machine-parseable comma-separated
1100 The output contains the following columns:
1102 .Bl -tag -compact -offset indent -width "Total Mem"
1104 Name of the UMA zone.
1105 The same string that was passed to
1107 as a first argument.
1109 Size of a given memory object (slab).
1111 Number of slabs being currently used.
1113 Number of free slabs within the UMA zone.
1115 Number of allocations requests to the given zone.
1117 Total memory in use (either allocated or free) by a zone, in bytes.
1119 Number of free slabs within the UMA zone that were freed on a different NUMA
1120 domain than allocated.
1123 column is inclusive of
1127 The same information might be gathered in the userspace
1129 .Dq Nm vmstat Fl z .
1132 .It Ic show Cm unpcb Ar addr
1133 Shows UNIX domain socket private control block
1135 present at the address
1139 .It Ic show Cm vmochk
1140 Prints, whether the internal VM objects are in a map somewhere
1141 and none have zero ref counts.
1144 .It Ic show Cm vmopag
1145 This is supposed to show physical addresses consumed by a
1147 Currently, it is not possible to use this command when
1149 is compiled in the kernel.
1152 .It Ic show Cm vnet Ar addr
1153 Prints virtualized network stack
1155 structure present at the address
1159 .It Ic show Cm vnode Op Ar addr
1164 For the exact interpretation of the output, look at the
1169 .It Ic show Cm vnodebufs Ar addr
1170 Shows clean/dirty buffer lists of the vnode located at
1174 .It Ic show Cm vpath Ar addr
1175 Walk the namecache to lookup the pathname of the vnode located at
1179 .It Ic show Cm watches
1180 Displays all watchpoints.
1181 Shows watchpoints set with "watch" command.
1184 .It Ic show Cm witness
1185 Shows information about lock acquisition coming from the
1190 .Ss OFFLINE DEBUGGING COMMANDS
1191 .Bl -tag -width indent -compact
1193 Switches to remote GDB mode.
1194 In remote GDB mode, another machine is required that runs
1196 using the remote debug feature, with a connection to the serial
1197 console port on the target machine.
1199 .It Ic netdump Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1202 with the provided parameters, and immediately perform a netdump.
1204 There are some known limitations.
1207 only supports IPv4 at this time.
1208 The address arguments to the
1210 command must be dotted decimal IPv4 addresses.
1211 (Hostnames are not supported.)
1212 At present, the command only works if the machine is in a panic state.
1216 command does not provide any way to configure compression or encryption.
1218 .It Ic netgdb Fl s Ar server Oo Fl g Ar gateway Fl c Ar client Fl i Ar iface Oc
1221 session with the provided parameters.
1224 has identical limitations to
1229 .It Ic capture reset
1230 .It Ic capture status
1232 supports a basic output capture facility, which can be used to retrieve the
1233 results of debugging commands from userspace using
1236 enables output capture;
1240 will clear the capture buffer and disable capture.
1242 will report current buffer use, buffer size, and disposition of output
1245 Userspace processes may inspect and manage
1250 .Va debug.ddb.capture.bufsize
1251 may be used to query or set the current capture buffer size.
1253 .Va debug.ddb.capture.maxbufsize
1254 may be used to query the compile-time limit on the capture buffer size.
1256 .Va debug.ddb.capture.bytes
1257 may be used to query the number of bytes of output currently in the capture
1260 .Va debug.ddb.capture.data
1261 returns the contents of the buffer as a string to an appropriately privileged
1264 This facility is particularly useful in concert with the scripting and
1266 facilities, allowing scripted debugging output to be captured and
1267 committed to disk as part of a textdump for later analysis.
1268 The contents of the capture buffer may also be inspected in a kernel core dump
1276 Run, define, list, and delete scripts.
1279 section for more information on the scripting facility.
1281 .It Ic textdump dump
1283 .It Ic textdump status
1284 .It Ic textdump unset
1287 command to immediately perform a textdump.
1288 More information may be found in
1292 command may be used to force the next kernel core dump to be a textdump
1293 rather than a traditional memory dump or minidump.
1295 reports whether a textdump has been scheduled.
1297 cancels a request to perform a textdump as the next kernel core dump.
1300 The debugger accesses registers and variables as
1302 Register names are as in the
1303 .Dq Ic show Cm registers
1305 Some variables are suffixed with numbers, and may have some modifier
1306 following a colon immediately after the variable name.
1307 For example, register variables can have a
1309 modifier to indicate user register (e.g.,
1312 Built-in variables currently supported are:
1314 .Bl -tag -width ".Va tabstops" -compact
1316 Input and output radix.
1318 Addresses are printed as
1319 .Dq Ar symbol Ns Li + Ns Ar offset
1325 The width of the displayed line.
1327 The number of lines.
1328 It is used by the built-in pager.
1329 Setting it to 0 disables paging.
1332 .It Va work Ns Ar xx
1335 can take values from 0 to 31.
1338 Most expression operators in C are supported except
1346 .Bl -tag -width ".No Identifiers"
1348 The name of a symbol is translated to the value of the symbol, which
1349 is the address of the corresponding object.
1353 can be used in the identifier.
1354 If supported by an object format dependent routine,
1356 .Oo Ar filename : Oc Ar func : lineno ,
1358 .Oo Ar filename : Oc Ns Ar variable ,
1360 .Oo Ar filename : Oc Ns Ar lineno
1361 can be accepted as a symbol.
1363 Radix is determined by the first two letters:
1369 decimal; otherwise, follow current radix.
1375 address of the start of the last line examined.
1380 this is only changed by
1386 last address explicitly specified.
1387 .It Li $ Ns Ar variable
1388 Translated to the value of the specified variable.
1389 It may be followed by a
1391 and modifiers as described above.
1392 .It Ar a Ns Li # Ns Ar b
1393 A binary operator which rounds up the left hand side to the next
1394 multiple of right hand side.
1397 It may be followed by a
1399 and modifiers as described above.
1403 supports a basic scripting facility to allow automating tasks or responses to
1405 Each script consists of a list of DDB commands to be executed sequentially,
1406 and is assigned a unique name.
1407 Certain script names have special meaning, and will be automatically run on
1410 events if scripts by those names have been defined.
1414 command may be used to define a script by name.
1415 Scripts consist of a series of
1417 commands separated with the
1421 .Bd -literal -offset indent
1422 script kdb.enter.panic=bt; show pcpu
1423 script lockinfo=show alllocks; show lockedvnods
1428 command lists currently defined scripts.
1432 command execute a script by name.
1434 .Bd -literal -offset indent
1440 command may be used to delete a script by name.
1442 .Bd -literal -offset indent
1443 unscript kdb.enter.panic
1446 These functions may also be performed from userspace using the
1450 Certain scripts are run automatically, if defined, for specific
1453 The follow scripts are run when various events occur:
1454 .Bl -tag -width kdb.enter.powerfail
1455 .It Va kdb.enter.acpi
1456 The kernel debugger was entered as a result of an
1459 .It Va kdb.enter.bootflags
1460 The kernel debugger was entered at boot as a result of the debugger boot
1462 .It Va kdb.enter.break
1463 The kernel debugger was entered as a result of a serial or console break.
1464 .It Va kdb.enter.cam
1465 The kernel debugger was entered as a result of a
1468 .It Va kdb.enter.mac
1469 The kernel debugger was entered as a result of an assertion failure in the
1472 TrustedBSD MAC Framework.
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.powerpc
1481 The kernel debugger was entered as a result of an unimplemented interrupt
1482 type on the powerpc platform.
1483 .It Va kdb.enter.sysctl
1484 The kernel debugger was entered as a result of the
1487 .It Va kdb.enter.unionfs
1488 The kernel debugger was entered as a result of an assertion failure in the
1490 .It Va kdb.enter.unknown
1491 The kernel debugger was entered, but no reason has been set.
1492 .It Va kdb.enter.vfslock
1493 The kernel debugger was entered as a result of a VFS lock violation.
1494 .It Va kdb.enter.watchdog
1495 The kernel debugger was entered as a result of a watchdog firing.
1496 .It Va kdb.enter.witness
1497 The kernel debugger was entered as a result of a
1502 In the event that none of these scripts is found,
1504 will attempt to execute a default script:
1505 .Bl -tag -width kdb.enter.powerfail
1506 .It Va kdb.enter.default
1507 The kernel debugger was entered, but a script exactly matching the reason for
1508 entering was not defined.
1509 This can be used as a catch-all to handle cases not specifically of interest;
1511 .Va kdb.enter.witness
1512 might be defined to have special handling, and
1513 .Va kdb.enter.default
1514 might be defined to simply panic and reboot.
1517 On machines with an ISA expansion bus, a simple NMI generation card can be
1518 constructed by connecting a push button between the A01 and B01 (CHCHK# and
1520 Momentarily shorting these two fingers together may cause the bridge chipset to
1521 generate an NMI, which causes the kernel to pass control to
1523 Some bridge chipsets do not generate a NMI on CHCHK#, so your mileage may vary.
1524 The NMI allows one to break into the debugger on a wedged machine to
1526 Other bus' bridge chipsets may be able to generate NMI using bus specific
1528 There are many PCI and PCIe add-in cards which can generate NMI for
1530 Modern server systems typically use IPMI to generate signals to enter the
1534 port can be used to send the
1535 .Cd chassis power diag
1536 command which delivers an NMI to the processor.
1537 Embedded systems often use JTAG for debugging, but rarely use it in
1541 For serial consoles, you can enter the debugger by sending a BREAK
1542 condition on the serial line if
1543 .Cd options BREAK_TO_DEBUGGER
1544 is specified in the kernel.
1545 Most terminal emulation programs can send a break sequence with a
1546 special key sequence or via a menu item.
1547 However, in some setups, sending the break can be difficult to arrange
1548 or happens spuriously, so if the kernel contains
1549 .Cd options ALT_BREAK_TO_DEBUGGER
1550 then the sequence of CR TILDE CTRL-B enters the debugger;
1551 CR TILDE CTRL-P causes a panic instead of entering the
1553 CR TILDE CTRL-R causes an immediate reboot.
1554 In all the above sequences, CR is a Carriage Return and is usually
1555 sent by hitting the Enter or Return key.
1556 TILDE is the ASCII tilde character (~).
1557 CTRL-x is Control x created by hitting the control key and then x
1558 and then releasing both.
1560 The break to enter the debugger behavior may be enabled at run-time
1563 .Va debug.kdb.break_to_debugger
1565 The alternate sequence to enter the debugger behavior may be enabled
1566 at run-time by setting the
1568 .Va debug.kdb.alt_break_to_debugger
1570 The debugger may be entered by setting the
1575 Header files mentioned in this manual page can be found below
1585 .Pa netinet/in_pcb.h
1606 debugger was developed for Mach, and ported to
1608 This manual page translated from
1611 .An Garrett Wollman .
1613 .An Robert N. M. Watson