xref: /openbsd/share/man/man4/ddb.4 (revision f1f9609d)
1.\"	$OpenBSD: ddb.4,v 1.110 2024/12/21 03:10:46 jsg Exp $
2.\"	$NetBSD: ddb.4,v 1.5 1994/11/30 16:22:09 jtc Exp $
3.\"
4.\" Mach Operating System
5.\" Copyright (c) 1991,1990 Carnegie Mellon University
6.\" All Rights Reserved.
7.\"
8.\" Permission to use, copy, modify and distribute this software and its
9.\" documentation is hereby granted, provided that both the copyright
10.\" notice and this permission notice appear in all copies of the
11.\" software, derivative works or modified versions, and any portions
12.\" thereof, and that both notices appear in supporting documentation.
13.\"
14.\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15.\" CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16.\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17.\"
18.\" Carnegie Mellon requests users of this software to return to
19.\"
20.\"  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
21.\"  School of Computer Science
22.\"  Carnegie Mellon University
23.\"  Pittsburgh PA 15213-3890
24.\"
25.\" any improvements or extensions that they make and grant Carnegie Mellon
26.\" the rights to redistribute these changes.
27.\"
28.Dd $Mdocdate: December 21 2024 $
29.Dt DDB 4
30.Os
31.Sh NAME
32.Nm ddb
33.Nd kernel debugger
34.Sh DESCRIPTION
35The
36.Nm
37debugger provides a means for debugging the kernel,
38and analysing the kernel after a system crash ("panic"), with a
39.Xr gdb 1 Ns \&-like
40syntax.
41.Pp
42.Nm
43is invoked upon a kernel panic when the
44.Xr sysctl 8
45.Va ddb.panic
46is set to 1.
47It may be invoked from the console when the sysctl
48.Va ddb.console
49is set to 1, using any of the following methods:
50.Bl -dash -offset 3n
51.It
52Using the key sequence
53.Li Ctrl-Alt-Esc .
54.It
55Sending a
56.Dv BREAK
57when using a serial console.
58.It
59Writing to the sysctl
60.Va ddb.trigger .
61.It
62For i386 and amd64 architectures,
63using the key sequence
64.Li Ctrl-Alt-Delete
65when the sysctl
66.Va machdep.kbdreset
67is set to 2.
68.El
69.Pp
70.Nm
71prompts for commands on the console with:
72.Pp
73.Dl ddb>
74.Pp
75The general syntax of a
76.Nm
77command is:
78.Bd -ragged -offset indent
79.Ar command
80.Oo Ic / Ns Ar modifiers Oc " "
81.Oo Ar address Oc Ns
82.Op Ic \&, Ns Ar count
83.Ed
84.Pp
85To save typing,
86.Nm
87makes use of a context inferred from previous commands.
88In this context,
89the current location is called
90.Va dot .
91.\" The
92.\" .Va dot
93.\" is displayed with
94.\" a hexadecimal format at a prompt.
95The
96.Ic examine ,
97.Ic search ,
98.Ic show struct ,
99and
100.Ic write
101commands update
102.Va dot
103to be that of the last address
104examined or the last location modified, and
105have intuitive effects on
106.Va next
107and
108.Va prev .
109All the other commands do not change
110.Va dot ,
111and set
112.Va next
113to be the same.
114(See
115.Sx VARIABLES . )
116.Pp
117.\" Specifying
118.\" .Ar address
119.\" in a command sets
120.\" .Va dot .
121An expression can be used in place of
122.Ar address
123(see
124.Sx EXPRESSIONS ) .
125Omitting
126.Ar address
127in a command uses the last value of
128.Va dot .
129A missing
130.Ar count
131is taken to be 1 for printing commands or \*(If
132for stack traces.
133Entering a blank line causes the last command to be repeated using
134.Va next
135in place of
136.Ar address ,
137a
138.Ar count
139of 1, and no modifiers.
140.Pp
141.Nm
142has a feature like
143.Xr more 1
144for the output.
145If the number of lines output in response to one command exceeds the number
146set in the
147.Va $lines
148variable, it displays the message
149.Ql "--db_more--"
150and waits for a response.
151.Pp
152The valid responses are:
153.Pp
154.Bl -tag -width 10n -offset indent -compact
155.It Aq Ic space
156One more page.
157.It Aq Ic return
158One more line.
159.It Ic q
160Abort the current command, and return to the command input mode.
161.El
162.Pp
163The following command line editing keys are provided:
164.Pp
165.Bl -tag -width 10n -offset indent -compact
166.It Ic ^b
167back one character
168.It Ic ^f
169forward one character
170.It Ic ^a
171beginning of line
172.It Ic ^e
173end of line
174.It Ic ^w
175erase word back
176.It Ic ^h | Aq Ic del
177erase previous character
178.It Ic ^d
179erase next character
180.It Ic ^k
181delete to end of line
182.It Ic ^u
183delete line
184.It Ic ^p
185previous in command history
186.It Ic ^n
187next in command history
188.It Ic ^r
189redraw line
190.It Ic ^t
191exchange the two characters to the left of the cursor
192.El
193.Sh COMMANDS
194The following commands may be typed at the
195.Ql ddb>
196prompt.
197Some commands consist of more than one word, and if only the first word
198or words are entered, the possible alternatives to complete the command
199are displayed and no other action is performed.
200.Bl -tag -width 10n
201.\" --------------------
202.It Ic help
203List the available commands.
204.\" --------------------
205.Tg examine
206.It Xo
207.Oo Ic e Oc Ns
208.Ic x Ns Op Ic amine
209.Op Cm /bhlqaAxzodurcsmiI
210.Op Ar addr Ns
211.Op Ic \&, Ns Ar count
212.Xc
213Display the contents at address
214.Ar addr
215according to the formats in the modifier.
216If no format is specified, the last formats specified for this command
217are used.
218.Pp
219The format characters are:
220.Pp
221.Bl -tag -width 4n -compact
222.It Cm /b
223look at by bytes (8 bits)
224.It Cm /h
225look at by half words (16 bits)
226.It Cm /l
227look at by long words (32 bits) (default)
228.It Cm /q
229look at by long longs (64 bits) (only available on 64-bit platforms)
230.It Cm /a
231print the location being displayed
232.It Cm /A
233print the location with a line number if possible
234.It Cm /x
235display in unsigned hex
236.It Cm /z
237display in signed hex
238.It Cm /o
239display in unsigned octal
240.It Cm /d
241display in signed decimal
242.It Cm /u
243display in unsigned decimal
244.It Cm /r
245display in current radix, signed
246.It Cm /c
247display low 8 bits as a character.
248Non-printing characters are displayed as an octal escape code (e.g., '\e000').
249.It Cm /s
250display the null-terminated string at the location.
251Non-printing characters are displayed as octal escapes.
252.It Cm /m
253display in unsigned hex with character dump at the end of each line.
254The location is also displayed in hex at the beginning of each line.
255.It Cm /i
256display as an instruction
257.It Cm /I
258display as an alternate format instruction depending on the
259machine:
260.Pp
261.Bl -tag -width powerpc_ -compact
262.It alpha
263Print affected register contents for every instruction.
264.It amd64 ,
265.It i386
266Do not skip padding to the next long word boundary for unconditional jumps.
267.It m88k
268Decode instructions for the opposite CPU model (e.g. m88110 when running on an
269m88100 processor).
270.El
271.El
272.Pp
273The value of
274.Va next
275is set to the
276.Ar addr
277plus the size of the data examined.
278.\" --------------------
279.Tg print
280.It Xo
281.Ic p Ns Op Ic rint
282.Op Cm /axzodurc
283.Op Ar addr
284.Xc
285Print
286.Ar addr
287according to the modifier character.
288The valid modifiers are a subset of those from the
289.Ic examine
290command, and act as described there.
291If no modifier is specified, the last one specified in a
292previous use of
293.Ic print
294is used.
295.Pp
296For example,
297.Bd -literal -offset indent
298print/x $eax
299.Ed
300.Pp
301will print something like this:
302.Bd -literal -offset indent
303xxxxxx
304.Ed
305.\" --------------------
306.Tg pprint
307.It Xo
308.Ic pp Ns Op Ic rint
309.Op Ar addr
310.Xc
311Pretty-print
312.Ar addr
313using CTF debug symbols included in the kernel binary image.
314The CTF section is normally added by running
315.Xr ctfstrip 1
316as part of building a new kernel.
317.\" --------------------
318.\" .It Xo Ic w Ns Op Cm /bhl
319.\" .Op Ar addr
320.\" .Ar expr Op expr ...
321.\" .Xc
322.Tg write
323.It Xo
324.Ic w Ns Op Ic rite
325.Op Cm /bhl
326.Op Ar addr
327.Ar expr Op Ar expr ...
328.Xc
329Write the value of each
330.Ar expr
331expression at succeeding locations start at
332.Ar addr .
333The write unit size can be specified using one of the modifiers:
334.Pp
335.Bl -tag -width 4n -offset indent -compact
336.It Cm /b
337byte (8 bits)
338.It Cm /h
339half word (16 bits)
340.It Cm /l
341long word (32 bits) (default)
342.El
343.Pp
344The value of
345.Va next
346is set to
347.Ar addr
348plus the size of values written.
349.Pp
350.Sy Warning :
351since there is no delimiter between expressions, the
352command may not parse as you expect.
353It is best to enclose each expression in parentheses.
354.\" --------------------
355.It Xo Ic set
356.Ic $ Ns Ar name
357.Op Ic =
358.Ar expr
359.Xc
360Set the named variable or register with the value of
361.Ar expr .
362For valid variable names,
363see
364.Sx VARIABLES .
365.\" --------------------
366.It Ic boot Ar how
367Reboot the machine depending on
368.Ar how :
369.Pp
370.Bl -tag -width "boot poweroff" -compact
371.It Ic boot sync
372Sync disks and reboot.
373.It Ic boot crash
374Dump core and reboot.
375.It Ic boot dump
376Sync disks, dump core and reboot.
377.It Ic boot halt
378Just halt.
379.It Ic boot reboot
380Just reboot.
381.It Ic boot poweroff
382Power down the machine whenever possible; if it fails, just halt.
383.El
384.\" --------------------
385.It Xo
386.Ic break
387.Op Ar addr Ns
388.Op Ic \&, Ns Ar count
389.Xc
390Set a break point at
391.Ar addr .
392If
393.Ar count
394is supplied,
395.Nm
396allows the breakpoint to be silently hit
397.Ar ( count No \- 1 )
398times before stopping at the
399break point.
400.\" --------------------
401.Tg delete
402.It Xo
403.Ic d Ns Op Ic elete
404.Op Ar addr
405.Xc
406Delete the break point set with the
407.Ic break
408command.
409.\" --------------------
410.\" .It Xo Ic s Ns Op Cm /p
411.\" .Op Ic \&, Ns Ar count
412.\" .Xc
413.Tg step
414.It Xo
415.Ic s Ns Op Ic tep
416.Op Cm /p
417.Op Ic \&, Ns Ar count
418.Xc
419Single step
420.Ar count
421times.
422If the
423.Cm /p
424modifier is specified, print each instruction at each step.
425Otherwise, only print the last instruction.
426.Pp
427.Sy Warning :
428depending on machine type, it may not be possible to
429single-step through some low-level code paths.
430On machines with software-emulated single-stepping (e.g., alpha),
431stepping through code executed by interrupt handlers will probably
432do the wrong thing.
433.\" --------------------
434.It Ic call Ar name Ns Xo
435.Ic \&( Ns Ar expr
436.Op Ic \&, Ar expr ...
437.Ic \&)
438.Xc
439Call the function named by
440.Ar name
441with the argument(s) listed in parentheses.
442Parentheses may be omitted if the function takes no arguments.
443The number of arguments is currently limited to 10.
444.\" --------------------
445.\" .It Ic c Ns Op Cm /c
446.Tg continue
447.It Xo
448.Ic c Ns Op Ic ontinue
449.Op Cm /c
450.Xc
451Continue execution until a breakpoint or watchpoint.
452If the
453.Cm /c
454modifier is given, instructions are counted while executing.
455.Pp
456.Sy Warning :
457when counting with
458.Cm /c ,
459.Nm
460is really silently single-stepping.
461This means that single-stepping on low-level code may cause strange
462behavior.
463.\" --------------------
464.It Xo
465.Ic watch
466.Ar addr
467.Op Ic \&, Ns Ar size
468.Xc
469Set a watchpoint for the region starting at
470.Ar addr .
471Execution stops and control returns to
472.Nm
473when an attempt is made to modify a watched region.
474The
475.Ar size
476argument defaults to 4.
477.Pp
478If you specify a wrong space address, the request is rejected
479with an error message.
480.Pp
481.Sy Warning :
482attempts to watch wired kernel memory
483may cause an unrecoverable error on some systems (e.g., i386).
484.\" --------------------
485.It Ic dwatch Ar addr
486Delete the watchpoint at address
487.Ar addr
488that was previously set with a
489.Ic watch
490command.
491.\" --------------------
492.It Xo
493.Ic hangman
494.Op Cm /s Ns Op Ic 0-9
495.Xc
496This is a tiny and handy tool for random kernel hangs analysis, of which its
497depth is controlled by the optional argument of the default value of five.
498It uses some sophisticated heuristics to spot the global symbol that
499caused the hang.
500Since the discovering algorithm is a probabilistic one,
501you may spend substantial time to figure the exact symbol name.
502This smart thing requires a little of your attention, the input it accepts
503is mostly of the same format as that of the famous
504.Xr hangman 6
505game, to which it, apparently, is obliged by the name.
506Hint: the
507.Xr nm 1
508utility might help.
509.\" --------------------
510.It Ic until Op Cm /p
511Stop at the next
512.Qq call
513or
514.Qq return
515instruction.
516If the
517.Cm /p
518modifier is specified,
519.Nm
520prints the call nesting depth and the
521cumulative instruction count at each call or return.
522Otherwise, it stays silent until the matching return is hit.
523.\" --------------------
524.It Ic match Op Cm /p
525Stop at the next matching return instruction.
526If the
527.Cm /p
528modifier is specified,
529.Nm
530prints the call nesting depth and the
531cumulative instruction count at each call or return.
532Otherwise, it remains mostly quiet.
533.\" --------------------
534.It Ic next Op Cm /p
535The
536.Ic next
537command is a synonym for
538.Ic match .
539.\" --------------------
540.It Ic kill Ar pid
541Send an uncatchable
542.Dv SIGABRT
543signal to the process specified by the
544.Ar pid
545argument.
546.\" --------------------
547.It Xo
548.Ic trace
549.Op Cm /tu
550.Op Ar frameaddr Ns
551.Op Ic \&, Ns Ar count
552.Xc
553Show the stack trace.
554The
555.Cm /t
556modifier interprets the
557.Ar frameaddr
558argument as the TID of a process and shows the stack trace of
559that process.
560.Ar frameaddr
561is subject to the radix; use the 0t prefix to enter a decimal TID.
562The
563.Cm /t
564modifier is not supported on all platforms.
565The
566.Cm /u
567modifier shows the stack trace of user space;
568if omitted, the kernel stack is traced instead.
569The
570.Ar count
571argument is the limit on the number of frames to be followed.
572If
573.Ar count
574is omitted, all frames are printed.
575.Pp
576.Sy Warning :
577user space stack trace is valid
578only if the machine dependent code supports it.
579.\" --------------------
580.It Xo
581.Ic search
582.Op Cm /bhl
583.Op Ar addr
584.Ar value
585.Op Ar mask
586.Op Ic \&, Ns Ar count
587.Xc
588Search memory for a value beginning at
589.Ar addr .
590This command might fail in interesting
591ways if it doesn't find the searched-for value.
592This is because
593.Nm
594doesn't always recover from touching bad memory.
595The optional
596.Ar count
597argument limits the search.
598The modifiers are the same as those of the
599.Ic write
600command.
601.Pp
602The
603.Va next
604address is set to the address where
605.Ar value
606is found, or just after where the search area finishes.
607.\" --------------------
608.It Ic reboot
609Shortcut for
610.Ic boot reboot
611.\" --------------------
612.It Ic show Ar what
613Displays various things, depending on
614.Ar what :
615.Bl -tag -width 4n
616.\" --------------------
617.It Ic show bcstats
618Prints the buffer cache statistics.
619.\" --------------------
620.It Ic show breaks
621Prints a list of all breakpoints that have been set with the
622.Ic break
623command.
624.\" --------------------
625.It Ic show buf Ar addr
626Prints the
627.Vt struct buf
628at
629.Ar addr .
630.\" --------------------
631.It Ic show extents
632Prints a detailed list of all extents.
633.\" --------------------
634.It Ic show locks Op Ar addr
635Prints the list of locks held by a thread.
636If an optional address is not specified,
637.Li curproc
638is assumed.
639The
640.Cm option WITNESS
641is required for this command to be available.
642.\" --------------------
643.It Ic show malloc Op Ar addr
644Prints malloc debugging information if available.
645If an optional address is specified, only information about that address
646is printed.
647.\" --------------------
648.It Xo
649.Ic show map
650.Op Cm /f
651.Ar addr
652.Xc
653Prints the
654.Li vm_map
655at
656.Ar addr .
657If the
658.Cm /f
659modifier is specified, the complete map is printed.
660.\" --------------------
661.It Xo
662.Ic show mbuf
663.Op Cm /cp
664.Ar addr
665.Xc
666Prints the
667.Vt struct mbuf
668header at
669.Ar addr .
670Depending on the mbuf flags
671.Vt struct pkthdr
672and
673.Vt struct m_ext
674are printed as well.
675If the
676.Cm /c
677modifier is specified, print the mbuf chain linked with the m_next
678pointer.
679.Cm /p
680does the same using m_nextpkt.
681Both can be combined.
682.\" --------------------
683.It Xo
684.Ic show mount
685.Op Cm /f
686.Ar addr
687.Xc
688Prints the
689.Vt struct mount
690at
691.Ar addr .
692If the
693.Cm /f
694modifier is specified, prints out all
695.Li vnodes
696(see also
697.Cm show vnode )
698and also all
699.Li bufs
700(see also
701.Cm show buf )
702on all those vnodes.
703.\" --------------------
704.It Xo
705.Ic show nfsnode
706.Op Cm /f
707.Ar addr
708.Xc
709Prints the
710.Vt struct nfsnode
711at
712.Ar addr .
713If the
714.Cm /f
715modifier is specified, prints out additional
716information as well.
717.\" --------------------
718.It Xo
719.Ic show nfsreq
720.Op Cm /f
721.Ar addr
722.Xc
723Prints the
724.Vt struct nfsreq
725at
726.Ar addr .
727If the
728.Cm /f
729modifier is specified, prints out additional
730information as well.
731.\" --------------------
732.It Xo
733.Ic show object
734.Op Cm /f
735.Ar addr
736.Xc
737Prints the
738.Li vm_object
739at
740.Ar addr .
741If the
742.Cm /f
743modifier is specified, the complete object is printed.
744.\" --------------------
745.It Xo
746.Ic show page
747.Op Cm /f
748.Ar addr
749.Xc
750Prints the
751.Li vm_page
752at
753.Ar addr .
754If the
755.Cm /f
756modifier is specified, the complete page is printed.
757.\" --------------------
758.It Ic show panic
759Prints the panic string.
760.\" --------------------
761.It Xo
762.Ic show pool
763.Op Cm /p
764.Ar addr
765.Xc
766Prints the
767.Li pool
768at
769.Ar addr .
770Valid modifiers:
771.Bl -tag -width xxx -compact
772.It Cm /p
773Print the pagelist for this pool.
774.El
775.\" --------------------
776.It Xo
777.Ic show proc
778.Op Cm /t
779.Op Ar addr
780.Xc
781Prints the
782.Vt struct proc
783at
784.Ar addr .
785If an optional address is not specified,
786.Li curproc
787is assumed.
788The
789.Cm /t
790modifier interprets the
791.Ar addr
792argument as the TID of a proc.
793.\" --------------------
794.It Ic show registers Op Cm /u
795Display the register set.
796If the
797.Cm /u
798modifier is specified, it displays user registers (or the currently
799saved registers) instead of the kernel's.
800Note: The
801.Cm /u
802modifier is not supported on every machine, in which case
803incorrect information may be displayed.
804.\" --------------------
805.It Ic show route Ar addr
806Prints the
807.Vt struct rtentry
808at
809.Ar addr .
810.\" --------------------
811.It Ic show socket Ar addr
812Prints the
813.Vt struct socket
814at
815.Ar addr .
816If the socket is spliced, the
817.Vt struct sosplice
818associated with the socket is printed as well.
819.\" --------------------
820.It Xo
821.Ic show struct
822.Ar name
823.Op addr
824.Xc
825Prints the content of the memory at
826.Ar addr
827as a struct
828.Ar name .
829Nested structures and bit fields are not printed.
830Character arrays are printed as bytes.
831.\" --------------------
832.It Ic show swap
833Prints a detailed list of all swaps.
834.\" --------------------
835.It Xo
836.Ic show tdb
837.Op Cm /f
838.Ar addr
839.Xc
840Prints the
841.Vt struct tdb
842at
843.Ar addr .
844If the
845.Cm /f
846modifier is specified, prints out all fields of this IPsec SA.
847.\" --------------------
848.It Ic show uvmexp
849Displays a selection of uvm counters and statistics.
850.\" --------------------
851.It Xo
852.Ic show vnode
853.Op Cm /f
854.Ar addr
855.Xc
856Prints the
857.Vt struct vnode
858at
859.Ar addr .
860If the
861.Cm /f
862modifier is specified, prints out all
863.Li bufs
864(see also
865.Cm show buf )
866currently attached to this
867.Li vnode .
868.\" --------------------
869.It Ic show watches
870Displays all watchpoints set with the
871.Ic watch
872command.
873.\" --------------------
874.It Ic show witness Op Cm /b
875Prints the current order list.
876If the
877.Cm /b
878modifier is specified, the list of found lock order violations is printed
879instead.
880The
881.Cm option WITNESS
882is required for this command to be available.
883.\" --------------------
884.It Ic show all procs Op Cm /anow
885Display information on all processes.
886.Pp
887.Bl -tag -width foo -compact
888.It Cm /n
889(Default) Show process information in a
890.Xr ps 1 Ns \&-like
891format.
892Information printed includes process ID, thread ID, parent
893process ID, UID, process status, process flags, process
894wait channel message and process command name.
895.It Cm /a
896Shows the kernel virtual addresses of each process'
897proc structure, u-area, and vmspace structure.
898The vmspace address is also the address of the process'
899.Li vm_map
900structure
901and can be used in the
902.Ic show map
903command.
904.It Cm /o
905Shows non-idle threads that were on CPU when ddb was entered.
906Information printed includes thread ID, process ID, UID, process flags,
907thread flags, current CPU, and command name.
908.It Cm /w
909Shows each thread's ID, command, process group,
910wait channel address, and wait channel message.
911.El
912.\" --------------------
913.It Ic show all bufs Op Cm /f
914Display information about all buffers in the system.
915.Pp
916.Bl -tag -width foo -compact
917.It Cm /f
918For each buffer, print a more detailed output.
919See the
920.Ic show buf
921command for more information.
922.El
923.\" --------------------
924.It Ic show all callout
925Display the contents of the callout table.
926.\" --------------------
927.It Ic show all pools Op Cm /a
928Display information about all system pools in a format similar to
929.Xr vmstat 8 .
930.Pp
931.Bl -tag -width foo -compact
932.It Cm /a
933Displays
934.Dq interesting
935address information.
936.El
937.\" --------------------
938.It Ic show all locks
939Prints the list of locks held by all threads in the system.
940The
941.Cm option WITNESS
942is required for this command to be available.
943.\" --------------------
944.It Ic show all mounts Op Cm /f
945Display information on all mounted filesystems.
946.Pp
947.Bl -tag -width foo -compact
948.It Cm /f
949For each filesystem, list all its struct vnode addresses.
950These addresses can be used in the
951.Ic show vnode
952command.
953.El
954.\" --------------------
955.It Ic show all nfsnodes Op Cm /f
956Display information about all nfsnodes in the system.
957.Pp
958.Bl -tag -width foo -compact
959.It Cm /f
960For each nfsnode, print a more detailed output.
961See the
962.Ic show nfsnode
963command for more information.
964.El
965.\" --------------------
966.It Ic show all nfsreqs Op Cm /f
967Display information for all outstanding NFS requests.
968.Pp
969.Bl -tag -width foo -compact
970.It Cm /f
971For each NFS requests, print a more detailed output.
972See the
973.Ic show nfsreq
974command for more information.
975.El
976.\" --------------------
977.It Xo
978.Ic show all routes
979.Op Cm /iI
980.Op Ar rtableid
981.Op Ic \&, Ns Ar count
982.Xc
983Show internet routing tables.
984Default for
985.Ar rtableid
986is 0 and
987.Ar count
988is 1.
989.Pp
990.Bl -tag -width foo -compact
991.It Cm /i
992Restrict to AF_INET.
993.It Cm /I
994Restrict to AF_INET6.
995.El
996.\" --------------------
997.It Ic show all tdbs Op Cm /f
998Display information about all IPsec SAs in the system.
999.Pp
1000.Bl -tag -width foo -compact
1001.It Cm /f
1002For each tdb, print a more detailed output.
1003See the
1004.Ic show tdb
1005command for more information.
1006.El
1007.\" --------------------
1008.It Ic show all vnodes Op Cm /f
1009Display information about all vnodes in the system.
1010.Pp
1011.Bl -tag -width foo -compact
1012.It Cm /f
1013For each vnode, print a more detailed output.
1014See the
1015.Ic show vnode
1016command for more information.
1017.El
1018.El
1019.\" --------------------
1020.It Ic callout
1021A synonym for the
1022.Ic show all callout
1023command.
1024.\" --------------------
1025.It Ic ps Op Cm /anow
1026A synonym for
1027.Ic show all procs .
1028.\" --------------------
1029.Tg machine
1030.It Xo
1031.Ic mac Ns Op Ic hine
1032.Ar subcommand Op Ar arg ...
1033.Xc
1034Perform a platform-specific command.
1035.Pp
1036The following commands are supported by multiprocessor kernels on
1037these platforms: amd64, i386, macppc, mips64, and sparc64.
1038.Pp
1039.Bl -tag -width "searchframe [addr]" -compact
1040.It Ic cpuinfo
1041Display the state of each CPU.
1042.It Ic ddbcpu Ar N
1043Stop the current CPU and start handling
1044.Nm
1045on the selected CPU.
1046.It Ic startcpu Op Ar N
1047Resume normal processing on the selected CPU,
1048or all CPUs if none is specified.
1049.It Ic stopcpu Op Ar N
1050Stop normal processing on the selected CPU,
1051or all CPUs (except the one handling
1052.Nm )
1053if none is specified.
1054.El
1055.Pp
1056Other platform-specific commands:
1057.\" .Pp
1058.\" amd64:
1059.Pp
1060arm:
1061.Bl -tag -width "searchframe [addr]" -compact
1062.It Ic frame Ar addr
1063Display the trapframe at
1064.Ar addr .
1065.El
1066.Pp
1067i386:
1068.Bl -tag -width "searchframe [addr]" -compact
1069.\" .It Ic acpi disasm Ar ??
1070.\" .It Ic acpi showval Ar ??
1071.\" .It Ic acpi tree Ar ??
1072.\" .It Ic acpi trace Ar ??
1073.\" Evil ACPI debugging magic.
1074.It Ic sysregs
1075Display the contents of the privileged registers:
1076.Va IDTR ,
1077.Va GDTR ,
1078.Va LDTR ,
1079.Va TR ,
1080.Va CR0 ,
1081.Va CR2 ,
1082.Va CR3 ,
1083and
1084.Va CR4 .
1085.\" (i386-only)
1086.El
1087.Pp
1088m88k:
1089.Bl -tag -width "searchframe [addr]" -compact
1090.It Ic ddbcpu Ar N
1091Stop the current CPU and start handling
1092.Nm
1093on the selected CPU.
1094.It Ic frame Ar addr
1095Display the trapframe at
1096.Ar addr .
1097.It Ic regs
1098Display the registers from when
1099.Nm
1100was entered.
1101.It Ic searchframe Op Ar addr
1102Search for and display stack exception frames,
1103starting from
1104.Ar addr
1105if given, else the address in register
1106.Va r31 ,
1107and stopping at the next 8k boundary.
1108.It Ic where
1109Display where the current CPU was stopped.
1110.El
1111.Pp
1112mips64:
1113.Bl -tag -width "searchframe [addr]" -compact
1114.It Xo
1115.Ic tlb Op Cm /p Ar asid
1116.Op Cm /c
1117.Op Ar tlb
1118.Xc
1119.It Ic trap Ar ??
1120.El
1121.Pp
1122sh:
1123.Bl -tag -width "searchframe [addr]" -compact
1124.It Ic cache Op Ar addr
1125Display the cache, starting from
1126.Ar addr ,
1127defaulting to 0.
1128.It Ic frame
1129Display the switch and trap frames.
1130.\" .It Ic stack
1131.It Ic tlb
1132Display the TLB.
1133.El
1134.Pp
1135sparc64:
1136.Bl -tag -width "searchframe [addr]" -compact
1137.It Ic ctx
1138Display the context addresses for all threads.
1139.\" .It Ic dtlb Ar 0,2
1140.\" .It Ic dtsb
1141.\" .It Ic esp
1142.\" .It Ic fpstate Op Ar addr
1143.\" .It Ic itlb Ar 0,1,2
1144.\" .It Ic kmap Op Ar addr
1145.\" .It Ic pcb Op Ar addr
1146.\" .It Ic pctx Ar pid
1147.\" .It Ic page Ar addr
1148.\" .It Ic phys Op Ar addr
1149.\" .It Ic pmap Op Ar addr
1150.\" .It Ic proc Op Ar addr
1151.\" .It Ic prom Ar ??
1152.\" .It Ic pv Ar addr
1153.\" .It Ic stack Op Ar addr
1154.\" .It Ic tf Op Ar addr
1155.\" .It Ic ts
1156.\" .It Ic traptrace Op Ar addr
1157.\" .It Ic watch Op Ar addr
1158.\" .It Ic window Op Ar winnum
1159.\" .It Ic xir Op Ar addr
1160.El
1161.\" --------------------
1162.El
1163.Sh VARIABLES
1164.Nm
1165denotes registers and variables by
1166.Ic $ Ns Va name .
1167Register names can be found with the
1168.Ic show registers
1169command.
1170.Pp
1171Built-in debugger variables currently supported are:
1172.Bl -tag -width 10n -compact -offset indent
1173.It Va $radix
1174Input and output radix.
1175.It Va $maxoff
1176Addresses are printed as
1177.Ar symbol Ns Li + Ns Ar offset
1178unless
1179.Ar offset
1180is greater than
1181.Va $maxoff .
1182.It Va $maxwidth
1183The width of the displayed lines.
1184.It Va $lines
1185The number of lines to page.
1186This is used by the
1187.Dq more
1188feature.
1189.It Va $tabstops
1190Tab stop width.
1191.It Va $log
1192Controls whether the output of
1193.Nm
1194will also appear in the system message
1195buffer.
1196.El
1197.Pp
1198These variables can also be controlled outside
1199.Nm
1200via the
1201.Sq ddb
1202.Xr sysctl 8
1203hierarchy.
1204.Sh EXPRESSIONS
1205Almost all expression operators in C are supported except for
1206.Ql ~ ,
1207.Ql ^ ,
1208and unary
1209.Ql & .
1210Special rules for expressions in
1211.Nm
1212are:
1213.Bl -tag -width 15n -compact -offset indent
1214.It Ar identifier
1215The name of a symbol.
1216It is translated to the address (or value) of the symbol.
1217.Ql \&.
1218and
1219.Ql \&:
1220can be used in the identifier.
1221The following can be accepted as an identifier,
1222if supported by an object format dependent routine:
1223.Bl -item -offset indent -compact
1224.It
1225.Sm off
1226.Oo Ar filename Li \&: Oc Ar func
1227.Op \&: Ar linenumber
1228.It
1229.Op Ar filename \&:
1230.Ar variable
1231.It
1232.Ar filename
1233.Op \&: Ar linenumber
1234.Sm on
1235.El
1236The symbol may be prefixed with
1237.Sq Ar symboltablename Ns ::
1238(e.g.,
1239.Ql emulator::mach_msg_trap )
1240to specify other than kernel symbols.
1241.It Ar number
1242The radix is determined by the first two letters:
1243.Ql 0x :
1244hex,
1245.Ql 0o :
1246octal,
1247.Ql 0t :
1248decimal, otherwise, the value of
1249.Va $radix
1250is used.
1251.It Li \&.
1252.Va dot :
1253the current address.
1254.It Li +
1255.Va next :
1256the next address.
1257.It Li ..
1258The address of the start of the last line examined.
1259Unlike
1260.Va dot
1261or
1262.Va next ,
1263this is only changed by the
1264.Ic examine
1265or
1266.Ic write
1267command.
1268.It Li '
1269The last address explicitly specified.
1270.It Li $ Ns Ar variable
1271The value of a register or variable.
1272.It Ar expr Li # Ar expr
1273A binary operator which rounds up the left hand side to the next
1274multiple of right hand side.
1275.It Li * Ns Ar expr
1276Indirection.
1277It may be followed by a ':' as described above with
1278.Ar identifier .
1279.El
1280.Sh SEE ALSO
1281.Xr ctfstrip 1 ,
1282.Xr gdb 1 ,
1283.Xr nm 1 ,
1284.Xr witness 4 ,
1285.Xr sysctl.conf 5 ,
1286.Xr hangman 6 ,
1287.Xr crash 8 ,
1288.Xr sysctl 8 ,
1289.Xr extent 9 ,
1290.Xr pool 9 ,
1291.Xr uvm_init 9
1292.Sh HISTORY
1293This kernel facility first appeared in the Mach 3.0 operating system
1294developed by CMU.
1295Hangman (which stands for "hangs maniacal analyzer") first appeared in
1296.Ox 1.2 .
1297