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