]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/ddb.4
Change header file references from <filename>.h to
[FreeBSD/FreeBSD.git] / share / man / man4 / ddb.4
1 .\"
2 .\" Mach Operating System
3 .\" Copyright (c) 1991,1990 Carnegie Mellon University
4 .\" Copyright (c) 2007 Robert N. M. Watson
5 .\" All Rights Reserved.
6 .\"
7 .\" Permission to use, copy, modify and distribute this software and its
8 .\" documentation is hereby granted, provided that both the copyright
9 .\" notice and this permission notice appear in all copies of the
10 .\" software, derivative works or modified versions, and any portions
11 .\" thereof, and that both notices appear in supporting documentation.
12 .\"
13 .\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 .\" CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
15 .\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 .\"
17 .\" Carnegie Mellon requests users of this software to return to
18 .\"
19 .\"  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
20 .\"  School of Computer Science
21 .\"  Carnegie Mellon University
22 .\"  Pittsburgh PA 15213-3890
23 .\"
24 .\" any improvements or extensions that they make and grant Carnegie Mellon
25 .\" the rights to redistribute these changes.
26 .\"
27 .\" changed a \# to #, since groff choked on it.
28 .\"
29 .\" HISTORY
30 .\" ddb.4,v
31 .\" Revision 1.1  1993/07/15  18:41:02  brezak
32 .\" Man page for DDB
33 .\"
34 .\" Revision 2.6  92/04/08  08:52:57  rpd
35 .\"     Changes from OSF.
36 .\"     [92/01/17  14:19:22  jsb]
37 .\"     Changes for OSF debugger modifications.
38 .\"     [91/12/12            tak]
39 .\"
40 .\" Revision 2.5  91/06/25  13:50:22  rpd
41 .\"     Added some watchpoint explanation.
42 .\"     [91/06/25            rpd]
43 .\"
44 .\" Revision 2.4  91/06/17  15:47:31  jsb
45 .\"     Added documentation for continue/c, match, search, and watchpoints.
46 .\"     I've not actually explained what a watchpoint is; maybe Rich can
47 .\"     do that (hint, hint).
48 .\"     [91/06/17  10:58:08  jsb]
49 .\"
50 .\" Revision 2.3  91/05/14  17:04:23  mrt
51 .\"     Correcting copyright
52 .\"
53 .\" Revision 2.2  91/02/14  14:10:06  mrt
54 .\"     Changed to new Mach copyright
55 .\"     [91/02/12  18:10:12  mrt]
56 .\"
57 .\" Revision 2.2  90/08/30  14:23:15  dbg
58 .\"     Created.
59 .\"     [90/08/30            dbg]
60 .\"
61 .\" $FreeBSD$
62 .\"
63 .Dd June 8, 2008
64 .Dt DDB 4
65 .Os
66 .Sh NAME
67 .Nm ddb
68 .Nd interactive kernel debugger
69 .Sh SYNOPSIS
70 In order to enable kernel debugging facilities include:
71 .Bd -ragged -offset indent
72 .Cd options KDB
73 .Cd options DDB
74 .Ed
75 .Pp
76 To prevent activation of the debugger on kernel
77 .Xr panic 9 :
78 .Bd -ragged -offset indent
79 .Cd options KDB_UNATTENDED
80 .Ed
81 .Pp
82 In order to print a stack trace of the current thread on the console
83 for a panic:
84 .Bd -ragged -offset indent
85 .Cd options KDB_TRACE
86 .Ed
87 .Pp
88 To print the numerical value of symbols in addition to the symbolic
89 representation, define:
90 .Bd -ragged -offset indent
91 .Cd options DDB_NUMSYM
92 .Ed
93 .Pp
94 To enable the
95 .Xr gdb 1
96 backend, so that remote debugging with
97 .Xr kgdb 1
98 is possible, include:
99 .Bd -ragged -offset indent
100 .Cd options GDB
101 .Ed
102 .Sh DESCRIPTION
103 The
104 .Nm
105 kernel debugger has most of the features of the old
106 .Nm kdb ,
107 but with a more rational syntax
108 inspired by
109 .Xr gdb 1 .
110 If linked into the running kernel,
111 it can be invoked locally with the
112 .Ql debug
113 .Xr keymap 5
114 action.
115 The debugger is also invoked on kernel
116 .Xr panic 9
117 if the
118 .Va debug.debugger_on_panic
119 .Xr sysctl 8
120 MIB variable is set non-zero,
121 which is the default
122 unless the
123 .Dv KDB_UNATTENDED
124 option is specified.
125 .Pp
126 The current location is called
127 .Va dot .
128 The
129 .Va dot
130 is displayed with
131 a hexadecimal format at a prompt.
132 The commands
133 .Ic examine
134 and
135 .Ic write
136 update
137 .Va dot
138 to the address of the last line
139 examined or the last location modified, and set
140 .Va next
141 to the address of
142 the next location to be examined or changed.
143 Other commands do not change
144 .Va dot ,
145 and set
146 .Va next
147 to be the same as
148 .Va dot .
149 .Pp
150 The general command syntax is:
151 .Ar command Ns Op Li / Ns Ar modifier
152 .Ar address Ns Op Li , Ns Ar count
153 .Pp
154 A blank line repeats the previous command from the address
155 .Va next
156 with
157 count 1 and no modifiers.
158 Specifying
159 .Ar address
160 sets
161 .Va dot
162 to the address.
163 Omitting
164 .Ar address
165 uses
166 .Va dot .
167 A missing
168 .Ar count
169 is taken
170 to be 1 for printing commands or infinity for stack traces.
171 .Pp
172 The
173 .Nm
174 debugger has a pager feature (like the
175 .Xr more 1
176 command)
177 for the output.
178 If an output line exceeds the number set in the
179 .Va lines
180 variable, it displays
181 .Dq Li --More--
182 and waits for a response.
183 The valid responses for it are:
184 .Pp
185 .Bl -tag -compact -width ".Li SPC"
186 .It Li SPC
187 one more page
188 .It Li RET
189 one more line
190 .It Li q
191 abort the current command, and return to the command input mode
192 .El
193 .Pp
194 Finally,
195 .Nm
196 provides a small (currently 10 items) command history, and offers
197 simple
198 .Nm emacs Ns -style
199 command line editing capabilities.
200 In addition to
201 the
202 .Nm emacs
203 control keys, the usual
204 .Tn ANSI
205 arrow keys might be used to
206 browse through the history buffer, and move the cursor within the
207 current line.
208 .Sh COMMANDS
209 .Bl -tag -width indent -compact
210 .It Ic examine
211 .It Ic x
212 Display the addressed locations according to the formats in the modifier.
213 Multiple modifier formats display multiple locations.
214 If no format is specified, the last format specified for this command
215 is used.
216 .Pp
217 The format characters are:
218 .Bl -tag -compact -width indent
219 .It Cm b
220 look at by bytes (8 bits)
221 .It Cm h
222 look at by half words (16 bits)
223 .It Cm l
224 look at by long words (32 bits)
225 .It Cm a
226 print the location being displayed
227 .It Cm A
228 print the location with a line number if possible
229 .It Cm x
230 display in unsigned hex
231 .It Cm z
232 display in signed hex
233 .It Cm o
234 display in unsigned octal
235 .It Cm d
236 display in signed decimal
237 .It Cm u
238 display in unsigned decimal
239 .It Cm r
240 display in current radix, signed
241 .It Cm c
242 display low 8 bits as a character.
243 Non-printing characters are displayed as an octal escape code (e.g.,
244 .Ql \e000 ) .
245 .It Cm s
246 display the null-terminated string at the location.
247 Non-printing characters are displayed as octal escapes.
248 .It Cm m
249 display in unsigned hex with character dump at the end of each line.
250 The location is also displayed in hex at the beginning of each line.
251 .It Cm i
252 display as an instruction
253 .It Cm I
254 display as an instruction with possible alternate formats depending on the
255 machine:
256 .Bl -tag -width ".Tn powerpc" -compact
257 .It Tn alpha
258 Show the registers of the instruction.
259 .It Tn amd64
260 No alternate format.
261 .It Tn i386
262 No alternate format.
263 .It Tn ia64
264 No alternate format.
265 .It Tn powerpc
266 No alternate format.
267 .It Tn sparc64
268 No alternate format.
269 .El
270 .It Cm S
271 display a symbol name for the pointer stored at the address
272 .El
273 .Pp
274 .It Ic xf
275 Examine forward:
276 execute an
277 .Ic examine
278 command with the last specified parameters to it
279 except that the next address displayed by it is used as the start address.
280 .Pp
281 .It Ic xb
282 Examine backward:
283 execute an
284 .Ic examine
285 command with the last specified parameters to it
286 except that the last start address subtracted by the size displayed by it
287 is used as the start address.
288 .Pp
289 .It Ic print Ns Op Li / Ns Cm acdoruxz
290 .It Ic p Ns Op Li / Ns Cm acdoruxz
291 Print
292 .Ar addr Ns s
293 according to the modifier character (as described above for
294 .Cm examine ) .
295 Valid formats are:
296 .Cm a , x , z , o , d , u , r ,
297 and
298 .Cm c .
299 If no modifier is specified, the last one specified to it is used.
300 The argument
301 .Ar addr
302 can be a string, in which case it is printed as it is.
303 For example:
304 .Bd -literal -offset indent
305 print/x "eax = " $eax "\enecx = " $ecx "\en"
306 .Ed
307 .Pp
308 will print like:
309 .Bd -literal -offset indent
310 eax = xxxxxx
311 ecx = yyyyyy
312 .Ed
313 .Pp
314 .It Xo
315 .Ic write Ns Op Li / Ns Cm bhl
316 .Ar addr expr1 Op Ar expr2 ...
317 .Xc
318 .It Xo
319 .Ic w Ns Op Li / Ns Cm bhl
320 .Ar addr expr1 Op Ar expr2 ...
321 .Xc
322 Write the expressions specified after
323 .Ar addr
324 on the command line at succeeding locations starting with
325 .Ar addr .
326 The write unit size can be specified in the modifier with a letter
327 .Cm b
328 (byte),
329 .Cm h
330 (half word) or
331 .Cm l
332 (long word) respectively.
333 If omitted,
334 long word is assumed.
335 .Pp
336 .Sy Warning :
337 since there is no delimiter between expressions, strange
338 things may happen.
339 It is best to enclose each expression in parentheses.
340 .Pp
341 .It Ic set Li $ Ns Ar variable Oo Li = Oc Ar expr
342 Set the named variable or register with the value of
343 .Ar expr .
344 Valid variable names are described below.
345 .Pp
346 .It Ic break Ns Op Li / Ns Cm u
347 .It Ic b Ns Op Li / Ns Cm u
348 Set a break point at
349 .Ar addr .
350 If
351 .Ar count
352 is supplied, continues
353 .Ar count
354 \- 1 times before stopping at the
355 break point.
356 If the break point is set, a break point number is
357 printed with
358 .Ql # .
359 This number can be used in deleting the break point
360 or adding conditions to it.
361 .Pp
362 If the
363 .Cm u
364 modifier is specified, this command sets a break point in user
365 address space.
366 Without the
367 .Cm u
368 option, the address is considered to be in the kernel
369 space, and a wrong space address is rejected with an error message.
370 This modifier can be used only if it is supported by machine dependent
371 routines.
372 .Pp
373 .Sy Warning :
374 If a user text is shadowed by a normal user space debugger,
375 user space break points may not work correctly.
376 Setting a break
377 point at the low-level code paths may also cause strange behavior.
378 .Pp
379 .It Ic delete Ar addr
380 .It Ic d Ar addr
381 .It Ic delete Li # Ns Ar number
382 .It Ic d Li # Ns Ar number
383 Delete the break point.
384 The target break point can be specified by a
385 break point number with
386 .Ql # ,
387 or by using the same
388 .Ar addr
389 specified in the original
390 .Ic break
391 command.
392 .Pp
393 .It Ic watch Ar addr Ns Li , Ns Ar size
394 Set a watchpoint for a region.
395 Execution stops when an attempt to modify the region occurs.
396 The
397 .Ar size
398 argument defaults to 4.
399 If you specify a wrong space address, the request is rejected
400 with an error message.
401 .Pp
402 .Sy Warning :
403 Attempts to watch wired kernel memory
404 may cause unrecoverable error in some systems such as i386.
405 Watchpoints on user addresses work best.
406 .Pp
407 .It Ic hwatch Ar addr Ns Li , Ns Ar size
408 Set a hardware watchpoint for a region if supported by the
409 architecture.
410 Execution stops when an attempt to modify the region occurs.
411 The
412 .Ar size
413 argument defaults to 4.
414 .Pp
415 .Sy Warning :
416 The hardware debug facilities do not have a concept of separate
417 address spaces like the watch command does.
418 Use
419 .Ic hwatch
420 for setting watchpoints on kernel address locations only, and avoid
421 its use on user mode address spaces.
422 .Pp
423 .It Ic dhwatch Ar addr Ns Li , Ns Ar size
424 Delete specified hardware watchpoint.
425 .Pp
426 .It Ic step Ns Op Li / Ns Cm p
427 .It Ic s Ns Op Li / Ns Cm p
428 Single step
429 .Ar count
430 times (the comma is a mandatory part of the syntax).
431 If the
432 .Cm p
433 modifier is specified, print each instruction at each step.
434 Otherwise, only print the last instruction.
435 .Pp
436 .Sy Warning :
437 depending on machine type, it may not be possible to
438 single-step through some low-level code paths or user space code.
439 On machines with software-emulated single-stepping (e.g., pmax),
440 stepping through code executed by interrupt handlers will probably
441 do the wrong thing.
442 .Pp
443 .It Ic continue Ns Op Li / Ns Cm c
444 .It Ic c Ns Op Li / Ns Cm c
445 Continue execution until a breakpoint or watchpoint.
446 If the
447 .Cm c
448 modifier is specified, count instructions while executing.
449 Some machines (e.g., pmax) also count loads and stores.
450 .Pp
451 .Sy Warning :
452 when counting, the debugger is really silently single-stepping.
453 This means that single-stepping on low-level code may cause strange
454 behavior.
455 .Pp
456 .It Ic until Ns Op Li / Ns Cm p
457 Stop at the next call or return instruction.
458 If the
459 .Cm p
460 modifier is specified, print the call nesting depth and the
461 cumulative instruction count at each call or return.
462 Otherwise,
463 only print when the matching return is hit.
464 .Pp
465 .It Ic next Ns Op Li / Ns Cm p
466 .It Ic match Ns Op Li / Ns Cm p
467 Stop at the matching return instruction.
468 If the
469 .Cm p
470 modifier is specified, print the call nesting depth and the
471 cumulative instruction count at each call or return.
472 Otherwise, only print when the matching return is hit.
473 .Pp
474 .It Xo
475 .Ic trace Ns Op Li / Ns Cm u
476 .Op Ar pid | tid
477 .Op Li , Ns Ar count
478 .Xc
479 .It Xo
480 .Ic t Ns Op Li / Ns Cm u
481 .Op Ar pid | tid
482 .Op Li , Ns Ar count
483 .Xc
484 .It Xo
485 .Ic where Ns Op Li / Ns Cm u
486 .Op Ar pid | tid
487 .Op Li , Ns Ar count
488 .Xc
489 .It Xo
490 .Ic bt Ns Op Li / Ns Cm u
491 .Op Ar pid | tid
492 .Op Li , Ns Ar count
493 .Xc
494 Stack trace.
495 The
496 .Cm u
497 option traces user space; if omitted,
498 .Ic trace
499 only traces
500 kernel space.
501 The optional argument
502 .Ar count
503 is the number of frames to be traced.
504 If
505 .Ar count
506 is omitted, all frames are printed.
507 .Pp
508 .Sy Warning :
509 User space stack trace is valid
510 only if the machine dependent code supports it.
511 .Pp
512 .It Xo
513 .Ic search Ns Op Li / Ns Cm bhl
514 .Ar addr
515 .Ar value
516 .Op Ar mask
517 .Op Li , Ns Ar count
518 .Xc
519 Search memory for
520 .Ar value .
521 This command might fail in interesting
522 ways if it does not find the searched-for value.
523 This is because
524 .Nm
525 does not always recover from touching bad memory.
526 The optional
527 .Ar count
528 argument limits the search.
529 .\"
530 .Pp
531 .It Ic show Cm all procs Ns Op Li / Ns Cm m
532 .It Ic ps Ns Op Li / Ns Cm m
533 Display all process information.
534 The process information may not be shown if it is not
535 supported in the machine, or the bottom of the stack of the
536 target process is not in the main memory at that time.
537 The
538 .Cm m
539 modifier will alter the display to show VM map
540 addresses for the process and not show other information.
541 .\"
542 .Pp
543 .It Ic show Cm allchains
544 Show the same information like "show lockchain" does, but
545 for every thread in the system.
546 .\"
547 .Pp
548 .It Ic show Cm alllocks
549 Show all locks that are currently held.
550 .\"
551 .Pp
552 .It Ic show Cm allpcpu
553 The same as "show pcpu", but for every CPU present in the system.
554 .\"
555 .Pp
556 .It Ic show Cm allrman
557 Show information related with resource management, including
558 interrupt request lines, DMA request lines, I/O ports and I/O memory
559 addresses.
560 .\"
561 .Pp
562 .It Ic show Cm apic
563 Dump data about APIC IDT vector mappings.
564 .\"
565 .Pp
566 .It Ic show Cm breaks
567 Show breakpoints set with the "break" command.
568 .\"
569 .Pp
570 .It Ic show Cm buffer
571 Show buffer structure of
572 .Vt struct buf
573 type.
574 Such a structure is used within the
575 .Fx
576 kernel for the I/O subsystem
577 implementation.
578 For an exact interpretation of the output, please see the
579 .Pa sys/buf.h
580 header file.
581 .\"
582 .Pp
583 .It Ic show Cm cbstat
584 Show brief information about the TTY subsystem.
585 .\"
586 .Pp
587 .It Ic show Cm cyrixreg
588 Show registers specific to the Cyrix processor.
589 .\"
590 .Pp
591 .It Ic show Cm domain Ar addr
592 Print protocol domain structure
593 .Vt struct domain
594 at address
595 .Ar addr .
596 See the
597 .Pa sys/domain.h
598 header file for more details on the exact meaning of the structure fields.
599 .\"
600 .Pp
601 .It Ic show Cm file Ar addr
602 Show information about the file structure
603 .Vt struct file
604 present at address
605 .Ar addr .
606 .\"
607 .Pp
608 .It Ic show Cm files
609 Show information about every file structure in the system.
610 .\"
611 .Pp
612 .It Ic show Cm freepages
613 Show the number of physical pages in each of the free lists.
614 .\"
615 .Pp
616 .It Ic show Cm geom Op Ar addr
617 If the
618 .Ar addr
619 argument is not given, displays the entire GEOM topology.
620 If
621 .Ar addr
622 is given, displays details about the given GEOM object (class, geom,
623 provider or consumer).
624 .\"
625 .Pp
626 .It Ic show Cm idt
627 Show IDT layout.
628 The first column specifies the IDT vector.
629 The second one is the name of the interrupt/trap handler.
630 Those functions are machine dependent.
631 .\"
632 .Pp
633 .It Ic show Cm inpcb Ar addr
634 Show information on IP Control Block
635 .Vt struct in_pcb
636 present at
637 .Ar addr .
638 .\"
639 .Pp
640 .It Ic show Cm intr
641 Dump information about interrupt handlers.
642 .\"
643 .Pp
644 .It Ic show Cm intrcnt
645 Dump the interrupt statistics.
646 .\"
647 .Pp
648 .It Ic show Cm irqs
649 Show interrupt lines and their respective kernel threads.
650 .\"
651 .Pp
652 .It Ic show Cm lapic
653 Show information from the local APIC registers for this CPU.
654 .\"
655 .Pp
656 .It Ic show Cm lock Ar addr
657 Show lock structure.
658 The output format is as follows:
659 .Bl -tag -offset 0 -width "flags"
660 .It Ic class:
661 Class of the lock.
662 Possible types include
663 .Xr mutex 9 ,
664 .Xr rmlock 9 ,
665 .Xr rwlock 9 ,
666 .Xr sx 9 .
667 .It Ic name:
668 Name of the lock.
669 .It Ic flags:
670 Flags passed to the lock initialization function.
671 For exact possibilities see manual pages of possible lock types.
672 .It Ic state:
673 Current state of a lock.
674 As well as
675 .Ic flags
676 it's lock-specific.
677 .It Ic owner:
678 Lock owner.
679 .El
680 .\"
681 .Pp
682 .It Ic show Cm lockchain Ar addr
683 Show all threads a particular thread at address
684 .Ar addr
685 is waiting on based on non-sleepable and non-spin locks.
686 .\"
687 .Pp
688 .It Ic show Cm lockedbufs
689 Show the same information as "show buf", but for every locked
690 .Vt struct buf
691 object.
692 .\"
693 .Pp
694 .It Ic show Cm lockedvnods
695 List all locked vnodes in the system.
696 .\"
697 .Pp
698 .It Ic show Cm locks
699 Prints all locks that are currently acquired.
700 .\"
701 .Pp
702 .It Ic show Cm locktree
703 .\"
704 .Pp
705 .It Ic show Cm malloc
706 Prints
707 .Xr malloc 9
708 memory allocator statistics.
709 The output format is as follows:
710 .Pp
711 .Bl -tag -compact -offset indent -width "Requests"
712 .It Ic Type
713 Specifies a type of memory.
714 It is the same as a description string used while defining the
715 given memory type with
716 .Xr MALLOC_DECLARE 9 .
717 .It Ic InUse
718 Number of memory allocations of the given type, for which
719 .Xr free 9
720 has not been called yet.
721 .It Ic MemUse
722 Total memory consumed by the given allocation type.
723 .It Ic Requests
724 Number of memory allocation requests for the given
725 memory type.
726 .El
727 .Pp
728 The same information can be gathered in userspace with
729 .Dq Nm vmstat Fl m .
730 .\"
731 .Pp
732 .It Ic show Cm map Ns Oo Li / Ns Cm f Oc Ar addr
733 Prints the VM map at
734 .Ar addr .
735 If the
736 .Cm f
737 modifier is specified the
738 complete map is printed.
739 .\"
740 .Pp
741 .It Ic show Cm msgbuf
742 Print the system's message buffer.
743 It is the same output as in the
744 .Dq Nm dmesg
745 case.
746 It is useful if you got a kernel panic, attached a serial cable
747 to the machine and want to get the boot messages from before the
748 system hang.
749 .\"
750 .It Ic show Cm mount
751 Displays short info about all currently mounted file systems.
752 .Pp
753 .It Ic show Cm mount Ar addr
754 Displays details about the given mount point.
755 .Pp
756 .\"
757 .Pp
758 .It Ic show Cm object Ns Oo Li / Ns Cm f Oc Ar addr
759 Prints the VM object at
760 .Ar addr .
761 If the
762 .Cm f
763 option is specified the
764 complete object is printed.
765 .\"
766 .Pp
767 .It Ic show Cm page
768 Show statistics on VM pages.
769 .\"
770 .Pp
771 .It Ic show Cm pageq
772 Show statistics on VM page queues.
773 .\"
774 .Pp
775 .It Ic show Cm pciregs
776 Print PCI bus registers.
777 The same information can be gathered in userspace by running
778 .Dq Nm pciconf Fl lv .
779 .\"
780 .Pp
781 .It Ic show Cm pcpu
782 Print current processor state.
783 The output format is as follows:
784 .Pp
785 .Bl -tag -compact -offset indent -width "spin locks held:"
786 .It Ic cpuid
787 Processor identifier.
788 .It Ic curthread
789 Thread pointer, process identifier and the name of the process.
790 .It Ic curpcb
791 Control block pointer.
792 .It Ic fpcurthread
793 FPU thread pointer.
794 .It Ic idlethread
795 Idle thread pointer.
796 .It Ic APIC ID
797 CPU identifier coming from APIC.
798 .It Ic currentldt
799 LDT pointer.
800 .It Ic spin locks held
801 Names of spin locks held.
802 .El
803 .\"
804 .Pp
805 .It Ic show Cm pgrpdump
806 Dump process groups present within the system.
807 .\"
808 .Pp
809 .It Ic show Cm proc Op Ar addr
810 If no
811 .Op Ar addr
812 is specified, print information about the current process.
813 Otherwise, show information about the process at address
814 .Ar addr .
815 .\"
816 .Pp
817 .It Ic show Cm procvm
818 Show process virtual memory layout.
819 .\"
820 .Pp
821 .It Ic show Cm protosw Ar addr
822 Print protocol switch structure
823 .Vt struct protosw
824 at address
825 .Ar addr .
826 .\"
827 .Pp
828 .It Ic show Cm registers Ns Op Li / Ns Cm u
829 Display the register set.
830 If the
831 .Cm u
832 modifier is specified, it displays user registers instead of
833 kernel registers or the currently saved one.
834 .Pp
835 .Sy Warning :
836 The support of the
837 .Cm u
838 modifier depends on the machine.
839 If not supported, incorrect information will be displayed.
840 .\"
841 .Pp
842 .It Ic show Cm rman Ar addr
843 Show resource manager object
844 .Vt struct rman
845 at address
846 .Ar addr .
847 Addresses of particular pointers can be gathered with "show allrman"
848 command.
849 .\"
850 .Pp
851 .It Ic show Cm rtc
852 Show real time clock value.
853 Useful for long debugging sessions.
854 .\"
855 .Pp
856 .It Ic show Cm sleepchain
857 Show all the threads a particular thread is waiting on based on
858 sleepable locks.
859 .\"
860 .Pp
861 .It Ic show Cm sleepq
862 .It Ic show Cm sleepqueue
863 Both commands provide the same functionality.
864 They show sleepqueue
865 .Vt struct sleepqueue
866 structure.
867 Sleepqueues are used within the
868 .Fx
869 kernel to implement sleepable
870 synchronization primitives (thread holding a lock might sleep or
871 be context switched), which at the time of writing are:
872 .Xr condvar 9 ,
873 .Xr sx 9
874 and standard
875 .Xr msleep 9
876 interface.
877 .\"
878 .Pp
879 .It Ic show Cm sockbuf Ar addr
880 .It Ic show Cm socket Ar addr
881 Those commands print
882 .Vt struct sockbuf
883 and
884 .Vt struct socket
885 objects placed at
886 .Ar addr .
887 Output consists of all values present in structures mentioned.
888 For exact interpretation and more details, visit
889 .Pa sys/socket.h
890 header file.
891 .\"
892 .Pp
893 .It Ic show Cm sysregs
894 Show system registers (e.g.,
895 .Li cr0-4
896 on i386.)
897 Not present on some platforms.
898 .\"
899 .Pp
900 .It Ic show Cm tcpcb Ar addr
901 Print TCP control block
902 .Vt struct tcpcb
903 lying at address
904 .Ar addr .
905 For exact interpretation of output, visit
906 .Pa netinet/tcp.h
907 header file.
908 .\"
909 .Pp
910 .It Ic show Cm thread Op Ar addr
911 If no
912 .Ar addr
913 is specified, show detailed information about current thread.
914 Otherwise, information about thread at
915 .Ar addr
916 is printed.
917 .\"
918 .Pp
919 .It Ic show Cm threads
920 Show all threads within the system.
921 Output format is as follows:
922 .Pp
923 .Bl -tag -width "PPID" -compact -offset indent -width "Second column"
924 .It Ic First column
925 Thread identifier (TID)
926 .It Ic Second column
927 Thread structure address
928 .It Ic Third column
929 Backtrace.
930 .El
931 .\"
932 .Pp
933 .It Ic show Cm turnstile Ar addr
934 Show turnstile
935 .Vt struct turnstile
936 structure at address
937 .Ar addr .
938 Turnstiles are structures used within the
939 .Fx
940 kernel to implement
941 synchronization primitives which, while holding a specific type of lock, cannot
942 sleep or context switch to another thread.
943 Currently, those are:
944 .Xr mutex 9 ,
945 .Xr rwlock 9 ,
946 .Xr rmlock 9 .
947 .\"
948 .Pp
949 .It Ic show Cm uma
950 Show UMA allocator statistics.
951 Output consists five columns:
952 .Pp
953 .Bl -tag -compact -offset indent -width "Requests"
954 .It Cm "Zone"
955 Name of the UMA zone.
956 The same string that was passed to
957 .Xr uma_zcreate 9
958 as a first argument.
959 .It Cm "Size"
960 Size of a given memory object (slab).
961 .It Cm "Used"
962 Number of slabs being currently used.
963 .It Cm "Free"
964 Number of free slabs within the UMA zone.
965 .It Cm "Requests"
966 Number of allocations requests to the given zone.
967 .El
968 .Pp
969 The very same information might be gathered in the userspace
970 with the help of
971 .Dq Nm vmstat Fl z
972 .\"
973 .Pp
974 .It Ic show Cm unpcb Ar addr
975 Shows UNIX domain socket private control block
976 .Vt struct unpcb
977 present at the address
978 .Ar addr
979 .\"
980 .Pp
981 .It Ic show Cm vmochk
982 Prints, whether the internal VM objects are in a map somewhere
983 and none have zero ref counts.
984 .\"
985 .Pp
986 .It Ic show Cm vmopag
987 This is supposed to show physical addresses consumed by a
988 VM object.
989 Currently, it is not possible to use this command when
990 .Xr witness 9
991 is compiled in the kernel.
992 .\"
993 .Pp
994 .It Ic show Cm vnode Op Ar addr
995 Prints vnode
996 .Vt struct vnode
997 structure lying at
998 .Op Ar addr .
999 For the exact interpretation of the output, look at the
1000 .Pa sys/vnode.h
1001 header file.
1002 .\"
1003 .Pp
1004 .It Ic show Cm watches
1005 Displays all watchpoints.
1006 Shows watchpoints set with "watch" command.
1007 .\"
1008 .Pp
1009 .It Ic show Cm witness
1010 Shows information about lock acquisition coming from the
1011 .Xr witness 9
1012 subsystem.
1013 .\"
1014 .Pp
1015 .It Ic gdb
1016 Toggles between remote GDB and DDB mode.
1017 In remote GDB mode, another machine is required that runs
1018 .Xr gdb 1
1019 using the remote debug feature, with a connection to the serial
1020 console port on the target machine.
1021 Currently only available on the
1022 i386
1023 architecture.
1024 .Pp
1025 .It Ic halt
1026 Halt the system.
1027 .Pp
1028 .It Ic kill Ar sig pid
1029 Send signal
1030 .Ar sig
1031 to process
1032 .Ar pid .
1033 The signal is acted on upon returning from the debugger.
1034 This command can be used to kill a process causing resource contention
1035 in the case of a hung system.
1036 See
1037 .Xr signal 3
1038 for a list of signals.
1039 Note that the arguments are reversed relative to
1040 .Xr kill 2 .
1041 .Pp
1042 .It Ic reboot
1043 .It Ic reset
1044 Hard reset the system.
1045 .Pp
1046 .It Ic help
1047 Print a short summary of the available commands and command
1048 abbreviations.
1049 .Pp
1050 .It Ic capture on
1051 .It Ic capture off
1052 .It Ic capture reset
1053 .It Ic capture status
1054 .Nm
1055 supports a basic output capture facility, which can be used to retrieve the
1056 results of debugging commands from userpsace using
1057 .Xr sysctl 2 .
1058 .Ic capture on
1059 enables output capture;
1060 .Ic capture off
1061 disables capture.
1062 .Ic capture reset
1063 will clear the capture buffer and disable capture.
1064 .Ic capture status
1065 will report current buffer use, buffer size, and disposition of output
1066 capture.
1067 .Pp
1068 Userspace processes may inspect and manage
1069 .Nm
1070 capture state using
1071 .Xr sysctl 8 :
1072 .Pp
1073 .Dv debug.ddb.capture.bufsize
1074 may be used to query or set the current capture buffer size.
1075 .Pp
1076 .Dv debug.ddb.capture.maxbufsize
1077 may be used to query the compile-time limit on the capture buffer size.
1078 .Pp
1079 .Dv debug.ddb.capture.bytes
1080 may be used to query the number of bytes of output currently in the capture
1081 buffer.
1082 .Pp
1083 .Dv debug.ddb.capture.data
1084 returns the contents of the buffer as a string to an appropriately privileged
1085 process.
1086 .Pp
1087 This facility is particularly useful in concert with the scripting and
1088 .Xr textdump 4
1089 facilities, allowing scripted debugging output to be captured and
1090 committed to disk as part of a textdump for later analysis.
1091 The contents of the capture buffer may also be inspected in a kernel core dump
1092 using
1093 .Xr kgdb 1 .
1094 .Pp
1095 .It Ic run
1096 .It Ic script
1097 .It Ic scripts
1098 .It Ic unscript
1099 Run, define, list, and delete scripts.
1100 See the
1101 .Sx SCRIPTING
1102 section for more information on the scripting facility.
1103 .Pp
1104 .It Ic textdump set
1105 .It Ic textdump status
1106 .It Ic textdump unset
1107 The
1108 .Ic textdump set
1109 command may be used to force the next kernel core dump to be a textdump
1110 rather than a traditional memory dump or minidump.
1111 .Ic textdump status
1112 reports whether a textdump has been scheduled.
1113 .Ic textdump unset
1114 cancels a request to perform a textdump as the next kernel core dump.
1115 More information may be found in
1116 .Xr textdump 4 .
1117 .El
1118 .Sh VARIABLES
1119 The debugger accesses registers and variables as
1120 .Li $ Ns Ar name .
1121 Register names are as in the
1122 .Dq Ic show Cm registers
1123 command.
1124 Some variables are suffixed with numbers, and may have some modifier
1125 following a colon immediately after the variable name.
1126 For example, register variables can have a
1127 .Cm u
1128 modifier to indicate user register (e.g.,
1129 .Dq Li $eax:u ) .
1130 .Pp
1131 Built-in variables currently supported are:
1132 .Pp
1133 .Bl -tag -width ".Va tabstops" -compact
1134 .It Va radix
1135 Input and output radix.
1136 .It Va maxoff
1137 Addresses are printed as
1138 .Dq Ar symbol Ns Li + Ns Ar offset
1139 unless
1140 .Ar offset
1141 is greater than
1142 .Va maxoff .
1143 .It Va maxwidth
1144 The width of the displayed line.
1145 .It Va lines
1146 The number of lines.
1147 It is used by the built-in pager.
1148 .It Va tabstops
1149 Tab stop width.
1150 .It Va work Ns Ar xx
1151 Work variable;
1152 .Ar xx
1153 can take values from 0 to 31.
1154 .El
1155 .Sh EXPRESSIONS
1156 Most expression operators in C are supported except
1157 .Ql ~ ,
1158 .Ql ^ ,
1159 and unary
1160 .Ql & .
1161 Special rules in
1162 .Nm
1163 are:
1164 .Bl -tag -width ".No Identifiers"
1165 .It Identifiers
1166 The name of a symbol is translated to the value of the symbol, which
1167 is the address of the corresponding object.
1168 .Ql \&.
1169 and
1170 .Ql \&:
1171 can be used in the identifier.
1172 If supported by an object format dependent routine,
1173 .Sm off
1174 .Oo Ar filename : Oc Ar func : lineno ,
1175 .Sm on
1176 .Oo Ar filename : Oc Ns Ar variable ,
1177 and
1178 .Oo Ar filename : Oc Ns Ar lineno
1179 can be accepted as a symbol.
1180 .It Numbers
1181 Radix is determined by the first two letters:
1182 .Ql 0x :
1183 hex,
1184 .Ql 0o :
1185 octal,
1186 .Ql 0t :
1187 decimal; otherwise, follow current radix.
1188 .It Li \&.
1189 .Va dot
1190 .It Li +
1191 .Va next
1192 .It Li ..
1193 address of the start of the last line examined.
1194 Unlike
1195 .Va dot
1196 or
1197 .Va next ,
1198 this is only changed by
1199 .Ic examine
1200 or
1201 .Ic write
1202 command.
1203 .It Li '
1204 last address explicitly specified.
1205 .It Li $ Ns Ar variable
1206 Translated to the value of the specified variable.
1207 It may be followed by a
1208 .Ql \&:
1209 and modifiers as described above.
1210 .It Ar a Ns Li # Ns Ar b
1211 A binary operator which rounds up the left hand side to the next
1212 multiple of right hand side.
1213 .It Li * Ns Ar expr
1214 Indirection.
1215 It may be followed by a
1216 .Ql \&:
1217 and modifiers as described above.
1218 .El
1219 .Sh SCRIPTING
1220 .Nm
1221 supports a basic scripting facility to allow automating tasks or responses to
1222 specific events.
1223 Each script consists of a list of DDB commands to be executed sequentially,
1224 and is assigned a unique name.
1225 Certain script names have special meaning, and will be automatically run on
1226 various
1227 .Nm
1228 events if scripts by those names have been defined.
1229 .Pp
1230 The
1231 .Ic script
1232 command may be used to define a script by name.
1233 Scripts consist of a series of
1234 .Nm
1235 commands separated with the
1236 .Ic ;
1237 character.
1238 For example:
1239 .Bd -literal -offset indent
1240 script kdb.enter.panic=bt; show pcpu
1241 script lockinfo=show alllocks; show lockedvnods
1242 .Ed
1243 .Pp
1244 The
1245 .Ic scripts
1246 command lists currently defined scripts.
1247 .Pp
1248 The
1249 .Ic run
1250 command execute a script by name.
1251 For example:
1252 .Bd -literal -offset indent
1253 run lockinfo
1254 .Ed
1255 .Pp
1256 The
1257 .Ic unscript
1258 command may be used to delete a script by name.
1259 For example:
1260 .Bd -literal -offset indent
1261 unscript kdb.enter.panic
1262 .Ed
1263 .Pp
1264 These functions may also be performed from userspace using the
1265 .Xr ddb 8
1266 command.
1267 .Pp
1268 Certain scripts are run automatically, if defined, for specific
1269 .Nm
1270 events.
1271 The follow scripts are run when various events occur:
1272 .Bl -tag -width kdb.enter.powerfail
1273 .It Dv kdb.enter.acpi
1274 The kernel debugger was entered as a result of an
1275 .Xr acpi 4
1276 event.
1277 .It Dv kdb.enter.bootflags
1278 The kernel debugger was entered at boot as a result of the debugger boot
1279 flag being set.
1280 .It Dv kdb.enter.break
1281 The kernel debugger was entered as a result of a serial or console break.
1282 .It Dv kdb.enter.cam
1283 The kernel debugger was entered as a result of a
1284 .Xr CAM 4
1285 event.
1286 .It Dv kdb.enter.mac
1287 The kernel debugger was entered as a result of an assertion failure in the
1288 .Xr mac_test 4
1289 module of the
1290 TrustedBSD MAC Framework.
1291 .It Dv kdb.enter.ndis
1292 The kernel debugger was entered as a result of an
1293 .Xr ndis 4
1294 breakpoint event.
1295 .It Dv kdb.enter.netgraph
1296 The kernel debugger was entered as a result of a
1297 .Xr netgraph 4
1298 event.
1299 .It Dv kdb.enter.panic
1300 .Xr panic 9
1301 was called.
1302 .It Dv kdb.enter.powerfail
1303 The kernel debugger was entered as a result of a powerfail NMI on the sparc64
1304 platform.
1305 .It Dv kdb.enter.powerpc
1306 The kernel debugger was entered as a result of an unimplemented interrupt
1307 type on the powerpc platform.
1308 .It Dv kdb.enter.sysctl
1309 The kernel debugger was entered as a result of the
1310 .Dv debug.kdb.enter
1311 sysctl being set.
1312 .It Dv kdb.enter.trapsig
1313 The kernel debugger was entered as a result of a trapsig event on the sparc64
1314 or sun4v platform.
1315 .It Dv kdb.enter.unionfs
1316 The kernel debugger was entered as a result of an assertion failure in the
1317 union file system.
1318 .It Dv kdb.enter.unknown
1319 The kernel debugger was entered, but no reason has been set.
1320 .It Dv kdb.enter.vfslock
1321 The kernel debugger was entered as a result of a VFS lock violation.
1322 .It Dv kdb.enter.watchdog
1323 The kernel debugger was entered as a result of a watchdog firing.
1324 .It Dv kdb.enter.witness
1325 The kernel debugger was entered as a result of a
1326 .Xr witness 4
1327 violation.
1328 .El
1329 .Pp
1330 In the event that none of these scripts is found,
1331 .Nm
1332 will attempt to execute a default script:
1333 .Bl -tag -width kdb.enter.powerfail
1334 .It Dv kdb.enter.default
1335 The kernel debugger was entered, but a script exactly matching the reason for
1336 entering was not defined.
1337 This can be used as a catch-all to handle cases not specifically of interest;
1338 for example,
1339 .Dv kdb.enter.witness
1340 might be defined to have special handling, and
1341 .Dv kdb.enter.default
1342 might be defined to simply panic and reboot.
1343 .El
1344 .Sh HINTS
1345 On machines with an ISA expansion bus, a simple NMI generation card can be
1346 constructed by connecting a push button between the A01 and B01 (CHCHK# and
1347 GND) card fingers.
1348 Momentarily shorting these two fingers together may cause the bridge chipset to
1349 generate an NMI, which causes the kernel to pass control to
1350 .Nm .
1351 Some bridge chipsets do not generate a NMI on CHCHK#, so your mileage may vary.
1352 The NMI allows one to break into the debugger on a wedged machine to
1353 diagnose problems.
1354 Other bus' bridge chipsets may be able to generate NMI using bus specific
1355 methods.
1356 .Sh FILES
1357 Header files mention in this manual page can be found below
1358 .Pa /usr/include
1359 directory.
1360 .Pp
1361 .Bl -dash -compact
1362 .It
1363 .Pa sys/buf.h
1364 .It
1365 .Pa sys/domain.h
1366 .It
1367 .Pa netinet/in_pcb.h
1368 .It
1369 .Pa sys/socket.h
1370 .It
1371 .Pa sys/vnode.h
1372 .El
1373 .Sh SEE ALSO
1374 .Xr gdb 1 ,
1375 .Xr kgdb 1 ,
1376 .Xr acpi 4 ,
1377 .Xr CAM 4 ,
1378 .Xr mac_test 4 ,
1379 .Xr ndis 4 ,
1380 .Xr netgraph 4 ,
1381 .Xr textdump 4 ,
1382 .Xr witness 4 ,
1383 .Xr ddb 8 ,
1384 .Xr sysctl 8 ,
1385 .Xr panic 9 ,
1386 .Xr witness 9
1387 .Sh HISTORY
1388 The
1389 .Nm
1390 debugger was developed for Mach, and ported to
1391 .Bx 386 0.1 .
1392 This manual page translated from
1393 .Xr man 7
1394 macros by
1395 .An Garrett Wollman .
1396 .Pp
1397 .An Robert N. M. Watson
1398 added support for
1399 .Nm
1400 output capture,
1401 .Xr textdump 4
1402 and scripting in
1403 .Fx 8.0 .