Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / kmdb.1
blobfdbb9d20d3761222ba3a7c4784d06f37d363a8e2
1 '\" te
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 "Dec 9, 2017"
7 .SH NAME
8 kmdb \- in situ kernel debugger
9 .SH SYNOPSIS
10 .SS "Boot-time Loading"
11 .LP
12 SPARC
13 .LP
14 .nf
15 \fBok boot\fR [\fIdevice-specifier\fR] \fB-k\fR [\fB-d\fR] [\fIboot-flags\fR]
16 .fi
18 .LP
19 .nf
20 \fBok boot\fR [\fIdevice-specifier\fR] kmdb [\fB-d\fR] [\fIboot-flags\fR]
21 .fi
23 .sp
24 .LP
25 x86
26 .LP
27 .nf
28 \fBkernel$\fR \fB/platform/kernel/$ISADIR/unix\fR \fB-k\fR [\fB-d\fR] [\fIboot-flags\fR]
29 .fi
31 .SS "Runtime Loading"
32 .LP
33 .nf
34 \fBmdb\fR \fB-K\fR
35 .fi
37 .SH DESCRIPTION
38 .LP
39 \fBkmdb\fR is an interactive kernel debugger which implements the user
40 interface and functionality of \fBmdb\fR(1) in a live kernel context.
41 \fBkmdb\fR provides features that allow for the control of kernel execution and
42 for the inspection and modification of live kernel state. \fBkmdb\fR can be
43 loaded at the beginning of a boot session or after the system is booted.
44 .sp
45 .LP
46 This man page describes the features and functionality that are unique to
47 \fBkmdb\fR or different in \fBkmdb\fR as compared to \fBmdb\fR(1). For more
48 information on \fBmdb\fR(1) or further details on the features and
49 functionality implemented by \fBkmdb\fR, see the \fBmdb\fR(1) man page and the
50 \fIModular Debugger Guide\fR.
51 .SS "Loading and Unloading"
52 .ne 2
53 .na
54 \fBBoot-time Loading\fR
55 .ad
56 .RS 21n
57 When requested, the kernel runtime linker (\fBkrtld\fR) loads \fBkmdb\fR prior
58 to the transfer of control to the kernel. If the \fB-d\fR flag is used, the
59 debugger gains control of the system prior to the execution of the initial
60 function in the 'unix' object. If \fB-d\fR is not used, \fBkmdb\fR is loaded
61 but does not gain control until such time as it is explicitly entered. See the
62 Debugger Entry section below. For a list of the boot commands which cause
63 \fBkmdb\fR to be loaded at boot, see the SYNOPSIS section above.
64 .sp
65 Boot-loaded \fBkmdb\fR can be unloaded only by means of a system reboot.
66 .sp
67 Some features of \fBkmdb\fR rely on the presence of kernel services and are not
68 immediately available to boot-loaded \fBkmdb\fR. In particular, the loading and
69 unloading of dmods is not available until the module subsystem is initialized.
70 Requests are queued until they can be processed. Similarly, translation of
71 virtual addresses to physical addresses is not be available until the VM system
72 has been initialized. Attempted translations fail until translation facilities
73 are available.
74 .RE
76 .sp
77 .ne 2
78 .na
79 \fBRun-time Loading\fR
80 .ad
81 .RS 21n
82 \fBkmdb\fR can also be loaded after the system has booted, using the \fB-K\fR
83 flag to \fBmdb\fR(1). When loaded in this fashion, it will immediately gain
84 control of the system. Run-time-loaded \fBkmdb\fR can be unloaded using the
85 \fB-U\fR flag to \fBmdb\fR(1) or from within the debugger with the \fB-u\fR
86 flag to the \fB::quit dcmd\fR.
87 .RE
89 .sp
90 .ne 2
91 .na
92 \fBTerminal types\fR
93 .ad
94 .RS 21n
95 When loaded, \fBkmdb\fR attempts to determine the proper terminal type in use
96 on the system console. If the system being debugged has an attached keyboard
97 and local display that are both used for the system console, \fBkmdb\fR uses
98 the terminal type appropriate for the machine: 'sun' for SPARC; 'sun-color' for
99 x86. When a serial console is in use, boot-loaded \fBkmdb\fR defaults to a
100 terminal type 'vt100'. Run-time-loaded \fBkmdb\fR defaults to the terminal type
101 requested by \fBmdb\fR(1). \fBmdb\fR(1) requests the terminal type specified by
102 the value of the \fBTERM\fR environment variable unless overridden by the
103 \fB-T\fR flag. \fB::term\fR can be used to view the current terminal type.
106 .SS "Debugger Entry"
108 Debugger entry can be requested explicitly or implicitly. Implicit entry,
109 encountered when breakpoints or other execution control features are used, is
110 discussed in the \fBExecution Control\fR section.
113 The primary means for explicit debugger entry is with the keyboard abort
114 sequence for systems with local consoles and the BREAK character for those with
115 serial consoles. The abort sequence is STOP-A or Shift-Pause for SPARC systems
116 with local consoles, and F1-A or Shift-Pause for x86 systems with local
117 consoles. See \fBkbd\fR(1) for a discussion of the abort sequence and for
118 instructions on disabling it.
121 A second way to request entry into the debugger is with the \fBmdb\fR(1)
122 command. Invocations of \fBmdb\fR(1) with the \fB-K\fR flag after the debugger
123 is loaded trigger debugger entry.
126 If the kernel panics and \fBkmdb\fR is loaded, by default, the panic routine
127 enters \fBkmdb\fR for live debugging. If a dump device is specified, and you
128 enter \fB::cont\fR, the debugger exits and a crash dump is performed. To
129 prevent the kernel from entering \fBkmdb\fR when panicking, you can set the
130 \fBnopanicdebug\fR variable to \fB1\fR. Set the \fBnopanicdebug\fR variable to
131 \fB1\fR using \fBkmdb\fR or including the following a line in
132 \fB/etc/system\fR:
134 .in +2
136 set nopanicdebug = 1
138 .in -2
143 This can be useful if you want to keep \fBkmdb\fR loaded, but always want a
144 panic to trigger a crash dump without entering the debugger.
145 .SS "Execution Control"
147 For the most part, the execution control facilities provided by \fBkmdb\fR for
148 the kernel mirror those provided by the \fBmdb\fR(1) process target.
149 Breakpoints (\fB::bp\fR), watchpoints (\fB::wp\fR), \fB::continue\fR, and the
150 various flavors of \fB::step\fR can be used.
153 In contrast to the unlimited user process watchpoints supplied by the kernel,
154 \fBkmdb\fR is restricted to a set of CPU watchpoints that limit the number,
155 size, and type of watchpoints allowed. The \fB::wp\fR command does not allow a
156 watchpoint to be created if it is incompatible with the watchpoints supported
157 by the hardware.
158 .SS "Debugger modules (dmods)"
160 As with \fBmdb\fR(1), \fBkmdb\fR is installed with a number of
161 subsystem-specific debugger modules, or dmods. The dmods are loaded and
162 unloaded automatically with the loading and unloading of the subsystems that
163 they support. The dmods can also be explicitly loaded and unloaded using
164 \fB::load\fR and \fB::unload\fR.
167 \fBkmdb\fR uses kernel facilities to load and unload dmods and must resume
168 system execution to perform each requested action. When a dmod load or unload
169 is complete, the system is stopped and the debugger is automatically
170 re-entered. For a dmod load, processing is completed when the load of a
171 requested dmod succeeds or fails. Status messages are provided in either case.
172 .SS "Processor-specific functionality"
174 Some functionality is specific to an individual processor type. An example of
175 such functionality is the branch tracing provided by various x86 processors.
176 Access to these processor-specific features is provided with processor-specific
177 dcmds that are present only on systems that support them. The availability of
178 processor-specific support is indicated in the output of the \fB::status
179 dcmd\fR. The debugger relies on the kernel to determine the processor type.
180 Even though the debugger might provide support for a given processor type, the
181 support is not exposed until the kernel has progressed to the point at which
182 processor identification has completed.
183 .SS "Kernel Macros"
185 The debugger provides access to a set of macros that are precompiled into the
186 debugger. Only the precompiled macros are available . Unlike with \fBmdb\fR(1),
187 the \fB$< dcmd\fR may not be used to load macros from arbitrary locations. Use
188 the \fB$M\fR command to list the available macros.
189 .SS "Built-in dcmds"
191 This section lists dcmds that are unique to \fBkmdb\fR or those with behavior
192 that differs in \fBkmdb\fR as compared to \fBmdb\fR(1).
194 .ne 2
196 \fB\fB[\fR\fIaddress\fR]\fB::bp [+/-dDestT]\fR [\fB-c\fR \fIcmd\fR] [\fB-n\fR
197 \fIcount\fR] \fIsym\fR ...\fR
201 \fB\fIaddress\fR \fB:b [\fR\fIcmd\fR \fB\&...]\fR\fR
203 .sp .6
204 .RS 4n
205 Set a breakpoint at the specified locations. The \fB::bp\fR dcmd sets a
206 breakpoint at each address or symbol specified, including an optional address
207 specified by an explicit expression preceding the dcmd, and each string or
208 immediate value following the dcmd. The arguments can be symbol names or
209 immediate values denoting a particular virtual address of interest.
211 If a symbol name is specified, the name may refer to a symbol that cannot yet
212 be evaluated. It might consist of an object name and function name in a load
213 object that has not yet been opened. In such a case, the breakpoint is deferred
214 and is not active in the target until an object matching the given name is
215 loaded. The breakpoint is automatically enabled when the load object is opened.
217 The \fB-d\fR, \fB-D\fR, \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and
218 \fB-n\fR options have the same meaning as they do for the \fB::evset\fR dcmd.
219 See \fBmdb\fR(1) for a description of \fB::evset\fR. If the \fB:b\fR form of
220 the dcmd is used, a breakpoint is set only at the virtual address specified by
221 the expression preceding the dcmd. The arguments following the \fB:b\fR dcmd
222 are concatenated together to form the callback string. If this string contains
223 meta-characters, it must be quoted.
227 .ne 2
229 \fB\fB::branches\fR [\fB-v\fR]\fR
233 \fB(x86 only)\fR
235 .sp .6
236 .RS 4n
237 Display the last branches taken by the CPU. This dcmd is supported only on x86
238 systems, and is available only when processor-specific support is detected and
239 enabled. The number and type of branches displayed is dependent on the
240 capabilities of the branch tracing facilities provided by the CPU. When the
241 \fB-v\fR option is used, the instructions prior to a given branch are
242 displayed.
246 .ne 2
248 \fB[\fIfunction\fR] \fB::call\fR [\fIarg\fR [\fIarg\fR ...]]\fR
250 .sp .6
251 .RS 4n
252 Call the specified function using the specified arguments. The called function
253 must be listed as a function in the symbol table for a loaded module. String
254 arguments are passed by reference. When the call completes, the return value of
255 the function is displayed.
257 This dcmd must be used with extreme caution. The kernel will not be resumed
258 when the call is made. The function being called may not make any assumptions
259 regarding the availability of any kernel services, and must not perform
260 operations or calls that may block. The user must also beware of any
261 side-effects introduced by the called function, as kernel stability might be
262 affected.
266 .ne 2
268 \fB[\fIaddr\fR] \fB::cpuregs\fR [\fB-c\fR \fIcpuid\fR]\fR
270 .sp .6
271 .RS 4n
272 Display the current general purpose register set for the specified CPU, in the
273 format used by \fB::regs\fR.
277 .ne 2
279 \fB[\fIaddr\fR] \fB::cpustack\fR [\fB-c\fR \fIcpuid\fR]\fR
281 .sp .6
282 .RS 4n
283 Print a C stack backtrace for the specified CPU. The backtrace displayed is for
284 the point at which the specified CPU entered or was stopped by the debugger.
288 .ne 2
290 \fB\fIaddr\fR[,\fIlen\fR] \fB::in\fR [\fB-L\fR \fIlen\fR]\fR
294 \fB(x86 only)\fR
296 .sp .6
297 .RS 4n
298 Read \fIlen\fR bytes from the I/O port specified by \fIaddr\fR. The value of
299 the \fB-L\fR option, if provided, takes precedence over the value of the repeat
300 count. The read length must be 1, 2, or 4 bytes, and the port address must have
301 the same alignment as the length.
305 .ne 2
307 \fB\fIaddr\fR[,\fIlen\fR] \fB::out\fR [\fB-L\fR \fIlen\fR] \fIvalue\fR\fR
311 \fB(x86 only)\fR
313 .sp .6
314 .RS 4n
315 Write value to the len-byte I/O port specified by \fIaddr\fR. The value of the
316 \fB-L\fR option, if provided, takes precedence over the value of the repeat
317 count. The write length must be 1, 2, or 4 bytes and the port address must have
318 the same alignment as the length.
322 .ne 2
324 \fB\fB::quit\fR [\fB-u\fR]\fR
328 \fB\fB$q\fR\fR
330 .sp .6
331 .RS 4n
332 Causes the debugger to exit. When the \fB-u\fR option is used, the system is
333 resumed and the debugger is unloaded. The \fB-u\fR option may not be used if
334 the debugger was loaded at boot. When the \fB-u\fR option is not used, SPARC
335 systems will exit to the boot PROM \fBok\fR prompt. The \fBgo\fR command can be
336 used to re-enter the debugger. On x86 systems, a prompt is displayed that
337 requests permission to reboot the machine.
341 .ne 2
343 \fB\fB::step [over|out|branch]\fR\fR
345 .sp .6
346 .RS 4n
347 Step the target one instruction. The optional \fBover\fR argument is used to
348 step over subroutine calls. When the optional \fBout\fR argument is specified,
349 the target program continues until control returns from the current function.
351 The optional \fBbranch\fR argument is available only on x86 systems when
352 processor-specific support is detected and enabled. When \fB::step branch\fR is
353 specified, the target program continues until the next branching instruction is
354 encountered.
356 On SPARC systems, the \fB::step dcmd\fR may not be used to step 'ta'
357 instructions. Similarly, it may not be used on x86 systems to step 'int'
358 instructions. If the step results in a trap that cannot be resolved by the
359 debugger, a message to that effect is printed and the step will fail.
363 .ne 2
365 \fB\fBcpuid::switch\fR\fR
369 \fB\fBcpuid:x\fR\fR
371 .sp .6
372 .RS 4n
373 Use the specified CPU as the representative. Stack traces, general purpose
374 register dumps, and similar functionality use the new representative CPU as the
375 data source. Full execution control functionality is available on the new
376 representative CPU.
380 .ne 2
382 \fB\fB::term\fR\fR
384 .sp .6
385 .RS 4n
386 Display the current terminal type.
390 .ne 2
392 \fB\fIaddr\fR\fB[,\fR\fIlen\fR]\fB::wp [+/-dDestT]\fR [\fB-rwx\fR] [\fB-pi\fR]
393 [\fB-n\fR \fIcount\fR] [\fB-c\fR \fIcmd\fR]\fR
397 \fB\fB\fIaddr\fR[,\fIlen\fR]\fR\fB:a [\fIcmd\fR\fR \fB\&...]\fR\fR
401 \fB\fB\fIaddr\fR[,\fIlen\fR]\fR\fB:p [\fIcmd\fR\fR \fB\&...]\fR\fR
405 \fB\fB\fIaddr\fR[,\fIlen\fR]\fR\fB:w [\fIcmd\fR\fR \fB\&...]\fR\fR
407 .sp .6
408 .RS 4n
409 Set a watchpoint at the specified address, interpreted by default as a virtual
410 address. If the \fB-p\fR option is used, the address is interpreted as a
411 physical address. On x86 platforms, watchpoints can be set on I/O ports using
412 the \fB-i\fR option. When the \fB-i\fR option is used, the address is
413 interpreted as that of an I/O port.
415 The length in bytes of the watched region can be set by specifying an optional
416 repeat count preceding the dcmd. If no length is explicitly set, the default is
417 one byte. The \fB::wp\fR dcmd allows the watchpoint to be configured to trigger
418 on any combination of read (\fB-r\fR option), write (\fB-w\fR option), or
419 execute (\fB-x\fR option) access.
421 The \fB-d\fR, \fB-D\fR, \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and
422 \fB-n\fR options have the same meaning as they do for the \fB::evset\fR dcmd.
423 See \fBmdb\fR(1) for a description of \fB::evset\fR. The \fB:a\fR dcmd sets a
424 read access watchpoint at the specified address. The \fB:p\fR dcmd sets an
425 execute access watchpoint at the specified address. The \fB:w\fR dcmd sets a
426 write access watchpoint at the specified address. The arguments following the
427 \fB:a\fR, \fB:p\fR, and \fB:w\fR dcmds are concatenated together to form the
428 callback string. If the string contains meta-characters, it must be quoted.
431 .SH ATTRIBUTES
433 See \fBattributes\fR(5) for descriptions of the following attributes:
438 box;
439 c | c
440 l | l .
441 ATTRIBUTE TYPE  ATTRIBUTE VALUE
443 Interface Stability     Evolving
446 .SH SEE ALSO
448 \fBkbd\fR(1), \fBmdb\fR(1), \fBboot\fR(8), \fBdumpadm\fR(8), \fBkernel\fR(8),
449 \fBsystem\fR(4), \fBattributes\fR(5)
452 \fIModular Debugger Guide\fR:
455 https://illumos.org/books/mdb/
456 .SH NOTES
457 .SS "Limitations on Memory Available to the Debugger"
459 The memory region available to the debugger is allocated when the debugger is
460 loaded, and is fixed at that point. If dcmds attempt to allocate more memory
461 than is available, they will, if possible, be terminated. The debugger will
462 attempt to recover gracefully from an out-of-memory situation, but may be
463 unable to, and may be forced to terminate the system. This constraint is
464 especially acute on 32-bit x86 systems.
465 .SS "Performance Impact"
467 System performance will be negatively impacted by the loading of \fBkmdb\fR, as
468 the debugger will consume kernel memory and other limited system resources.