xref: /netbsd-src/share/man/man4/ddb.4 (revision de1dfb1250df962f1ff3a011772cf58e605aed11)
1.\"	$NetBSD: ddb.4,v 1.78 2004/03/02 20:57:45 jdc Exp $
2.\"
3.\" Copyright (c) 1997 - 2003 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Luke Mewburn
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.\" ---
38.\"	This manual page was derived from a -man.old document which bore
39.\"	the following copyright message:
40.\" ---
41.\"
42.\" Mach Operating System
43.\" Copyright (c) 1991,1990 Carnegie Mellon University
44.\" All Rights Reserved.
45.\"
46.\" Permission to use, copy, modify and distribute this software and its
47.\" documentation is hereby granted, provided that both the copyright
48.\" notice and this permission notice appear in all copies of the
49.\" software, derivative works or modified versions, and any portions
50.\" thereof, and that both notices appear in supporting documentation.
51.\"
52.\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
53.\" CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
54.\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
55.\"
56.\" Carnegie Mellon requests users of this software to return to
57.\"
58.\"  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
59.\"  School of Computer Science
60.\"  Carnegie Mellon University
61.\"  Pittsburgh PA 15213-3890
62.\"
63.\" any improvements or extensions that they make and grant Carnegie Mellon
64.\" the rights to redistribute these changes.
65.\"
66.Dd March 2, 2004
67.Dt DDB 4
68.Os
69.Sh NAME
70.Nm ddb
71.Nd in-kernel debugger
72.Sh SYNOPSIS
73.Cd options DDB
74.Pp
75To enable history editing:
76.Cd options DDB_HISTORY_SIZE=integer
77.Pp
78To disable entering
79.\" XXX: hack; .Nm automatically introduces newline in SYNOPSIS
80.Ic ddb
81upon kernel panic:
82.Cd options DDB_ONPANIC=0
83.Sh DESCRIPTION
84.Nm
85is the in-kernel debugger.
86It may be entered at any time via a special key sequence, and
87optionally may be invoked when the kernel panics.
88.Sh ENTERING THE DEBUGGER
89Unless
90.Dv DDB_ONPANIC
91is set to 0,
92.Nm
93will be activated whenever the kernel would otherwise panic.
94.Pp
95.Nm
96may also be activated from the console.
97In general, sending a break on a serial console will activate
98.Nm .
99There are also key sequences for each port that will activate
100.Nm
101from the keyboard:
102.Bl -tag -offset indent -width "mvme68k" -compact
103.It alpha
104\*[Lt]Ctrl\*[Gt]-\*[Lt]Alt\*[Gt]-\*[Lt]Esc\*[Gt] on PC style keyboards.
105.It amiga
106\*[Lt]LAlt\*[Gt]-\*[Lt]LAmiga\*[Gt]-\*[Lt]F10\*[Gt]
107.It atari
108\*[Lt]Alt\*[Gt]-\*[Lt]LeftShift\*[Gt]-\*[Lt]F9\*[Gt]
109.It hp300
110\*[Lt]Shift\*[Gt]-\*[Lt]Reset\*[Gt]
111.It hpcarm
112\*[Lt]Ctrl\*[Gt]-\*[Lt]Alt\*[Gt]-\*[Lt]Esc\*[Gt]
113.It hpcmips
114\*[Lt]Ctrl\*[Gt]-\*[Lt]Alt\*[Gt]-\*[Lt]Esc\*[Gt]
115.It hpcsh
116\*[Lt]Ctrl\*[Gt]-\*[Lt]Alt\*[Gt]-\*[Lt]Esc\*[Gt]
117.It i386
118\*[Lt]Ctrl\*[Gt]-\*[Lt]Alt\*[Gt]-\*[Lt]Esc\*[Gt]
119.br
120\*[Lt]Break\*[Gt] on serial console.
121.It mac68k
122\*[Lt]Command\*[Gt]-\*[Lt]Power\*[Gt], or the Interrupt switch.
123.It macppc
124Some models:
125\*[Lt]Command\*[Gt]-\*[Lt]Option\*[Gt]-\*[Lt]Power\*[Gt]
126.It mvme68k
127Abort switch on CPU card.
128.It pmax
129\*[Lt]Do\*[Gt] on
130.Tn LK-201
131rcons console.
132.br
133\*[Lt]Break\*[Gt] on serial console.
134.It sparc
135\*[Lt]L1\*[Gt]-A, or \*[Lt]Stop\*[Gt]-A on a
136.Tn Sun
137keyboard.
138.br
139\*[Lt]Break\*[Gt] on serial console.
140.It sparc64
141\*[Lt]L1\*[Gt]-A, or \*[Lt]Stop\*[Gt]-A on a
142.Tn Sun
143keyboard.
144.br
145\*[Lt]Break\*[Gt] on serial console.
146.It sun3
147\*[Lt]L1\*[Gt]-A, or \*[Lt]Stop\*[Gt]-A on a
148.Tn Sun
149keyboard.
150.br
151\*[Lt]Break\*[Gt] on serial console.
152.It vax
153\*[Lt]Esc\*[Gt]-\*[Lt]Shift\*[Gt]-D on serial console.
154.It x68k
155Interrupt switch on the body.
156.El
157.Pp
158The key sequence to activate
159.Nm
160can be changed by modifying
161.Dq hw.cnmagic
162with
163.Xr sysctl 8 .
164If the console is not dedicated to
165.Nm
166the sequence should not be easily typed by accident.
167In addition,
168.Nm
169may be explicitly activated by the debugging code in the kernel
170if
171.Cm DDB
172is configured.
173.Sh COMMAND SYNTAX
174The general command syntax is:
175.Bd -ragged -offset indent
176.Ic command Ns Op Cm / Ns Ar modifier
177.Ar address
178.Op Cm , Ns Ar count
179.Ed
180.Pp
181The current memory location being edited is referred to as
182.Ar dot ,
183and the next location is
184.Ar next .
185They are displayed as hexadecimal numbers.
186.Pp
187Commands that examine and/or modify memory update
188.Ar dot
189to the address of the last line examined or the last location
190modified, and set
191.Ar next
192to the next location to be examined or modified.
193Other commands don't change
194.Ar dot ,
195and set
196.Ar next
197to be the same as
198.Ar dot .
199.Pp
200A blank line repeats the previous command from the address
201.Ar next
202with the previous
203.Cm count
204and no modifiers.
205Specifying
206.Cm address
207sets
208.Em dot
209to the address.
210If
211.Cm address
212is omitted,
213.Em dot
214is used.
215A missing
216.Cm count
217is taken to be 1 for printing commands, and infinity for stack traces.
218.Pp
219The syntax:
220.Bd -ragged -offset indent
221.Cm , Ns Ar count
222.Ed
223.Pp
224repeats the previous command, just as a blank line does, but with
225the specified
226.Cm count .
227.Pp
228.Nm
229has a
230.Xr more 1 Ns -like
231functionality; if a number of lines in a command's output exceeds the number
232defined in the
233.Va lines
234variable, then
235.Nm
236displays
237.Dq "--db more--"
238and waits for a response, which may be one of:
239.Bl -tag -offset indent -width "\*[Lt]return\*[Gt]"
240.It \*[Lt]return\*[Gt]
241one more line.
242.It \*[Lt]space\*[Gt]
243one more page.
244.It Ic q
245abort the current command, and return to the command input mode.
246.El
247.Pp
248If
249.Nm
250history editing is enabled (by defining the
251.D1 Cd options DDB_HISTORY_SIZE=num
252kernel option), then a history of the last
253.Cm num
254commands is kept.
255The history can be manipulated with the following key sequences:
256.Bl -tag -offset indent -width "\*[Lt]Ctrl\*[Gt]-P"
257.It \*[Lt]Ctrl\*[Gt]-P
258retrieve previous command in history (if any).
259.It \*[Lt]Ctrl\*[Gt]-N
260retrieve next command in history (if any).
261.El
262.Sh COMMANDS
263.Nm
264supports the following commands:
265.Bl -tag -width 5n
266.It Xo
267.Sm off
268.Ic \&!
269.Ar address
270.Oo
271.Cm ( Ar expression
272.Op Ar ,...
273.Cm )
274.Oc
275.Sm on
276.Xc
277A synonym for
278.Ic call .
279.It Xo
280.Ic break Ns Op Cm /u
281.Ar address Ns Op Cm , Ns Ar count
282.Xc
283Set a breakpoint at
284.Ar address .
285If
286.Ar count
287is supplied, continues
288.Pq Ar count Ns -1
289times before stopping at the breakpoint.
290If the breakpoint is set, a breakpoint number is printed with
291.Sq \&# .
292This number can be used to
293.Ic delete
294the breakpoint, or to add
295conditions to it.
296.Pp
297If
298.Cm /u
299is specified,
300set a breakpoint at a user-space address.
301Without
302.Cm /u ,
303.Ar address
304is considered to be in the kernel-space, and an address in the wrong
305space will be rejected, and an error message will be emitted.
306This modifier may only be used if it is supported by machine dependent
307routines.
308.Pp
309Warning: if a user text is shadowed by a normal user-space debugger,
310user-space breakpoints may not work correctly.
311Setting a breakpoint at the low-level code paths may also cause
312strange behavior.
313.It Xo
314.Ic bt Ns Op Cm /u
315.Sm off
316.Op Ar frame-address
317.Op Cm , Ar count
318.Sm on
319.Xc
320A synonym for
321.Ic trace .
322.It Xo
323.Ic bt/t
324.Sm off
325.Op Ar pid
326.Op Cm , Ar count
327.Sm on
328.Xc
329A synonym for
330.Ic trace .
331.It Xo
332.Ic call
333.Sm off
334.Ar address
335.Oo
336.Cm ( Ar expression
337.Op Ar ,...
338.Cm )
339.Oc
340.Sm on
341.Xc
342Call the function specified by
343.Ar address
344with the argument(s) listed in parentheses.
345Parentheses may be omitted if the function takes no arguments.
346The number of arguments is currently limited to 10.
347.It Ic continue Ns Op Cm /c
348Continue execution until a breakpoint or watchpoint.
349If
350.Cm /c
351is specified, count instructions while executing.
352Some machines (e.g., pmax) also count loads and stores.
353.Pp
354Warning: when counting, the debugger is really silently
355single-stepping.
356This means that single-stepping on low-level may cause strange
357behavior.
358.It Xo
359.Ic delete
360.Ar "address" |
361.Cm # Ns Ar number
362.Xc
363Delete a breakpoint.
364The target breakpoint may be specified by
365.Ar address ,
366as per
367.Ic break ,
368or by the breakpoint number returned by
369.Ic break
370if it's prefixed with
371.Sq Cm \&# .
372.It Xo
373.Ic dmesg Op Ar count
374.Xc
375Prints the contents of the kernel message buffer.
376The optional
377.Ar count
378argument will limit printing to at most the last
379.Ar count
380bytes of the message buffer.
381.It Xo
382.Ic dwatch
383.Ar address
384.Xc
385Delete the watchpoint at
386.Ar address
387that was previously set with
388.Ic watch
389command.
390.It Xo
391.Ic examine Ns Op Cm / Ns Ar modifier
392.Ar address Ns Op Cm , Ns Ar count
393.Xc
394Display the address locations according to the format in
395.Ar modifier .
396Multiple modifier formats display multiple locations.
397If
398.Ar modifier
399isn't specified, the modifier from the last use of
400.Ic examine
401is used.
402.Pp
403The valid format characters for
404.Ar modifier
405are:
406.Bl -tag -offset indent -width 2n -compact
407.It Cm b
408examine bytes (8 bits).
409.It Cm h
410examine half-words (16 bits).
411.It Cm l
412examine words (legacy
413.Dq long ,
41432 bits).
415.It Cm L
416examine long words (implementation dependent)
417.It Cm a
418print the location being examined.
419.It Cm A
420print the location with a line number if possible.
421.It Cm x
422display in unsigned hex.
423.It Cm z
424display in signed hex.
425.It Cm o
426display in unsigned octal.
427.It Cm d
428display in signed decimal.
429.It Cm u
430display in unsigned decimal.
431.It Cm r
432display in current radix, signed.
433.It Cm c
434display low 8 bits as a character.
435Non-printing characters as displayed as an octal escape code
436(e.g.,
437.Sq \e000 ) .
438.It Cm s
439display the NUL terminated string at the location.
440Non-printing characters are displayed as octal escapes.
441.It Cm m
442display in unsigned hex with a character dump at the end of each line.
443The location is displayed as hex at the beginning of each line.
444.It Cm i
445display as a machine instruction.
446.It Cm I
447display as a machine instruction, with possible alternative formats
448depending upon the machine:
449.Bl -tag -offset indent -width "sparc" -compact
450.It alpha
451print register operands
452.It m68k
453use Motorola syntax
454.It pc532
455print instruction bytes in hex
456.It vax
457don't assume that each external label is a procedure entry mask
458.El
459.El
460.It Xo
461.Ic kill
462.Ar pid Ns Op Cm , Ns Ar signal_number
463.Xc
464Send a signal to the process specified by the
465.Ar pid .
466Note that
467.Ar pid
468is interpreted using the current radix (see
469.Cm trace/t
470command for details).
471If
472.Ar signal_number
473isn't specified, the SIGTERM signal is sent.
474.It Ic match Ns Op Cm /p
475A synonym for
476.Ic next .
477.It Ic next Ns Op Cm /p
478Stop at the matching return instruction.
479If
480.Cm /p
481is specified, print the call nesting depth and the
482cumulative instruction count at each call or return.
483Otherwise, only print when the matching return is hit.
484.It Xo
485.Ic print Ns Op Cm /axzodurc
486.Ar address Op Ar address ...
487.Xc
488Print addresses
489.Ar address
490according to the modifier character, as per
491.Ic examine .
492Valid modifiers are:
493.Cm /a ,
494.Cm /x ,
495.Cm /z ,
496.Cm /o ,
497.Cm /d ,
498.Cm /u ,
499.Cm /r ,
500and
501.Cm /c
502(as per
503.Ic examine ) .
504If no modifier is specified, the most recent one specified is used.
505.Ar address
506may be a string, and is printed
507.Dq as-is .
508For example:
509.Bd -literal -offset indent
510print/x "eax = " $eax "\enecx = " $ecx "\en"
511.Ed
512.Pp
513will produce:
514.Bd -literal -offset indent
515eax = xxxxxx
516ecx = yyyyyy
517.Ed
518.It Xo
519.Sm off
520.Ic ps
521.Op Cm /a
522.Op Cm /n
523.Op Cm /w
524.Sm on
525.Xc
526A synonym for
527.Ic "show all procs" .
528.It Ic reboot Op Ar flags
529Reboot, using the optionally supplied boot
530.Ar flags ,
531which is a bitmask supporting the following values:
532.Bl -column "Value" "RB_AUTOBOOT" "Description"
533.It Sy "Value" Ta Sy "Name" Ta Sy "Description"
534.It 0x1 Ta RB_ASKNAME Ta Ask for file name to reboot from
535.It 0x2 Ta RB_SINGLE Ta Reboot to single user mode
536.It 0x4 Ta RB_NOSYNC Ta Don't sync before reboot
537.It 0x8 Ta RB_HALT Ta Halt instead of reboot
538.It 0x40 Ta RB_KDB Ta Boot into kernel debugger
539.It 0x808 Ta RB_POWERDOWN Ta Power off (or at least halt)
540.El
541.Pp
542Note: Limitations of the command line interface preclude
543specification of a boot string.
544.It Xo
545.Ic search Ns Op Cm /bhl
546.Ar address
547.Ar value
548.Op Ar mask
549.Op Cm , Ns Ar count
550.Xc
551Search memory from
552.Ar address
553for
554.Ar value .
555The unit size is specified with a modifier character, as per
556.Ic examine .
557Valid modifiers are:
558.Cm /b ,
559.Cm /h ,
560and
561.Cm /l .
562If no modifier is specified,
563.Cm /l
564is used.
565.Pp
566This command might fail in interesting ways if it doesn't find
567.Ar value .
568This is because
569.Nm
570doesn't always recover from touching bad memory.
571The optional
572.Ar count
573limits the search.
574.It Xo
575.Ic set
576.Cm $ Ns Ar variable
577.Op Cm =
578.Ar expression
579.Xc
580Set the named variable or register to the value of
581.Ar expression .
582Valid variable names are described in
583.Sx VARIABLES .
584.It Xo
585.Sm off
586.Ic "show\ all\ procs"
587.Op Cm /a
588.Op Cm /n
589.Op Cm /w
590.Sm on
591.Xc
592Display all process information.
593Valid modifiers:
594.Bl -tag -width 3n
595.It Cm /n
596show process information in a
597.Xr ps 1
598style format (this is the default).
599Information printed includes: process ID, parent process ID,
600process group, UID, process status, process flags, process
601command name, and process wait channel message.
602.It Cm /a
603show the kernel virtual addresses of each process'
604proc structure, u-area, and vmspace structure.
605The vmspace address is also the address of the process'
606vm_map structure, and can be used in the
607.Ic "show map"
608command.
609.It Cm /w
610show each process' PID, command, system call emulation, wait channel
611address, and wait channel message.
612.El
613.It Ic "show breaks"
614Display all breakpoints.
615.It Xo
616.Ic "show buf" Ns Op Cm /f
617.Ar address
618.Xc
619Print the struct buf at
620.Ar address .
621The
622.Cm /f
623does nothing at this time.
624.It Xo
625.Ic "show event" Ns Op Cm /f
626.Xc
627Print all the non-zero
628.Xr evcnt 9
629event counters.
630If
631.Cm /f
632is specified, all event counters with a count of zero are printed as well.
633.It Xo
634.Ic "show map" Ns Op Cm /f
635.Ar address
636.Xc
637Print the vm_map at
638.Ar address .
639If
640.Cm /f
641is specified, the complete map is printed.
642.It Xo
643.Ic "show mount" Ns Op Cm /f
644.Ar address
645.Xc
646Print the mount structure at
647.Ar address .
648If
649.Cm /f
650is specified, the complete vnode list is printed.
651.It Ic "show ncache" Ar address
652Dump the namecache list associated with vnode at
653.Ar address .
654.It Xo
655.Ic "show object" Ns Op Cm /f
656.Ar address
657.Xc
658Print the vm_object at
659.Ar address .
660If
661.Cm /f
662is specified, the complete object is printed.
663.It Xo
664.Ic "show page" Ns Op Cm /f
665.Ar address
666.Xc
667Print the vm_page at
668.Ar address .
669If
670.Cm /f
671is specified, the complete page is printed.
672.It Xo
673.Ic "show pool" Ns Op Cm /clp
674.Ar address
675.Xc
676Print the pool at
677.Ar address .
678Valid modifiers:
679.Bl -tag -width 4n -compact
680.It Cm /c
681Print the cachelist and its statistics for this pool.
682.It Cm /l
683Print the log entries for this pool.
684.It Cm /p
685Print the pagelist for this pool.
686.El
687.It Ic "show registers" Ns Op Cm /u
688Display the register set.
689If
690.Cm /u
691is specified, display user registers instead of kernel registers
692or the currently save one.
693.Pp
694Warning: support for
695.Cm /u
696is machine dependent.
697If not supported, incorrect information will be displayed.
698.It Ic "show sched_qs"
699Print the state of the scheduler's run queues.
700For each run queue that has an LWP, the run queue index and the list
701of LWPs will be shown.
702If the run queue has LWPs, but the sched_whichqs bit is not set for that
703queue, the queue index will be prefixed with a
704.Sq \&! .
705.It Ic "show uvmexp"
706Print a selection of UVM counters and statistics.
707.It Xo
708.Ic "show vnode" Ns Op Cm /f
709.Ar address
710.Xc
711Print the vnode at
712.Ar address .
713If
714.Cm /f
715is specified, the complete vnode is printed.
716.It Ic "show watches"
717Display all watchpoints.
718.It Xo
719.Ic sifting Ns Op Cm /F
720.Ar string
721.Xc
722Search the symbol tables for all symbols of which
723.Ar string
724is a substring, and display them.
725If
726.Cm /F
727is specified, a character is displayed immediately after each symbol
728name indicating the type of symbol.
729.Pp
730For
731.Xr a.out 5 Ns -format
732symbol tables,
733absolute symbols display
734.Sy @ ,
735text segment symbols display
736.Sy * ,
737data segment symbols display
738.Sy + ,
739.Tn BSS
740segment symbols display
741.Sy - ,
742and filename symbols display
743.Sy / .
744For
745.Tn ELF Ns -format
746symbol tables,
747object symbols display
748.Sy + ,
749function symbols display
750.Sy * ,
751section symbols display
752.Sy \*[Am] ,
753and file symbols display
754.Sy / .
755.Pp
756To sift for a string beginning with a number, escape the first
757character with a backslash as:
758.Bd -literal -offset indent
759sifting \\386
760.Ed
761.It Xo
762.Ic step Ns Op Cm /p
763.Op Cm , Ns Ar count
764.Xc
765Single-step
766.Ar count
767times.
768If
769.Cm /p
770is specified, print each instruction at each step.
771Otherwise, only print the last instruction.
772.Pp
773Warning: depending on the machine type, it may not be possible
774to single-step through some low-level code paths or user-space
775code.
776On machines with software-emulated single-stepping (e.g., pmax),
777stepping through code executed by interrupt handlers will probably
778do the wrong thing.
779.It Ic sync
780Force a crash dump, and then reboot.
781.It Xo
782.Ic trace
783.Ns Op Cm /u Ns Op Cm l
784.Sm off
785.Op Ar frame-address
786.Op Cm , Ar count
787.Sm on
788.Xc
789Stack trace from
790.Ar frame-address .
791If
792.Cm /u
793is specified, trace user-space, otherwise trace kernel-space.
794.Ar count
795is the number of frames to be traced.
796If
797.Ar count
798is omitted, all frames are printed.
799If
800.Cm /l
801is specified, the trace is printed and also stored in the kernel
802message buffer.
803.Pp
804Warning: user-space stack trace is valid only if the machine dependent
805code supports it.
806.It Xo
807.Ic trace/t Ns Op Cm l
808.Sm off
809.Op Ar pid
810.Op Cm , Ar count
811.Sm on
812.Xc
813Stack trace by
814.Dq thread
815(process, on
816.Nx )
817rather than by stack frame address.
818Note that
819.Ar pid
820is interpreted using the current radix, whilst
821.Ic ps
822displays pids in decimal; prefix
823.Ar pid
824with
825.Sq 0t
826to force it to be interpreted as decimal (see
827.Sx VARIABLES
828section for radix).
829If
830.Cm /l
831is specified, the trace is printed and also stored in the kernel
832message buffer.
833.Pp
834Warning: trace by pid is valid only if the machine dependent code
835supports it.
836.It Ic until Ns Op Cm /p
837Stop at the next call or return instruction.
838If
839.Cm /p
840is specified, print the call nesting depth and the
841cumulative instruction count at each call or return.
842Otherwise, only print when the matching return is hit.
843.It Xo
844.Ic watch
845.Sm off
846.Ar address
847.Op Cm , Ar size
848.Sm on
849.Xc
850Set a watchpoint for a region.
851Execution stops when an attempt to modify the region occurs.
852.Ar size
853defaults to 4.
854.Pp
855If you specify a wrong space address, the request is
856rejected with an error message.
857.Pp
858Warning: attempts to watch wired kernel memory may cause
859an unrecoverable error in some systems such as i386.
860Watchpoints on user addresses work the best.
861.It Xo
862.Ic write Ns Op Cm /bhl
863.Ar address
864.Ar expression Op Ar expression ...
865.Xc
866Write the
867.Ar expression Ns s
868at succeeding locations.
869The unit size is specified with a modifier character, as per
870.Ic examine .
871Valid modifiers are:
872.Cm /b ,
873.Cm /h ,
874and
875.Cm /l .
876If no modifier is specified,
877.Cm /l
878is used.
879.Pp
880Warning: since there is no delimiter between
881.Ar expression Ns s ,
882strange things may occur.
883It's best to enclose each
884.Ar expression
885in parentheses.
886.It Xo
887.Ic x Ns Op Cm / Ns Ar modifier
888.Ar address Ns Op Cm , Ns Ar count
889.Xc
890A synonym for
891.Ic examine .
892.\" XXX - these commands aren't implemented; jhawk 19 May 2000
893.\" .It Ic xf
894.\" Examine forward.
895.\" .Ic xf
896.\" re-executes the most recent
897.\" .Ic execute
898.\" command with the same parameters except that
899.\" .Ar address
900.\" is set to
901.\" .Ar next .
902.\" .It Ic xb
903.\" Examine backward.
904.\" .Ic xb
905.\" re-executes the most recent
906.\" .Ic execute
907.\" command with the same parameters, except that
908.\" .Ar address
909.\" is set to the last start address minus its size.
910.El
911.Sh MACHINE-SPECIFIC COMMANDS
912The "glue" code that hooks
913.Nm
914into the
915.Nx
916kernel for any given port can also add machine specific commands
917to the
918.Nm
919command parser.
920All of these commands are preceded by the command word
921.Em machine
922to indicate that they are part of the machine-specific command
923set (e.g.
924.Ic "machine reboot" ) .
925Some of these commands are:
926.Ss ALPHA
927.Bl -tag -width "intrchain" -compact
928.It Ic halt
929Call the PROM monitor to halt the CPU.
930.It Ic reboot
931Call the PROM monitor to reboot the CPU.
932.El
933.Ss ARM32
934.Bl -tag -width "intrchain" -compact
935.It Ic vmstat
936Equivalent to
937.Xr vmstat 1
938output with "-s" option (statistics).
939.It Ic vnode
940Print out a description of a vnode.
941.It Ic intrchain
942Print the list of IRQ handlers.
943.It Ic panic
944Print the current "panic" string.
945.It Ic frame
946Given a trap frame address, print out the trap frame.
947.El
948.Ss MIPS
949.Bl -tag -width "intrchain" -compact
950.It Ic kvtop
951Print the physical address for a given kernel virtual address.
952.It Ic tlb
953Print out the Translation Lookaside Buffer (TLB).
954Only works in
955.Nx
956kernels compiled with
957.Dv DEBUG
958option.
959.El
960.Ss SH3
961.Bl -tag -width "intrchain" -compact
962.It Ic tlb
963Print TLB entries
964.It Ic cache
965Print cache entries
966.It Ic frame
967Print switch frame and trap frames.
968.It Ic stack
969Print kernel stack usage.
970Only works in
971.Nx
972kernels compiled with the
973.Dv KSTACK_DEBUG
974option.
975.El
976.Ss SPARC
977.Bl -tag -width "intrchain" -compact
978.It Ic prom
979Exit to the Sun PROM monitor.
980.El
981.Ss SPARC64
982.Bl -tag -width "intrchain" -compact
983.It Ic buf
984Print buffer information.
985.It Ic ctx
986Print process context information.
987.It Ic dtlb
988Print data translation look-aside buffer context information.
989.It Ic dtsb
990Display data translation storage buffer information.
991.It Ic kmap
992Display information about the listed mapping in the kernel pmap.
993Use the
994.Dq f
995modifier to get a full listing.
996.It Ic pcb
997Display information about the
998.Dq struct pcb
999listed.
1000.It Ic pctx
1001Attempt to change process context.
1002.It Ic page
1003Display the pointer to the
1004.Dq struct vm_page
1005for this physical address.
1006.It Ic phys
1007Display physical memory.
1008.It Ic pmap
1009Display the pmap.
1010Use the
1011.Dq f
1012modifier to get a fuller listing.
1013.It Ic proc
1014Display some information about the process pointed to, or curproc.
1015.It Ic prom
1016Enter the OFW PROM.
1017.It Ic pv
1018Display the
1019.Dq struct pv_entry
1020pointed to.
1021.It Ic stack
1022Dump the window stack.
1023Use the
1024.Dq u
1025modifier to get userland information.
1026.It Ic tf
1027Display full trap frame state.
1028This is most useful for inclusion with bug reports.
1029.It Ic ts
1030Display trap state.
1031.It Ic traptrace
1032Display or set trap trace information.
1033Use the
1034.Dq r
1035and
1036.Dq f
1037modifiers to get reversed and full information, respectively.
1038.It Ic uvmdump
1039Dumps the UVM histories.
1040.It Ic watch
1041Set or clear a physical or virtual hardware watchpoint.
1042Pass the address to be watched, or
1043.Dq 0
1044to clear the watchpoint.
1045Append
1046.Dq p
1047to the watch point to use the physical watchpoint registers.
1048.It Ic window
1049Print register window information about given address.
1050.El
1051.Ss SUN3 and SUN3X
1052.Bl -tag -width "intrchain" -compact
1053.It Ic abort
1054Drop into monitor via abort (allows continue).
1055.It Ic halt
1056Exit to Sun PROM monitor as in
1057.Xr halt 8 .
1058.It Ic reboot
1059Reboot the machine as in
1060.Xr reboot 8 .
1061.It Ic pgmap
1062Given an address, print the address, segment map, page map, and
1063Page Table Entry (PTE).
1064.El
1065.Sh VARIABLES
1066.Nm
1067accesses registers and variables as
1068.Cm $ Ns Ar name .
1069Register names are as per the
1070.Ic "show registers"
1071command.
1072Some variables are suffixed with numbers, and may have a modifier
1073following a colon immediately after the variable name.
1074For example, register variables may have a
1075.Sq u
1076modifier to indicate user register
1077(e.g.,
1078.Li "$eax:u" ) .
1079.Pp
1080Built-in variables currently supported are:
1081.Bl -tag -offset indent -width "maxwidth" -compact
1082.It Va lines
1083The number of lines.
1084This is used by the
1085.Ic more
1086feature.
1087.It Va maxoff
1088Addresses are printed as
1089.Li 'symbol'+offset
1090unless
1091.Li offset
1092is greater than
1093.Va maxoff .
1094.It Va maxwidth
1095The width of the displayed line.
1096.It Va onpanic
1097If non-zero (the default),
1098.Nm
1099will be invoked when the kernel panics.
1100If the kernel configuration option
1101.D1 Cd options DDB_ONPANIC=0
1102is used,
1103.Va onpanic
1104will be initialized to off.
1105.It Va fromconsole
1106If non-zero (the default),
1107the kernel allows to enter
1108.Nm
1109from the console (by break signal or special key sequence).
1110If the kernel configuration option
1111.D1 Cd options DDB_FROMCONSOLE=0
1112is used,
1113.Va fromconsole
1114will be initialized to off.
1115.It Va radix
1116Input and output radix.
1117.It Va tabstops
1118Tab stop width.
1119.\" .It Va work Ns Sy xx
1120.\" Temporary work variable.
1121.\" .Sq Sy xx
1122.\" is between 0 and 31.
1123.El
1124.Pp
1125All built-in variables are accessible via
1126.Xr sysctl 3 .
1127.Sh EXPRESSIONS
1128Almost all expression operators in C are supported, except
1129.Sq \&~ ,
1130.Sq \&^ ,
1131and unary
1132.Sq \&\*[Am] .
1133Special rules in
1134.Nm
1135are:
1136.Bl -tag -offset indent -width "identifier"
1137.It Ar identifier
1138name of a symbol.
1139It is translated to the address (or value) of it.
1140.Sq \&.
1141and
1142.Sq \&:
1143can be used in the identifier.
1144If supported by an object format dependent routine,
1145.Sm off
1146.Xo
1147.Oo Ar filename : Oc
1148.Ar function
1149.Oo : Ar "line number" Oc ,
1150.Xc
1151.Xo
1152.Oo Ar filename : Oc
1153.Ar variable ,
1154.Xc
1155and
1156.Xo
1157.Ar filename
1158.Oo : Ar "line number" Oc ,
1159.Xc
1160.Sm on
1161can be accepted as a symbol.
1162The symbol may be prefixed with
1163.Ar symbol_table_name : :
1164(e.g.,
1165.Li emulator::mach_msg_trap )
1166to specify other than kernel symbols.
1167.It Ar number
1168number.
1169Radix is determined by the first two characters:
1170.Sq 0x
1171- hex,
1172.Sq 0o
1173- octal,
1174.Sq 0t
1175- decimal,
1176otherwise follow current radix.
1177.It Cm .
1178.Ar dot
1179.It Cm +
1180.Ar next
1181.It Cm ..
1182address of the start of the last line examined.
1183Unlike
1184.Ar dot
1185or
1186.Ar next ,
1187this is only changed by the
1188.Ic examine
1189or
1190.Ic write
1191commands.
1192.It Cm \&"
1193last address explicitly specified.
1194.It Cm $ Ns Ar name
1195register name or variable.
1196It is translated to the value of it.
1197It may be followed by a
1198.Sq \&:
1199and modifiers as described above.
1200.It Cm a
1201multiple of right-hand side.
1202.It Cm * Ns Ar expr
1203expression indirection.
1204It may be followed by a
1205.Sq \&:
1206and modifiers as described above.
1207.El
1208.Sh SEE ALSO
1209.Xr options 4 ,
1210.Xr sysctl 8 ,
1211.Xr cnmagic 9
1212.Sh HISTORY
1213The
1214.Nm
1215kernel debugger was written as part of the MACH project at
1216Carnegie-Mellon University.
1217