1.\" $OpenBSD: ddb.4,v 1.82 2016/09/01 12:24:56 jmc 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: September 1 2016 $ 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> 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> 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.El 270.El 271.Pp 272The value of 273.Va next 274is set to the 275.Ar addr 276plus the size of the data examined. 277.\" -------------------- 278.It Xo 279.Ic print 280.Op Cm /axzodurc 281.Op Ar addr Op Ar addr ... 282.Xc 283Print each 284.Ar addr 285according to the modifier character. 286The valid modifiers are a subset of those from the 287.Ic examine 288command, and act as described there. 289If no modifier is specified, the last one specified in a 290previous use of 291.Ic print 292is used. 293The 294.Ar addr 295argument 296can be a string, and it is printed as a literal. 297.Pp 298For example, 299.Bd -literal -offset indent 300print/x "eax = " $eax "\enecx = " $ecx "\en" 301.Ed 302.Pp 303will print something like this: 304.Bd -literal -offset indent 305eax = xxxxxx 306ecx = yyyyyy 307.Ed 308.\" -------------------- 309.\" .It Xo Ic w Ns Op Cm /bhl 310.\" .Op Ar addr 311.\" .Ar expr Op expr ... 312.\" .Xc 313.It Xo 314.Ic w Ns Op Ic rite 315.Op Cm /bhl 316.Op Ar addr 317.Ar expr Op Ar expr ... 318.Xc 319Write the value of each 320.Ar expr 321expression at succeeding locations start at 322.Ar addr . 323The write unit size can be specified using one of the modifiers: 324.Pp 325.Bl -tag -width 4n -offset indent -compact 326.It Cm /b 327byte (8 bits) 328.It Cm /h 329half word (16 bits) 330.It Cm /l 331long word (32 bits) (default) 332.El 333.Pp 334The value of 335.Va next 336is set to 337.Ar addr 338plus the size of values written. 339.Pp 340.Sy Warning: 341since there is no delimiter between expressions, the 342command may not parse as you expect. 343It is best to enclose each expression in parentheses. 344.\" -------------------- 345.It Xo Ic set 346.Ic $ Ns Ar name 347.Op Ic = 348.Ar expr 349.Xc 350Set the named variable or register with the value of 351.Ar expr . 352Valid variable names are described below. 353.\" -------------------- 354.It Ic boot Ar how 355Reboot the machine depending on 356.Ar how : 357.Pp 358.Bl -tag -width "boot poweroff" -compact 359.It Ic boot sync 360Sync disks and reboot. 361.It Ic boot crash 362Dump core and reboot. 363.It Ic boot dump 364Sync disks, dump core and reboot. 365.It Ic boot halt 366Just halt. 367.It Ic boot reboot 368Just reboot. 369.It Ic boot poweroff 370Power down the machine whenever possible; if it fails, just halt. 371.El 372.\" -------------------- 373.It Xo 374.Ic break 375.Op Ar addr Ns 376.Op Ic \&, Ns Ar count 377.Xc 378Set a break point at 379.Ar addr . 380If 381.Ar count 382is supplied, 383.Nm 384allows the breakpoint to be silently hit 385.Ar ( count No \- 1 ) 386times before stopping at the 387break point. 388.Pp 389If the break point is successfully set, a break point number is 390displayed, in the form 391.Ic # Ns Ar number . 392This can later be used in deleting the break point 393or for adding conditions to it. 394.\" -------------------- 395.\" .It Xo Ic d 396.\" .Op Ar addr | Ic # Ns Ar number 397.\" .Xc 398.It Xo 399.Ic d Ns Op Ic elete 400.Op Ar addr | Ic # Ns Ar number 401.Xc 402Delete the break point set with the 403.Ic break 404command. 405.\" -------------------- 406.\" .It Xo Ic s Ns Op Cm /p 407.\" .Op Ic \&, Ns Ar count 408.\" .Xc 409.It Xo 410.Ic s Ns Op Ic tep 411.Op Cm /p 412.Op Ic \&, Ns Ar count 413.Xc 414Single step 415.Ar count 416times. 417If the 418.Cm /p 419modifier is specified, print each instruction at each step. 420Otherwise, only print the last instruction. 421.Pp 422.Sy Warning: 423depending on machine type, it may not be possible to 424single-step through some low-level code paths. 425On machines with software-emulated single-stepping (e.g., alpha), 426stepping through code executed by interrupt handlers will probably 427do the wrong thing. 428.\" -------------------- 429.It Ic call Ar name Ns Xo 430.Ic \&( Ns Ar expr 431.Op Ic \&, Ar expr ... 432.Ic \&) 433.Xc 434Call the function named by 435.Ar name 436with the argument(s) listed in parentheses. 437Parentheses may be omitted if the function takes no arguments. 438The number of arguments is currently limited to 10. 439.\" -------------------- 440.\" .It Ic c Ns Op Cm /c 441.It Xo 442.Ic c Ns Op Ic ontinue 443.Op Cm /c 444.Xc 445Continue execution until a breakpoint or watchpoint. 446If the 447.Cm /c 448modifier is given, instructions are counted while executing. 449.Pp 450.Sy Warning: 451when counting with 452.Cm /c , 453.Nm 454is really silently single-stepping. 455This means that single-stepping on low-level code may cause strange 456behavior. 457.\" -------------------- 458.It Xo 459.Ic watch 460.Ar addr 461.Op Ic \&, Ns Ar size 462.Xc 463Set a watchpoint for the region starting at 464.Ar addr . 465Execution stops and control returns to 466.Nm 467when an attempt is made to modify a watched region. 468The 469.Ar size 470argument defaults to 4. 471.Pp 472If you specify a wrong space address, the request is rejected 473with an error message. 474.Pp 475.Sy Warning: 476attempts to watch wired kernel memory 477may cause an unrecoverable error on some systems (e.g., i386). 478.\" -------------------- 479.It Ic dwatch Ar addr 480Delete the watchpoint at address 481.Ar addr 482that was previously set with a 483.Ic watch 484command. 485.\" -------------------- 486.It Xo 487.Ic hangman 488.Op Cm /s Ns Op Ic 0-9 489.Xc 490This is a tiny and handy tool for random kernel hangs analysis, of which its 491depth is controlled by the optional argument of the default value of five. 492It uses some sophisticated heuristics to spot the global symbol that 493caused the hang. 494Since the discovering algorithm is a probabilistic one, 495you may spend substantial time to figure the exact symbol name. 496This smart thing requires a little of your attention, the input it accepts 497is mostly of the same format as that of the famous 498.Xr hangman 6 499game, to which it, apparently, is obliged by the name. 500Hint: the 501.Xr nm 1 502utility might help. 503.\" -------------------- 504.It Ic until Op Cm /p 505Stop at the next 506.Qq call 507or 508.Qq return 509instruction. 510If the 511.Cm /p 512modifier is specified, 513.Nm 514prints the call nesting depth and the 515cumulative instruction count at each call or return. 516Otherwise, it stays silent until the matching return is hit. 517.\" -------------------- 518.It Ic match Op Cm /p 519Stop at the next matching return instruction. 520If the 521.Cm /p 522modifier is specified, 523.Nm 524prints the call nesting depth and the 525cumulative instruction count at each call or return. 526Otherwise, it remains mostly quiet. 527.\" -------------------- 528.It Ic next Op Cm /p 529The 530.Ic next 531command is a synonym for 532.Ic match . 533.\" -------------------- 534.It Xo 535.Ic trace 536.Op Cm /pu 537.Op Ar frameaddr Ns 538.Op Ic \&, Ns Ar count 539.Xc 540Show the stack trace. 541The 542.Cm /p 543modifier interprets the 544.Ar frameaddr 545argument as the PID of a process and shows the stack trace of 546that process. 547The 548.Cm /p 549modifier is not supported on all platforms. 550The 551.Cm /u 552modifier shows the stack trace of user space; 553if omitted, the kernel stack is traced instead. 554The 555.Ar count 556argument is the limit on the number of frames to be followed. 557If 558.Ar count 559is omitted, all frames are printed. 560.Pp 561.Sy Warning: 562user space stack trace is valid 563only if the machine dependent code supports it. 564.\" -------------------- 565.It Xo 566.Ic search 567.Op Cm /bhl 568.Op Ar addr 569.Ar value 570.Op Ar mask 571.Op Ic \&, Ns Ar count 572.Xc 573Search memory for a value beginning at 574.Ar addr . 575This command might fail in interesting 576ways if it doesn't find the searched-for value. 577This is because 578.Nm 579doesn't always recover from touching bad memory. 580The optional 581.Ar count 582argument limits the search. 583The modifiers are the same as those of the 584.Ic write 585command. 586.Pp 587The 588.Va next 589address is set to the address where 590.Ar value 591is found, or just after where the search area finishes. 592.\" -------------------- 593.It Ic show Ar what 594Displays various things, depending on 595.Ar what : 596.Bl -tag -width 4n 597.\" -------------------- 598.It Ic show bcstats 599Prints the buffer cache statistics. 600.\" -------------------- 601.It Ic show breaks 602Prints a list of all breakpoints that have been set with the 603.Ic break 604command. 605.\" -------------------- 606.It Xo 607.Ic show buf 608.Op Cm /f 609.Ar addr 610.Xc 611Prints the 612.Li struct buf 613at 614.Ar addr . 615If the 616.Cm /f 617modifier is specified output will also include 618.Li softdep 619printout, if those are available. 620.\" -------------------- 621.It Ic show extents 622Prints a detailed list of all extents. 623.\" -------------------- 624.It Ic show malloc Op Ar addr 625Prints malloc debugging information if available. 626If an optional address is specified, only information about that address 627is printed. 628.\" -------------------- 629.It Xo 630.Ic show map 631.Op Cm /f 632.Ar addr 633.Xc 634Prints the 635.Li vm_map 636at 637.Ar addr . 638If the 639.Cm /f 640modifier is specified the complete map is printed. 641.\" -------------------- 642.It Ic show mbuf Ar addr 643Prints the 644.Li struct mbuf 645header at 646.Ar addr . 647Depending on the mbuf flags 648.Li struct pkthdr 649and 650.Li struct m_ext 651are printed as well. 652.\" -------------------- 653.It Xo 654.Ic show mount 655.Op Cm /f 656.Ar addr 657.Xc 658Prints the 659.Li struct mount 660at 661.Ar addr . 662If the 663.Cm /f 664modifier is specified prints out all 665.Li vnodes 666(see also 667.Cm show vnode ) 668and also all 669.Li bufs 670(see also 671.Cm show buf ) 672on all those vnodes. 673.\" -------------------- 674.It Xo 675.Ic show nfsnode 676.Op Cm /f 677.Ar addr 678.Xc 679Prints the 680.Li struct nfsnode 681at 682.Ar addr . 683If the 684.Cm /f 685modifier is specified prints out additional 686information as well. 687.\" -------------------- 688.It Xo 689.Ic show nfsreq 690.Op Cm /f 691.Ar addr 692.Xc 693Prints the 694.Li struct nfsreq 695at 696.Ar addr . 697If the 698.Cm /f 699modifier is specified prints out additional 700information as well. 701.\" -------------------- 702.It Xo 703.Ic show object 704.Op Cm /f 705.Ar addr 706.Xc 707Prints the 708.Li vm_object 709at 710.Ar addr . 711If the 712.Cm /f 713modifier is specified the complete object is printed. 714.\" -------------------- 715.It Xo 716.Ic show offset 717.Ar offset 718.Xc 719Prints a list of the known kernel structure fields which occur at the given 720.Ar offset 721from the beginning of the struct, as well as their size. 722The 723.Cm option DDB_STRUCT 724is required for this command to be available. 725.\" -------------------- 726.It Xo 727.Ic show page 728.Op Cm /f 729.Ar addr 730.Xc 731Prints the 732.Li vm_page 733at 734.Ar addr . 735If the 736.Cm /f 737modifier is specified the complete page is printed. 738.\" -------------------- 739.It Ic show panic 740Prints the panic string. 741.\" -------------------- 742.It Xo 743.Ic show pool 744.Op Cm /p 745.Ar addr 746.Xc 747Prints the 748.Li pool 749at 750.Ar addr . 751Valid modifiers: 752.Bl -tag -width xxx -compact 753.It Cm /p 754Print the pagelist for this pool. 755.El 756.\" -------------------- 757.It Ic show proc Op Ar addr 758Prints the 759.Li struct proc 760at 761.Ar addr . 762If an optional address is not specified 763.Li curproc 764is assumed. 765.\" -------------------- 766.It Ic show registers Op Cm /u 767Display the register set. 768If the 769.Cm /u 770modifier is specified, it displays user registers (or the currently 771saved registers) instead of the kernel's. 772Note: The 773.Cm /u 774modifier is not supported on every machine, in which case 775incorrect information may be displayed. 776.\" -------------------- 777.It Ic show socket Ar addr 778Prints the 779.Li struct socket 780at 781.Ar addr . 782If the socket is spliced, the 783.Li struct sosplice 784associated with the socket is printed as well. 785.\" -------------------- 786.It Xo 787.Ic show struct 788.Ar name 789.Op addr 790.Xc 791Prints the content of the memory at 792.Ar addr 793as a struct 794.Ar name . 795Nested structures and bit fields are not printed. 796Character arrays are printed as bytes. 797The 798.Cm option DDB_STRUCT 799is required for this command to be available. 800.\" -------------------- 801.It Ic show uvmexp 802Displays a selection of uvm counters and statistics. 803.\" -------------------- 804.It Xo 805.Ic show vnode 806.Op Cm /f 807.Ar addr 808.Xc 809Prints the 810.Li struct vnode 811at 812.Ar addr . 813If the 814.Cm /f 815modifier is specified prints out all 816.Li bufs 817(see also 818.Cm show buf ) 819currently attached to this 820.Li vnode . 821.\" -------------------- 822.It Ic show watches 823Displays all watchpoints set with the 824.Ic watch 825command. 826.\" -------------------- 827.It Ic show all procs Op Cm /anow 828Display information on all processes. 829.Pp 830.Bl -tag -width foo -compact 831.It Cm /n 832(Default) Show process information in a 833.Xr ps 1 Ns \&-like 834format. 835Information printed includes thread ID, parent 836process ID, process group, UID, process status, process flags, process 837command name, and process wait channel message. 838.It Cm /a 839Shows the kernel virtual addresses of each process' 840proc structure, u-area, and vmspace structure. 841The vmspace address is also the address of the process' 842.Li vm_map 843structure 844and can be used in the 845.Ic show map 846command. 847.It Cm /o 848Shows non-idle threads that were on CPU when ddb was entered. 849Information printed includes thread ID, process ID, UID, process flags, 850thread flags, current CPU, and command name. 851.It Cm /w 852Shows each thread's ID, command, system call emulation, 853wait channel address, and wait channel message. 854.El 855.\" -------------------- 856.It Ic show all bufs Op Cm /f 857Display information about all buffers in the system. 858.Pp 859.Bl -tag -width foo -compact 860.It Cm /f 861For each buffer, print a more detailed output. 862See the 863.Ic show buf 864command for more information. 865.El 866.\" -------------------- 867.It Ic show all callout 868Display the contents of the callout table. 869.\" -------------------- 870.It Ic show all pools Op Cm /a 871Display information about all system pools in a format similar to 872.Xr vmstat 8 . 873.Pp 874.Bl -tag -width foo -compact 875.It Cm /a 876Displays 877.Dq interesting 878address information. 879.El 880.\" -------------------- 881.It Ic show all mounts Op Cm /f 882Display information on all mounted filesystems. 883.Pp 884.Bl -tag -width foo -compact 885.It Cm /f 886For each filesystem, list all its struct vnode addresses. 887These addresses can be used in the 888.Ic show vnode 889command. 890.El 891.\" -------------------- 892.It Ic show all nfsnodes Op Cm /f 893Display information about all nfsnodes in the system. 894.Pp 895.Bl -tag -width foo -compact 896.It Cm /f 897For each nfsnode, print a more detailed output. 898See the 899.Ic show nfsnode 900command for more information. 901.El 902.\" -------------------- 903.It Ic show all nfsreqs Op Cm /f 904Display information for all outstanding NFS requests. 905.Pp 906.Bl -tag -width foo -compact 907.It Cm /f 908For each NFS requests, print a more detailed output. 909See the 910.Ic show nfsreq 911command for more information. 912.El 913.\" -------------------- 914.It Ic show all vnodes Op Cm /f 915Display information about all vnodes in the system. 916.Pp 917.Bl -tag -width foo -compact 918.It Cm /f 919For each vnode, print a more detailed output. 920See the 921.Ic show vnode 922command for more information. 923.El 924.El 925.\" -------------------- 926.It Ic callout 927A synonym for the 928.Ic show all callout 929command. 930.\" -------------------- 931.It Ic ps Op Cm /anw 932A synonym for 933.Ic show all procs . 934.\" -------------------- 935.It Xo 936.Ic mac Ns Op Ic hine 937.Ar subcommand Op Ar args ... 938.Xc 939Perform a platform-specific command. 940.Pp 941The following commands are supported by multiprocessor kernels on 942these platforms: amd64, i386, macppc, mips64, and sparc64. 943.Pp 944.Bl -tag -width "searchframe [addr]" -compact 945.It Ic cpuinfo 946Display the state of each CPU. 947.It Ic ddbcpu Ar N 948Stop the current CPU and start handling 949.Nm 950on the selected CPU. 951.It Ic startcpu Op Ar N 952Resume normal processing on the selected CPU, 953or all CPUs if none is specified. 954.It Ic stopcpu Op Ar N 955Stop normal processing on the selected CPU, 956or all CPUs (except the one handling 957.Nm ) 958if none is specified. 959.El 960.Pp 961Other platform-specific commands: 962.\" .Pp 963.\" amd64: 964.Pp 965arm: 966.Bl -tag -width "searchframe [addr]" -compact 967.It Ic frame Ar addr 968Display the trapframe at 969.Ar addr . 970.El 971.Pp 972i386: 973.Bl -tag -width "searchframe [addr]" -compact 974.\" .It Ic acpi disasm Ar ?? 975.\" .It Ic acpi showval Ar ?? 976.\" .It Ic acpi tree Ar ?? 977.\" .It Ic acpi trace Ar ?? 978.\" Evil ACPI debugging magic. 979.It Ic sysregs 980Display the contents of the privileged registers: 981.Va IDTR , 982.Va GDTR , 983.Va LDTR , 984.Va TR , 985.Va CR0 , 986.Va CR2 , 987.Va CR3 , 988and 989.Va CR4 . 990.\" (i386-only) 991.El 992.Pp 993m88k: 994.Bl -tag -width "searchframe [addr]" -compact 995.It Ic ddbcpu Ar N 996Stop the current CPU and start handling 997.Nm 998on the selected CPU. 999.It Ic frame Ar addr 1000Display the trapframe at 1001.Ar addr . 1002.It Ic regs 1003Display the registers from when 1004.Nm 1005was entered. 1006.It Ic searchframe Op Ar addr 1007Search for and display stack exception frames, 1008starting from 1009.Ar addr 1010if given, else the address in register 1011.Va r31 , 1012and stopping at the next 8k boundary. 1013.It Ic where 1014Display where the current CPU was stopped. 1015.El 1016.Pp 1017mips64: 1018.Bl -tag -width "searchframe [addr]" -compact 1019.It Xo 1020.Ic tlb Op Cm /p Ar asid 1021.Op Cm /c 1022.Op Ar tlb 1023.Xc 1024.It Ic trap Ar ?? 1025.El 1026.Pp 1027sh: 1028.Bl -tag -width "searchframe [addr]" -compact 1029.It Ic cache Op Ar addr 1030Display the cache, starting from 1031.Ar addr , 1032defaulting to 0. 1033.It Ic frame 1034Display the switch and trap frames. 1035.\" .It Ic stack 1036.It Ic tlb 1037Display the TLB. 1038.El 1039.Pp 1040sparc64: 1041.Bl -tag -width "searchframe [addr]" -compact 1042.It Ic ctx 1043Display the context addresses for all threads. 1044.\" .It Ic dtlb Ar 0,2 1045.\" .It Ic dtsb 1046.\" .It Ic esp 1047.\" .It Ic fpstate Op Ar addr 1048.\" .It Ic itlb Ar 0,1,2 1049.\" .It Ic kmap Op Ar addr 1050.\" .It Ic pcb Op Ar addr 1051.\" .It Ic pctx Ar pid 1052.\" .It Ic page Ar addr 1053.\" .It Ic phys Op Ar addr 1054.\" .It Ic pmap Op Ar addr 1055.\" .It Ic proc Op Ar addr 1056.\" .It Ic prom Ar ?? 1057.\" .It Ic pv Ar addr 1058.\" .It Ic stack Op Ar addr 1059.\" .It Ic tf Op Ar addr 1060.\" .It Ic ts 1061.\" .It Ic traptrace Op Ar addr 1062.\" .It Ic watch Op Ar addr 1063.\" .It Ic window Op Ar winnum 1064.\" .It Ic xir Op Ar addr 1065.El 1066.\" -------------------- 1067.El 1068.Sh VARIABLES 1069.Nm 1070denotes registers and variables by 1071.Ic $ Ns Va name . 1072Register names can be found with the 1073.Ic show registers 1074command. 1075.Pp 1076Some variable names are suffixed with numbers, and some may have a modifier 1077following a colon immediately after the variable name. 1078For example, register variables can have the 1079.Ql :u 1080modifier to indicate a 1081user register (e.g., 1082.Ql $eax:u ) . 1083.Pp 1084Built-in debugger variables currently supported are: 1085.Bl -tag -width 10n -compact -offset indent 1086.It Va $radix 1087Input and output radix. 1088.It Va $maxoff 1089Addresses are printed as 1090.Ar symbol Ns Li + Ns Ar offset 1091unless 1092.Ar offset 1093is greater than 1094.Va $maxoff . 1095.It Va $maxwidth 1096The width of the displayed lines. 1097.It Va $lines 1098The number of lines to page. 1099This is used by the 1100.Dq more 1101feature. 1102.It Va $tabstops 1103Tab stop width. 1104.It Va $log 1105Controls whether the output of 1106.Nm 1107will also appear in the system message 1108buffer. 1109.El 1110.Pp 1111These variables can also be controlled outside 1112.Nm 1113via the 1114.Sq ddb 1115.Xr sysctl 8 1116hierarchy. 1117.Sh EXPRESSIONS 1118Almost all expression operators in C are supported except for 1119.Ql ~ , 1120.Ql ^ , 1121and unary 1122.Ql & . 1123Special rules for expressions in 1124.Nm 1125are: 1126.Bl -tag -width 15n -compact -offset indent 1127.It Ar identifier 1128The name of a symbol. 1129It is translated to the address (or value) of the symbol. 1130.Ql \&. 1131and 1132.Ql \&: 1133can be used in the identifier. 1134The following can be accepted as an identifier, 1135if supported by an object format dependent routine: 1136.Bl -item -offset indent -compact 1137.It 1138.Sm off 1139.Oo Ar filename Li \&: Oc Ar func 1140.Op \&: Ar linenumber 1141.It 1142.Op Ar filename \&: 1143.Ar variable 1144.It 1145.Ar filename 1146.Op \&: Ar linenumber 1147.Sm on 1148.El 1149The symbol may be prefixed with 1150.Sq Ar symboltablename Ns :: 1151(e.g., 1152.Ql emulator::mach_msg_trap ) 1153to specify other than kernel symbols. 1154.It Ar number 1155The radix is determined by the first two letters: 1156.Ql 0x : 1157hex, 1158.Ql 0o : 1159octal, 1160.Ql 0t : 1161decimal, otherwise, the value of 1162.Va $radix 1163is used. 1164.It Li \&. 1165.Va dot : 1166the current address. 1167.It Li + 1168.Va next : 1169the next address. 1170.It Li .. 1171The address of the start of the last line examined. 1172Unlike 1173.Va dot 1174or 1175.Va next , 1176this is only changed by the 1177.Ic examine 1178or 1179.Ic write 1180command. 1181.It Li ' 1182The last address explicitly specified. 1183.It Li $ Ns Ar variable 1184The value of a register or variable. 1185The name may be followed by a 1186.Ql \&: 1187and modifiers as described above with 1188.Ar identifier . 1189.It Ar expr Li # Ar expr 1190A binary operator which rounds up the left hand side to the next 1191multiple of right hand side. 1192.It Li * Ns Ar expr 1193Indirection. 1194It may be followed by a ':' and modifiers as described above. 1195.El 1196.Sh SEE ALSO 1197.Xr gdb 1 , 1198.Xr nm 1 , 1199.Xr sysctl.conf 5 , 1200.Xr hangman 6 , 1201.Xr kgdb 7 , 1202.Xr crash 8 , 1203.Xr sysctl 8 , 1204.Xr extent 9 , 1205.Xr pool 9 , 1206.Xr uvm 9 1207.Sh HISTORY 1208This kernel facility first appeared in the MACH 2 operating system 1209developed by CMU. 1210Hangman (which stands for "hangs maniacal analyzer") first appeared in 1211.Ox 1.2 . 1212