xref: /openbsd/share/man/man4/ddb.4 (revision dd5075a3)
1.\"	$OpenBSD: ddb.4,v 1.94 2019/08/29 21:21:18 kn 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: August 29 2019 $
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.It Xo
206.Oo Ic e Oc Ns
207.Ic x Ns Op Ic amine
208.Op Cm /bhlqaAxzodurcsmiI
209.Op Ar addr Ns
210.Op Ic \&, Ns Ar count
211.Xc
212Display the contents at address
213.Ar addr
214according to the formats in the modifier.
215If no format is specified, the last formats specified for this command
216are used.
217.Pp
218The format characters are:
219.Pp
220.Bl -tag -width 4n -compact
221.It Cm /b
222look at by bytes (8 bits)
223.It Cm /h
224look at by half words (16 bits)
225.It Cm /l
226look at by long words (32 bits) (default)
227.It Cm /q
228look at by long longs (64 bits) (only available on 64-bit platforms)
229.It Cm /a
230print the location being displayed
231.It Cm /A
232print the location with a line number if possible
233.It Cm /x
234display in unsigned hex
235.It Cm /z
236display in signed hex
237.It Cm /o
238display in unsigned octal
239.It Cm /d
240display in signed decimal
241.It Cm /u
242display in unsigned decimal
243.It Cm /r
244display in current radix, signed
245.It Cm /c
246display low 8 bits as a character.
247Non-printing characters are displayed as an octal escape code (e.g., '\e000').
248.It Cm /s
249display the null-terminated string at the location.
250Non-printing characters are displayed as octal escapes.
251.It Cm /m
252display in unsigned hex with character dump at the end of each line.
253The location is also displayed in hex at the beginning of each line.
254.It Cm /i
255display as an instruction
256.It Cm /I
257display as an alternate format instruction depending on the
258machine:
259.Pp
260.Bl -tag -width powerpc_ -compact
261.It alpha
262Print affected register contents for every instruction.
263.It amd64 ,
264.It i386
265Do not skip padding to the next long word boundary for unconditional jumps.
266.It m88k
267Decode instructions for the opposite CPU model (e.g. m88110 when running on an
268m88100 processor).
269.El
270.El
271.Pp
272The value of
273.Va next
274is set to the
275.Ar addr
276plus the size of the data examined.
277.\" --------------------
278.It Xo
279.Ic p Ns Op Ic rint
280.Op Cm /axzodurc
281.Op Ar addr
282.Xc
283Print
284.Ar addr
285according to the modifier character.
286The valid modifiers are a subset of those from the
287.Ic examine
288command, and act as described there.
289If no modifier is specified, the last one specified in a
290previous use of
291.Ic print
292is used.
293.Pp
294For example,
295.Bd -literal -offset indent
296print/x $eax
297.Ed
298.Pp
299will print something like this:
300.Bd -literal -offset indent
301xxxxxx
302.Ed
303.\" --------------------
304.It Xo
305.Ic pp Ns Op Ic rint
306.Op Ar addr
307.Xc
308Pretty-print
309.Ar addr
310using CTF debug symbols included in the kernel binary image.
311The CTF section is normally added by running
312.Xr ctfstrip 1
313as part of building a new kernel.
314.\" --------------------
315.\" .It Xo Ic w Ns Op Cm /bhl
316.\" .Op Ar addr
317.\" .Ar expr Op expr ...
318.\" .Xc
319.It Xo
320.Ic w Ns Op Ic rite
321.Op Cm /bhl
322.Op Ar addr
323.Ar expr Op Ar expr ...
324.Xc
325Write the value of each
326.Ar expr
327expression at succeeding locations start at
328.Ar addr .
329The write unit size can be specified using one of the modifiers:
330.Pp
331.Bl -tag -width 4n -offset indent -compact
332.It Cm /b
333byte (8 bits)
334.It Cm /h
335half word (16 bits)
336.It Cm /l
337long word (32 bits) (default)
338.El
339.Pp
340The value of
341.Va next
342is set to
343.Ar addr
344plus the size of values written.
345.Pp
346.Sy Warning :
347since there is no delimiter between expressions, the
348command may not parse as you expect.
349It is best to enclose each expression in parentheses.
350.\" --------------------
351.It Xo Ic set
352.Ic $ Ns Ar name
353.Op Ic =
354.Ar expr
355.Xc
356Set the named variable or register with the value of
357.Ar expr .
358For valid variable names,
359see
360.Sx VARIABLES .
361.\" --------------------
362.It Ic boot Ar how
363Reboot the machine depending on
364.Ar how :
365.Pp
366.Bl -tag -width "boot poweroff" -compact
367.It Ic boot sync
368Sync disks and reboot.
369.It Ic boot crash
370Dump core and reboot.
371.It Ic boot dump
372Sync disks, dump core and reboot.
373.It Ic boot halt
374Just halt.
375.It Ic boot reboot
376Just reboot.
377.It Ic boot poweroff
378Power down the machine whenever possible; if it fails, just halt.
379.El
380.\" --------------------
381.It Xo
382.Ic break
383.Op Ar addr Ns
384.Op Ic \&, Ns Ar count
385.Xc
386Set a break point at
387.Ar addr .
388If
389.Ar count
390is supplied,
391.Nm
392allows the breakpoint to be silently hit
393.Ar ( count No \- 1 )
394times before stopping at the
395break point.
396.\" --------------------
397.It Xo
398.Ic d Ns Op Ic elete
399.Op Ar addr
400.Xc
401Delete the break point set with the
402.Ic break
403command.
404.\" --------------------
405.\" .It Xo Ic s Ns Op Cm /p
406.\" .Op Ic \&, Ns Ar count
407.\" .Xc
408.It Xo
409.Ic s Ns Op Ic tep
410.Op Cm /p
411.Op Ic \&, Ns Ar count
412.Xc
413Single step
414.Ar count
415times.
416If the
417.Cm /p
418modifier is specified, print each instruction at each step.
419Otherwise, only print the last instruction.
420.Pp
421.Sy Warning :
422depending on machine type, it may not be possible to
423single-step through some low-level code paths.
424On machines with software-emulated single-stepping (e.g., alpha),
425stepping through code executed by interrupt handlers will probably
426do the wrong thing.
427.\" --------------------
428.It Ic call Ar name Ns Xo
429.Ic \&( Ns Ar expr
430.Op Ic \&, Ar expr ...
431.Ic \&)
432.Xc
433Call the function named by
434.Ar name
435with the argument(s) listed in parentheses.
436Parentheses may be omitted if the function takes no arguments.
437The number of arguments is currently limited to 10.
438.\" --------------------
439.\" .It Ic c Ns Op Cm /c
440.It Xo
441.Ic c Ns Op Ic ontinue
442.Op Cm /c
443.Xc
444Continue execution until a breakpoint or watchpoint.
445If the
446.Cm /c
447modifier is given, instructions are counted while executing.
448.Pp
449.Sy Warning :
450when counting with
451.Cm /c ,
452.Nm
453is really silently single-stepping.
454This means that single-stepping on low-level code may cause strange
455behavior.
456.\" --------------------
457.It Xo
458.Ic watch
459.Ar addr
460.Op Ic \&, Ns Ar size
461.Xc
462Set a watchpoint for the region starting at
463.Ar addr .
464Execution stops and control returns to
465.Nm
466when an attempt is made to modify a watched region.
467The
468.Ar size
469argument defaults to 4.
470.Pp
471If you specify a wrong space address, the request is rejected
472with an error message.
473.Pp
474.Sy Warning :
475attempts to watch wired kernel memory
476may cause an unrecoverable error on some systems (e.g., i386).
477.\" --------------------
478.It Ic dwatch Ar addr
479Delete the watchpoint at address
480.Ar addr
481that was previously set with a
482.Ic watch
483command.
484.\" --------------------
485.It Xo
486.Ic hangman
487.Op Cm /s Ns Op Ic 0-9
488.Xc
489This is a tiny and handy tool for random kernel hangs analysis, of which its
490depth is controlled by the optional argument of the default value of five.
491It uses some sophisticated heuristics to spot the global symbol that
492caused the hang.
493Since the discovering algorithm is a probabilistic one,
494you may spend substantial time to figure the exact symbol name.
495This smart thing requires a little of your attention, the input it accepts
496is mostly of the same format as that of the famous
497.Xr hangman 6
498game, to which it, apparently, is obliged by the name.
499Hint: the
500.Xr nm 1
501utility might help.
502.\" --------------------
503.It Ic until Op Cm /p
504Stop at the next
505.Qq call
506or
507.Qq return
508instruction.
509If the
510.Cm /p
511modifier is specified,
512.Nm
513prints the call nesting depth and the
514cumulative instruction count at each call or return.
515Otherwise, it stays silent until the matching return is hit.
516.\" --------------------
517.It Ic match Op Cm /p
518Stop at the next matching return instruction.
519If the
520.Cm /p
521modifier is specified,
522.Nm
523prints the call nesting depth and the
524cumulative instruction count at each call or return.
525Otherwise, it remains mostly quiet.
526.\" --------------------
527.It Ic next Op Cm /p
528The
529.Ic next
530command is a synonym for
531.Ic match .
532.\" --------------------
533.It Ic kill Ar pid
534Send an uncatchable
535.Dv SIGABRT
536signal to the process specified by the
537.Ar pid
538argument.
539.\" --------------------
540.It Xo
541.Ic trace
542.Op Cm /pu
543.Op Ar frameaddr Ns
544.Op Ic \&, Ns Ar count
545.Xc
546Show the stack trace.
547The
548.Cm /p
549modifier interprets the
550.Ar frameaddr
551argument as the TID of a process and shows the stack trace of
552that process.
553The
554.Cm /p
555modifier is not supported on all platforms.
556The
557.Cm /u
558modifier shows the stack trace of user space;
559if omitted, the kernel stack is traced instead.
560The
561.Ar count
562argument is the limit on the number of frames to be followed.
563If
564.Ar count
565is omitted, all frames are printed.
566.Pp
567.Sy Warning :
568user space stack trace is valid
569only if the machine dependent code supports it.
570.\" --------------------
571.It Xo
572.Ic search
573.Op Cm /bhl
574.Op Ar addr
575.Ar value
576.Op Ar mask
577.Op Ic \&, Ns Ar count
578.Xc
579Search memory for a value beginning at
580.Ar addr .
581This command might fail in interesting
582ways if it doesn't find the searched-for value.
583This is because
584.Nm
585doesn't always recover from touching bad memory.
586The optional
587.Ar count
588argument limits the search.
589The modifiers are the same as those of the
590.Ic write
591command.
592.Pp
593The
594.Va next
595address is set to the address where
596.Ar value
597is found, or just after where the search area finishes.
598.\" --------------------
599.It Ic show Ar what
600Displays various things, depending on
601.Ar what :
602.Bl -tag -width 4n
603.\" --------------------
604.It Ic show bcstats
605Prints the buffer cache statistics.
606.\" --------------------
607.It Ic show breaks
608Prints a list of all breakpoints that have been set with the
609.Ic break
610command.
611.\" --------------------
612.It Xo
613.Ic show buf
614.Op Cm /f
615.Ar addr
616.Xc
617Prints the
618.Li struct buf
619at
620.Ar addr .
621If the
622.Cm /f
623modifier is specified output will also include
624.Li softdep
625printout, if those are available.
626.\" --------------------
627.It Ic show extents
628Prints a detailed list of all extents.
629.\" --------------------
630.It Ic show locks Op Ar addr
631Prints the list of locks held by a thread.
632If an optional address is not specified,
633.Li curproc
634is assumed.
635The
636.Cm option WITNESS
637is required for this command to be available.
638.\" --------------------
639.It Ic show malloc Op Ar addr
640Prints malloc debugging information if available.
641If an optional address is specified, only information about that address
642is printed.
643.\" --------------------
644.It Xo
645.Ic show map
646.Op Cm /f
647.Ar addr
648.Xc
649Prints the
650.Li vm_map
651at
652.Ar addr .
653If the
654.Cm /f
655modifier is specified the complete map is printed.
656.\" --------------------
657.It Ic show mbuf Ar addr
658Prints the
659.Li struct mbuf
660header at
661.Ar addr .
662Depending on the mbuf flags
663.Li struct pkthdr
664and
665.Li struct m_ext
666are printed as well.
667.\" --------------------
668.It Xo
669.Ic show mount
670.Op Cm /f
671.Ar addr
672.Xc
673Prints the
674.Li struct mount
675at
676.Ar addr .
677If the
678.Cm /f
679modifier is specified prints out all
680.Li vnodes
681(see also
682.Cm show vnode )
683and also all
684.Li bufs
685(see also
686.Cm show buf )
687on all those vnodes.
688.\" --------------------
689.It Xo
690.Ic show nfsnode
691.Op Cm /f
692.Ar addr
693.Xc
694Prints the
695.Li struct nfsnode
696at
697.Ar addr .
698If the
699.Cm /f
700modifier is specified prints out additional
701information as well.
702.\" --------------------
703.It Xo
704.Ic show nfsreq
705.Op Cm /f
706.Ar addr
707.Xc
708Prints the
709.Li struct nfsreq
710at
711.Ar addr .
712If the
713.Cm /f
714modifier is specified prints out additional
715information as well.
716.\" --------------------
717.It Xo
718.Ic show object
719.Op Cm /f
720.Ar addr
721.Xc
722Prints the
723.Li vm_object
724at
725.Ar addr .
726If the
727.Cm /f
728modifier is specified the complete object is printed.
729.\" --------------------
730.It Xo
731.Ic show page
732.Op Cm /f
733.Ar addr
734.Xc
735Prints the
736.Li vm_page
737at
738.Ar addr .
739If the
740.Cm /f
741modifier is specified the complete page is printed.
742.\" --------------------
743.It Ic show panic
744Prints the panic string.
745.\" --------------------
746.It Xo
747.Ic show pool
748.Op Cm /p
749.Ar addr
750.Xc
751Prints the
752.Li pool
753at
754.Ar addr .
755Valid modifiers:
756.Bl -tag -width xxx -compact
757.It Cm /p
758Print the pagelist for this pool.
759.El
760.\" --------------------
761.It Ic show proc Op Ar addr
762Prints the
763.Li struct proc
764at
765.Ar addr .
766If an optional address is not specified
767.Li curproc
768is assumed.
769.\" --------------------
770.It Ic show registers Op Cm /u
771Display the register set.
772If the
773.Cm /u
774modifier is specified, it displays user registers (or the currently
775saved registers) instead of the kernel's.
776Note: The
777.Cm /u
778modifier is not supported on every machine, in which case
779incorrect information may be displayed.
780.\" --------------------
781.It Ic show socket Ar addr
782Prints the
783.Li struct socket
784at
785.Ar addr .
786If the socket is spliced, the
787.Li struct sosplice
788associated with the socket is printed as well.
789.\" --------------------
790.It Xo
791.Ic show struct
792.Ar name
793.Op addr
794.Xc
795Prints the content of the memory at
796.Ar addr
797as a struct
798.Ar name .
799Nested structures and bit fields are not printed.
800Character arrays are printed as bytes.
801.\" --------------------
802.It Ic show uvmexp
803Displays a selection of uvm counters and statistics.
804.\" --------------------
805.It Xo
806.Ic show vnode
807.Op Cm /f
808.Ar addr
809.Xc
810Prints the
811.Li struct vnode
812at
813.Ar addr .
814If the
815.Cm /f
816modifier is specified prints out all
817.Li bufs
818(see also
819.Cm show buf )
820currently attached to this
821.Li vnode .
822.\" --------------------
823.It Ic show watches
824Displays all watchpoints set with the
825.Ic watch
826command.
827.\" --------------------
828.It Ic show witness Op Cm /b
829Prints the current order list.
830If the
831.Cm /b
832modifier is specified, the list of found lock order violations is printed
833instead.
834The
835.Cm option WITNESS
836is required for this command to be available.
837.\" --------------------
838.It Ic show all procs Op Cm /anow
839Display information on all processes.
840.Pp
841.Bl -tag -width foo -compact
842.It Cm /n
843(Default) Show process information in a
844.Xr ps 1 Ns \&-like
845format.
846Information printed includes process ID, thread ID, parent
847process ID, UID, process status, process flags, process
848wait channel message and process command name.
849.It Cm /a
850Shows the kernel virtual addresses of each process'
851proc structure, u-area, and vmspace structure.
852The vmspace address is also the address of the process'
853.Li vm_map
854structure
855and can be used in the
856.Ic show map
857command.
858.It Cm /o
859Shows non-idle threads that were on CPU when ddb was entered.
860Information printed includes thread ID, process ID, UID, process flags,
861thread flags, current CPU, and command name.
862.It Cm /w
863Shows each thread's ID, command, process group,
864wait channel address, and wait channel message.
865.El
866.\" --------------------
867.It Ic show all bufs Op Cm /f
868Display information about all buffers in the system.
869.Pp
870.Bl -tag -width foo -compact
871.It Cm /f
872For each buffer, print a more detailed output.
873See the
874.Ic show buf
875command for more information.
876.El
877.\" --------------------
878.It Ic show all callout
879Display the contents of the callout table.
880.\" --------------------
881.It Ic show all pools Op Cm /a
882Display information about all system pools in a format similar to
883.Xr vmstat 8 .
884.Pp
885.Bl -tag -width foo -compact
886.It Cm /a
887Displays
888.Dq interesting
889address information.
890.El
891.\" --------------------
892.It Ic show all locks
893Prints the list of locks held by all threads in the system.
894The
895.Cm option WITNESS
896is required for this command to be available.
897.\" --------------------
898.It Ic show all mounts Op Cm /f
899Display information on all mounted filesystems.
900.Pp
901.Bl -tag -width foo -compact
902.It Cm /f
903For each filesystem, list all its struct vnode addresses.
904These addresses can be used in the
905.Ic show vnode
906command.
907.El
908.\" --------------------
909.It Ic show all nfsnodes Op Cm /f
910Display information about all nfsnodes in the system.
911.Pp
912.Bl -tag -width foo -compact
913.It Cm /f
914For each nfsnode, print a more detailed output.
915See the
916.Ic show nfsnode
917command for more information.
918.El
919.\" --------------------
920.It Ic show all nfsreqs Op Cm /f
921Display information for all outstanding NFS requests.
922.Pp
923.Bl -tag -width foo -compact
924.It Cm /f
925For each NFS requests, print a more detailed output.
926See the
927.Ic show nfsreq
928command for more information.
929.El
930.\" --------------------
931.It Ic show all vnodes Op Cm /f
932Display information about all vnodes in the system.
933.Pp
934.Bl -tag -width foo -compact
935.It Cm /f
936For each vnode, print a more detailed output.
937See the
938.Ic show vnode
939command for more information.
940.El
941.El
942.\" --------------------
943.It Ic callout
944A synonym for the
945.Ic show all callout
946command.
947.\" --------------------
948.It Ic ps Op Cm /anow
949A synonym for
950.Ic show all procs .
951.\" --------------------
952.It Xo
953.Ic mac Ns Op Ic hine
954.Ar subcommand Op Ar args ...
955.Xc
956Perform a platform-specific command.
957.Pp
958The following commands are supported by multiprocessor kernels on
959these platforms: amd64, i386, macppc, mips64, and sparc64.
960.Pp
961.Bl -tag -width "searchframe [addr]" -compact
962.It Ic cpuinfo
963Display the state of each CPU.
964.It Ic ddbcpu Ar N
965Stop the current CPU and start handling
966.Nm
967on the selected CPU.
968.It Ic startcpu Op Ar N
969Resume normal processing on the selected CPU,
970or all CPUs if none is specified.
971.It Ic stopcpu Op Ar N
972Stop normal processing on the selected CPU,
973or all CPUs (except the one handling
974.Nm )
975if none is specified.
976.El
977.Pp
978Other platform-specific commands:
979.\" .Pp
980.\" amd64:
981.Pp
982arm:
983.Bl -tag -width "searchframe [addr]" -compact
984.It Ic frame Ar addr
985Display the trapframe at
986.Ar addr .
987.El
988.Pp
989i386:
990.Bl -tag -width "searchframe [addr]" -compact
991.\" .It Ic acpi disasm Ar ??
992.\" .It Ic acpi showval Ar ??
993.\" .It Ic acpi tree Ar ??
994.\" .It Ic acpi trace Ar ??
995.\" Evil ACPI debugging magic.
996.It Ic sysregs
997Display the contents of the privileged registers:
998.Va IDTR ,
999.Va GDTR ,
1000.Va LDTR ,
1001.Va TR ,
1002.Va CR0 ,
1003.Va CR2 ,
1004.Va CR3 ,
1005and
1006.Va CR4 .
1007.\" (i386-only)
1008.El
1009.Pp
1010m88k:
1011.Bl -tag -width "searchframe [addr]" -compact
1012.It Ic ddbcpu Ar N
1013Stop the current CPU and start handling
1014.Nm
1015on the selected CPU.
1016.It Ic frame Ar addr
1017Display the trapframe at
1018.Ar addr .
1019.It Ic regs
1020Display the registers from when
1021.Nm
1022was entered.
1023.It Ic searchframe Op Ar addr
1024Search for and display stack exception frames,
1025starting from
1026.Ar addr
1027if given, else the address in register
1028.Va r31 ,
1029and stopping at the next 8k boundary.
1030.It Ic where
1031Display where the current CPU was stopped.
1032.El
1033.Pp
1034mips64:
1035.Bl -tag -width "searchframe [addr]" -compact
1036.It Xo
1037.Ic tlb Op Cm /p Ar asid
1038.Op Cm /c
1039.Op Ar tlb
1040.Xc
1041.It Ic trap Ar ??
1042.El
1043.Pp
1044sh:
1045.Bl -tag -width "searchframe [addr]" -compact
1046.It Ic cache Op Ar addr
1047Display the cache, starting from
1048.Ar addr ,
1049defaulting to 0.
1050.It Ic frame
1051Display the switch and trap frames.
1052.\" .It Ic stack
1053.It Ic tlb
1054Display the TLB.
1055.El
1056.Pp
1057sparc64:
1058.Bl -tag -width "searchframe [addr]" -compact
1059.It Ic ctx
1060Display the context addresses for all threads.
1061.\" .It Ic dtlb Ar 0,2
1062.\" .It Ic dtsb
1063.\" .It Ic esp
1064.\" .It Ic fpstate Op Ar addr
1065.\" .It Ic itlb Ar 0,1,2
1066.\" .It Ic kmap Op Ar addr
1067.\" .It Ic pcb Op Ar addr
1068.\" .It Ic pctx Ar pid
1069.\" .It Ic page Ar addr
1070.\" .It Ic phys Op Ar addr
1071.\" .It Ic pmap Op Ar addr
1072.\" .It Ic proc Op Ar addr
1073.\" .It Ic prom Ar ??
1074.\" .It Ic pv Ar addr
1075.\" .It Ic stack Op Ar addr
1076.\" .It Ic tf Op Ar addr
1077.\" .It Ic ts
1078.\" .It Ic traptrace Op Ar addr
1079.\" .It Ic watch Op Ar addr
1080.\" .It Ic window Op Ar winnum
1081.\" .It Ic xir Op Ar addr
1082.El
1083.\" --------------------
1084.El
1085.Sh VARIABLES
1086.Nm
1087denotes registers and variables by
1088.Ic $ Ns Va name .
1089Register names can be found with the
1090.Ic show registers
1091command.
1092.Pp
1093Some variable names are suffixed with numbers, and some may have a modifier
1094following a colon immediately after the variable name.
1095For example, register variables can have the
1096.Ql :u
1097modifier to indicate a
1098user register (e.g.,
1099.Ql $eax:u ) .
1100.Pp
1101Built-in debugger variables currently supported are:
1102.Bl -tag -width 10n -compact -offset indent
1103.It Va $radix
1104Input and output radix.
1105.It Va $maxoff
1106Addresses are printed as
1107.Ar symbol Ns Li + Ns Ar offset
1108unless
1109.Ar offset
1110is greater than
1111.Va $maxoff .
1112.It Va $maxwidth
1113The width of the displayed lines.
1114.It Va $lines
1115The number of lines to page.
1116This is used by the
1117.Dq more
1118feature.
1119.It Va $tabstops
1120Tab stop width.
1121.It Va $log
1122Controls whether the output of
1123.Nm
1124will also appear in the system message
1125buffer.
1126.El
1127.Pp
1128These variables can also be controlled outside
1129.Nm
1130via the
1131.Sq ddb
1132.Xr sysctl 8
1133hierarchy.
1134.Sh EXPRESSIONS
1135Almost all expression operators in C are supported except for
1136.Ql ~ ,
1137.Ql ^ ,
1138and unary
1139.Ql & .
1140Special rules for expressions in
1141.Nm
1142are:
1143.Bl -tag -width 15n -compact -offset indent
1144.It Ar identifier
1145The name of a symbol.
1146It is translated to the address (or value) of the symbol.
1147.Ql \&.
1148and
1149.Ql \&:
1150can be used in the identifier.
1151The following can be accepted as an identifier,
1152if supported by an object format dependent routine:
1153.Bl -item -offset indent -compact
1154.It
1155.Sm off
1156.Oo Ar filename Li \&: Oc Ar func
1157.Op \&: Ar linenumber
1158.It
1159.Op Ar filename \&:
1160.Ar variable
1161.It
1162.Ar filename
1163.Op \&: Ar linenumber
1164.Sm on
1165.El
1166The symbol may be prefixed with
1167.Sq Ar symboltablename Ns ::
1168(e.g.,
1169.Ql emulator::mach_msg_trap )
1170to specify other than kernel symbols.
1171.It Ar number
1172The radix is determined by the first two letters:
1173.Ql 0x :
1174hex,
1175.Ql 0o :
1176octal,
1177.Ql 0t :
1178decimal, otherwise, the value of
1179.Va $radix
1180is used.
1181.It Li \&.
1182.Va dot :
1183the current address.
1184.It Li +
1185.Va next :
1186the next address.
1187.It Li ..
1188The address of the start of the last line examined.
1189Unlike
1190.Va dot
1191or
1192.Va next ,
1193this is only changed by the
1194.Ic examine
1195or
1196.Ic write
1197command.
1198.It Li '
1199The last address explicitly specified.
1200.It Li $ Ns Ar variable
1201The value of a register or variable.
1202The name may be followed by a
1203.Ql \&:
1204and modifiers as described above with
1205.Ar identifier .
1206.It Ar expr Li # Ar expr
1207A binary operator which rounds up the left hand side to the next
1208multiple of right hand side.
1209.It Li * Ns Ar expr
1210Indirection.
1211It may be followed by a ':' and modifiers as described above.
1212.El
1213.Sh SEE ALSO
1214.Xr ctfstrip 1 ,
1215.Xr gdb 1 ,
1216.Xr nm 1 ,
1217.Xr witness 4 ,
1218.Xr sysctl.conf 5 ,
1219.Xr hangman 6 ,
1220.Xr crash 8 ,
1221.Xr sysctl 8 ,
1222.Xr extent 9 ,
1223.Xr pool 9 ,
1224.Xr uvm 9
1225.Sh HISTORY
1226This kernel facility first appeared in the MACH 2 operating system
1227developed by CMU.
1228Hangman (which stands for "hangs maniacal analyzer") first appeared in
1229.Ox 1.2 .
1230