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