1.\" $NetBSD: ddb.4,v 1.166 2017/01/12 13:14:41 wiz 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 January 12, 2017 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 one or more 748of the kernel history options 749.Cd KERNHIST , 750.Cd SYSCALL_DEBUG , 751.Cd USB_DEBUG , 752.Cd BIOHIST , 753or 754.Cd UVMHIST . 755.It Ic show vnode Ns Oo Cm /f Oc Ar address 756Print the vnode at 757.Ar address . 758If 759.Cm /f 760is specified, the complete vnode is printed. 761.It Ic show vnode_lock Ns Oo Cm /f Oc Ar address 762Print the vnode which has its lock at 763.Ar address . 764If 765.Cm /f 766is specified, the complete vnode is printed. 767.It Ic show watches 768Display all watchpoints. 769.It Ic sifting Ns Oo Cm /F Oc Ar string 770Search the symbol tables for all symbols of which 771.Ar string 772is a substring, and display them. 773If 774.Cm /F 775is specified, a character is displayed immediately after each symbol 776name indicating the type of symbol. 777.Pp 778For 779.Xr a.out 5 Ns -format 780symbol tables, 781absolute symbols display 782.Sy @ , 783text segment symbols display 784.Sy * , 785data segment symbols display 786.Sy + , 787.Tn BSS 788segment symbols display 789.Sy - , 790and filename symbols display 791.Sy / . 792For 793.Tn ELF Ns -format 794symbol tables, 795object symbols display 796.Sy + , 797function symbols display 798.Sy * , 799section symbols display 800.Sy \*[Am] , 801and file symbols display 802.Sy / . 803.Pp 804To sift for a string beginning with a number, escape the first 805character with a backslash as: 806.Bd -literal -offset indent 807sifting \\386 808.Ed 809.It Ic step Ns Oo Cm /p Oc Op Cm , Ns Ar count 810Single-step 811.Ar count 812times. 813If 814.Cm /p 815is specified, print each instruction at each step. 816Otherwise, only print the last instruction. 817.Pp 818Warning: depending on the machine type, it may not be possible 819to single-step through some low-level code paths or user-space 820code. 821On machines with software-emulated single-stepping (e.g., pmax), 822stepping through code executed by interrupt handlers will probably 823do the wrong thing. 824.It Ic sync 825Sync the disks, force a crash dump, and then reboot. 826.It Ic trace Ns Oo Cm /u Ns Oo Cm l Oc Oc Oo Ar frame-address Oc Ns \ 827Oo Cm , Ns Ar count Oc 828Stack trace from 829.Ar frame-address . 830If 831.Cm /u 832is specified, trace user-space, otherwise trace kernel-space. 833.Ar count 834is the number of frames to be traced. 835If 836.Ar count 837is omitted, all frames are printed. 838If 839.Cm /l 840is specified, the trace is printed and also stored in the kernel 841message buffer. 842.Pp 843Warning: user-space stack trace is valid only if the machine dependent 844code supports it. 845.It Ic trace/t Ns Oo Cm l Oc Oo Ar pid Oc Ns Oo Cm , Ns Ar count Oc 846Stack trace by 847.Dq thread 848(process, on 849.Nx ) 850rather than by stack frame address. 851Note that 852.Ar pid 853is interpreted using the current radix, whilst 854.Ic ps 855displays pids in decimal; prefix 856.Ar pid 857with 858.Sq 0t 859to force it to be interpreted as decimal (see 860.Sx VARIABLES 861section for radix). 862If 863.Cm /l 864is specified, the trace is printed and also stored in the kernel 865message buffer. 866.Pp 867Warning: trace by pid is valid only if the machine dependent code 868supports it. 869.It Ic trace/a Ns Oo Cm l Oc Oo Ar lwpaddr Oc Ns Oo Cm , Ns Ar count Oc 870Stack trace by light weight process (LWP) address 871rather than by stack frame address. 872If 873.Cm /l 874is specified, the trace is printed and also stored in the kernel 875message buffer. 876.Pp 877Warning: trace by LWP address is valid only if the machine dependent 878code supports it. 879.It Ic until Ns Op Cm /p 880Stop at the next call or return instruction. 881If 882.Cm /p 883is specified, print the call nesting depth and the 884cumulative instruction count at each call or return. 885Otherwise, only print when the matching return is hit. 886.It Ic watch Ar address Ns Oo Cm , Ns Ar size Oc 887Set a watchpoint for a region. 888Execution stops when an attempt to modify the region occurs. 889.Ar size 890defaults to 4. 891.Pp 892If you specify a wrong space address, the request is 893rejected with an error message. 894.Pp 895Warning: attempts to watch wired kernel memory may cause 896an unrecoverable error in some systems such as i386. 897Watchpoints on user addresses work the best. 898.It Ic whatis Ar address 899Describe what an address is. 900.It Ic write Ns Oo Cm /bhlBHL Oc Ar address Ar expression Oo Ar expression ... Oc 901Write the 902.Ar expression Ns s 903at succeeding locations. 904The unit size is specified with a modifier character, as per 905.Ic examine . 906Valid modifiers are: 907.Cm /b , 908.Cm /h , 909and 910.Cm /l . 911If no modifier is specified, 912.Cm /l 913is used. 914.Pp 915Specifying the modifiers in upper case, 916.Cm /B , 917.Cm /H , 918.Cm /L , 919will prevent 920.Nm 921from reading the memory location first, which is useful for avoiding 922side effects when writing to I/O memory regions. 923.Pp 924Warning: since there is no delimiter between 925.Ar expression Ns s , 926strange things may occur. 927It's best to enclose each 928.Ar expression 929in parentheses. 930.It Ic x Ns Oo Cm / Ns Ar modifier Oc Ar address Ns Op Cm , Ns Ar count 931A synonym for 932.Ic examine . 933.\" XXX - these commands aren't implemented; jhawk 19 May 2000 934.\" .It Ic xf 935.\" Examine forward. 936.\" .Ic xf 937.\" re-executes the most recent 938.\" .Ic execute 939.\" command with the same parameters except that 940.\" .Ar address 941.\" is set to 942.\" .Ar next . 943.\" .It Ic xb 944.\" Examine backward. 945.\" .Ic xb 946.\" re-executes the most recent 947.\" .Ic execute 948.\" command with the same parameters, except that 949.\" .Ar address 950.\" is set to the last start address minus its size. 951.El 952.Sh MACHINE-SPECIFIC COMMANDS 953The "glue" code that hooks 954.Nm 955into the 956.Nx 957kernel for any given port can also add machine specific commands 958to the 959.Nm 960command parser. 961All of these commands are preceded by the command word 962.Em machine 963to indicate that they are part of the machine-specific command 964set (e.g. 965.Ic machine reboot ) . 966Some of these commands are: 967.Ss ACORN26 968.Bl -tag -width "traptrace" -compact 969.It Ic bsw 970Writes one or two bytes to the IObus. 971Takes an address and a value. 972Use the 973.Dq b 974modifier to write a single byte and the 975.Dq h 976modifier to write two bytes. 977.It Ic frame 978Given a trap frame address, print out the trap frame. 979.It Ic irqstat 980Display the IRQ statistics 981.El 982.Ss ALPHA 983.Bl -tag -width "traptrace" -compact 984.It Ic cpu 985Switch to another cpu. 986.\" .It Ic halt 987.\" Call the PROM monitor to halt the CPU. 988.\" .It Ic reboot 989.\" Call the PROM monitor to reboot the CPU. 990.El 991.Ss AMD64 992.Bl -tag -width "traptrace" -compact 993.It Ic cpu 994Switch to another cpu. 995.El 996.Ss ARM32 997.Bl -tag -width "traptrace" -compact 998.It Ic frame 999Given a trap frame address, print out the trap frame. 1000.El 1001.Ss HPPA 1002.Bl -tag -width "traptrace" -compact 1003.It Ic frame 1004Without an address the default trap frame is printed. 1005Otherwise, the trap frame address can be given, or, when the 1006.Dq l 1007modifier is used, an LWP address. 1008.El 1009.Ss I386 1010.Bl -tag -width "traptrace" -compact 1011.It Ic cpu 1012Switch to another cpu. 1013.El 1014.Ss IA64 1015.Bl -tag -width "traptrace" -compact 1016.It Ic vector 1017Without a vector, information about all 256 vectors is shown. 1018Otherwise, the given vector is shown. 1019.El 1020.Ss MIPS 1021.Bl -tag -width "traptrace" -compact 1022.It Ic cp0 1023Dump CP0 (coprocessor 0) register values. 1024.It Ic kvtop 1025Print the physical address for a given kernel virtual address. 1026.It Ic tlb 1027Print out the Translation Lookaside Buffer (TLB). 1028Only works in 1029.Nx 1030kernels compiled with 1031.Dv DEBUG 1032option. 1033.El 1034.Ss POWERPC 4xx 1035.Bl -tag -width "traptrace" -compact 1036.It Ic ctx 1037Print process MMU context information. 1038.It Ic pv 1039Print PA-\*[Gt]VA mapping information. 1040.It Ic reset 1041Reset the system. 1042.It Ic tf 1043Display the contents of the trapframe. 1044.It Ic tlb 1045Display instruction translation storage buffer information. 1046.It Ic dcr 1047Set the DCR register. 1048Must be between 0x00 and 0x3ff. 1049.It Ic user 1050Display user memory. 1051Use the 1052.Dq i 1053modifier to get instruction decoding. 1054.El 1055.Ss POWERPC OEA 1056.Bl -tag -width "traptrace" -compact 1057.It Ic bat 1058Print BAT registers and translations. 1059.It Ic mmu 1060Print MMU registers. 1061.El 1062.Ss SH3 1063.Bl -tag -width "traptrace" -compact 1064.It Ic tlb 1065Print TLB entries. 1066.It Ic cache 1067Print cache entries. 1068.It Ic frame 1069Print switch frame and trap frames. 1070.It Ic stack 1071Print kernel stack usage. 1072Only works in 1073.Nx 1074kernels compiled with the 1075.Dv KSTACK_DEBUG 1076option. 1077.El 1078.Ss SPARC 1079.Bl -tag -width "traptrace" -compact 1080.It Ic cpu 1081Switch to another cpu. 1082.It Ic prom 1083Enter the Sun PROM monitor. 1084.It Ic proc 1085Display some information about the LWP pointed to, or curlwp. 1086.It Ic pcb 1087Display information about the 1088.Dq struct pcb 1089listed. 1090.It Ic page 1091Display the pointer to the 1092.Dq struct vm_page 1093for this physical address. 1094.El 1095.Ss SPARC64 1096.Bl -tag -width "traptrace" -compact 1097.It Ic ctx 1098Print process context information. 1099.It Ic cpu 1100Switch to another cpu. 1101.It Ic dtlb 1102Print data translation look-aside buffer context information. 1103.It Ic dtsb 1104Display data translation storage buffer information. 1105.It Ic kmap 1106Display information about the listed mapping in the kernel pmap. 1107Use the 1108.Dq f 1109modifier to get a full listing. 1110.It Ic extract 1111Extract the physical address for a given virtual address from the kernel pmap. 1112.It Ic fpstate 1113Dump the FPU state. 1114.It Ic itlb 1115Print instruction translation look-aside buffer context information. 1116.It Ic itsb 1117Display instruction translation storage buffer information. 1118.It Ic lwp 1119Display a struct lwp 1120.It Ic pcb 1121Display information about the 1122.Dq struct pcb 1123listed. 1124.It Ic pctx 1125Attempt to change process context. 1126.It Ic page 1127Display the pointer to the 1128.Dq struct vm_page 1129for this physical address. 1130.It Ic phys 1131Display physical memory. 1132.It Ic pmap 1133Display the pmap. 1134Use the 1135.Dq f 1136modifier to get a fuller listing. 1137.It Ic proc 1138Display some information about the process pointed to, or curproc. 1139.It Ic prom 1140Enter the OFW PROM. 1141.It Ic pv 1142Display the 1143.Dq struct pv_entry 1144pointed to. 1145.It Ic sir 1146Reset the machine and enter prom (do a Software Initiated Reset). 1147.It Ic stack 1148Dump the window stack. 1149Use the 1150.Dq u 1151modifier to get userland information. 1152.It Ic tf 1153Display full trap frame state. 1154This is most useful for inclusion with bug reports. 1155.It Ic ts 1156Display trap state. 1157.It Ic traptrace 1158Display or set trap trace information. 1159Use the 1160.Dq r 1161and 1162.Dq f 1163modifiers to get reversed and full information, respectively. 1164.It Ic watch 1165Set or clear a physical or virtual hardware watchpoint. 1166Pass the address to be watched, or 1167.Dq 0 1168(or omit the address) to clear the watchpoint. 1169Optional modifiers are 1170.Dq p 1171for physical address, 1172.Dq r 1173for trap on read access (default: trap on write access only), 1174.Dq b 1175for 8 bit width, 1176.Dq h 1177for 16 bit, 1178.Dq l 1179for 32 bit or 1180.Dq L 1181for 64 bit. 1182.It Ic window 1183Print register window information. 1184Argument is a stack frame number (0 is 1185top of stack, which is used when no index is given). 1186.El 1187.Ss SUN2, SUN3 and SUN3X 1188.Bl -tag -width "traptrace" -compact 1189.It Ic abort 1190Drop into monitor via abort (allows continue). 1191.It Ic halt 1192Exit to Sun PROM monitor as in 1193.Xr halt 8 . 1194.It Ic reboot 1195Reboot the machine as in 1196.Xr reboot 8 . 1197.It Ic pgmap 1198Given an address, print the address, segment map, page map, and 1199Page Table Entry (PTE). 1200.El 1201.Ss VAX 1202.Bl -tag -width "traptrace" -compact 1203.It Ic cpu 1204Switch to another cpu. 1205.El 1206.Sh VARIABLES 1207.Nm 1208accesses registers and variables as 1209.Cm $ Ns Ar name . 1210Register names are as per the 1211.Ic show registers 1212command. 1213Some variables are suffixed with numbers, and may have a modifier 1214following a colon immediately after the variable name. 1215For example, register variables may have a 1216.Sq u 1217modifier to indicate user register 1218(e.g., 1219.Li "$eax:u" ) . 1220.Pp 1221Built-in variables currently supported are: 1222.Bl -tag -offset indent -width "maxwidth" -compact 1223.It Va lines 1224The number of lines. 1225This is used by the 1226.Ic more 1227feature. 1228When this variable is set to zero the 1229.Ic more 1230feature is disabled. 1231.It Va maxoff 1232Addresses are printed as 1233.Li 'symbol'+offset 1234unless 1235.Li offset 1236is greater than 1237.Va maxoff . 1238.It Va maxwidth 1239The width of the displayed line. 1240.Nm 1241wraps the current line by printing new line when 1242.Va maxwidth 1243column is reached. 1244When this variable is set to zero 1245.Nm 1246doesn't perform any wrapping. 1247.It Va onpanic 1248If greater than zero (the default is 1), 1249.Nm 1250will be invoked when the kernel panics. 1251If the kernel configuration option 1252.D1 Cd options DDB_ONPANIC=0 1253is used, 1254.Va onpanic 1255will be initialized to off, causing a stack trace to be printed and 1256the system to be rebooted instead of 1257.Nm 1258being entered. 1259Other useful settings are \-1, which suppresses the stack trace before 1260reboot, and 2, which causes a stack trace to be printed and 1261.Nm 1262to be entered. 1263.It Va fromconsole 1264If non-zero (the default), 1265the kernel allows to enter 1266.Nm 1267from the console (by break signal or special key sequence). 1268If the kernel configuration option 1269.D1 Cd options DDB_FROMCONSOLE=0 1270is used, 1271.Va fromconsole 1272will be initialized to off. 1273.It Va radix 1274Input and output radix. 1275.It Va tabstops 1276Tab stop width. 1277.It Va tee_msgbuf 1278If explicitly set to non zero (zero is the default) all 1279.Nm 1280output will not only be displayed on screen but 1281also be fed to the msgbuf. 1282The default of the variable can be set using the kernel configuration option 1283.D1 Cd options DDB_TEE_MSGBUF=1 1284which will initialize 1285.Va tee_msgbuf 1286to be 1. 1287This option is especially handy for poor souls 1288who don't have a serial console but want to recall 1289.Nm 1290output from a crash investigation. 1291This option is more generic than the /l command modifier possible for 1292selected commands as discussed above to log the output. 1293Mixing both /l 1294and this setting can give double loggings. 1295.\" .It Va work Ns Sy xx 1296.\" Temporary work variable. 1297.\" .Sq Sy xx 1298.\" is between 0 and 31. 1299.El 1300.Pp 1301All built-in variables are accessible via 1302.Xr sysctl 3 . 1303.Sh EXPRESSIONS 1304Almost all expression operators in C are supported, except 1305.Sq \&~ , 1306.Sq \&^ , 1307and unary 1308.Sq \&\*[Am] . 1309Special rules in 1310.Nm 1311are: 1312.Bl -tag -offset indent -width "identifier" 1313.It Ar identifier 1314name of a symbol. 1315It is translated to the address (or value) of it. 1316.Sq \&. 1317and 1318.Sq \&: 1319can be used in the identifier. 1320If supported by an object format dependent routine, 1321.Sm off 1322.Xo 1323.Oo Ar filename : Oc 1324.Ar function 1325.Oo : Ar line\ number Oc , 1326.Xc 1327.Sm on 1328.Sm off 1329.Xo 1330.Oo Ar filename : Oc 1331.Ar variable , 1332.Xc 1333.Sm on 1334and 1335.Sm off 1336.Xo 1337.Ar filename 1338.Oo : Ar "line number" Oc , 1339.Xc 1340.Sm on 1341can be accepted as a symbol. 1342The symbol may be prefixed with 1343.Ar symbol_table_name\^ : : 1344(e.g., 1345.Li emulator::mach_msg_trap ) 1346to specify other than kernel symbols. 1347.It Ar number 1348number. 1349Radix is determined by the first two characters: 1350.Sq 0x 1351- hex, 1352.Sq 0o 1353- octal, 1354.Sq 0t 1355- decimal, 1356otherwise follow current radix. 1357.It Cm . 1358.Ar dot 1359.It Cm + 1360.Ar next 1361.It Cm .. 1362address of the start of the last line examined. 1363Unlike 1364.Ar dot 1365or 1366.Ar next , 1367this is only changed by the 1368.Ic examine 1369or 1370.Ic write 1371commands. 1372.It Cm \&" \"" XXX: emacs highlighting 1373last address explicitly specified. 1374.It Cm $ Ns Ar name 1375register name or variable. 1376It is translated to the value of it. 1377It may be followed by a 1378.Sq \&: 1379and modifiers as described above. 1380.It Cm # 1381a binary operator which rounds up the left hand side to the next 1382multiple of right hand side. 1383.It Cm * Ns Ar expr 1384expression indirection. 1385It may be followed by a 1386.Sq \&: 1387and modifiers as described above. 1388.El 1389.Sh SEE ALSO 1390.Xr reboot 2 , 1391.Xr options 4 , 1392.Xr crash 8 , 1393.Xr reboot 8 , 1394.Xr sysctl 8 , 1395.Xr cnmagic 9 1396.Sh HISTORY 1397The 1398.Nm 1399kernel debugger was written as part of the MACH project at 1400Carnegie-Mellon University. 1401