1.\" $OpenBSD: ddb.4,v 1.76 2014/03/18 22:36:31 miod Exp $ 2.\" $NetBSD: ddb.4,v 1.5 1994/11/30 16:22:09 jtc Exp $ 3.\" 4.\" Mach Operating System 5.\" Copyright (c) 1991,1990 Carnegie Mellon University 6.\" All Rights Reserved. 7.\" 8.\" Permission to use, copy, modify and distribute this software and its 9.\" documentation is hereby granted, provided that both the copyright 10.\" notice and this permission notice appear in all copies of the 11.\" software, derivative works or modified versions, and any portions 12.\" thereof, and that both notices appear in supporting documentation. 13.\" 14.\" CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 15.\" CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR 16.\" ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 17.\" 18.\" Carnegie Mellon requests users of this software to return to 19.\" 20.\" Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 21.\" School of Computer Science 22.\" Carnegie Mellon University 23.\" Pittsburgh PA 15213-3890 24.\" 25.\" any improvements or extensions that they make and grant Carnegie Mellon 26.\" the rights to redistribute these changes. 27.\" 28.Dd $Mdocdate: March 18 2014 $ 29.Dt DDB 4 30.Os 31.Sh NAME 32.Nm ddb 33.Nd kernel debugger 34.Sh DESCRIPTION 35The 36.Nm 37debugger provides a means for debugging the kernel, 38and analysing the kernel after a system crash ("panic"), with a 39.Xr gdb 1 Ns \&-like 40syntax. 41.Pp 42.Nm 43is invoked upon a kernel panic when the 44.Xr sysctl 8 45.Va ddb.panic 46is set to 1. 47It may be invoked from the console when the sysctl 48.Va ddb.console 49is set to 1, using any of the following methods: 50.Bl -dash -offset 3n 51.It 52Using the key sequence 53.Li Ctrl-Alt-Esc . 54.It 55Sending a 56.Dv BREAK 57when using a serial console. 58.It 59Writing to the sysctl 60.Va ddb.trigger . 61.It 62For i386 and amd64 architectures, 63using the key sequence 64.Li Ctrl-Alt-Delete 65when the sysctl 66.Va machdep.kbdreset 67is set to 2. 68.El 69.Pp 70.Nm 71prompts for commands on the console with: 72.Pp 73.Dl ddb\*(Gt 74.Pp 75The general syntax of a 76.Nm 77command is: 78.Bd -ragged -offset indent 79.Ar command 80.Oo Ic / Ns Ar modifiers Oc " " 81.Oo Ar address Oc Ns 82.Op Ic \&, Ns Ar count 83.Ed 84.Pp 85To save typing, 86.Nm 87makes use of a context inferred from previous commands. 88In this context, 89the current location is called 90.Va dot . 91.\" The 92.\" .Va dot 93.\" is displayed with 94.\" a hexadecimal format at a prompt. 95The 96.Ic examine , 97.Ic search , 98.Ic show struct , 99and 100.Ic write 101commands update 102.Va dot 103to be that of the last address 104examined or the last location modified, and 105have intuitive effects on 106.Va next 107and 108.Va prev . 109All the other commands do not change 110.Va dot , 111and set 112.Va next 113to be the same. 114(See 115.Sx VARIABLES . ) 116.Pp 117.\" Specifying 118.\" .Ar address 119.\" in a command sets 120.\" .Va dot . 121An expression can be used in place of 122.Ar address 123(see 124.Sx EXPRESSIONS ) . 125Omitting 126.Ar address 127in a command uses the last value of 128.Va dot . 129A missing 130.Ar count 131is taken to be 1 for printing commands or \*(If 132for stack traces. 133Entering a blank line causes the last command to be repeated using 134.Va next 135in place of 136.Ar address , 137a 138.Ar count 139of 1, and no modifiers. 140.Pp 141.Nm 142has a feature like 143.Xr more 1 144for the output. 145If the number of lines output in response to one command exceeds the number 146set in the 147.Va $lines 148variable, it displays the message 149.Ql "--db_more--" 150and waits for a response. 151.Pp 152The valid responses are: 153.Pp 154.Bl -tag -width 10n -offset indent -compact 155.It Aq Ic space 156One more page. 157.It Aq Ic return 158One more line. 159.It Ic q 160Abort the current command, and return to the command input mode. 161.El 162.Pp 163The following command line editing keys are provided: 164.Pp 165.Bl -tag -width 10n -offset indent -compact 166.It Ic ^b 167back one character 168.It Ic ^f 169forward one character 170.It Ic ^a 171beginning of line 172.It Ic ^e 173end of line 174.It Ic ^w 175erase word back 176.It Ic ^h | Aq Ic del 177erase previous character 178.It Ic ^d 179erase next character 180.It Ic ^k 181delete to end of line 182.It Ic ^u 183delete line 184.It Ic ^p 185previous in command history 186.It Ic ^n 187next in command history 188.It Ic ^r 189redraw line 190.It Ic ^t 191exchange the two characters to the left of the cursor 192.El 193.Sh COMMANDS 194The following commands may be typed at the 195.Ql ddb\*(Gt 196prompt. 197Some commands consist of more than one word, and if only the first word 198or words are entered, the possible alternatives to complete the command 199are displayed and no other action is performed. 200.Bl -tag -width 10n 201.\" -------------------- 202.It Ic help 203List the available commands. 204.\" -------------------- 205.It Xo 206.Oo Ic e Oc Ns 207.Ic x Ns Op Ic amine 208.Op Cm /bhlqaAxzodurcsmiI 209.Op Ar addr Ns 210.Op Ic \&, Ns Ar count 211.Xc 212Display the contents at address 213.Ar addr 214according to the formats in the modifier. 215If no format is specified, the last formats specified for this command 216are used. 217.Pp 218The format characters are: 219.Pp 220.Bl -tag -width 4n -compact 221.It Cm /b 222look at by bytes (8 bits) 223.It Cm /h 224look at by half words (16 bits) 225.It Cm /l 226look at by long words (32 bits) (default) 227.It Cm /q 228look at by long longs (64 bits) (only available on 64-bit platforms) 229.It Cm /a 230print the location being displayed 231.It Cm /A 232print the location with a line number if possible 233.It Cm /x 234display in unsigned hex 235.It Cm /z 236display in signed hex 237.It Cm /o 238display in unsigned octal 239.It Cm /d 240display in signed decimal 241.It Cm /u 242display in unsigned decimal 243.It Cm /r 244display in current radix, signed 245.It Cm /c 246display low 8 bits as a character. 247Non-printing characters are displayed as an octal escape code (e.g., '\e000'). 248.It Cm /s 249display the null-terminated string at the location. 250Non-printing characters are displayed as octal escapes. 251.It Cm /m 252display in unsigned hex with character dump at the end of each line. 253The location is also displayed in hex at the beginning of each line. 254.It Cm /i 255display as an instruction 256.It Cm /I 257display as an alternate format instruction depending on the 258machine: 259.Pp 260.Bl -tag -width powerpc_ -compact 261.It alpha 262Print affected register contents for every instruction. 263.It amd64 , 264.It i386 265Do not skip padding to the next long word boundary for unconditional jumps. 266.It m88k 267Decode instructions for the opposite CPU model (e.g. m88110 when running on an 268m88100 processor). 269.It vax 270Don't assume that each external label is a procedure entry mask. 271.El 272.El 273.Pp 274The value of 275.Va next 276is set to the 277.Ar addr 278plus the size of the data examined. 279.\" -------------------- 280.It Xo 281.Ic print 282.Op Cm /axzodurc 283.Op Ar addr Op Ar addr ... 284.Xc 285Print each 286.Ar addr 287according to the modifier character. 288The valid modifiers are a subset of those from the 289.Ic examine 290command, and act as described there. 291If no modifier is specified, the last one specified in a 292previous use of 293.Ic print 294is used. 295The 296.Ar addr 297argument 298can be a string, and it is printed as a literal. 299.Pp 300For example, 301.Bd -literal -offset indent 302print/x "eax = " $eax "\enecx = " $ecx "\en" 303.Ed 304.Pp 305will print something like this: 306.Bd -literal -offset indent 307eax = xxxxxx 308ecx = yyyyyy 309.Ed 310.\" -------------------- 311.\" .It Xo Ic w Ns Op Cm /bhl 312.\" .Op Ar addr 313.\" .Ar expr Op expr ... 314.\" .Xc 315.It Xo 316.Ic w Ns Op Ic rite 317.Op Cm /bhl 318.Op Ar addr 319.Ar expr Op Ar expr ... 320.Xc 321Write the value of each 322.Ar expr 323expression at succeeding locations start at 324.Ar addr . 325The write unit size can be specified using one of the modifiers: 326.Pp 327.Bl -tag -width 4n -offset indent -compact 328.It Cm /b 329byte (8 bits) 330.It Cm /h 331half word (16 bits) 332.It Cm /l 333long word (32 bits) (default) 334.El 335.Pp 336The value of 337.Va next 338is set to 339.Ar addr 340plus the size of values written. 341.Pp 342.Sy Warning: 343since there is no delimiter between expressions, the 344command may not parse as you expect. 345It is best to enclose each expression in parentheses. 346.\" -------------------- 347.It Xo Ic set 348.Ic $ Ns Ar name 349.Op Ic = 350.Ar expr 351.Xc 352Set the named variable or register with the value of 353.Ar expr . 354Valid variable names are described below. 355.\" -------------------- 356.It Ic boot Ar how 357Reboot the machine depending on 358.Ar how : 359.Pp 360.Bl -tag -width "boot poweroff" -compact 361.It Ic boot sync 362Sync disks and reboot. 363.It Ic boot crash 364Dump core and reboot. 365.It Ic boot dump 366Sync disks, dump core and reboot. 367.It Ic boot halt 368Just halt. 369.It Ic boot reboot 370Just reboot. 371.It Ic boot poweroff 372Power down the machine whenever possible; if it fails, just halt. 373.El 374.\" -------------------- 375.It Xo 376.Ic break 377.Op Ar addr Ns 378.Op Ic \&, Ns Ar count 379.Xc 380Set a break point at 381.Ar addr . 382If 383.Ar count 384is supplied, 385.Nm 386allows the breakpoint to be silently hit 387.Ar ( count No \- 1 ) 388times before stopping at the 389break point. 390.Pp 391If the break point is successfully set, a break point number is 392displayed, in the form 393.Ic # Ns Ar number . 394This can later be used in deleting the break point 395or for adding conditions to it. 396.\" -------------------- 397.\" .It Xo Ic d 398.\" .Op Ar addr | Ic # Ns Ar number 399.\" .Xc 400.It Xo 401.Ic d Ns Op Ic elete 402.Op Ar addr | Ic # Ns Ar number 403.Xc 404Delete the break point set with the 405.Ic break 406command. 407.\" -------------------- 408.\" .It Xo Ic s Ns Op Cm /p 409.\" .Op Ic \&, Ns Ar count 410.\" .Xc 411.It Xo 412.Ic s Ns Op Ic tep 413.Op Cm /p 414.Op Ic \&, Ns Ar count 415.Xc 416Single step 417.Ar count 418times. 419If the 420.Cm /p 421modifier is specified, print each instruction at each step. 422Otherwise, only print the last instruction. 423.Pp 424.Sy Warning: 425depending on machine type, it may not be possible to 426single-step through some low-level code paths. 427On machines with software-emulated single-stepping (e.g., alpha), 428stepping through code executed by interrupt handlers will probably 429do the wrong thing. 430.\" -------------------- 431.It Ic call Ar name Ns Xo 432.Ic \&( Ns Ar expr 433.Op Ic \&, Ar expr ... 434.Ic \&) 435.Xc 436Call the function named by 437.Ar name 438with the argument(s) listed in parentheses. 439Parentheses may be omitted if the function takes no arguments. 440The number of arguments is currently limited to 10. 441.\" -------------------- 442.\" .It Ic c Ns Op Cm /c 443.It Xo 444.Ic c Ns Op Ic ontinue 445.Op Cm /c 446.Xc 447Continue execution until a breakpoint or watchpoint. 448If the 449.Cm /c 450modifier is given, instructions are counted while executing. 451.Pp 452.Sy Warning: 453when counting with 454.Cm /c , 455.Nm 456is really silently single-stepping. 457This means that single-stepping on low-level code may cause strange 458behavior. 459.\" -------------------- 460.It Xo 461.Ic watch 462.Ar addr 463.Op Ic \&, Ns Ar size 464.Xc 465Set a watchpoint for the region starting at 466.Ar addr . 467Execution stops and control returns to 468.Nm 469when an attempt is made to modify a watched region. 470The 471.Ar size 472argument defaults to 4. 473.Pp 474If you specify a wrong space address, the request is rejected 475with an error message. 476.Pp 477.Sy Warning: 478attempts to watch wired kernel memory 479may cause an unrecoverable error on some systems (e.g., i386). 480.\" -------------------- 481.It Ic dwatch Ar addr 482Delete the watchpoint at address 483.Ar addr 484that was previously set with a 485.Ic watch 486command. 487.\" -------------------- 488.It Xo 489.Ic hangman 490.Op Cm /s Ns Op Ic 0-9 491.Xc 492This is a tiny and handy tool for random kernel hangs analysis, of which its 493depth is controlled by the optional argument of the default value of five. 494It uses some sophisticated heuristics to spot the global symbol that 495caused the hang. 496Since the discovering algorithm is a probabilistic one, 497you may spend substantial time to figure the exact symbol name. 498This smart thing requires a little of your attention, the input it accepts 499is mostly of the same format as that of the famous 500.Xr hangman 6 501game, to which it, apparently, is obliged by the name. 502Hint: the 503.Xr nm 1 504utility might help. 505.\" -------------------- 506.It Ic until Op Cm /p 507Stop at the next 508.Qq call 509or 510.Qq return 511instruction. 512If the 513.Cm /p 514modifier is specified, 515.Nm 516prints the call nesting depth and the 517cumulative instruction count at each call or return. 518Otherwise, it stays silent until the matching return is hit. 519.\" -------------------- 520.It Ic match Op Cm /p 521Stop at the next matching return instruction. 522If the 523.Cm /p 524modifier is specified, 525.Nm 526prints the call nesting depth and the 527cumulative instruction count at each call or return. 528Otherwise, it remains mostly quiet. 529.\" -------------------- 530.It Ic next Op Cm /p 531The 532.Ic next 533command is a synonym for 534.Ic match . 535.\" -------------------- 536.It Xo 537.Ic trace 538.Op Cm /pu 539.Op Ar frameaddr Ns 540.Op Ic \&, Ns Ar count 541.Xc 542Show the stack trace. 543The 544.Cm /p 545modifier interprets the 546.Ar frameaddr 547argument as the PID of a process and shows the stack trace of 548that process. 549The 550.Cm /p 551modifier is not supported on all platforms. 552The 553.Cm /u 554modifier shows the stack trace of user space; 555if omitted, the kernel stack is traced instead. 556The 557.Ar count 558argument is the limit on the number of frames to be followed. 559If 560.Ar count 561is omitted, all frames are printed. 562.Pp 563.Sy Warning: 564user space stack trace is valid 565only if the machine dependent code supports it. 566.\" -------------------- 567.It Xo 568.Ic search 569.Op Cm /bhl 570.Op Ar addr 571.Ar value 572.Op Ar mask 573.Op Ic \&, Ns Ar count 574.Xc 575Search memory for a value beginning at 576.Ar addr . 577This command might fail in interesting 578ways if it doesn't find the searched-for value. 579This is because 580.Nm 581doesn't always recover from touching bad memory. 582The optional 583.Ar count 584argument limits the search. 585The modifiers are the same as those of the 586.Ic write 587command. 588.Pp 589The 590.Va next 591address is set to the address where 592.Ar value 593is found, or just after where the search area finishes. 594.\" -------------------- 595.It Ic show Ar what 596Displays various things, depending on 597.Ar what : 598.Bl -tag -width 4n 599.\" -------------------- 600.It Ic show bcstats 601Prints the buffer cache statistics. 602.\" -------------------- 603.It Ic show breaks 604Prints a list of all breakpoints that have been set with the 605.Ic break 606command. 607.\" -------------------- 608.It Xo 609.Ic show buf 610.Op Cm /f 611.Ar addr 612.Xc 613Prints the 614.Li struct buf 615at 616.Ar addr . 617If the 618.Cm /f 619modifier is specified output will also include 620.Li softdep 621printout, if those are available. 622.\" -------------------- 623.It Ic show extents 624Prints a detailed list of all extents. 625.\" -------------------- 626.It Ic show malloc Op Ar addr 627Prints malloc debugging information if available. 628If an optional address is specified, only information about that address 629is printed. 630.\" -------------------- 631.It Xo 632.Ic show map 633.Op Cm /f 634.Ar addr 635.Xc 636Prints the 637.Li vm_map 638at 639.Ar addr . 640If the 641.Cm /f 642modifier is specified the complete map is printed. 643.\" -------------------- 644.It Ic show mbuf Ar addr 645Prints the 646.Li struct mbuf 647header at 648.Ar addr . 649Depending on the mbuf flags 650.Li struct pkthdr 651and 652.Li struct m_ext 653are printed as well. 654.\" -------------------- 655.It Xo 656.Ic show mount 657.Op Cm /f 658.Ar addr 659.Xc 660Prints the 661.Li struct mount 662at 663.Ar addr . 664If the 665.Cm /f 666modifier is specified prints out all 667.Li vnodes 668(see also 669.Cm show vnode ) 670and also all 671.Li bufs 672(see also 673.Cm show buf ) 674on all those vnodes. 675.\" -------------------- 676.It Xo 677.Ic show nfsnode 678.Op Cm /f 679.Ar addr 680.Xc 681Prints the 682.Li struct nfsnode 683at 684.Ar addr . 685If the 686.Cm /f 687modifier is specified prints out additional 688information as well. 689.\" -------------------- 690.It Xo 691.Ic show nfsreq 692.Op Cm /f 693.Ar addr 694.Xc 695Prints the 696.Li struct nfsreq 697at 698.Ar addr . 699If the 700.Cm /f 701modifier is specified prints out additional 702information as well. 703.\" -------------------- 704.It Xo 705.Ic show object 706.Op Cm /f 707.Ar addr 708.Xc 709Prints the 710.Li vm_object 711at 712.Ar addr . 713If the 714.Cm /f 715modifier is specified the complete object is printed. 716.\" -------------------- 717.It Xo 718.Ic show offset 719.Ar offset 720.Xc 721Prints a list of the known kernel structure fields which occur at the given 722.Ar offset 723from the beginning of the struct, as well as their size. 724The 725.Cm option DDB_STRUCT 726is required for this command to be available. 727.\" -------------------- 728.It Xo 729.Ic show page 730.Op Cm /f 731.Ar addr 732.Xc 733Prints the 734.Li vm_page 735at 736.Ar addr . 737If the 738.Cm /f 739modifier is specified the complete page is printed. 740.\" -------------------- 741.It Ic show panic 742Prints the panic string. 743.\" -------------------- 744.It Xo 745.Ic show pool 746.Op Cm /p 747.Ar addr 748.Xc 749Prints the 750.Li pool 751at 752.Ar addr . 753Valid modifiers: 754.Bl -tag -width xxx -compact 755.It Cm /p 756Print the pagelist for this pool. 757.El 758.\" -------------------- 759.It Ic show proc Op Ar addr 760Prints the 761.Li struct proc 762at 763.Ar addr . 764If an optional address is not specified 765.Li curproc 766is assumed. 767.\" -------------------- 768.It Ic show registers Op Cm /u 769Display the register set. 770If the 771.Cm /u 772modifier is specified, it displays user registers (or the currently 773saved registers) instead of the kernel's. 774Note: The 775.Cm /u 776modifier is not supported on every machine, in which case 777incorrect information may be displayed. 778.\" -------------------- 779.It Xo 780.Ic show struct 781.Ar name 782.Op addr 783.Xc 784Prints the content of the memory at 785.Ar addr 786as a struct 787.Ar name . 788Nested structures and bit fields are not printed. 789Character arrays are printed as bytes. 790The 791.Cm option DDB_STRUCT 792is required for this command to be available. 793.\" -------------------- 794.It Ic show uvmexp 795Displays a selection of uvm counters and statistics. 796.\" -------------------- 797.It Xo 798.Ic show vnode 799.Op Cm /f 800.Ar addr 801.Xc 802Prints the 803.Li struct vnode 804at 805.Ar addr . 806If the 807.Cm /f 808modifier is specified prints out all 809.Li bufs 810(see also 811.Cm show buf ) 812currently attached to this 813.Li vnode . 814.\" -------------------- 815.It Ic show watches 816Displays all watchpoints set with the 817.Ic watch 818command. 819.\" -------------------- 820.It Ic show all procs Op Cm /anw 821Display information on all processes. 822.Pp 823.Bl -tag -width foo -compact 824.It Cm /n 825(Default) Show process information in a 826.Xr ps 1 Ns \&-like 827format. 828Information printed includes process ID, parent 829process ID, process group, UID, process status, process flags, process 830command name, and process wait channel message. 831.It Cm /a 832Shows the kernel virtual addresses of each process' 833proc structure, u-area, and vmspace structure. 834The vmspace address is also the address of the process' 835.Li vm_map 836structure 837and can be used in the 838.Ic show map 839command. 840.It Cm /w 841Shows each process' PID, command, system call emulation, 842wait channel address, and wait channel message. 843.El 844.\" -------------------- 845.It Ic show all bufs Op Cm /f 846Display information about all buffers in the system. 847.Pp 848.Bl -tag -width foo -compact 849.It Cm /f 850For each buffer, print a more detailed output. 851See the 852.Ic show buf 853command for more information. 854.El 855.\" -------------------- 856.It Ic show all callout 857Display the contents of the callout table. 858.\" -------------------- 859.It Ic show all pools Op Cm /a 860Display information about all system pools in a format similar to 861.Xr vmstat 8 . 862.Pp 863.Bl -tag -width foo -compact 864.It Cm /a 865Displays 866.Dq interesting 867address information. 868.El 869.\" -------------------- 870.It Ic show all mounts Op Cm /f 871Display information on all mounted filesystems. 872.Pp 873.Bl -tag -width foo -compact 874.It Cm /f 875For each filesystem, list all its struct vnode addresses. 876These addresses can be used in the 877.Ic show vnode 878command. 879.El 880.\" -------------------- 881.It Ic show all nfsnodes Op Cm /f 882Display information about all nfsnodes in the system. 883.Pp 884.Bl -tag -width foo -compact 885.It Cm /f 886For each nfsnode, print a more detailed output. 887See the 888.Ic show nfsnode 889command for more information. 890.El 891.\" -------------------- 892.It Ic show all nfsreqs Op Cm /f 893Display information for all outstanding NFS requests. 894.Pp 895.Bl -tag -width foo -compact 896.It Cm /f 897For each NFS requests, print a more detailed output. 898See the 899.Ic show nfsreq 900command for more information. 901.El 902.\" -------------------- 903.It Ic show all vnodes Op Cm /f 904Display information about all vnodes in the system. 905.Pp 906.Bl -tag -width foo -compact 907.It Cm /f 908For each vnode, print a more detailed output. 909See the 910.Ic show vnode 911command for more information. 912.El 913.El 914.\" -------------------- 915.It Ic callout 916A synonym for the 917.Ic show all callout 918command. 919.\" -------------------- 920.It Ic ps Op Cm /anw 921A synonym for 922.Ic show all procs . 923.\" -------------------- 924.It Xo 925.Ic mac Ns Op Ic hine 926.Ar subcommand Op Ar args ... 927.Xc 928Perform a platform-specific command. 929.Pp 930The following commands are supported by multiprocessor kernels on 931these platforms: amd64, i386, macppc, and mips64. 932.Pp 933.Bl -tag -width "searchframe [addr]" -compact 934.It Ic cpuinfo 935Display the state of each CPU. 936.It Ic ddbcpu Ar N 937Stop the current CPU and start handling 938.Nm 939on the selected CPU. 940.It Ic startcpu Op Ar N 941Resume normal processing on the selected CPU, 942or all CPUs if none is specified. 943.It Ic stopcpu Op Ar N 944Stop normal processing on the selected CPU, 945or all CPUs (except the one handling 946.Nm ) 947if none is specified. 948.El 949.Pp 950Other platform-specific commands: 951.\" .Pp 952.\" amd64: 953.Pp 954arm: 955.Bl -tag -width "searchframe [addr]" -compact 956.It Ic frame Ar addr 957Display the trapframe at 958.Ar addr . 959.El 960.Pp 961i386: 962.Bl -tag -width "searchframe [addr]" -compact 963.\" .It Ic acpi disasm Ar ?? 964.\" .It Ic acpi showval Ar ?? 965.\" .It Ic acpi tree Ar ?? 966.\" .It Ic acpi trace Ar ?? 967.\" Evil ACPI debugging magic. 968.It Ic sysregs 969Display the contents of the privileged registers: 970.Va IDTR , 971.Va GDTR , 972.Va LDTR , 973.Va TR , 974.Va CR0 , 975.Va CR2 , 976.Va CR3 , 977and 978.Va CR4 . 979.\" (i386-only) 980.El 981.Pp 982m88k: 983.Bl -tag -width "searchframe [addr]" -compact 984.It Ic ddbcpu Ar N 985Stop the current CPU and start handling 986.Nm 987on the selected CPU. 988.It Ic frame Ar addr 989Display the trapframe at 990.Ar addr . 991.It Ic regs 992Display the registers from when 993.Nm 994was entered. 995.It Ic searchframe Op Ar addr 996Search for and display stack exception frames, 997starting from 998.Ar addr 999if given, else the address in register 1000.Va r31 , 1001and stopping at the next 8k boundary. 1002.It Ic where 1003Display where the current CPU was stopped. 1004.El 1005.Pp 1006mips64: 1007.Bl -tag -width "searchframe [addr]" -compact 1008.It Xo 1009.Ic tlb Op Cm /p Ar asid 1010.Op Cm /c 1011.Op Ar tlb 1012.Xc 1013.It Ic trap Ar ?? 1014.El 1015.Pp 1016sh: 1017.Bl -tag -width "searchframe [addr]" -compact 1018.It Ic cache Op Ar addr 1019Display the cache, starting from 1020.Ar addr , 1021defaulting to 0. 1022.It Ic frame 1023Display the switch and trap frames. 1024.\" .It Ic stack 1025.It Ic tlb 1026Display the TLB. 1027.El 1028.Pp 1029sparc: 1030.Bl -tag -width "searchframe [addr]" -compact 1031.It Ic proc Ar ?? 1032.El 1033.Pp 1034sparc64: 1035.Bl -tag -width "searchframe [addr]" -compact 1036.It Ic ctx 1037Display the context addresses for all threads. 1038.\" .It Ic dtlb Ar 0,2 1039.\" .It Ic dtsb 1040.\" .It Ic esp 1041.\" .It Ic fpstate Op Ar addr 1042.\" .It Ic itlb Ar 0,1,2 1043.\" .It Ic kmap Op Ar addr 1044.\" .It Ic pcb Op Ar addr 1045.\" .It Ic pctx Ar pid 1046.\" .It Ic page Ar addr 1047.\" .It Ic phys Op Ar addr 1048.\" .It Ic pmap Op Ar addr 1049.\" .It Ic proc Op Ar addr 1050.\" .It Ic prom Ar ?? 1051.\" .It Ic pv Ar addr 1052.\" .It Ic stack Op Ar addr 1053.\" .It Ic tf Op Ar addr 1054.\" .It Ic ts 1055.\" .It Ic traptrace Op Ar addr 1056.\" .It Ic watch Op Ar addr 1057.\" .It Ic window Op Ar winnum 1058.\" .It Ic xir Op Ar addr 1059.El 1060.\" -------------------- 1061.El 1062.Sh VARIABLES 1063.Nm 1064denotes registers and variables by 1065.Ic $ Ns Va name . 1066Register names can be found with the 1067.Ic show registers 1068command. 1069.Pp 1070Some variable names are suffixed with numbers, and some may have a modifier 1071following a colon immediately after the variable name. 1072For example, register variables can have the 1073.Ql :u 1074modifier to indicate a 1075user register (e.g., 1076.Ql $eax:u ) . 1077.Pp 1078Built-in debugger variables currently supported are: 1079.Bl -tag -width 10n -compact -offset indent 1080.It Va $radix 1081Input and output radix. 1082.It Va $maxoff 1083Addresses are printed as 1084.Ar symbol Ns Li + Ns Ar offset 1085unless 1086.Ar offset 1087is greater than 1088.Va $maxoff . 1089.It Va $maxwidth 1090The width of the displayed lines. 1091.It Va $lines 1092The number of lines to page. 1093This is used by the 1094.Dq more 1095feature. 1096.It Va $tabstops 1097Tab stop width. 1098.It Va $log 1099Controls whether the output of 1100.Nm 1101will also appear in the system message 1102buffer. 1103.El 1104.Pp 1105These variables can also be controlled outside 1106.Nm 1107via the 1108.Sq ddb 1109.Xr sysctl 8 1110hierarchy. 1111.Sh EXPRESSIONS 1112Almost all expression operators in C are supported except for 1113.Ql ~ , 1114.Ql ^ , 1115and unary 1116.Ql & . 1117Special rules for expressions in 1118.Nm 1119are: 1120.Bl -tag -width 15n -compact -offset indent 1121.It Ar identifier 1122The name of a symbol. 1123It is translated to the address (or value) of the symbol. 1124.Ql \&. 1125and 1126.Ql \&: 1127can be used in the identifier. 1128The following can be accepted as an identifier, 1129if supported by an object format dependent routine: 1130.Bl -item -offset indent -compact 1131.It 1132.Sm off 1133.Oo Ar filename Li \&: Oc Ar func 1134.Op \&: Ar linenumber 1135.It 1136.Op Ar filename \&: 1137.Ar variable 1138.It 1139.Ar filename 1140.Op \&: Ar linenumber 1141.Sm on 1142.El 1143The symbol may be prefixed with 1144.Sq Ar symboltablename Ns :: 1145(e.g., 1146.Ql emulator::mach_msg_trap ) 1147to specify other than kernel symbols. 1148.It Ar number 1149The radix is determined by the first two letters: 1150.Ql 0x : 1151hex, 1152.Ql 0o : 1153octal, 1154.Ql 0t : 1155decimal, otherwise, the value of 1156.Va $radix 1157is used. 1158.It Li \&. 1159.Va dot : 1160the current address. 1161.It Li + 1162.Va next : 1163the next address. 1164.It Li .. 1165The address of the start of the last line examined. 1166Unlike 1167.Va dot 1168or 1169.Va next , 1170this is only changed by the 1171.Ic examine 1172or 1173.Ic write 1174command. 1175.It Li ' 1176The last address explicitly specified. 1177.It Li $ Ns Ar variable 1178The value of a register or variable. 1179The name may be followed by a 1180.Ql \&: 1181and modifiers as described above with 1182.Ar identifier . 1183.It Ar expr Li # Ar expr 1184A binary operator which rounds up the left hand side to the next 1185multiple of right hand side. 1186.It Li * Ns Ar expr 1187Indirection. 1188It may be followed by a ':' and modifiers as described above. 1189.El 1190.Sh SEE ALSO 1191.Xr gdb 1 , 1192.Xr nm 1 , 1193.Xr sysctl.conf 5 , 1194.Xr hangman 6 , 1195.Xr kgdb 7 , 1196.Xr crash 8 , 1197.Xr sysctl 8 , 1198.Xr extent 9 , 1199.Xr pool 9 , 1200.Xr uvm 9 1201.Sh HISTORY 1202This kernel facility first appeared in the MACH 2 operating system 1203developed by CMU. 1204Hangman (which stands for "hangs maniacal analyzer") first appeared in 1205.Ox 1.2 . 1206