2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH KMDB 1 "May 3, 2007"
8 kmdb \- in situ kernel debugger
10 .SS "Boot-time Loading"
16 \fBok boot\fR [\fIdevice-specifier\fR] \fB-k\fR [\fB-d\fR] [\fIboot-flags\fR]
21 \fBok boot\fR [\fIdevice-specifier\fR] kmdb [\fB-d\fR] [\fIboot-flags\fR]
29 \fBkernel$\fR \fB/platform/i86pc/kernel/$ISADIR/unix\fR \fB-k\fR [\fB-d\fR] [\fIboot-flags\fR]
41 \fBkmdb\fR is an interactive kernel debugger which implements the user
42 interface and functionality of \fBmdb\fR(1) in a live kernel context.
43 \fBkmdb\fR provides features that allow for the control of kernel execution and
44 for the inspection and modification of live kernel state. \fBkmdb\fR can be
45 loaded at the beginning of a boot session or after the system is booted.
48 This man page describes the features and functionality that are unique to
49 \fBkmdb\fR or different in \fBkmdb\fR as compared to \fBmdb\fR(1). For more
50 information on \fBmdb\fR(1) or further details on the features and
51 functionality implemented by \fBkmdb\fR, see the \fBmdb\fR(1) man page and the
52 \fISolaris Modular Debugger Guide\fR.
53 .SS "Loading and Unloading"
57 \fBBoot-time Loading\fR
60 When requested, the kernel runtime linker (\fBkrtld\fR) loads \fBkmdb\fR prior
61 to the transfer of control to the kernel. If the \fB-d\fR flag is used, the
62 debugger gains control of the system prior to the execution of the initial
63 function in the 'unix' object. If \fB-d\fR is not used, \fBkmdb\fR is loaded
64 but does not gain control until such time as it is explicitly entered. See the
65 Debugger Entry section below. For a list of the boot commands which cause
66 \fBkmdb\fR to be loaded at boot, see the SYNOPSIS section above.
68 Boot-loaded \fBkmdb\fR can be unloaded only by means of a system reboot.
70 Some features of \fBkmdb\fR rely on the presence of kernel services and are not
71 immediately available to boot-loaded \fBkmdb\fR. In particular, the loading and
72 unloading of dmods is not available until the module subsystem is initialized.
73 Requests are queued until they can be processed. Similarly, translation of
74 virtual addresses to physical addresses is not be available until the VM system
75 has been initialized. Attempted translations fail until translation facilities
82 \fBRun-time Loading\fR
85 \fBkmdb\fR can also be loaded after the system has booted, using the \fB-K\fR
86 flag to \fBmdb\fR(1). When loaded in this fashion, it will immediately gain
87 control of the system. Run-time-loaded \fBkmdb\fR can be unloaded using the
88 \fB-U\fR flag to \fBmdb\fR(1) or from within the debugger with the \fB-u\fR
89 flag to the \fB::quit dcmd\fR.
98 When loaded, \fBkmdb\fR attempts to determine the proper terminal type in use
99 on the system console. If the system being debugged has an attached keyboard
100 and local display that are both used for the system console, \fBkmdb\fR uses
101 the terminal type appropriate for the machine: 'sun' for SPARC; 'sun-color' for
102 x86. When a serial console is in use, boot-loaded \fBkmdb\fR defaults to a
103 terminal type 'vt100'. Run-time-loaded \fBkmdb\fR defaults to the terminal type
104 requested by \fBmdb\fR(1). \fBmdb\fR(1) requests the terminal type specified by
105 the value of the \fBTERM\fR environment variable unless overridden by the
106 \fB-T\fR flag. \fB::term\fR can be used to view the current terminal type.
112 Debugger entry can be requested explicitly or implicitly. Implicit entry,
113 encountered when breakpoints or other execution control features are used, is
114 discussed in the \fBExecution Control\fR section.
117 The primary means for explicit debugger entry is with the keyboard abort
118 sequence for systems with local consoles and the BREAK character for those with
119 serial consoles. The abort sequence is STOP-A or Shift-Pause for SPARC systems
120 with local consoles, and F1-A or Shift-Pause for x86 systems with local
121 consoles. See \fBkbd\fR(1) for a discussion of the abort sequence and for
122 instructions on disabling it.
125 A second way to request entry into the debugger is with the \fBmdb\fR(1)
126 command. Invocations of \fBmdb\fR(1) with the \fB-K\fR flag after the debugger
127 is loaded trigger debugger entry.
130 If the kernel panics and \fBkmdb\fR is loaded, by default, the panic routine
131 enters \fBkmdb\fR for live debugging. If a dump device is specified, and you
132 enter \fB::cont\fR, the debugger exits and a crash dump is performed. To
133 prevent the kernel from entering \fBkmdb\fR when panicking, you can set the
134 \fBnopanicdebug\fR variable to \fB1\fR. Set the \fBnopanicdebug\fR variable to
135 \fB1\fR using \fBkmdb\fR or including the following a line in
147 This can be useful if you want to keep \fBkmdb\fR loaded, but always want a
148 panic to trigger a crash dump without entering the debugger.
149 .SS "Execution Control"
152 For the most part, the execution control facilities provided by \fBkmdb\fR for
153 the kernel mirror those provided by the \fBmdb\fR(1) process target.
154 Breakpoints (\fB::bp\fR), watchpoints (\fB::wp\fR), \fB::continue\fR, and the
155 various flavors of \fB::step\fR can be used.
158 In contrast to the unlimited user process watchpoints supplied by the kernel,
159 \fBkmdb\fR is restricted to a set of CPU watchpoints that limit the number,
160 size, and type of watchpoints allowed. The \fB::wp\fR command does not allow a
161 watchpoint to be created if it is incompatible with the watchpoints supported
163 .SS "Debugger modules (dmods)"
166 As with \fBmdb\fR(1), \fBkmdb\fR is installed with a number of
167 subsystem-specific debugger modules, or dmods. The dmods are loaded and
168 unloaded automatically with the loading and unloading of the subsystems that
169 they support. The dmods can also be explicitly loaded and unloaded using
170 \fB::load\fR and \fB::unload\fR.
173 \fBkmdb\fR uses kernel facilities to load and unload dmods and must resume
174 system execution to perform each requested action. When a dmod load or unload
175 is complete, the system is stopped and the debugger is automatically
176 re-entered. For a dmod load, processing is completed when the load of a
177 requested dmod succeeds or fails. Status messages are provided in either case.
178 .SS "Processor-specific functionality"
181 Some functionality is specific to an individual processor type. An example of
182 such functionality is the branch tracing provided by various x86 processors.
183 Access to these processor-specific features is provided with processor-specific
184 dcmds that are present only on systems that support them. The availability of
185 processor-specific support is indicated in the output of the \fB::status
186 dcmd\fR. The debugger relies on the kernel to determine the processor type.
187 Even though the debugger might provide support for a given processor type, the
188 support is not exposed until the kernel has progressed to the point at which
189 processor identification has completed.
193 The debugger provides access to a set of macros that are precompiled into the
194 debugger. Only the precompiled macros are available . Unlike with \fBmdb\fR(1),
195 the \fB$< dcmd\fR may not be used to load macros from arbitrary locations. Use
196 the \fB$M\fR command to list the available macros.
200 This section lists dcmds that are unique to \fBkmdb\fR or those with behavior
201 that differs in \fBkmdb\fR as compared to \fBmdb\fR(1).
205 \fB\fB[\fR\fIaddress\fR]\fB::bp [+/-dDestT]\fR [\fB-c\fR \fIcmd\fR] [\fB-n\fR
206 \fIcount\fR] \fIsym\fR ...\fR
210 \fB\fIaddress\fR \fB:b [\fR\fIcmd\fR \fB\&...]\fR\fR
214 Set a breakpoint at the specified locations. The \fB::bp\fR dcmd sets a
215 breakpoint at each address or symbol specified, including an optional address
216 specified by an explicit expression preceding the dcmd, and each string or
217 immediate value following the dcmd. The arguments can be symbol names or
218 immediate values denoting a particular virtual address of interest.
220 If a symbol name is specified, the name may refer to a symbol that cannot yet
221 be evaluated. It might consist of an object name and function name in a load
222 object that has not yet been opened. In such a case, the breakpoint is deferred
223 and is not active in the target until an object matching the given name is
224 loaded. The breakpoint is automatically enabled when the load object is opened.
226 The \fB-d\fR, \fB-D\fR, \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and
227 \fB-n\fR options have the same meaning as they do for the \fB::evset\fR dcmd.
228 See \fBmdb\fR(1) for a description of \fB::evset\fR. If the \fB:b\fR form of
229 the dcmd is used, a breakpoint is set only at the virtual address specified by
230 the expression preceding the dcmd. The arguments following the \fB:b\fR dcmd
231 are concatenated together to form the callback string. If this string contains
232 meta-characters, it must be quoted.
238 \fB\fB::branches\fR [\fB-v\fR]\fR
246 Display the last branches taken by the CPU. This dcmd is supported only on x86
247 systems, and is available only when processor-specific support is detected and
248 enabled. The number and type of branches displayed is dependent on the
249 capabilities of the branch tracing facilities provided by the CPU. When the
250 \fB-v\fR option is used, the instructions prior to a given branch are
257 \fB[\fIfunction\fR] \fB::call\fR [\fIarg\fR [\fIarg\fR ...]]\fR
261 Call the specified function using the specified arguments. The called function
262 must be listed as a function in the symbol table for a loaded module. String
263 arguments are passed by reference. When the call completes, the return value of
264 the function is displayed.
266 This dcmd must be used with extreme caution. The kernel will not be resumed
267 when the call is made. The function being called may not make any assumptions
268 regarding the availability of any kernel services, and must not perform
269 operations or calls that may block. The user must also beware of any
270 side-effects introduced by the called function, as kernel stability might be
277 \fB[\fIaddr\fR] \fB::cpuregs\fR [\fB-c\fR \fIcpuid\fR]\fR
281 Display the current general purpose register set for the specified CPU, in the
282 format used by \fB::regs\fR.
288 \fB[\fIaddr\fR] \fB::cpustack\fR [\fB-c\fR \fIcpuid\fR]\fR
292 Print a C stack backtrace for the specified CPU. The backtrace displayed is for
293 the point at which the specified CPU entered or was stopped by the debugger.
299 \fB\fIaddr\fR[,\fIlen\fR] \fB::in\fR [\fB-L\fR \fIlen\fR]\fR
307 Read \fIlen\fR bytes from the I/O port specified by \fIaddr\fR. The value of
308 the \fB-L\fR option, if provided, takes precedence over the value of the repeat
309 count. The read length must be 1, 2, or 4 bytes, and the port address must have
310 the same alignment as the length.
316 \fB\fIaddr\fR[,\fIlen\fR] \fB::out\fR [\fB-L\fR \fIlen\fR] \fIvalue\fR\fR
324 Write value to the len-byte I/O port specified by \fIaddr\fR. The value of the
325 \fB-L\fR option, if provided, takes precedence over the value of the repeat
326 count. The write length must be 1, 2, or 4 bytes and the port address must have
327 the same alignment as the length.
333 \fB\fB::quit\fR [\fB-u\fR]\fR
341 Causes the debugger to exit. When the \fB-u\fR option is used, the system is
342 resumed and the debugger is unloaded. The \fB-u\fR option may not be used if
343 the debugger was loaded at boot. When the \fB-u\fR option is not used, SPARC
344 systems will exit to the boot PROM \fBok\fR prompt. The \fBgo\fR command can be
345 used to re-enter the debugger. On x86 systems, a prompt is displayed that
346 requests permission to reboot the machine.
352 \fB\fB::step [over|out|branch]\fR\fR
356 Step the target one instruction. The optional \fBover\fR argument is used to
357 step over subroutine calls. When the optional \fBout\fR argument is specified,
358 the target program continues until control returns from the current function.
360 The optional \fBbranch\fR argument is available only on x86 systems when
361 processor-specific support is detected and enabled. When \fB::step branch\fR is
362 specified, the target program continues until the next branching instruction is
365 On SPARC systems, the \fB::step dcmd\fR may not be used to step 'ta'
366 instructions. Similarly, it may not be used on x86 systems to step 'int'
367 instructions. If the step results in a trap that cannot be resolved by the
368 debugger, a message to that effect is printed and the step will fail.
374 \fB\fBcpuid::switch\fR\fR
382 Use the specified CPU as the representative. Stack traces, general purpose
383 register dumps, and similar functionality use the new representative CPU as the
384 data source. Full execution control functionality is available on the new
395 Display the current terminal type.
401 \fB\fIaddr\fR\fB[,\fR\fIlen\fR]\fB::wp [+/-dDestT]\fR [\fB-rwx\fR] [\fB-pi\fR]
402 [\fB-n\fR \fIcount\fR] [\fB-c\fR \fIcmd\fR]\fR
406 \fB\fB\fIaddr\fR[,\fIlen\fR]\fR\fB:a [\fIcmd\fR\fR \fB\&...]\fR\fR
410 \fB\fB\fIaddr\fR[,\fIlen\fR]\fR\fB:p [\fIcmd\fR\fR \fB\&...]\fR\fR
414 \fB\fB\fIaddr\fR[,\fIlen\fR]\fR\fB:w [\fIcmd\fR\fR \fB\&...]\fR\fR
418 Set a watchpoint at the specified address, interpreted by default as a virtual
419 address. If the \fB-p\fR option is used, the address is interpreted as a
420 physical address. On x86 platforms, watchpoints can be set on I/O ports using
421 the \fB-i\fR option. When the \fB-i\fR option is used, the address is
422 interpreted as that of an I/O port.
424 The length in bytes of the watched region can be set by specifying an optional
425 repeat count preceding the dcmd. If no length is explicitly set, the default is
426 one byte. The \fB::wp\fR dcmd allows the watchpoint to be configured to trigger
427 on any combination of read (\fB-r\fR option), write (\fB-w\fR option), or
428 execute (\fB-x\fR option) access.
430 The \fB-d\fR, \fB-D\fR, \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and
431 \fB-n\fR options have the same meaning as they do for the \fB::evset\fR dcmd.
432 See \fBmdb\fR(1) for a description of \fB::evset\fR. The \fB:a\fR dcmd sets a
433 read access watchpoint at the specified address. The \fB:p\fR dcmd sets an
434 execute access watchpoint at the specified address. The \fB:w\fR dcmd sets a
435 write access watchpoint at the specified address. The arguments following the
436 \fB:a\fR, \fB:p\fR, and \fB:w\fR dcmds are concatenated together to form the
437 callback string. If the string contains meta-characters, it must be quoted.
443 See \fBattributes\fR(5) for descriptions of the following attributes:
451 ATTRIBUTE TYPE ATTRIBUTE VALUE
453 Interface Stability Evolving
459 \fBmdb\fR(1), \fBboot\fR(1M), \fBdumpadm\fR(1M), \fBkernel\fR(1M),
460 \fBsystem\fR(4), \fBattributes\fR(5)
463 \fISolaris Modular Debugger Guide\fR
469 .SS "Limitations on Memory Available to the Debugger"
472 The memory region available to the debugger is allocated when the debugger is
473 loaded, and is fixed at that point. If dcmds attempt to allocate more memory
474 than is available, they will, if possible, be terminated. The debugger will
475 attempt to recover gracefully from an out-of-memory situation, but may be
476 unable to, and may be forced to terminate the system. This constraint is
477 especially acute on 32-bit x86 systems.
478 .SS "Performance Impact"
481 System performance will be negatively impacted by the loading of \fBkmdb\fR, as
482 the debugger will consume kernel memory and other limited system resources.