11159af41SGreg Lehey.\" $FreeBSD$ 21159af41SGreg Lehey.Dd December 30, 2003 31159af41SGreg Lehey.Dt GDB 4 41159af41SGreg Lehey.Os 51159af41SGreg Lehey.Sh NAME 61159af41SGreg Lehey.Nm gdb 71159af41SGreg Lehey.Nd external kernel debugger 81159af41SGreg Lehey.Sh SYNOPSIS 91159af41SGreg Lehey.Cd makeoptions DEBUG=-g 101159af41SGreg Lehey.Cd options DDB 111159af41SGreg Lehey.Cd options GDB_REMOTE_CHAT 121159af41SGreg Lehey.Pp 131159af41SGreg LeheyTo prevent activation of the debugger on kernel 141159af41SGreg Lehey.Xr panic 9 : 151159af41SGreg Lehey.Cd options DDB_UNATTENDED 161159af41SGreg Lehey.Sh DESCRIPTION 171159af41SGreg LeheyThe 181159af41SGreg Lehey.Nm 191159af41SGreg Leheykernel debugger is a variation of 201159af41SGreg Lehey.Xr gdb 1 211159af41SGreg Leheywhich understands some aspects of the 221159af41SGreg Lehey.Fx 231159af41SGreg Leheykernel environment. It can be used in a number of ways: 241159af41SGreg Lehey.Pp 251159af41SGreg Lehey.Bl -bullet -offset indent -compact 261159af41SGreg Lehey.It 271159af41SGreg LeheyIt can be used to debug another system interactively via a serial or firewire 281159af41SGreg Leheylink. In this mode, the processor can be stopped and single stepped. 291159af41SGreg Lehey.It 301159af41SGreg LeheyIt can be used to examine the memory of the processor on which it runs. 311159af41SGreg Lehey.It 321159af41SGreg LeheyIt can be used to analyse a processor dump after a panic. 331159af41SGreg Lehey.El 341159af41SGreg Lehey.Pp 351159af41SGreg LeheyWhen used for remote debugging, 361159af41SGreg Lehey.Nm 371159af41SGreg Leheyrequires the presence of the 381159af41SGreg Lehey.Xr ddb 4 391159af41SGreg Leheykernel debugger. 401159af41SGreg LeheyCommands exist to switch between 411159af41SGreg Lehey.Nm 421159af41SGreg Leheyand 431159af41SGreg Lehey.Xr ddb 4 . 441159af41SGreg Lehey.Sh PREPARING FOR DEBUGGING 451159af41SGreg LeheyWhen debugging kernels, it is practically essential to have built a kernel with 461159af41SGreg Leheydebugging symbols 471159af41SGreg Lehey.Cd ( makeoptions DEBUG=-g ). 481159af41SGreg LeheyIt's easiest to perform operations from the kernel build directory, by default 491159af41SGreg Lehey.Pa /usr/obj/sys/GENERIC . 501159af41SGreg Lehey.Pp 511159af41SGreg LeheyFirst, ensure you have a copy of the debug macros in the directory: 521159af41SGreg Lehey.Bd -literal -offset 5m 531159af41SGreg Lehey# \f(CBmake gdbinit\fP 541159af41SGreg Lehey.Ed 551159af41SGreg Lehey.Pp 561159af41SGreg LeheyThis command performs some transformations on the macros installed in 571159af41SGreg Lehey.Pa /usr/src/tools/debugscripts 581159af41SGreg Leheyto adapt them to the local environment. 591159af41SGreg Lehey.Ss Debugging a local machine 601159af41SGreg LeheyTo look at and change the contents of the memory of the system you're running 611159af41SGreg Leheyon, 621159af41SGreg Lehey.Bd -literal -offset 5m 631159af41SGreg Lehey# \f(CBgdb -k -wcore kernel.debug /dev/mem\fP 641159af41SGreg Lehey.Ed 651159af41SGreg Lehey.Pp 661159af41SGreg LeheyIn this mode, you need the 671159af41SGreg Lehey.Fl k 681159af41SGreg Leheyflag to indicate to 691159af41SGreg Lehey.Nm gdb 701159af41SGreg Leheythat the ``dump file'' 711159af41SGreg Lehey.Pa /dev/mem 721159af41SGreg Leheyis a kernel data file. 731159af41SGreg LeheyYou can look at live data, and if you include the 741159af41SGreg Lehey.Fl wcore 751159af41SGreg Leheyoption, you can change it at your peril. 761159af41SGreg LeheyThe system does not stop (obviously), so a number of things will not work. 771159af41SGreg LeheyYou can set breakpoints, but you can't ``continue'' execution, so they won't 781159af41SGreg Leheywork. 791159af41SGreg Lehey.Ss Debugging a crash dump 801159af41SGreg LeheyBy default, crash dumps are stored in the directory 811159af41SGreg Lehey.Pa /var/crash . 821159af41SGreg LeheyInvestigate them from the kernel build directory with: 831159af41SGreg Lehey.Bd -literal -offset 5m 841159af41SGreg Lehey# \f(CBgdb -k kernel.debug /var/crash/vmcore.29\fP 851159af41SGreg Lehey.Ed 861159af41SGreg Lehey.Pp 871159af41SGreg LeheyIn this mode, the system is obviously stopped, so you can only look at it. 881159af41SGreg Lehey.Ss Debugging a live system with a remote link 891159af41SGreg LeheyTo debug a live system with a remote link, the kernel must be compiled with the 901159af41SGreg Leheyoptions 911159af41SGreg Lehey.Cd options DDB 921159af41SGreg Leheyand 931159af41SGreg Lehey.Cd options GDB_REMOTE_CHAT . 941159af41SGreg LeheyThe option 951159af41SGreg Lehey.Cd options BREAK_TO_DEBUGGER 961159af41SGreg Leheyenables the debugging machine stop the debugged machine once a connection has 971159af41SGreg Leheybeen established by pressing 981159af41SGreg Lehey.Li ^C. 991159af41SGreg Lehey.Ss Debugging a live system with a remote serial link 1001159af41SGreg LeheyWhen using a serial port for the remote link on the i386 platform the serial 1011159af41SGreg Leheyport must be identified by setting the flag bit 1021159af41SGreg Lehey.Li 0x80 1031159af41SGreg Leheyfor the specified interface. 1041159af41SGreg LeheyGenerally this port will also be used as a serial console (flag bit 1051159af41SGreg Lehey.Li 0x10a), 1061159af41SGreg Leheyso the entry in 1071159af41SGreg Lehey.Pa /boot/device.hints 1081159af41SGreg Leheyshould be: 1091159af41SGreg Lehey.Bd -literal -offset 5m 1101159af41SGreg Leheyhint.sio.0.flags="0x90" 1111159af41SGreg Lehey.Ed 1121159af41SGreg Lehey.Ss Debugging a live system with a remote firewire link 1131159af41SGreg LeheyAs with serial debugging, to debug a live system with a firewire link, the 1141159af41SGreg Leheykernel must be compiled with the options 1151159af41SGreg Lehey.Cd options DDB 1161159af41SGreg Leheyand 1171159af41SGreg Lehey.Cd options GDB_REMOTE_CHAT . 1181159af41SGreg Lehey.Pp 1191159af41SGreg LeheyA number of steps must be performed to set up a firewire link: 1201159af41SGreg Lehey.Pp 1211159af41SGreg Lehey.Bl -bullet -offset indent -compact 1221159af41SGreg Lehey.It 1231159af41SGreg LeheyFirst, ensure that the kernels of both systems include firewire support. 1241159af41SGreg LeheyIf it isn't compiled into the kernel, load the klds: 1251159af41SGreg Lehey.Bd -literal -offset 5m 1261159af41SGreg Lehey# \f(CBkldload dcons\fP 1271159af41SGreg Lehey# \f(CBkldload dcons_crom\fP 1281159af41SGreg Lehey.Ed 1291159af41SGreg Lehey.Pp 1301159af41SGreg LeheyYou should see something like this in the 1311159af41SGreg Lehey.Nm dmesg 1321159af41SGreg Leheyoutput: 1331159af41SGreg Lehey.Pp 1341159af41SGreg Lehey.Bd -literal -offset 5m 1351159af41SGreg Leheyfwohci0: BUS reset 1361159af41SGreg Leheyfwohci0: node_id=0xc000ffc1, gen=3, CYCLEMASTER mode 1371159af41SGreg Leheyfirewire0: 2 nodes, maxhop <= 1, cable IRM = 1 (me) 1381159af41SGreg Leheyfirewire0: bus manager 1 (me) 1391159af41SGreg Leheyfirewire0: New S400 device ID:000199000003622b 1401159af41SGreg Leheydcons_crom0: <dcons configuration ROM> on firewire0 1411159af41SGreg Leheydcons_crom0: bus_addr 0xf93000 1421159af41SGreg Lehey.Ed 1431159af41SGreg Lehey.Pp 1441159af41SGreg LeheyThe corresponding output on the other machine looks like this: 1451159af41SGreg Lehey.Pp 1461159af41SGreg Lehey.Bd -literal -offset 5m 1471159af41SGreg Leheyfwohci0: BUS reset 1481159af41SGreg Leheyfwohci0: node_id=0x8800ffc0, gen=2, non CYCLEMASTER mode 1491159af41SGreg Leheyfirewire0: 2 nodes, maxhop <= 1, cable IRM = 1 1501159af41SGreg Leheyfirewire0: bus manager 1 1511159af41SGreg Leheyfirewire0: New S400 device ID:00c04f3226e88061 1521159af41SGreg Leheydcons_crom0: <dcons configuration ROM> on firewire0 1531159af41SGreg Leheydcons_crom0: bus_addr 0x22a000 1541159af41SGreg Lehey.Ed 1551159af41SGreg Lehey.Pp 1561159af41SGreg LeheyIt's a good idea to load these modules at boot time with the following entry in 1571159af41SGreg Lehey.Pa /boot/loader.conf : 1581159af41SGreg Lehey.Pp 1591159af41SGreg Lehey.Bd -literal -offset 5m 1601159af41SGreg Leheydcons_enable=YES 1611159af41SGreg Lehey.Ed 1621159af41SGreg Lehey.Pp 1631159af41SGreg Lehey.It 1641159af41SGreg LeheyNext, use 1651159af41SGreg Lehey.Nm fwcontrol 1661159af41SGreg Leheyto find the firewire node corresponding to the remote machine: 1671159af41SGreg Lehey.Pp 1681159af41SGreg Lehey.Bd -literal -offset 5m 1691159af41SGreg Lehey# \f(CBfwcontrol\fP 1701159af41SGreg Lehey2 devices (info_len=2) 1711159af41SGreg Leheynode EUI64 status 1721159af41SGreg Lehey 1 0x00c04f3226e88061 0 1731159af41SGreg Lehey 0 0x000199000003622b 1 1741159af41SGreg Lehey.Ed 1751159af41SGreg Lehey.Pp 1761159af41SGreg LeheyThe first node is always the local system, so in this case, node 0 is the remote 1771159af41SGreg Leheysystem. 1781159af41SGreg LeheyIf there are more than two systems, check from the other end to find which node 1791159af41SGreg Leheycorresponds to the remote system. 1806d8cac85SGreg LeheyOn the remote machine, it looks like this: 1811159af41SGreg Lehey.Pp 1821159af41SGreg Lehey.Bd -literal -offset 5m 1831159af41SGreg Lehey# \f(CBfwcontrol\fP 1841159af41SGreg Lehey2 devices (info_len=2) 1851159af41SGreg Leheynode EUI64 status 1861159af41SGreg Lehey 0 0x000199000003622b 0 1871159af41SGreg Lehey 1 0x00c04f3226e88061 1 1881159af41SGreg Lehey.Ed 1891159af41SGreg Lehey.Pp 1901159af41SGreg Lehey.It 1911159af41SGreg LeheyNext, establish a firewire connection with 1921159af41SGreg Lehey.Nm fwchat : 1931159af41SGreg Lehey.Pp 1941159af41SGreg Lehey.Bd -literal -offset 5m 1951159af41SGreg Lehey# \f(CBfwchat -b -t \f[CBI]target-address\fR 1961159af41SGreg Lehey.Ed 1971159af41SGreg Lehey.Pp 1981159af41SGreg Lehey.Ar target-address 1991159af41SGreg Leheyis the EUI64 address of the remote node, in this case 2006d8cac85SGreg Lehey.Li 0x000199000003622b . 2011159af41SGreg LeheyWhen started in this manner, 2021159af41SGreg Lehey.Nm fwchat 2031159af41SGreg Leheyestablishes two local tunnel connections: 2041159af41SGreg Lehey.Ar localhost:5555 2051159af41SGreg Leheyis a connection to a 2061159af41SGreg Lehey.Nm getty 2071159af41SGreg Leheyprocess, which is not of interest here, and 2081159af41SGreg Lehey.Ar localhost:5556 2091159af41SGreg Leheyis a connection to the debugger. 2101159af41SGreg LeheyThe port numbers can be changed with the 2111159af41SGreg Lehey.Fl p 2121159af41SGreg Leheyflag to 2131159af41SGreg Lehey.Nm fwcontrol . 2141159af41SGreg Lehey.Pp 2156d8cac85SGreg Lehey.Nm fwcontrol 2166d8cac85SGreg Leheydoes not return control to the user. 2176d8cac85SGreg LeheyYou can start it in the background, but sometimes it will produce error 2186d8cac85SGreg Leheymessages, so it's a good idea to start it in its own window. 2196d8cac85SGreg Lehey.Pp 2206d8cac85SGreg Lehey.It 2216d8cac85SGreg LeheyFinally, establish connection: 2226d8cac85SGreg Lehey.Bd -literal -offset 5m 2236d8cac85SGreg Lehey# \f(CBgdb kernel.debug\fP 2246d8cac85SGreg LeheyGNU gdb 5.2.1 (FreeBSD) 2256d8cac85SGreg Lehey\&\fI(politcal statements omitted)\fP\/ 2266d8cac85SGreg LeheyReady to go. Enter 'tr' to connect to the remote target 2276d8cac85SGreg Leheywith /dev/cuaa0, 'tr /dev/cuaa1' to connect to a different port 2286d8cac85SGreg Leheyor 'trf portno' to connect to the remote target with the firewire 2296d8cac85SGreg Leheyinterface. portno defaults to 5556. 2306d8cac85SGreg Lehey 2316d8cac85SGreg LeheyType 'getsyms' after connection to load kld symbols. 2326d8cac85SGreg Lehey 2336d8cac85SGreg LeheyIf you're debugging a local system, you can use 'kldsyms' instead 2346d8cac85SGreg Leheyto load the kld symbols. That's a less obnoxious interface. 2356d8cac85SGreg Lehey(gdb) \f(CBtrf\fP 2366d8cac85SGreg Lehey0xc21bd378 in ?? () 2376d8cac85SGreg Lehey.Ed 2386d8cac85SGreg Lehey.Pp 2396d8cac85SGreg Lehey.It 2406d8cac85SGreg LeheyIt's currently possible for the two ends of the firewire link to get out of sync 2416d8cac85SGreg Leheyafter a reboot. 2426d8cac85SGreg LeheyOn the 2436d8cac85SGreg Lehey.Nm fwchat 2446d8cac85SGreg Leheyscreen you see: 2456d8cac85SGreg Lehey.Bd -literal -offset 5m 2466d8cac85SGreg Leheyfwchat: get crom faild 2476d8cac85SGreg Lehey.Ed 2486d8cac85SGreg Lehey.Pp 2496d8cac85SGreg LeheyIn this case, stop 2506d8cac85SGreg Lehey.Nm fwchat 2516d8cac85SGreg Leheyand perform a firewire bus reset: 2526d8cac85SGreg Lehey.Pp 2536d8cac85SGreg Lehey.Bd -literal -offset 5m 2546d8cac85SGreg Lehey# \f(CBfwcontrol -r\fP 2556d8cac85SGreg Lehey# \f(CBfwchat -b -t 0x000199000003622b\fP 2566d8cac85SGreg Lehey.El 2571159af41SGreg Lehey.Sh COMMANDS 2581159af41SGreg LeheyThe user interface to 2591159af41SGreg Lehey.Nm 2601159af41SGreg Leheyis via 2611159af41SGreg Lehey.Xr gdb 1 , 2621159af41SGreg Leheyso 2631159af41SGreg Lehey.Xr gdb 1 2641159af41SGreg Leheycommands also work. 2651159af41SGreg LeheyThis section discusses only the extensions for kernel debugging that get 2661159af41SGreg Leheyinstalled in the kernel build directory. 2671159af41SGreg Lehey.Ss "Debugging Environment" 2681159af41SGreg LeheyThe following macros manipulate the debugging environment: 2691159af41SGreg Lehey.Bl -ohang -offset 3m 2701159af41SGreg Lehey.It Cm ddb 2711159af41SGreg LeheySwitch back to 2721159af41SGreg Lehey.Nm ddb . 2731159af41SGreg LeheyThis command is only meaningful when performing remote debugging. 2741159af41SGreg Lehey.It Cm getsyms 2751159af41SGreg LeheyDisplay 2761159af41SGreg Lehey.Nm kldstat 2771159af41SGreg Leheyinformation for the target machine and invite user to paste it back in. 2781159af41SGreg LeheyThis is required because 2791159af41SGreg Lehey.Nm gdb 2801159af41SGreg Leheydoes not allow data to be passed to shell scripts. 2811159af41SGreg LeheyIt's necessary for remote debugging and crash dumps; for local memory debugging 2821159af41SGreg Leheyuse 2831159af41SGreg Lehey.Nm kldsyms 2841159af41SGreg Leheyinstead. 2851159af41SGreg Lehey.It Cm kldsyms 2861159af41SGreg LeheyRead in the symbol tables for the debugging machine. This doesn't work for 2871159af41SGreg Leheyremote debugging and crash dumps; use 2881159af41SGreg Lehey.Nm getsyms 2891159af41SGreg Leheyinstead. 2901159af41SGreg Lehey.It Cm tr Ar interface 2911159af41SGreg LeheyDebug a remote system via the specified serial or firewire interface. 2921159af41SGreg Lehey.It Cm tr0 2931159af41SGreg LeheyDebug a remote system via serial interface 2941159af41SGreg Lehey.Pa /dev/cuaa0 . 2951159af41SGreg Lehey.It Cm tr1 2961159af41SGreg LeheyDebug a remote system via serial interface 2971159af41SGreg Lehey.Pa /dev/cuaa1 . 2981159af41SGreg Lehey.It Cm trf 2991159af41SGreg LeheyDebug a remote system via firewire interface at default port 5556. 3001159af41SGreg Lehey.El 3011159af41SGreg Lehey.Pp 3021159af41SGreg LeheyThe commands 3031159af41SGreg Lehey.Nm tr0 , 3041159af41SGreg Lehey.Nm tr1 3051159af41SGreg Leheyand 3061159af41SGreg Lehey.Nm trf 3071159af41SGreg Leheyare convenience commands which invoke 3081159af41SGreg Lehey.Nm tr . 3091159af41SGreg Lehey.Ss "The current process environment" 3101159af41SGreg LeheyThe following macros are convenience functions intended to make things easier 3111159af41SGreg Leheythan the standard 3121159af41SGreg Lehey.Nm gdb 3131159af41SGreg Leheycommands. 3141159af41SGreg Lehey.Bl -ohang -offset 3m 3151159af41SGreg Lehey.It Cm f0 3161159af41SGreg LeheySelect stack frame 0 and show assembler-level details. 3171159af41SGreg Lehey.It Cm f1 3181159af41SGreg LeheySelect stack frame 1 and show assembler-level details. 3191159af41SGreg Lehey.It Cm f2 3201159af41SGreg LeheySelect stack frame 2 and show assembler-level details. 3211159af41SGreg Lehey.It Cm f3 3221159af41SGreg LeheySelect stack frame 3 and show assembler-level details. 3231159af41SGreg Lehey.It Cm f4 3241159af41SGreg LeheySelect stack frame 4 and show assembler-level details. 3251159af41SGreg Lehey.It Cm f5 3261159af41SGreg LeheySelect stack frame 5 and show assembler-level details. 3271159af41SGreg Lehey.It Cm xb 3281159af41SGreg LeheyShow 12 words in hex, starting at current 3291159af41SGreg Lehey.Va ebp 3301159af41SGreg Leheyvalue. 3311159af41SGreg Lehey.It Cm xi 3321159af41SGreg LeheyList the next 10 instructions from the current 3331159af41SGreg Lehey.Va eip 3341159af41SGreg Leheyvalue. 3351159af41SGreg Lehey.It Cm xp 3361159af41SGreg LeheyShow the register contents and the first four parameters of the current stack 3371159af41SGreg Leheyframe. 3381159af41SGreg Lehey.It Cm xp0 3391159af41SGreg LeheyShow the first parameter of current stack frame in various formats. 3401159af41SGreg Lehey.It Cm xp1 3411159af41SGreg LeheyShow the second parameter of current stack frame in various formats. 3421159af41SGreg Lehey.It Cm xp2 3431159af41SGreg LeheyShow the third parameter of current stack frame in various formats. 3441159af41SGreg Lehey.It Cm xp3 3451159af41SGreg LeheyShow the fourth parameter of current stack frame in various formats. 3461159af41SGreg Lehey.It Cm xp4 3471159af41SGreg LeheyShow the fifth parameter of current stack frame in various formats. 3481159af41SGreg Lehey.It Cm xs 3491159af41SGreg LeheyShow the last 12 words on stack in hexadecimal. 3501159af41SGreg Lehey.It Cm xxp 3511159af41SGreg LeheyShow the register contents and the first ten parameters. 3521159af41SGreg Lehey.It Cm z 3531159af41SGreg LeheySingle step 1 instruction (over calls) and show next instruction. 3541159af41SGreg Lehey.It Cm zs 3551159af41SGreg LeheySingle step 1 instruction (through calls) and show next instruction. 3561159af41SGreg Lehey.El 3571159af41SGreg Lehey.Ss "Examining other processes" 3581159af41SGreg LeheyThe following macros access other processes. 3591159af41SGreg Lehey.Nm gdb 3601159af41SGreg Leheydoes not understand the concept of multiple processes, so they effectively 3611159af41SGreg Leheybypass the entire 3621159af41SGreg Lehey.Nm gdb 3631159af41SGreg Leheyenvironment. 3641159af41SGreg Lehey.Bl -ohang -offset 3m 3651159af41SGreg Lehey.It Cm btp Ar pid 3661159af41SGreg LeheyShow a backtrace for the process 3671159af41SGreg Lehey.Va pid . 3681159af41SGreg Lehey.It Cm btpa 3691159af41SGreg LeheyShow backtraces for all processes in the system. 3701159af41SGreg Lehey.It Cm btpp 3711159af41SGreg LeheyShow a backtrace for the process previously selected with 3721159af41SGreg Lehey.Nm defproc . 3731159af41SGreg Lehey.It Cm btr Ar ebp 3741159af41SGreg LeheyShow a backtrace from the 3751159af41SGreg Lehey.Va ebp 3761159af41SGreg Leheyaddress specified 3771159af41SGreg Lehey.It Cm defproc Ar pid 3781159af41SGreg LeheySpecify the PID of the process for some other commands in this section. 3791159af41SGreg Lehey.It Cm fr Ar frame 3801159af41SGreg LeheyShow frame 3811159af41SGreg Lehey.Va frame 3821159af41SGreg Leheyof the stack of the process previously selected with 3831159af41SGreg Lehey.Nm defproc . 3841159af41SGreg Lehey.It Cm pcb Ar proc 3851159af41SGreg LeheyShow some pcb contents of process 3861159af41SGreg Lehey.Ar proc . 3871159af41SGreg Lehey.El 3881159af41SGreg Lehey.Ss "Examining data structures" 3891159af41SGreg LeheyYou can use standard 3901159af41SGreg Lehey.Nm gdb 3911159af41SGreg Leheycommands to look at most data structures. The macros in this section are 3921159af41SGreg Leheyconvenience functions which typically display the data in a more readable 3931159af41SGreg Leheyformat, or which omit less interesting parts of the structure. 3941159af41SGreg Lehey.Bl -ohang -offset 3m 3951159af41SGreg Lehey.It Cm bp 3961159af41SGreg LeheyShow information about the buffer header pointed to by the variable 3971159af41SGreg Lehey.Va bp 3981159af41SGreg Leheyin the current frame. 3991159af41SGreg Lehey.It Cm bpd 4001159af41SGreg LeheyShow the contents 4011159af41SGreg Lehey.Vt (char*) 4021159af41SGreg Leheyof 4031159af41SGreg Lehey.Va bp->data 4041159af41SGreg Leheyin the current frame. 4051159af41SGreg Lehey.It Cm bpl 4061159af41SGreg LeheyShow detailed information about the buffer header 4071159af41SGreg Lehey.Vt (struct bp) 4081159af41SGreg Leheypointed at by the local variable 4091159af41SGreg Lehey.Va bp . 4101159af41SGreg Lehey.It Cm bpp bp 4111159af41SGreg LeheyShow summary information about the buffer header 4121159af41SGreg Lehey.Vt (struct bp) 4131159af41SGreg Leheypointed at by the parameter 4141159af41SGreg Lehey.Va bp . 4151159af41SGreg Lehey.It Cm bx 4161159af41SGreg LeheyPrint a number of fields from the buffer header pointed at in by the pointer 4171159af41SGreg Lehey.Va bp 4181159af41SGreg Leheyin the current environment. 4191159af41SGreg Lehey.It Cm vdev 4201159af41SGreg LeheyShow some information of the vnode pointed to by the local variable 4211159af41SGreg Lehey.Va vp . 4221159af41SGreg Lehey.El 4231159af41SGreg Lehey.Ss "Miscellaneous macros" 4241159af41SGreg Lehey.Bl -ohang -offset 3m 4251159af41SGreg Lehey.It Cm checkmem 4261159af41SGreg LeheyCheck unallocated memory for modifications. 4271159af41SGreg LeheyThis assumes that the kernel has been compiled with 4281159af41SGreg Lehey.Cd options DIAGNOSTIC 4291159af41SGreg LeheyThis causes the contents of free memory to be set to 4301159af41SGreg Lehey.Li 0xdeadc0de . 4311159af41SGreg Lehey.It Cm dmesg 4321159af41SGreg LeheyPrint the system message buffer. This corresponds to the 4331159af41SGreg Lehey.Nm dmesg 4341159af41SGreg Leheycommand. 4351159af41SGreg LeheyIt can take a very long time over a serial line, and it's even slow via firewire 4361159af41SGreg Leheyor local memory due to inefficiencies in 4371159af41SGreg Lehey.Nm gdb . 4381159af41SGreg LeheyThis macro used to be called 4391159af41SGreg Lehey.Nm msgbuf . 4401159af41SGreg Lehey.It Cm kldstat 4411159af41SGreg LeheyEquivalent of the kldstat(8) command without options 4421159af41SGreg Lehey.It Cm pname 4431159af41SGreg LeheyPrint the command name of the current process. 4441159af41SGreg Lehey.It Cm ps 4451159af41SGreg LeheyShow process status. 4461159af41SGreg LeheyThis corresponds in concept, but not in appearance, to the 4471159af41SGreg Lehey.Nm ps 4481159af41SGreg Leheycommand. 4491159af41SGreg Lehey.It Cm y 4501159af41SGreg LeheyKludge for writing macros. When writing macros, it's convenient to paste them 4511159af41SGreg Leheyback into the 4521159af41SGreg Lehey.Nm gdb 4531159af41SGreg Leheywindow. Unfortunately, if the macro is already defined, 4541159af41SGreg Lehey.Nm gdb 4551159af41SGreg Leheyinsists on asking 4561159af41SGreg Lehey.Bd -literal -offset 5m 4571159af41SGreg LeheyRedefine foo? 4581159af41SGreg Lehey.Ed 4591159af41SGreg Lehey.Pp 4601159af41SGreg LeheyIt won't give up until you answer 4611159af41SGreg Lehey.Li y . 4621159af41SGreg LeheyThis command is that answer. It does nothing else except to print a warning 4631159af41SGreg Leheymessage to remind you to remove it again. 4641159af41SGreg Lehey.El 4651159af41SGreg Lehey.Sh AUTHORS 4661159af41SGreg LeheyThis man page was written by 4671159af41SGreg Lehey.An "Greg Lehey" Aq grog@FreeBSD.org 4681159af41SGreg Lehey.Sh SEE ALSO 4691159af41SGreg Lehey.Xr ddb 4 , 4701159af41SGreg Lehey.Xr fwchat 8 , 4711159af41SGreg Lehey.Xr fwcontrol 8 , 4721159af41SGreg Lehey.Xr gdb 1 , 4731159af41SGreg Lehey.Xr vinumdebug 4 . 4741159af41SGreg Lehey.\" .Sh HISTORY 4751159af41SGreg Lehey.Sh BUGS 4761159af41SGreg Lehey.Bl -bullet -offset indent -compact 4771159af41SGreg Lehey.It 4781159af41SGreg Lehey.Nm 4791159af41SGreg Leheywas never designed to debug kernels, and it's not a very good match. 4801159af41SGreg LeheyMany problems exist. 4811159af41SGreg Lehey.It 4821159af41SGreg LeheyThe debugging macros ``just growed''. 4831159af41SGreg LeheyIn general, the person who wrote them did so while looking for a specific 4841159af41SGreg Leheyproblem, so they may not be general enough, and they may behave badly when used 4851159af41SGreg Leheyin ways for which they were not intended, even if those ways make sense. 4861159af41SGreg Lehey.It 4871159af41SGreg LeheySerial debugging is very slow, and race conditions can make it difficult to run 4881159af41SGreg Leheythe link at more than 9600 bps. Firewire connections do not have this problem. 4891159af41SGreg Lehey.It 4901159af41SGreg LeheyMany of these commands only work on the ia32 architecture. 4911159af41SGreg Lehey.El 492