Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / mdb.1
bloba1bdc1242ea7e1861916cec4f9b6efdc1259bde4
1 '\" te
2 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright (c) 2012, Joyent, Inc. All Rights Reserved.
4 .\" Copyright (c) 2014, 2017 by Delphix. All rights reserved.
5 .\" 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.
6 .\" 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.
7 .\" 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]
8 .TH MDB 1 "Dec 9, 2017"
9 .SH NAME
10 mdb \- modular debugger
11 .SH SYNOPSIS
12 .LP
13 .nf
14 \fBmdb\fR [\fB-fkmuwyAFKMSUW\fR] [\(+-o \fIoption\fR] [\fB-p\fR \fIpid\fR] [\fB-s\fR \fIdistance\fR]
15      [\fB-I\fR \fIpath\fR] [\fB-L\fR \fIpath\fR] [\fB-P\fR \fIprompt\fR] [\fB-R\fR \fIroot\fR]
16      [\fB-V\fR \fIdis-version\fR] [\fB-e\fR \fIexpr\fR] [object [core] | core | suffix]
17 .fi
19 .SH DESCRIPTION
20 .SS "Introduction"
21 .LP
22 The \fBmdb\fR utility is an extensible utility for low-level debugging and
23 editing of the live operating system, operating system crash dumps, user
24 processes, user process core dumps, and object files. For a more detailed
25 description of \fBmdb\fR features, refer to the \fIModular
26 Debugger Guide\fR.
27 .sp
28 .LP
29 Debugging is the process of analyzing the execution and state of a software
30 program in order to remove defects. Traditional debugging tools provide
31 facilities for execution control so that programmers can re-execute programs in
32 a controlled environment and display the current state of program data or
33 evaluate expressions in the source language used to develop the program.
34 .sp
35 .LP
36 Unfortunately, these techniques are often inappropriate for debugging complex
37 software systems such as an operating system, where bugs might not be
38 reproducible and program state is massive and distributed, for programs that
39 are highly optimized, have had their debug information removed, or are
40 themselves low-level debugging tools, or for customer situations where the
41 developer can only access post-mortem information.
42 .sp
43 .LP
44 \fBmdb\fR provides a completely customizable environment for debugging these
45 programs and scenarios, including a dynamic module facility that programmers
46 can use to implement their own debugging commands to perform program-specific
47 analysis. Each \fBmdb\fR module can be used to examine the program in several
48 different contexts, including live and post-mortem.
49 .SS "Definitions"
50 .LP
51 The \fItarget\fR is the program being inspected by the debugger. \fBmdb\fR
52 currently provides support for the following types of targets: user processes,
53 user process core files, the live operating system (via \fB/dev/kmem\fR and
54 \fB/dev/ksyms\fR), operating system crash dumps, user process images recorded
55 inside an operating system crash dump, \fBELF\fR object files, and raw binary
56 files. Each target exports a standard set of properties, including one or more
57 address spaces, one or more symbol tables, a set of load objects, and a set of
58 threads that can be examined using the debugger commands described below.
59 .sp
60 .LP
61 A debugger command, or \fIdcmd\fR (pronounced dee-command) in \fBmdb\fR
62 terminology, is a routine in the debugger that can access any of the properties
63 of the current target. \fBmdb\fR parses commands from standard input, and then
64 executes the corresponding dcmds. Each dcmd can also accept a list of string or
65 numerical arguments, as shown in the syntax description below. \fBmdb\fR
66 contains a set of built-in dcmds, described below, that are always available.
67 You can also extend the capabilities of \fBmdb\fR itself by writing your own
68 dcmds, as described in the \fIModular Debugger Guide\fR.
69 .sp
70 .LP
71 A \fIwalker\fR is a set of routines that describe how to walk, or iterate,
72 through the elements of a particular program data structure. A walker
73 encapsulates the data structure's implementation from dcmds and from \fBmdb\fR
74 itself. You can use walkers interactively, or use them as a primitive to build
75 other dcmds or walkers. As with dcmds, you can extend \fBmdb\fR by implementing
76 your own walkers as part of a debugger module.
77 .sp
78 .LP
79 A debugger module, or \fIdmod\fR (pronounced dee-mod), is a dynamically loaded
80 library containing a set of dcmds and walkers. During initialization, \fBmdb\fR
81 attempts to load dmods corresponding to the load objects present in the target.
82 You can subsequently load or unload dmods at any time while running \fBmdb\fR.
83 \fBmdb\fR ships with a set of standard dmods for debugging the kernel.
84 The \fIModular Debugger Guide\fR contains more information on
85 developing your own debugger modules.
86 .sp
87 .LP
88 A \fImacro file\fR is a text file containing a set of commands to execute.
89 Macro files are typically used to automate the process of displaying a simple
90 data structure. \fBmdb\fR provides complete backward compatibility for the
91 execution of macro files written for \fBadb\fR(1), and illumos
92 includes a set of macro files for debugging the kernel that can be used
93 with either tool.
94 .SS "Syntax"
95 .LP
96 The debugger processes commands from standard input. If standard input is a
97 terminal, \fBmdb\fR provides terminal editing capabilities. \fBmdb\fR can also
98 process commands from macro files and from dcmd pipelines, described below. The
99 language syntax is designed around the concept of computing the value of an
100 expression (typically a memory address in the target), and then applying a dcmd
101 to that address. The current address location is referred to as \fIdot\fR, and
102 its value is referenced using ``.''.
105 A \fImetacharacter\fR is one of the following characters:
107 .in +2
109 [   ]   |   !   /   \e   ?   =   >   $   :   ;
110             \fINEWLINE\fR   \fISPACE\fR   \fITAB\fR
112 .in -2
117 A \fIblank\fR is a \fITAB\fR or a \fISPACE\fR. A \fIword\fR is a sequence of
118 characters separated by one or more non-quoted metacharacters. Some of the
119 metacharacters only function as delimiters in certain contexts, as described
120 below. An \fIidentifier\fR is a sequence of letters, digits, underscores,
121 periods, or backquotes beginning with a letter, underscore, or period.
122 Identifiers are used as the names of symbols, variables, dcmds, and walkers.
123 Commands are delimited by a \fINEWLINE\fR or semicolon ( \fB;\fR ).
126 A dcmd is denoted by one of the following words or metacharacters:
128 .in +2
130 /   \e   ?   =   >   $character   :character  ::identifier
132 .in -2
137 dcmds named by metacharacters or prefixed by a single \fB$\fR or \fB:\fR are
138 provided as built-in operators, and implement complete compatibility with the
139 command set of the legacy \fBadb\fR(1) utility. Once a dcmd has been parsed,
140 the \fB/\fR, \fB\e\fR, \fB?\fR, \fB=\fR, \fB>\fR, \fB$\fR, and \fB:\fR
141 characters are no longer recognized as metacharacters until the termination of
142 the argument list.
145 A \fIsimple-command\fR is a dcmd followed by a sequence of zero or more
146 blank-separated words. The words are passed as arguments to the invoked dcmd,
147 except as specified under \fBQuoting and Arithmetic Expansion\fR below. Each
148 dcmd returns an exit status that indicates it was either successful, failed, or
149 was invoked with invalid arguments.
152 A \fIpipeline\fR is a sequence of one or more simple commands separated by
153 \fB|\fR. Unlike the shell, dcmds in \fBmdb\fR pipelines are not executed as
154 separate processes. After the pipeline has been parsed, each dcmd is invoked in
155 order from left to right. Each dcmd's output is processed and stored as
156 described under \fBdcmd Pipelines\fR below. Once the left-hand dcmd is
157 complete, its processed output is used as input for the next dcmd in the
158 pipeline. If any dcmd does not return a successful exit status, the pipeline is
159 aborted.
162 An \fIexpression\fR is a sequence of words that is evaluated to compute a
163 64-bit unsigned integer value. The words are evaluated using the rules
164 described under \fBArithmetic Expansion\fR below.
165 .SS "Commands"
167 A \fIcommand\fR is one of the following:
169 .ne 2
171 \fB\fIpipeline\fR [\fB!\fR \fIword\fR .\|.\|.] [ \fB;\fR ]\fR
173 .sp .6
174 .RS 4n
175 A simple-command or pipeline can be optionally suffixed with the \fB!\fR
176 character, indicating that the debugger should open a \fBpipe\fR(2) and send
177 the standard output of the last dcmd in the \fBmdb\fR pipeline to an external
178 process created by executing \fB$SHELL\fR \fB-c\fR followed by the string
179 formed by concatenating the words after the \fB!\fR character. For more
180 details, refer to \fBShell Escapes\fR below.
184 .ne 2
186 \fB\fIexpression\fR \fI pipeline\fR [\fB!\fR \fIword\fR .\|.\|.] [ \fB;\fR ]\fR
188 .sp .6
189 .RS 4n
190 A simple-command or pipeline can be prefixed with an expression. Before
191 execution of the pipeline, the value of dot (the variable denoted by
192 ``\fB\&.\fR'') is set to the value of the expression.
196 .ne 2
198 \fB\fIexpression\fR\fB ,\fR \fIexpression\fR \fIpipeline \fR [\fB!\fR
199 \fIword\fR .\|.\|.] [ \fB;\fR ]\fR
201 .sp .6
202 .RS 4n
203 A simple-command or pipeline can be prefixed with two expressions. The first is
204 evaluated to determine the new value of dot, and the second is evaluated to
205 determine a repeat count for the first dcmd in the pipeline. This dcmd is
206 executed \fIcount\fR times before the next dcmd in the pipeline is executed.
207 The repeat count only applies to the first dcmd in the pipeline.
211 .ne 2
213 \fB\fB,\fR \fIexpression\fR \fIpipeline\fR [\fB!\fR \fIword\fR .\|.\|.] [
214 \fB;\fR ]\fR
216 .sp .6
217 .RS 4n
218 If the initial expression is omitted, dot is not modified but the first dcmd in
219 the pipeline is repeated according to the value of the expression.
223 .ne 2
225 \fB\fIexpression\fR [\fB!\fR \fIword\fR .\|.\|.] [ \fB;\fR ]\fR
227 .sp .6
228 .RS 4n
229 A command can consist only of an arithmetic expression. The expression is
230 evaluated and the dot variable is set to its value, and then the previous dcmd
231 and arguments are executed using the new value of dot.
235 .ne 2
237 \fB\fIexpression\fR\fB,\fR \fIexpression\fR  [\fB!\fR \fI word\fR .\|.\|.] [
238 \fB;\fR ]\fR
240 .sp .6
241 .RS 4n
242 A command can consist only of a dot expression and repeat count expression.
243 After dot is set to the value of the first expression, the previous dcmd and
244 arguments are repeatedly executed the number of times specified by the value of
245 the second expression.
249 .ne 2
251 \fB\fB,\fR \fIexpression \fR  [\fB!\fR \fIword\fR .\|.\|.] [ \fB;\fR ]\fR
253 .sp .6
254 .RS 4n
255 If the initial expression is omitted, dot is not modified but the previous dcmd
256 and arguments are repeatedly executed the number of times specified by the
257 value of the count expression.
261 .ne 2
263 \fB\fB!\fR \fIword\fR .\|.\|. [ \fB;\fR ]\fR
265 .sp .6
266 .RS 4n
267 If the command begins with the \fB!\fR character, no dcmds are executed and the
268 debugger simply executes \fB$SHELL\fR \fB-c\fR followed by the string formed by
269 concatenating the words after the \fB!\fR character.
272 .SS "Comments"
274 A word beginning with \fB//\fR causes that word and all the subsequent
275 characters up to a \fINEWLINE\fR to be ignored.
276 .SS "Arithmetic Expansion"
278 Arithmetic expansion is performed when an \fBmdb\fR command is preceded by an
279 optional expression representing a start address, or a start address and a
280 repeat count. Arithmetic expansion can also be performed to compute a numerical
281 argument for a dcmd. An arithmetic expression can appear in an argument list
282 enclosed in square brackets preceded by a dollar sign (\fB$[ expression ]\fR),
283 and is replaced by the value of the expression.
286 Expressions can contain any of the following special words:
288 .ne 2
290 \fB\fIinteger\fR\fR
292 .RS 22n
293 The specified integer value. Integer values can be prefixed with \fB0i\fR or
294 \fB0I\fR to indicate binary values, \fB0o\fR or \fB0O\fR to indicate octal
295 values, \fB0t\fR or \fB0T\fR to indicate decimal values, and \fB0x\fR or
296 \fB0X\fR to indicate hexadecimal values (the default).
300 .ne 2
302 \fB0[tT][0-9]+.[0-9]+\fR
304 .RS 22n
305 The specified decimal floating point value, converted to its \fBIEEE\fR
306 double-precision floating point representation.
310 .ne 2
312 \fB\&'\fIcccccccc\fR'\fR
314 .RS 22n
315 The integer value computed by converting each character to a byte equal to its
316 \fBASCII\fR value. Up to eight characters can be specified in a character
317 constant. Characters are packed into the integer in reverse order
318 (right-to-left) beginning at the least significant byte.
322 .ne 2
324 \fB<\fIidentifier\fR\fR
326 .RS 22n
327 The value of the variable named by \fIidentifier\fR.
331 .ne 2
333 \fB\fIidentifier\fR\fR
335 .RS 22n
336 The value of the symbol named by \fIidentifier\fR.
340 .ne 2
342 \fB(\fIexpression\fR)\fR
344 .RS 22n
345 The value of \fIexpression\fR.
349 .ne 2
351 \fB\&.\fR
353 .RS 22n
354 The value of dot.
358 .ne 2
360 \fB&\fR
362 .RS 22n
363 The most recent value of dot used to execute a dcmd.
367 .ne 2
369 \fB+\fR
371 .RS 22n
372 The value of dot incremented by the current increment.
376 .ne 2
378 \fB^\fR
380 .RS 22n
381 The value of dot decremented by the current increment.
386 The increment is a global variable that stores the total bytes read by the last
387 formatting dcmd. For more information on the increment, refer to the discussion
388 of \fBFormatting dcmds\fR below.
391 Unary operators are right associative and have higher precedence than binary
392 operators. The unary operators are:
394 .ne 2
396 \fB#\fIexpression\fR\fR
398 .RS 23n
399 Logical negation.
403 .ne 2
405 \fB~\fIexpression\fR\fR
407 .RS 23n
408 Bitwise complement.
412 .ne 2
414 \fB-\fIexpression\fR\fR
416 .RS 23n
417 Integer negation.
421 .ne 2
423 \fB%\fIexpression\fR\fR
425 .RS 23n
426 The value of a pointer-sized quantity at the object file location corresponding
427 to virtual address \fIexpression\fR in the target's virtual address space.
431 .ne 2
433 \fB%/[csil]/\fIexpression\fR\fR
435 .RS 23n
436 The value of a char, short, int, or long-sized quantity at the object file
437 location corresponding to virtual address \fIexpression\fR in the target's
438 virtual address space.
442 .ne 2
444 \fB%/[1248]/\fIexpression\fR\fR
446 .RS 23n
447 The value of a one, two, four, or eight-byte quantity at the object file
448 location corresponding to virtual address \fIexpression\fR in the target's
449 virtual address space.
453 .ne 2
455 \fB*\fIexpression\fR\fR
457 .RS 23n
458 The value of a pointer-sized quantity at virtual address \fIexpression\fR in
459 the target's virtual address space.
463 .ne 2
465 \fB*/[csil]/\fIexpression\fR\fR
467 .RS 23n
468 The value of a char, short, int, or long-sized quantity at virtual address
469 \fIexpression\fR in the target's virtual address space.
473 .ne 2
475 \fB*/[1248]/\fIexpression\fR\fR
477 .RS 23n
478 The value of a one, two, four, or eight-byte quantity at virtual address
479 \fIexpression\fR in the target's virtual address space.
484 Binary operators are left associative and have lower precedence than unary
485 operators. The binary operators, in order of precedence from highest to lowest,
486 are:
488 .ne 2
490 \fB\fB*\fR\fR
492 .RS 6n
493 Integer multiplication.
497 .ne 2
499 \fB\fB%\fR\fR
501 .RS 6n
502 Integer division.
506 .ne 2
508 \fB\fB#\fR\fR
510 .RS 6n
511 Left-hand side rounded up to next multiple of right-hand side.
515 .ne 2
517 \fB\fB+\fR\fR
519 .RS 6n
520 Integer addition.
524 .ne 2
526 \fB\fB-\fR\fR
528 .RS 6n
529 Integer subtraction.
533 .ne 2
535 \fB\fB<<\fR\fR
537 .RS 6n
538 Bitwise shift left.
542 .ne 2
544 \fB\fB>>\fR\fR
546 .RS 6n
547 Bitwise shift right.
551 .ne 2
553 \fB\fB==\fR\fR
555 .RS 6n
556 Logical equality.
560 .ne 2
562 \fB\fB!=\fR\fR
564 .RS 6n
565 Logical inequality.
569 .ne 2
571 \fB\fB&\fR\fR
573 .RS 6n
574 Bitwise AND.
578 .ne 2
580 \fB\fB\fR^\fR
582 .RS 6n
583 Bitwise exclusive OR.
587 .ne 2
589 \fB\fB|\fR\fR
591 .RS 6n
592 Bitwise inclusive OR.
595 .SS "Quoting"
597 Each metacharacter described above (see \fBSyntax\fR) terminates a word unless
598 quoted. Characters can be quoted (forcing \fBmdb\fR to interpret each character
599 as itself without any special significance) by enclosing them in a pair of
600 single (\fB\&' '\fR) or double (\fB" "\fR) quote marks. A single quote cannot
601 appear within single quotes. Inside double quotes, \fBmdb\fR recognizes the C
602 programming language character escape sequences.
603 .SS "Shell Escapes"
605 The \fB!\fR character can be used to create a pipeline between an \fBmdb\fR
606 command and the user's shell. If the $\fBSHELL\fR environment variable is set,
607 \fBmdb\fR forks and execs this program for shell escapes; otherwise
608 \fB/bin/sh\fR is used. The shell is invoked with the \fB-c\fR option followed
609 by a string formed by concatenating the words after the \fB!\fR character. The
610 \fB!\fR character takes precedence over all other metacharacters, except
611 semicolon (\fB;\fR) and \fINEWLINE\fR. Once a shell escape is detected, the
612 remaining characters up to the next semicolon or \fINEWLINE\fR are passed as is
613 to the shell. The output of shell commands can not be piped to \fBmdb\fR dcmds.
614 Commands executed by a shell escape have their output sent directly to the
615 terminal, not to \fBmdb\fR.
616 .SS "Variables"
618 A \fIvariable\fR is a variable name, a corresponding integer value, and a set
619 of attributes. A variable name is a sequence of letters, digits, underscores,
620 or periods. A variable can be assigned a value using the \fB>\fR dcmd or
621 \fB::typeset\fR dcmd, and its attributes can be manipulated using the
622 \fB::typeset\fR dcmd. Each variable's value is represented as a 64-bit unsigned
623 integer. A variable can have one or more of the following attributes: read-only
624 (cannot be modified by the user), persistent (cannot be unset by the user), and
625 tagged (user-defined indicator).
628 The following variables are defined as persistent:
630 .ne 2
632 \fB0\fR
634 .RS 10n
635 The most recent value printed using the \fB/\fR, \fB\e\fR, \fB?\fR, or \fB=\fR
636 dcmd.
640 .ne 2
642 \fB9\fR
644 .RS 10n
645 The most recent count used with the \fB$<\fR dcmd.
649 .ne 2
651 \fBb\fR
653 .RS 10n
654 The virtual address of the base of the data section.
658 .ne 2
660 \fBd\fR
662 .RS 10n
663 The size of the data section in bytes.
667 .ne 2
669 \fBe\fR
671 .RS 10n
672 The virtual address of the entry point.
676 .ne 2
678 \fBm\fR
680 .RS 10n
681 The initial bytes (magic number) of the target's primary object file, or zero
682 if no object file has been read yet.
686 .ne 2
688 \fBt\fR
690 .RS 10n
691 The size of the text section in bytes.
695 .ne 2
697 \fBhits\fR
699 .RS 10n
700 The count of the number of times the matched software event specifier has been
701 matched. See \fBEvent Callbacks\fR, below.
705 .ne 2
707 \fBthread\fR
709 .RS 10n
710 The thread identifier of the current representative thread. The value of the
711 identifier depends on the threading model used by the current target. See
712 \fBThread Support\fR, below.
717 In addition, the \fBmdb\fR kernel and process targets export the current values
718 of the representative thread's register set as named variables. The names of
719 these variables depend on the target's platform and instruction set
720 architecture.
721 .SS "Symbol Name Resolution"
723 As explained in the \fBSyntax\fR description above, a symbol identifier present
724 in an expression context evaluates to the value of this symbol. The value
725 typically denotes the virtual address of the storage associated with the symbol
726 in the target's virtual address space. A target can support multiple symbol
727 tables including, but not limited to, a primary executable symbol table, a
728 primary dynamic symbol table, a run-time link-editor symbol table, and standard
729 and dynamic symbol tables for each of a number of load objects (such as shared
730 libraries in a user process, or kernel modules in the kernel). The
731 target typically searches the primary executable's symbol tables first, and
732 then one or more of the other symbol tables. Notice that \fBELF\fR symbol
733 tables only contain entries for external, global, and static symbols; automatic
734 symbols do not appear in the symbol tables processed by \fBmdb\fR.
737 Additionally, \fBmdb\fR provides a private user-defined symbol table that is
738 searched prior to any of the target symbol tables. The private symbol table is
739 initially empty, and can be manipulated using the \fB::nmadd\fR and
740 \fB::nmdel\fR dcmds. The \fB::nm\fR \fB-P\fR option can be used to display the
741 contents of the private symbol table. The private symbol table allows the user
742 to create symbol definitions for program functions or data that were either
743 missing from the original program or stripped out. These definitions are then
744 used whenever \fBmdb\fR converts a symbolic name to an address, or an address
745 to the nearest symbol.
748 As targets contain multiple symbol tables, and each symbol table can include
749 symbols from multiple object files, different symbols with the same name can
750 exist. \fBmdb\fR uses the backquote (\fB`\fR) character as a symbol name
751 scoping operator to allow the programmer to obtain the value of the desired
752 symbol in this situation. The programmer can specify the scope used to resolve
753 a symbol name as either: \fIobject\fR\fB`\fR\fIname\fR, or
754 \fIfile\fR\fB`\fR\fIname\fR, or \fIobject\fR\fB`\fR\fIfile\fR\fB`\fR\fIname\fR.
755 The object identifier refers to the name of a load object. The file identifier
756 refers to the basename of a source file that has a symbol of type
757 \fBSTT_FILE\fR in the specified object's symbol table. The object identifier's
758 interpretation depends on the target type.
761 The \fBmdb\fR kernel target expects \fIobject\fR to specify the basename of a
762 loaded kernel module. For example, the symbol name
764 .in +2
766 specfs`_init
768 .in -2
773 evaluates to the value of the \fB_init\fR symbol in the \fBspecfs\fR kernel
774 module.
777 The \fBmdb\fR process target expects \fIobject\fR to specify the name of the
778 executable or of a loaded shared library. It can take any of the following
779 forms:
780 .RS +4
783 An exact match (that is, a full pathname): \fB/usr/lib/libc.so.1\fR
785 .RS +4
788 An exact basename match: \fBlibc.so.1\fR
790 .RS +4
793 An initial basename match up to a ``\fB\&.\fR'' suffix: \fBlibc.so\fR or
794 \fBlibc\fR
796 .RS +4
799 The literal string \fBa.out\fR is accepted as an alias for the executable.
803 The process target also accepts any of the four forms described above preceded
804 by an optional link-map id (lmid). The lmid prefix is specified by an initial
805 "\fBLM\fR" followed by the link-map id in hexadecimal followed by an additional
806 backquote. For example, the symbol name
808 .in +2
810 LM0`libc.so.1`_init
812 .in -2
817 evaluates to the value of the \fB_init\fR symbol in the \fBlibc.so.1\fR library
818 that is loaded on link-map 0 (\fBLM_ID_BASE\fR). The link-map specifier can be
819 necessary to resolve symbol naming conflicts in the event that the same library
820 is loaded on more than one link map. For more information on link maps, refer
821 to the \fILinker and Libraries Guide\fR and \fBdlopen\fR(3C). Link-map
822 identifiers are displayed when symbols are printed according to the setting of
823 the \fBshowlmid\fR option, as described under OPTIONS.
826 In the case of a naming conflict between symbols and hexadecimal integer
827 values, \fBmdb\fR attempts to evaluate an ambiguous token as a symbol first,
828 before evaluating it as an integer value. For example, the token \fBf\fR can
829 either refer to the decimal integer value \fB15\fR specified in hexadecimal
830 (the default base), or to a global variable named \fBf\fR in the target's
831 symbol table. If a symbol with an ambiguous name is present, the integer value
832 can be specified by using an explicit \fB0x\fR or \fB0X\fR prefix.
833 .SS "dcmd and Walker Name Resolution"
835 As described earlier, each \fBmdb\fR dmod provides a set of dcmds and walkers.
836 dcmds and walkers are tracked in two distinct, global namespaces. \fBmdb\fR
837 also keeps track of a dcmd and walker namespace associated with each dmod.
838 Identically named dcmds or walkers within a given dmod are not allowed: a dmod
839 with this type of naming conflict fails to load. Name conflicts between dcmds
840 or walkers from different dmods are allowed in the global namespace. In the
841 case of a conflict, the first dcmd or walker with that particular name to be
842 loaded is given precedence in the global namespace. Alternate definitions are
843 kept in a list in load order. The backquote character (\fB`\fR) can be used in
844 a dcmd or walker name as a scoping operator to select an alternate definition.
845 For example, if dmods \fBm1\fR and \fBm2\fR each provide a dcmd \fBd\fR, and
846 \fBm1\fR is loaded prior to \fBm2\fR, then:
848 .ne 2
850 \fB\fB::d\fR\fR
852 .RS 10n
853 Executes \fBm1\fR's definition of \fBd\fR.
857 .ne 2
859 \fB\fB::m1`d\fR\fR
861 .RS 10n
862 Executes \fBm1\fR's definition of \fBd\fR.
866 .ne 2
868 \fB\fB::m2`d\fR\fR
870 .RS 10n
871 Executes \fBm2'\fRs definition of \fBd\fR.
876 If module \fBm1\fR were now unloaded, the next dcmd on the global definition
877 list (\fBm2`d\fR) would be promoted to global visibility. The current
878 definition of a dcmd or walker can be determined using the \fB::which\fR dcmd,
879 described below. The global definition list can be displayed using the
880 \fB::which\fR \fB-v\fR option.
881 .SS "dcmd Pipelines"
883 dcmds can be composed into a pipeline using the \fB|\fR operator. The purpose
884 of a pipeline is to pass a list of values, typically virtual addresses, from
885 one dcmd or walker to another. Pipeline stages might be used to map a pointer
886 from one type of data structure to a pointer to a corresponding data structure,
887 to sort a list of addresses, or to select the addresses of structures with
888 certain properties.
891 \fBmdb\fR executes each dcmd in the pipeline in order from left to right. The
892 leftmost dcmd is executed using the current value of dot, or using the value
893 specified by an explicit expression at the start of the command. When a \fB|\fR
894 operator is encountered, \fBmdb\fR creates a pipe (a shared buffer) between the
895 output of the dcmd to its left and the \fBmdb\fR parser, and an empty list of
896 values. As the dcmd executes, its standard output is placed in the pipe and
897 then consumed and evaluated by the parser, as if \fBmdb\fR were reading this
898 data from standard input. Each line must consist of an arithmetic expression
899 terminated by a \fINEWLINE\fR or semicolon (\fB;\fR). The value of the
900 expression is appended to the list of values associated with the pipe. If a
901 syntax error is detected, the pipeline is aborted.
904 When the dcmd to the left of a \fB|\fR operator completes, the list of values
905 associated with the pipe is then used to invoke the dcmd to the right of the
906 \fB|\fR operator. For each value in the list, dot is set to this value and the
907 right-hand dcmd is executed. Only the rightmost dcmd in the pipeline has its
908 output printed to standard output. If any dcmd in the pipeline produces output
909 to standard error, these messages are printed directly to standard error and
910 are not processed as part of the pipeline.
911 .SS "Signal Handling"
913 The debugger ignores the \fBPIPE\fR and \fBQUIT\fR signals. The \fBINT\fR
914 signal aborts the command that is currently executing. The debugger intercepts
915 and provides special handling for the \fBILL\fR, \fBTRAP\fR, \fBEMT\fR,
916 \fBFPE\fR, \fBBUS\fR, and \fBSEGV\fR signals. If any of these signals are
917 generated asynchronously (that is, delivered from another process using
918 \fBkill\fR(2)), \fBmdb\fR restores the signal to its default disposition and
919 dump core. However, if any of these signals are generated synchronously by the
920 debugger process itself and a dcmd from an externally loaded dmod is currently
921 executing, and standard input is a terminal, \fBmdb\fR provides a menu of
922 choices allowing the user to force a core dump, quit without producing a core
923 dump, stop for attach by a debugger, or attempt to resume. The resume option
924 aborts all active commands and unload the dmod whose dcmd was active at the
925 time the fault occurred. It can then be subsequently re-loaded by the user. The
926 resume option provides limited protection against buggy dcmds. Refer to
927 WARNINGS, \fBUse of the Error Recovery Mechanism\fR, below for information
928 about the risks associated with the resume option.
929 .SS "Command Re-entry"
931 The text of the last \fBHISTSIZE \fR (default 128) commands entered from a
932 terminal device are saved in memory. The in-line editing facility, described
933 next, provides key mappings for searching and fetching elements from the
934 history list.
935 .SS "In-line Editing"
937 If standard input is a terminal device, \fBmdb\fR provides some simple
938 emacs-style facilities for editing the command line. The \fBsearch\fR,
939 \fBprevious\fR, and \fBnext\fR commands in edit mode provide access to the
940 history list. Only strings, not patterns, are matched when searching. In the
941 table below, the notation for control characters is caret (\fB^\fR) followed by
942 a character shown in upper case. The notation for escape sequences is \fBM-\fR
943 followed by a character. For example, \fBM-f\fR (pronounced meta-eff) is
944 entered by depressing ESC followed by '\fBf\fR', or by depressing Meta followed
945 by '\fBf\fR' on keyboards that support a \fBMeta\fR key. A command line is
946 committed and executed using \fIRETURN\fR or \fINEWLINE\fR. The edit commands
947 are:
949 .ne 2
951 \fB^F\fR
953 .RS 14n
954 Move cursor forward (right) one character.
958 .ne 2
960 \fBM-f\fR
962 .RS 14n
963 Move cursor forward one word.
967 .ne 2
969 \fB^B\fR
971 .RS 14n
972 Move cursor backward (left) one character.
976 .ne 2
978 \fBM-b\fR
980 .RS 14n
981 Move cursor backward one word.
985 .ne 2
987 \fB^A\fR
989 .RS 14n
990 Move cursor to start of line.
994 .ne 2
996 \fB^E\fR
998 .RS 14n
999 Move cursor to end of line.
1003 .ne 2
1005 \fB^D\fR
1007 .RS 14n
1008 Delete current character, if the current line is not empty. If the current line
1009 is empty, \fB^D\fR denotes \fBEOF\fR and the debugger exits.
1013 .ne 2
1015 \fBM-^H\fR
1017 .RS 14n
1018 (Meta-backspace) Delete previous word.
1022 .ne 2
1024 \fB^K\fR
1026 .RS 14n
1027 Delete from the cursor to the end of the line.
1031 .ne 2
1033 \fB^L\fR
1035 .RS 14n
1036 Clear the screen and reprint the current line.
1040 .ne 2
1042 \fB^T\fR
1044 .RS 14n
1045 Transpose current character with next character.
1049 .ne 2
1051 \fB^N\fR
1053 .RS 14n
1054 Fetch the next command from the history. Each time \fB^N\fR is entered, the
1055 next command forward in time is retrieved.
1059 .ne 2
1061 \fB^P\fR
1063 .RS 14n
1064 Fetch the previous command from the history. Each time \fB^P\fR is entered, the
1065 next command backward in time is retrieved.
1069 .ne 2
1071 \fB^R[\fIstring\fR]\fR
1073 .RS 14n
1074 Search backward in the history for a previous command line containing
1075 \fIstring\fR. The string should be terminated by a \fIRETURN\fR or
1076 \fINEWLINE\fR. If \fIstring\fR is omitted, the previous history element
1077 containing the most recent string is retrieved.
1082 The editing mode also interprets the following user-defined sequences as
1083 editing commands. User defined sequences can be read or modified using the
1084 \fBstty\fR(1) command.
1086 .ne 2
1088 \fBerase\fR
1090 .RS 11n
1091 User defined erase character (usually \fB^H\fR or \fB^?\fR). Delete previous
1092 character.
1096 .ne 2
1098 \fBintr\fR
1100 .RS 11n
1101 User defined interrupt character (usually \fB^C\fR). Abort the current command
1102 and print a new prompt.
1106 .ne 2
1108 \fBkill\fR
1110 .RS 11n
1111 User defined kill character (usually \fB^U\fR). Kill the entire current command
1112 line.
1116 .ne 2
1118 \fBquit\fR
1120 .RS 11n
1121 User defined quit character (usually \fB^\e\fR). Quit the debugger.
1125 .ne 2
1127 \fBsuspend\fR
1129 .RS 11n
1130 User defined suspend character (usually \fB^Z\fR). Suspend the debugger.
1134 .ne 2
1136 \fBwerase\fR
1138 .RS 11n
1139 User defined word erase character (usually \fB^W\fR). Erase the preceding word.
1144 On keyboards that support an extended keypad with arrow keys, \fBmdb\fR
1145 interprets these keystrokes as editing commands:
1147 .ne 2
1149 \fBup-arrow\fR
1151 .RS 15n
1152 Fetch the previous command from the history (same as \fB^P\fR).
1156 .ne 2
1158 \fBdown-arrow\fR
1160 .RS 15n
1161 Fetch the next command from the history (same as \fB^N\fR).
1165 .ne 2
1167 \fBleft-arrow\fR
1169 .RS 15n
1170 Move cursor backward one character (same as \fB^B\fR).
1174 .ne 2
1176 \fBright-arrow\fR
1178 .RS 15n
1179 Move cursor forward one character (same as \fB^F\fR).
1182 .SS "Output Pager"
1184 \fBmdb\fR provides a built-in output pager. The output pager is enabled if the
1185 debugger's standard output is a terminal device. Each time a command is
1186 executed, \fBmdb\fR pauses after one screenful of output is produced and
1187 displays a pager prompt:
1189 .in +2
1191  >> More [<space>, <cr>, q, n, c, a] ?
1193 .in -2
1198 The following key sequences are recognized by the pager:
1200 .ne 2
1202 \fB\fISPACE\fR\fR
1204 .RS 25n
1205 Display the next screenful of output.
1209 .ne 2
1211 \fBa, A\fR
1213 .RS 25n
1214 Abort the current top-level command and return to the prompt.
1218 .ne 2
1220 \fBc, C\fR
1222 .RS 25n
1223 Continue displaying output without pausing at each screenful until the current
1224 top-level command is complete.
1228 .ne 2
1230 \fBn, N, \fINEWLINE\fR, \fIRETURN\fR\fR
1232 .RS 25n
1233 Display the next line of output.
1237 .ne 2
1239 \fBq, Q, ^C, ^\e\fR
1241 .RS 25n
1242 Quit (abort) the current dcmd only.
1245 .SS "Formatting dcmds"
1247 The \fB/\fR, \fB\e\fR, \fB?\fR, and \fB=\fR metacharacters are used to denote
1248 the special output formatting dcmds. Each of these dcmds accepts an argument
1249 list consisting of one or more format characters, repeat counts, or quoted
1250 strings. A format character is one of the \fBASCII\fR characters shown in the
1251 table below. Format characters are used to read and format data from the
1252 target. A repeat count is a positive integer preceding the format character
1253 that is always interpreted in base 10 (decimal). A repeat count can also be
1254 specified as an expression enclosed in square brackets preceded by a dollar
1255 sign (\fB$[ ]\fR). A string argument must be enclosed in double-quotes (\fB"
1256 "\fR). No blanks are necessary between format arguments.
1259 The formatting dcmds are:
1261 .ne 2
1263 \fB\fB/\fR\fR
1265 .RS 6n
1266 Display data from the target's virtual address space starting at the virtual
1267 address specified by dot.
1271 .ne 2
1273 \fB\fB\e\fR\fR
1275 .RS 6n
1276 Display data from the target's physical address space starting at the physical
1277 address specified by dot.
1281 .ne 2
1283 \fB\fB?\fR\fR
1285 .RS 6n
1286 Display data from the target's primary object file starting at the object file
1287 location corresponding to the virtual address specified by dot.
1291 .ne 2
1293 \fB\fB=\fR\fR
1295 .RS 6n
1296 Display the value of dot itself in each of the specified data formats. The
1297 \fB=\fR dcmd is therefore useful for converting between bases and performing
1298 arithmetic.
1303 In addition to dot, \fBmdb\fR keeps track of another global value called the
1304 \fIincrement\fR. The increment represents the distance between dot and the
1305 address following all the data read by the last formatting dcmd. For example,
1306 if a formatting dcmd is executed with dot equal to address A, and displays a
1307 4-byte integer, then after this dcmd completes, dot is still A, but the
1308 increment is set to \fB4\fR. The \fB+\fR character (described under
1309 \fBArithmetic Expansion\fR above) would now evaluate to the value \fBA + 4\fR,
1310 and could be used to reset dot to the address of the next data object for a
1311 subsequent dcmd.
1314 Most format characters increase the value of the increment by the number of
1315 bytes corresponding to the size of the data format, shown in the table. The
1316 table of format characters can be displayed from within \fBmdb\fR using the
1317 \fB::formats\fR dcmd. The format characters are:
1322 l l
1323 l l .
1324 \fB+\fR T{
1325 increment dot by the count (variable size)
1327 \fB-\fR T{
1328 decrement dot by the count (variable size)
1330 B       hexadecimal int (1 byte)
1331 C       T{
1332 character using C character notation (1 byte)
1334 D       decimal signed int (4 bytes)
1335 E       decimal unsigned long long (8 bytes)
1336 F       double (8 bytes)
1337 G       octal unsigned long long (8 bytes)
1338 H       swap bytes and shorts (4 bytes)
1339 I       T{
1340 address and disassembled instruction (variable size)
1342 J       hexadecimal long long (8 bytes)
1343 K       hexadecimal uintptr_t (4 or 8 bytes)
1344 N       newline
1345 O       octal unsigned int (4 bytes)
1346 P       symbol (4 or 8 bytes)
1347 Q       octal signed int (4 bytes)
1348 R       binary int (8 bytes)
1349 S       T{
1350 string using C string notation (variable size)
1352 T       horizontal tab
1353 U       decimal unsigned int (4 bytes)
1354 V       decimal unsigned int (1 byte)
1355 W       default radix unsigned int (4 bytes)
1356 X       hexadecimal int (4 bytes)
1357 Y       decoded time32_t (4 bytes)
1358 Z       hexadecimal long long (8 bytes)
1359 ^       T{
1360 decrement dot by increment * count (variable size)
1362 a       dot as symbol+offset
1363 b       octal unsigned int (1 byte)
1364 c       character (1 byte)
1365 d       decimal signed short (2 bytes)
1366 e       decimal signed long long (8 bytes)
1367 f       float (4 bytes)
1368 g       octal signed long long (8 bytes)
1369 h       swap bytes (2 bytes)
1370 i       disassembled instruction (variable size)
1371 n       newline
1372 o       octal unsigned short (2 bytes)
1373 p       symbol (4 or 8 bytes)
1374 q       octal signed short (2 bytes)
1375 r       whitespace
1376 s       raw string (variable size)
1377 t       horizontal tab
1378 u       decimal unsigned short (2 bytes)
1379 v       decimal signed int (1 byte)
1380 w       default radix unsigned short (2 bytes)
1381 x       hexadecimal short (2 bytes)
1382 y       decoded time64_t (8 bytes)
1383 z       write whose size is inferred by CTF info (variable size)
1388 The \fB/\fR, \fB\e\fR, and \fB?\fR formatting dcmds can also be used to write
1389 to the target's virtual address space, physical address space, or object file
1390 by specifying one of the following modifiers as the first format character, and
1391 then specifying a list of words that are either immediate values or expressions
1392 enclosed in square brackets preceded by a dollar sign (\fB$[ ]\fR).
1395 The write modifiers are:
1397 .ne 2
1399 \fB\fBv\fR\fR
1401 .RS 5n
1402 Write the lowest byte of the value of each expression to the target beginning
1403 at the location specified by dot.
1407 .ne 2
1409 \fB\fBw\fR\fR
1411 .RS 5n
1412 Write the lowest two bytes of the value of each expression to the target
1413 beginning at the location specified by dot.
1417 .ne 2
1419 \fB\fBW\fR\fR
1421 .RS 5n
1422 Write the lowest 4 bytes of the value of each expression to the target
1423 beginning at the location specified by dot.
1427 .ne 2
1429 \fB\fBZ\fR\fR
1431 .RS 5n
1432 Write the complete 8 bytes of the value of each expression to the target
1433 beginning at the location specified by dot.
1438 The \fB/\fR, \fB\e\fR, and \fB?\fR formatting dcmds can also be used to search
1439 for a particular integer value in the target's virtual address space, physical
1440 address space, and object file, respectively, by specifying one of the
1441 following modifiers as the first format character, and then specifying a value
1442 and optional mask. The value and mask are each specified as either immediate
1443 values or expressions enclosed in square brackets preceded by a dollar sign. If
1444 only a value is specified, \fBmdb\fR reads integers of the appropriate size and
1445 stops at the address containing the matching value. If a value \fBV\fR and mask
1446 \fBM\fR are specified, \fBmdb\fR reads integers of the appropriate size and
1447 stops at the address containing a value \fBX\fR where \fB(X & M) == V\fR. At
1448 the completion of the dcmd, dot is updated to the address containing the match.
1449 If no match is found, dot is left at the last address that was read.
1452 The search modifiers are:
1457 l l
1458 l l .
1459 l       Search for the specified 2-byte value.
1460 L       Search for the specified 4-byte value.
1461 M       Search for the specified 8-byte value.
1466 Notice that for both user and kernel targets, an address space is typically
1467 composed of a set of discontiguous segments. It is not legal to read from an
1468 address that does not have a corresponding segment. If a search reaches a
1469 segment boundary without finding a match, it aborts when the read past the end
1470 of the segment boundary fails.
1471 .SS "Execution Control"
1473 \fBmdb\fR provides facilities for controlling and tracing the execution of a
1474 live running program. Currently, only the user process target provides support
1475 for execution control. \fBmdb\fR provides a simple model of execution control:
1476 a target process can be started from within the debugger using \fB::run\fR, or
1477 \fBmdb\fR can attach to an existing process using \fB:A\fR, \fB::attach\fR, or
1478 the \fB-p\fR command-line option, as described below. A list of traced software
1479 events can be specified by the user. Each time a traced event occurs in the
1480 target process, all threads in the target stop, the thread that triggered the
1481 event is chosen as the representative thread, and control returns to the
1482 debugger. Once the target program is set running, control can be asynchronously
1483 returned to the debugger by typing the user-defined interrupt character
1484 (typically \fB^C\fR).
1487 A \fBsoftware event\fR is a state transition in the target program that is
1488 observed by the debugger. For example, the debugger can observe the transition
1489 of a program counter register to a value of interest (a breakpoint) or the
1490 delivery of a particular signal.
1493 A \fBsoftware event specifier\fR is a description of a class of software events
1494 that is used by the debugger to instrument the target program in order to
1495 observe these events. The \fB::events\fR dcmd is used to list the software
1496 event specifiers. A set of standard properties is associated with each event
1497 specifier, as described under \fB::events\fR, below.
1500 The debugger can observe a variety of different software events, including
1501 breakpoints, watchpoints, signals, machine faults, and system calls. New
1502 specifiers can be created using \fB::bp\fR, \fB::fltbp\fR, \fB::sigbp\fR,
1503 \fB::sysbp\fR, or \fB::wp\fR. Each specifier has an associated callback (an
1504 \fBmdb\fR command string to execute as if it had been typed at the command
1505 prompt) and a set of properties, as described below. Any number of specifiers
1506 for the same event can be created, each with different callbacks and
1507 properties. The current list of traced events and the properties of the
1508 corresponding event specifiers can be displayed using the \fB::events\fR dcmd.
1509 The event specifier properties are defined as part of the description of the
1510 \fB::events\fR and \fB::evset\fR dcmds, below.
1513 The execution control built-in dcmds, described below, are always available,
1514 but issues an error message indicating they are not supported if applied to a
1515 target that does not support execution control. For more information about the
1516 interaction of exec, attach, release, and job control with debugger execution
1517 control, refer to NOTES, below.
1518 .SS "Event Callbacks"
1520 The \fB::evset\fR dcmd and event tracing dcmds allow you to associate an event
1521 callback (using the \fB-c\fR option) with each event specifier. The event
1522 callbacks are strings that represent \fBmdb\fR commands to execute when the
1523 corresponding event occurs in the target. These commands are executed as if
1524 they had been typed at the command prompt. Before executing each callback, the
1525 dot variable is set to the value of the representative thread's program counter
1526 and the "\fBhits\fR" variable is set to the number of times this specifier has
1527 been matched, including the current match.
1530 If the event callbacks themselves contain one or more commands to continue the
1531 target (for example, \fB::cont\fR or \fB::step\fR), these commands do not
1532 immediately continue the target and wait for it to stop again. Instead, inside
1533 of an event callback, the continue dcmds note that a continue operation is now
1534 pending, and then return immediately. Therefore, if multiple dcmds are included
1535 in an event callback, the step or continue dcmd should be the last command
1536 specified. Following the execution of \fBall\fR event callbacks, the target
1537 immediately resumes execution if \fBall\fR matching event callbacks requested a
1538 continue. If conflicting continue operations are requested, the operation with
1539 the highest precedence determines what type of continue occurs. The order of
1540 precedence from highest to lowest is: step, step-over (next), step-out,
1541 continue.
1542 .SS "Thread Support"
1544 \fBmdb\fR provides facilities to examine the stacks and registers of each
1545 thread associated with the target. The persistent "\fBthread\fR" variable
1546 contains the current representative thread identifier. The format of the thread
1547 identifier depends on the target. The \fB::regs\fR and \fB::fpregs\fR dcmds can
1548 be used to examine the register set of the representative thread, or of another
1549 thread if its register set is currently available. In addition, the register
1550 set of the representative thread is exported as a set of named variables. The
1551 user can modify the value of one or more registers by applying the \fB>\fR dcmd
1552 to the corresponding named variable.
1555 The \fBmdb\fR kernel target exports the virtual address of the corresponding
1556 internal thread structure as the identifier for a given thread. The \fIModular
1557 Debugger Guide\fR provides more information on debugging support for
1558 threads in the kernel. The \fBmdb\fR process target provides proper
1559 support for examination of multi-threaded user processes that use the native
1560 \fBlwp_*\fR interfaces, \fB/usr/lib/libthread.so\fR or
1561 \fB/usr/lib/lwp/libthread.so\fR. When debugging a live user process, \fBmdb\fR
1562 detects if a single threaded process \fBdlopen\fRs or closes \fBlibthread\fR
1563 and automatically adjusts its view of the threading model on-the-fly. The
1564 process target thread identifiers corresponds to either the \fBlwpid_t\fR,
1565 \fBthread_t\fR, or \fBpthread_t\fR of the representative, depending on the
1566 threading model used by the application.
1569 If \fBmdb\fR is debugging a user process target and the target makes use of
1570 compiler-supported thread-local storage, \fBmdb\fR automatically evaluates
1571 symbol names referring to thread-local storage to the address of the storage
1572 corresponding to the current representative thread. The \fB::tls\fR built-in
1573 dcmd can be used to display the value of the symbol for threads other than the
1574 representative thread.
1575 .SS "Built-in dcmds"
1577 \fBmdb\fR provides a set of built-in dcmds that are always defined. Some of
1578 these dcmds are only applicable to certain targets: if a dcmd is not applicable
1579 to the current target, it fails and prints a message indicating "command is not
1580 supported by current target". In many cases, \fBmdb\fR provides a mnemonic
1581 equivalent (\fB::identifier\fR) for the legacy \fBadb\fR(1) dcmd names. For
1582 example, \fB::quit\fR is provided as the equivalent of \fB$q\fR. Programmers
1583 who are experienced with \fBadb\fR(1) or who appreciate brevity or arcana can
1584 prefer the \fB$\fR or \fB:\fR forms of the built-ins. Programmers who are new
1585 to \fBmdb\fR might prefer the more verbose \fB::\fR form. The built-ins are
1586 shown in alphabetical order. If a \fB$\fR or \fB:\fR form has a
1587 \fB::identifier\fR equivalent, it is shown underneath the \fB::identifier\fR
1588 form. The built-in dcmds are:
1590 .ne 2
1592 \fB> \fIvariable-name\fR\fR
1596 \fB\fB>\fR/\fImodifier\fR/\fIvariable-name\fR\fR
1598 .sp .6
1599 .RS 4n
1600 Assign the value of dot to the specified named variable. Some variables are
1601 read-only and can not be modified. If the \fB>\fR is followed by a modifier
1602 character surrounded by \fB/ /\fR, then the value is modified as part of the
1603 assignment. The modifier characters are:
1605 .ne 2
1607 \fB\fBc\fR\fR
1609 .RS 5n
1610 unsigned char quantity (1-byte)
1614 .ne 2
1616 \fB\fBs\fR\fR
1618 .RS 5n
1619 unsigned short quantity (2-byte)
1623 .ne 2
1625 \fB\fBi\fR\fR
1627 .RS 5n
1628 unsigned int quantity (4-byte)
1632 .ne 2
1634 \fB\fBl\fR\fR
1636 .RS 5n
1637 unsigned long quantity (4-byte in 32-bit, 8-byte in 64-bit)
1640 Notice that these operators do not perform a cast. Instead, they fetch the
1641 specified number of low-order bytes (on little-endian architectures) or
1642 high-order bytes (big-endian architectures). Modifiers are provided for
1643 backwards compatibility; the \fBmdb\fR */\fImodifier\fR/ and %/\fImodifier\fR/
1644 syntax should be used instead.
1648 .ne 2
1650 \fB\fB$<\fR \fImacro-name\fR\fR
1652 .sp .6
1653 .RS 4n
1654 Read and execute commands from the specified macro file. The filename can be
1655 given as an absolute or relative path. If the filename is a simple name (that
1656 is, if it does not contain a '\fB/\fR'), \fBmdb\fR searches for it in the macro
1657 file include path. If another macro file is currently being processed, this
1658 file is closed and replaced with the new file.
1662 .ne 2
1664 \fB\fB$<<\fR \fImacro-name\fR\fR
1666 .sp .6
1667 .RS 4n
1668 Read and execute commands from the specified macro file (as with \fB$<\fR), but
1669 do not close the current open macro file.
1673 .ne 2
1675 \fB\fB$?\fR\fR
1677 .sp .6
1678 .RS 4n
1679 Print the process-\fBID\fR and current signal of the target if it is a user
1680 process or core file, and then print the general register set of the
1681 representative thread.
1685 .ne 2
1687 \fB[ \fIaddress\fR ] \fB$C\fR [ \fIcount\fR ]\fR
1689 .sp .6
1690 .RS 4n
1691 Print a C stack backtrace, including stack frame pointer information. If the
1692 dcmd is preceded by an explicit \fIaddress\fR, a backtrace beginning at this
1693 virtual memory address is displayed. Otherwise the stack of the representative
1694 thread is displayed. If an optional count value is given as an argument, no
1695 more than \fIcount\fR arguments are displayed for each stack frame in the
1696 output.
1700 .ne 2
1702 \fB[ \fIbase\fR ] \fB$d\fR\fR
1704 .sp .6
1705 .RS 4n
1706 Get or set the default output radix. If the dcmd is preceded by an explicit
1707 expression, the default output radix is set to the given \fIbase\fR; otherwise
1708 the current radix is printed in base 10 (decimal). The default radix is base 16
1709 (hexadecimal).
1713 .ne 2
1715 \fB\fB$e\fR\fR
1717 .sp .6
1718 .RS 4n
1719 Print a list of all known external (global) symbols of type object or function,
1720 the value of the symbol, and the first 4 (32-bit \fBmdb\fR) or 8 (64-bit
1721 \fBmdb\fR) bytes stored at this location in the target's virtual address space.
1722 The \fB::nm\fR dcmd provides more flexible options for displaying symbol
1723 tables.
1727 .ne 2
1729 \fB\fB$P\fR \fIprompt-string\fR\fR
1731 .sp .6
1732 .RS 4n
1733 Set the prompt to the specified \fIprompt-string\fR. The default prompt
1734 is '\fB>\fR '. The prompt can also be set using \fB::set\fR \fB-P\fR or the
1735 \fB-P\fR command-line option.
1739 .ne 2
1741 \fB\fIdistance\fR \fB$s\fR\fR
1743 .sp .6
1744 .RS 4n
1745 Get or set the symbol matching \fIdistance\fR for address-to-symbol-name
1746 conversions. The symbol matching distance modes are discussed along with the
1747 \fB-s\fR command-line option under OPTIONS. The symbol matching distance can
1748 also be modified using the \fB::set\fR \fB-s\fR option. If no distance is
1749 specified, the current setting is displayed.
1753 .ne 2
1755 \fB\fB$v\fR\fR
1757 .sp .6
1758 .RS 4n
1759 Print a list of the named variables that have non-zero values. The \fB::vars\fR
1760 dcmd provides other options for listing variables.
1764 .ne 2
1766 \fB\fIwidth\fR \fB$w\fR\fR
1768 .sp .6
1769 .RS 4n
1770 Set the output page \fIwidth\fR to the specified value. Typically, this command
1771 is not necessary as \fBmdb\fR queries the terminal for its width and handles
1772 resize events.
1776 .ne 2
1778 \fB\fB$W\fR\fR
1780 .sp .6
1781 .RS 4n
1782 Re-open the target for writing, as if \fBmdb\fR had been executed with the
1783 \fB-w\fR option on the command line. Write mode can also be enabled with the
1784 \fB::set\fR \fB-w\fR option.
1788 .ne 2
1790 \fB[ \fIpid\fR ] \fB::attach \fR [ \fIcore\fR | \fIpid\fR ]\fR
1794 \fB[ \fIpid\fR ] \fB:A\fR [ \fI core\fR | \fIpid\fR ]\fR
1796 .sp .6
1797 .RS 4n
1798 If the user process target is active, attach to and debug the specified
1799 process-\fBID\fR or \fIcore\fR file. The core file pathname should be specified
1800 as a string argument. The process-\fBID\fR can be specified as the string
1801 argument, or as the value of the expression preceding the dcmd. Recall that the
1802 default base is hexadecimal, so decimal \fBPID\fRs obtained using
1803 \fBpgrep\fR(1) or \fBps\fR(1) should be preceded with "\fB0t\fR" when specified
1804 as expressions.
1808 .ne 2
1810 \fB[\fIaddress\fR] \fB::bp\fR [\fB-/\fR\fB-dDesT\fR] [\fB-c\fR \fIcmd\fR]
1811 [\fB-n\fR \fIcount\fR] \fIsym\fR ...\fR
1815 \fB\fIaddress\fR \fB:b\fR [\fIcmd\fR ...]\fR
1817 .sp .6
1818 .RS 4n
1819 Set a breakpoint at the specified locations. The \fB::bp\fR dcmd sets a
1820 breakpoint at each address or symbol specified, including an optional address
1821 specified by an explicit expression preceding the dcmd, and each string or
1822 immediate value following the dcmd. The arguments can either be symbol names or
1823 immediate values denoting a particular virtual address of interest. If a symbol
1824 name is specified, it can refer to a symbol that cannot yet be evaluated in the
1825 target process. That is, it can consist of an object name and function name in
1826 a load object that has not yet been opened. In this case, the breakpoint is
1827 deferred and is not active in the target until an object matching the given
1828 name is loaded. The breakpoint is automatically enabled when the load object is
1829 opened. Breakpoints on symbols defined in a shared library should always be set
1830 using a symbol name and not using an address expression, as the address can
1831 refer to the corresponding Procedure Linkage Table (\fBPLT\fR) entry instead of
1832 the actual symbol definition. Breakpoints set on \fBPLT\fR entries can be
1833 overwritten by the run-time link-editor when the \fBPLT\fR entry is
1834 subsequently resolved to the actual symbol definition. The \fB-d\fR, \fB-D\fR,
1835 \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and \fB-n\fR options have the
1836 same meaning as they do for the \fB::evset\fR dcmd, as described below. If the
1837 \fB:b\fR form of the dcmd is used, a breakpoint is only set at the virtual
1838 address specified by the expression preceding the dcmd. The arguments following
1839 the \fB:b\fR dcmd are concatenated together to form the callback string. If
1840 this string contains meta-characters, it must be quoted.
1844 .ne 2
1846 \fB\fB::cat\fR \fIfilename\fR ...\fR
1848 .sp .6
1849 .RS 4n
1850 Concatenate and display files. Each filename can be specified as a relative or
1851 absolute pathname. The file contents are printed to standard output, but are
1852 not passed to the output pager. This dcmd is intended to be used with the
1853 \fB|\fR operator; the programmer can initiate a pipeline using a list of
1854 addresses stored in an external file.
1858 .ne 2
1860 \fB\fB::cont\fR [ \fISIG\fR ]\fR
1864 \fB\fB:c\fR [ \fISIG\fR ]\fR
1866 .sp .6
1867 .RS 4n
1868 Suspend the debugger, continue the target program, and wait for it to terminate
1869 or stop following a software event of interest. If the target is already
1870 running because the debugger was attached to a running program with the
1871 \fB-o\fR \fBnostop\fR option enabled, this dcmd simply waits for the target to
1872 terminate or stop after an event of interest. If an optional signal name or
1873 number (see \fBsignal.h\fR(3HEAD)) is specified as an argument, the signal is
1874 immediately delivered to the target as part of resuming its execution. If the
1875 \fBSIGINT\fR signal is traced, control can be asynchronously returned to the
1876 debugger by typing the user-defined interrupt character (usually \fB^C\fR).
1877 This \fBSIGINT\fR signal is automatically cleared and is not observed by the
1878 target the next time it is continued. If no target program is currently
1879 running, \fB::cont\fR starts a new program running as if by \fB::run\fR.
1883 .ne 2
1885 \fB\fIaddress\fR \fB::context\fR\fR
1889 \fB\fIaddress\fR \fB$p\fR\fR
1891 .sp .6
1892 .RS 4n
1893 Context switch to the specified process. A context switch operation is only
1894 valid when using the kernel target. The process context is specified using the
1895 \fIaddress\fR of its proc structure in the kernel's virtual address space. The
1896 special context address "\fB0\fR" is used to denote the context of the kernel
1897 itself. \fBmdb\fR can only perform a context switch when examining a crash dump
1898 if the dump contains the physical memory pages of the specified user process
1899 (as opposed to just kernel pages). The kernel crash dump facility can be
1900 configured to dump all pages or the pages of the current user process using
1901 \fBdumpadm\fR(8). The \fB::status\fR dcmd can be used to display the contents
1902 of the current crash dump.
1904 When the user requests a context switch from the kernel target, \fBmdb\fR
1905 constructs a new target representing the specified user process. Once the
1906 switch occurs, the new target interposes its dcmds at the global level: thus
1907 the \fB/\fR dcmd now formats and displays data from the virtual address space
1908 of the user process, the \fB::mappings\fR dcmd displays the mappings in the
1909 address space of the user process, and so on. The kernel target can be restored
1910 by executing \fB0::context\fR.
1914 .ne 2
1916 \fB\fB::dcmds\fR\fR
1918 .sp .6
1919 .RS 4n
1920 List the available dcmds and print a brief description for each one.
1924 .ne 2
1926 \fB[ \fIaddress\fR ] \fB::delete\fR [ \fIid\fR | \fBall\fR ]\fR
1930 \fB[ \fIaddress\fR ] \fB:d\fR [ \fIid\fR | \fBall\fR ]\fR
1932 .sp .6
1933 .RS 4n
1934 Delete the event specifiers with the given id number. The id number argument is
1935 interpreted in decimal by default. If an optional address is specified
1936 preceding the dcmd, all event specifiers that are associated with the given
1937 virtual address are deleted (for example, all breakpoints or watchpoints
1938 affecting that address). If the special argument "\fBall\fR" is given, all
1939 event specifiers are deleted, except those that are marked sticky (\fBT\fR
1940 flag). The \fB::events\fR dcmd displays the current list of event specifiers.
1944 .ne 2
1946 \fB[ \fIaddress\fR ] \fB::dis\fR [ \fB-fw\fR ] [ \fB-n\fR \fIcount\fR ] [
1947 \fIaddress\fR ]\fR
1949 .sp .6
1950 .RS 4n
1951 Disassemble starting at or around the \fIaddress\fR specified by the final
1952 argument, or the current value of dot. If the address matches the start of a
1953 known function, the entire function is disassembled. Otherwise, a "window" of
1954 instructions before and after the specified address is printed in order to
1955 provide context. By default, instructions are read from the target's virtual
1956 address space. If the \fB-f\fR option is present, instructions are read from
1957 the target's object file instead. The \fB-f\fR option is enabled by default if
1958 the debugger is not currently attached to a live process, core file, or crash
1959 dump. The \fB-w\fR option can be used to force "window"-mode, even if the
1960 address is the start of a known function. The size of the window defaults to
1961 ten instructions; the number of instructions can be specified explicitly using
1962 the \fB-n\fR option.
1966 .ne 2
1968 \fB\fB::disasms\fR\fR
1970 .sp .6
1971 .RS 4n
1972 List the available disassembler modes. When a target is initialized, \fBmdb\fR
1973 attempts to select the appropriate disassembler mode. The user can change the
1974 mode to any of the modes listed using the \fB::dismode\fR dcmd.
1978 .ne 2
1980 \fB\fB::dismode\fR [ \fImode\fR ]\fR
1984 \fB\fB$V\fR [ \fImode\fR ] \fR
1986 .sp .6
1987 .RS 4n
1988 Get or set the disassembler mode. If no argument is specified, print the
1989 current disassembler mode. If a \fImode\fR argument is specified, switch the
1990 disassembler to the specified mode. The list of available disassemblers can be
1991 displayed using the \fB::disasms\fR dcmd.
1995 .ne 2
1997 \fB\fB::dmods\fR [ \fB-l\fR ] [ \fImodule-name\fR ]\fR
1999 .sp .6
2000 .RS 4n
2001 List the loaded debugger modules. If the \fB-l\fR option is specified, the list
2002 of the dcmds and walkers associated with each dmod is printed below its name.
2003 The output can be restricted to a particular dmod by specifying its name as an
2004 additional argument.
2008 .ne 2
2010 \fB[ \fIaddress\fR ] \fB::dump\fR [ \fB-eqrstu\fR ] [ \fB-f\fR|\fB-p\fR ]\fR
2014 \fB#sp;#sp;[ \fB-g\fR \fIbytes\fR ] [ \fB-w\fR \fIparagraphs\fR ]\fR
2016 .sp .6
2017 .RS 4n
2018 Print a hexadecimal and ASCII memory dump of the 16-byte aligned region of
2019 memory containing the address specified by dot. If a repeat count is specified
2020 for \fB::dump\fR, this is interpreted as a number of bytes to dump rather than
2021 a number of iterations. The \fB::dump\fR dcmd also recognizes the following
2022 options:
2024 .ne 2
2026 \fB\fB-e\fR\fR
2028 .RS 17n
2029 Adjusts for endian-ness. The \fB-e\fR option assumes 4-byte words. The \fB-g\fR
2030 option can be used to change the default word size.
2034 .ne 2
2036 \fB\fB-f\fR\fR
2038 .RS 17n
2039 Reads data from the object file location corresponding to the given virtual
2040 address instead of from the target's virtual address space. The \fB-f\fR option
2041 is enabled by default if the debugger is not currently attached to a live
2042 process, core file, or crash dump.
2046 .ne 2
2048 \fB\fB-g\fR \fIbytes\fR\fR
2050 .RS 17n
2051 Displays bytes in groups of \fIbytes\fR. The default group size is 4 bytes. The
2052 group size must be a power of two that divides the line width.
2056 .ne 2
2058 \fB\fB-p\fR\fR
2060 .RS 17n
2061 Interprets \fIaddress\fR as a physical address location in the target's address
2062 space instead of a virtual address.
2066 .ne 2
2068 \fB\fB-q\fR\fR
2070 .RS 17n
2071 Does not print an ASCII decoding of the data.
2075 .ne 2
2077 \fB\fB-r\fR\fR
2079 .RS 17n
2080 Numbers lines relative to the start address instead of with the explicit
2081 address of each line. This option implies the \fB-u\fR option.
2085 .ne 2
2087 \fB\fB-s\fR\fR
2089 .RS 17n
2090 Elides repeated lines.
2094 .ne 2
2096 \fB\fB-t\fR\fR
2098 .RS 17n
2099 Only reads from and displays the contents of the specified addresses, instead
2100 of reading and printing entire lines.
2104 .ne 2
2106 \fB\fB-u\fR\fR
2108 .RS 17n
2109 Unaligns output instead of aligning the output at a paragraph boundary.
2113 .ne 2
2115 \fB\fB-w\fR \fIparagraphs\fR\fR
2117 .RS 17n
2118 Displays paragraphs at 16-byte paragraphs per line. The default number of
2119 \fIparagraphs\fR is one. The maximum value accepted for \fB-w\fR is \fB16\fR.
2125 .ne 2
2127 \fB\fB::echo\fR [ \fIstring\fR | \fIvalue\fR ...]\fR
2129 .sp .6
2130 .RS 4n
2131 Print the arguments separated by blanks and terminated by a \fINEWLINE\fR to
2132 standard output. Expressions enclosed in \fB$[ ]\fR is evaluated to a value
2133 and printed in the default base.
2137 .ne 2
2139 \fB\fB::eval\fR \fIcommand\fR\fR
2141 .sp .6
2142 .RS 4n
2143 Evaluate and execute the specified string as a command. If the command contains
2144 metacharacters or whitespace, it should be enclosed in double or single quotes.
2148 .ne 2
2150 \fB\fB::events\fR [ \fB-av\fR ]\fR
2154 \fB\fB$b\fR [ \fB-av\fR ]\fR
2156 .sp .6
2157 .RS 4n
2158 Display the list of software event specifiers. Each event specifier is assigned
2159 a unique \fBID\fR number that can be used to delete or modify it at a later
2160 time. The debugger can also have its own internal events enabled for tracing.
2161 These events are only be displayed if the \fB-a\fR option is present. If the
2162 \fB-v\fR option is present, a more verbose display, including the reason for
2163 any specifier inactivity, are shown. Here is some sample output:
2165 .in +2
2167 > ::events
2168    ID S TA HT LM Description                      Action
2169 ----- - -- -- -- -------------------------------- ------
2170 [ 1 ] - T   1  0 stop on SIGINT                   -
2171 [ 2 ] - T   0  0 stop on SIGQUIT                  -
2172 [ 3 ] - T   0  0 stop on SIGILL                   -
2173  ...
2174 [ 11] - T   0  0 stop on SIGXCPU                  -
2175 [ 12] - T   0  0 stop on SIGXFSZ                  -
2176 [ 13] -     2  0 stop at libc`printf              ::echo printf
2179 .in -2
2182 The following table explains the meaning of each column. A summary of this
2183 information is available using \fB::help\fR \fBevents\fR.
2185 .ne 2
2187 \fB\fBID\fR\fR
2189 .RS 15n
2190 The event specifier identifier. The identifier is shown in square brackets \fB[
2191 ]\fR if the specifier is enabled, in parentheses \fB( )\fR if the specifier is
2192 disabled, or in angle brackets \fB< >\fR if the target program is currently
2193 stopped on an event that matches the given specifier.
2197 .ne 2
2199 \fB\fBS\fR\fR
2201 .RS 15n
2202 The event specifier state. The state is one of the following symbols:
2204 .ne 2
2206 \fB\fB-\fR\fR
2208 .RS 5n
2209 The event specifier is idle. When no target program is running, all specifiers
2210 are idle. When the target program is running, a specifier can be idle if it
2211 cannot be evaluated (for example, a deferred breakpoint in a shared object that
2212 is not yet loaded).
2216 .ne 2
2218 \fB\fB+\fR\fR
2220 .RS 5n
2221 The event specifier is active. When the target is continued, events of this
2222 type is detected by the debugger.
2226 .ne 2
2228 \fB\fB*\fR\fR
2230 .RS 5n
2231 The event specifier is armed. This state means that the target is currently
2232 running with instrumentation for this type of event. This state is only visible
2233 if the debugger is attached to a running program with the \fB-o\fR \fBnostop\fR
2234 option.
2238 .ne 2
2240 \fB\fB!\fR\fR
2242 .RS 5n
2243 The event specifier was not armed due to an operating system error. The
2244 \fB::events\fR \fB-v\fR option can be used to display more information about
2245 the reason the instrumentation failed.
2251 .ne 2
2253 \fB\fBTA\fR\fR
2255 .RS 15n
2256 The Temporary, Sticky, and Automatic event specifier properties. One or more of
2257 the following symbols can be shown:
2259 .ne 2
2261 \fB\fBt\fR\fR
2263 .RS 5n
2264 The event specifier is temporary, and is deleted the next time the target
2265 stops, regardless of whether it is matched.
2269 .ne 2
2271 \fB\fBT\fR\fR
2273 .RS 5n
2274 The event specifier is sticky, and is not be deleted by \fB::delete\fR
2275 \fBall\fR or \fB:z\fR. The specifier can be deleted by explicitly specifying
2276 its id number to \fB::delete\fR.
2280 .ne 2
2282 \fB\fBd\fR\fR
2284 .RS 5n
2285 The event specifier is automatically disabled when the hit count is equal to
2286 the hit limit.
2290 .ne 2
2292 \fB\fBD\fR\fR
2294 .RS 5n
2295 The event specifier is automatically deleted when the hit count is equal to the
2296 hit limit.
2300 .ne 2
2302 \fB\fBs\fR\fR
2304 .RS 5n
2305 The target automatically stops when the hit count is equal to the hit limit.
2311 .ne 2
2313 \fB\fBHT\fR\fR
2315 .RS 15n
2316 The current hit count. This column displays the number of times the
2317 corresponding software event has occurred in the target since the creation of
2318 this event specifier.
2322 .ne 2
2324 \fB\fBLM\fR\fR
2326 .RS 15n
2327 The current hit limit. This column displays the limit on the hit count at which
2328 the auto-disable, auto-delete, or auto-stop behavior takes effect. These
2329 behaviors can be configured using the \fB::evset\fR dcmd, described below.
2333 .ne 2
2335 \fB\fBDescription\fR\fR
2337 .RS 15n
2338 A description of the type of software event that is matched by the given
2339 specifier.
2343 .ne 2
2345 \fB\fBAction\fR\fR
2347 .RS 15n
2348 The callback string to execute when the corresponding software event occurs.
2349 This callback is executed as if it had been typed at the command prompt.
2355 .ne 2
2357 \fB[\fIid\fR] \fB::evset\fR [\fB-/\fR\fB-dDestT\fR] [\fB-c\fR \fIcmd\fR]
2358 [\fB-n\fR \fIcount\fR] \fIid\fR ...\fR
2360 .sp .6
2361 .RS 4n
2362 Modify the properties of one or more software event specifiers. The properties
2363 are set for each specifier identified by the optional expression preceding the
2364 dcmd and an optional list of arguments following the dcmd. The argument list is
2365 interpreted as a list of decimal integers, unless an explicit radix is
2366 specified. The \fB::evset\fR dcmd recognizes the following options:
2368 .ne 2
2370 \fB\fB-d\fR\fR
2372 .RS 6n
2373 Disables the event specifier when the hit count reaches the hit limit. If the
2374 \fB-d\fR form of the option is given, this behavior is disabled. Once an event
2375 specifier is disabled, the debugger removes any corresponding instrumentation
2376 and ignores the corresponding software events until the specifier is
2377 subsequently re-enabled. If the \fB-n\fR option is not present, the specifier
2378 is disabled immediately.
2382 .ne 2
2384 \fB\fB-D\fR\fR
2386 .RS 6n
2387 Deletes the event specifier when the hit count reaches the hit limit. If the
2388 \fB-D\fR form of the option is given, this behavior is disabled. The \fB-D\fR
2389 option takes precedence over the \fB-d\fR option. The hit limit can be
2390 configured using the \fB-n\fR option.
2394 .ne 2
2396 \fB\fB-e\fR\fR
2398 .RS 6n
2399 Enables the event specifier. If the \fB-e\fR form of the option is given, the
2400 specifier is disabled.
2404 .ne 2
2406 \fB\fB-s\fR\fR
2408 .RS 6n
2409 Stops the target program when the hit count reaches the hit limit. If the
2410 \fB-s\fR form of the option is given, this behavior is disabled. The \fB-s\fR
2411 behavior tells the debugger to act as if the \fB::cont\fR were issued following
2412 each execution of the specifier's callback, except for the \fIN\fRth execution,
2413 where \fIN\fR is the current value of the specifier's hit limit. The \fB-s\fR
2414 option takes precedence over both the \fB-D\fR option and the \fB-d\fR option.
2418 .ne 2
2420 \fB\fB-t\fR\fR
2422 .RS 6n
2423 Marks the event specifier as temporary. Temporary specifiers are automatically
2424 deleted the next time the target stops, regardless of whether it stopped as the
2425 result of a software event corresponding to the given specifier. If the
2426 \fB-t\fR form of the option is given, the temporary marker is removed. The
2427 \fB-t\fR option takes precedence over the \fB-T\fR option.
2431 .ne 2
2433 \fB\fB-T\fR\fR
2435 .RS 6n
2436 Marks the event specifier as sticky. Sticky specifiers are not deleted by
2437 \fB::delete\fR \fBall\fR or \fB:z.\fR They can be deleted by specifying the
2438 corresponding specifier \fBID\fR as an explicit argument to \fB::delete\fR. If
2439 the \fB-T\fR form of the option is given, the sticky property is removed. The
2440 default set of event specifiers are all initially marked sticky.
2444 .ne 2
2446 \fB\fB-c\fR\fR
2448 .RS 6n
2449 Executes the specified \fIcmd\fR string each time the corresponding software
2450 event occurs in the target program. The current callback string can be
2451 displayed using \fB::events\fR.
2455 .ne 2
2457 \fB\fB-n\fR\fR
2459 .RS 6n
2460 Sets the current value of the hit limit to \fIcount\fR. If no hit limit is
2461 currently set and the \fB-n\fR option does not accompany \fB-s\fR or D, the hit
2462 limit is set to one.
2465 A summary of this information is available using \fB::help\fR \fBevset\fR.
2469 .ne 2
2471 \fB\fB::files\fR\fR
2475 \fB\fB$f\fR\fR
2477 .sp .6
2478 .RS 4n
2479 Print a list of the known source files (symbols of type \fISTT_FILE\fR present
2480 in the various target symbol tables).
2484 .ne 2
2486 \fB[\fIflt\fR] \fB::fltbp\fR [\fB-/\fR\fB-dDestT\fR] [\fB-c\fR \fIcmd\fR]
2487 [\fB-n\fR \fIcount\fR] \fIflt\fR ...\fR
2489 .sp .6
2490 .RS 4n
2491 Trace the specified machine faults. The faults are identified using an optional
2492 fault number preceding the dcmd, or a list of fault names or numbers (see
2493 \fB<sys/fault.h>\fR) following the dcmd. The \fB-d\fR, \fB-D\fR, \fB-e\fR,
2494 \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and \fB-n\fR options have the same
2495 meaning as they do for the \fB::evset\fR dcmd.
2499 .ne 2
2501 \fB[ \fB\fIthread\fR\fR ] \fB::fpregs\fR\fR
2505 \fB[ \fB\fIthread\fR\fR ] \fB$x\fR, \fB$X\fR, \fB$y\fR, \fB$Y\fR\fR
2507 .sp .6
2508 .RS 4n
2509 Print the floating-point register set of the representative thread. If a thread
2510 is specified, the floating point registers of that thread are displayed. The
2511 thread expression should be one of the thread identifiers described under
2512 \fBThread Support\fR, above.
2516 .ne 2
2518 \fB\fB::formats\fR\fR
2520 .sp .6
2521 .RS 4n
2522 List the available output format characters for use with the \fB/\fR, \fB\e\fR,
2523 \fB?\fR, and \fB=\fR formatting dcmds. The formats and their use is described
2524 under \fBFormatting dcmds\fR, above.
2528 .ne 2
2530 \fB\fB::grep\fR \fIcommand\fR\fR
2532 .sp .6
2533 .RS 4n
2534 Evaluate the specified command string, and then print the old value of dot if
2535 the new value of dot is non-zero. If the \fIcommand\fR contains whitespace or
2536 metacharacters, it must be quoted. The \fB::grep\fR dcmd can be used in
2537 pipelines to filter a list of addresses.
2541 .ne 2
2543 \fB\fB::help\fR [ \fIdcmd-name\fR ]\fR
2545 .sp .6
2546 .RS 4n
2547 With no arguments, the \fB::help\fR dcmd prints a brief overview of the help
2548 facilities available in \fBmdb\fR. If a \fIdcmd-name\fR is specified, \fBmdb\fR
2549 prints a usage summary for that dcmd.
2553 .ne 2
2555 \fB\fIsignal\fR \fB:i\fR\fR
2557 .sp .6
2558 .RS 4n
2559 If the target is a live user process, ignore the specified signal and allow it
2560 to be delivered transparently to the target. All event specifiers that are
2561 tracing delivery of the specified signal is deleted from the list of traced
2562 events. By default, the set of ignored signals is initialized to the complement
2563 of the set of signals that cause a process to dump core by default (see
2564 \fBsignal.h\fR(3HEAD)), except for \fBSIGINT\fR, which is traced by default.
2568 .ne 2
2570 \fB\fB$i\fR\fR
2572 .sp .6
2573 .RS 4n
2574 Display the list of signals that are ignored by the debugger and that is
2575 handled directly by the target. More information on traced signals can be
2576 obtained using the \fB::events\fR dcmd.
2580 .ne 2
2582 \fB\fB::kill\fR\fR
2586 \fB\fB:k\fR\fR
2588 .sp .6
2589 .RS 4n
2590 Forcibly terminate the target if it is a live user process. The target is also
2591 forcibly terminated when the debugger exits if it was created by the debugger
2592 using \fB::run\fR.
2596 .ne 2
2598 \fB\fB$l\fR\fR
2600 .sp .6
2601 .RS 4n
2602 Print the \fBLWPID\fR of the representative thread, if the target is a user
2603 process.
2607 .ne 2
2609 \fB\fB$L\fR\fR
2611 .sp .6
2612 .RS 4n
2613 Print the \fBLWPID\fRs of each \fBLWP\fR in the target, if the target is a user
2614 process.
2618 .ne 2
2620 \fB[ \fIaddress\fR ] \fB::list\fR \fItype\fR \fImember\fR [ \fIvariable-name\fR
2621 ]\fR
2623 .sp .6
2624 .RS 4n
2625 Walk through the elements of a linked list data structure and print the address
2626 of each element in the list. The address of the first element in the list can
2627 be specified using an optional address. Otherwise, the list is assumed to start
2628 at the current value of dot. The type parameter must name a C struct or union
2629 type and is used to describe the type of the list elements so that \fBmdb\fR
2630 can read in objects of the appropriate size. The member parameter is used to
2631 name the \fImember\fR of \fItype\fR that contains a pointer to the next list
2632 element. The \fB::list\fR dcmd continues iterating until a \fBNULL\fR pointer
2633 is encountered, the first element is reached again (a circular list), or an
2634 error occurs while reading an element. If the optional \fIvariable-name\fR is
2635 specified, the specified variable is assigned the value returned at each step
2636 of the walk when \fBmdb\fR invokes the next stage of a pipeline. The
2637 \fB::list\fR dcmd can only be used with objects that contain symbolic debugging
2638 information designed for use with mdb. Refer to NOTES, \fBSymbolic Debugging
2639 Information\fR, below for more information.
2643 .ne 2
2645 \fB\fB::load\fR [ \fB-s\fR ] \fImodule-name\fR\fR
2647 .sp .6
2648 .RS 4n
2649 Load the specified dmod. The module name can be given as an absolute or
2650 relative path. If \fImodule-name\fR is a simple name (that is, does not contain
2651 a '\fB/\fR'), \fBmdb\fR searches for it in the module library path. Modules
2652 with conflicting names can not be loaded; the existing module must be unloaded
2653 first. If the \fB-s\fR option is present, \fBmdb\fR remains silent and not
2654 issue any error messages if the module is not found or could not be loaded.
2658 .ne 2
2660 \fB\fB::log\fR [ \fB-d\fR | [ \fB-e\fR ] \fIfilename\fR ]\fR
2664 \fB\fB$>\fR [ \fIfilename\fR ]\fR
2666 .sp .6
2667 .RS 4n
2668 Enable or disable the output log. \fBmdb\fR provides an interactive logging
2669 facility where both the input commands and standard output can be logged to a
2670 file while still interacting with the user. The \fB-e\fR option enables logging
2671 to the specified file, or re-enables logging to the previous log file if no
2672 filename is given. The \fB-d\fR option disables logging. If the \fB$>\fR dcmd
2673 is used, logging is enabled if a filename argument is specified; otherwise,
2674 logging is disabled. If the specified log file already exists, \fBmdb\fR
2675 appends any new log output to the file.
2679 .ne 2
2681 \fB\fB::map\fR \fIcommand\fR\fR
2683 .sp .6
2684 .RS 4n
2685 Map the value of dot to a corresponding value using the \fIcommand\fR specified
2686 as a string argument, and then print the new value of dot. If the command
2687 contains whitespace or metacharacters, it must be quoted. The \fB::map\fR dcmd
2688 can be used in pipelines to transform the list of addresses into a new list of
2689 addresses.
2693 .ne 2
2695 \fB[ \fIaddress\fR ] \fB::mappings\fR [ \fIname\fR ]\fR
2699 \fB[ \fI address\fR ] \fB$m\fR [ \fIname\fR ]\fR
2701 .sp .6
2702 .RS 4n
2703 Print a list of each mapping in the target's virtual address space, including
2704 the address, size, and description of each mapping. If the dcmd is preceded by
2705 an \fIaddress\fR, \fBmdb\fR only shows the mapping that contains the given
2706 address. If a string \fIname\fR argument is given, \fBmdb\fR only shows the
2707 mapping matching that description.
2711 .ne 2
2713 \fB\fB::next\fR [ \fISIG\fR ]\fR
2717 \fB\fB:e\fR [ \fISIG\fR ]\fR
2719 .sp .6
2720 .RS 4n
2721 Step the target program one instruction, but step over subroutine calls. If an
2722 optional signal name or number (see \fBsignal.h\fR(3HEAD)) is specified as an
2723 argument, the signal is immediately delivered to the target as part of resuming
2724 its execution. If no target program is currently running, \fB::next\fR starts a
2725 new program running as if by \fB::run\fR and stop at the first instruction.
2729 .ne 2
2731 \fB[ \fIaddress\fR ] \fB::nm\fR [ \fB-DPdghnopuvx\fR ] [ \fB-t\fR \fItypes\fR
2732 ]\fR
2736 \fB#sp;#sp;[ \fB-f\fR \fIformat\fR ] [ \fIobject\fR ]\fR
2738 .sp .6
2739 .RS 4n
2740 Print the symbol tables associated with the current target. If an optional
2741 address preceding the dcmd is specified, only the symbol table entry for the
2742 symbol corresponding to \fIaddress\fR is displayed. If an \fIobject\fR is
2743 specified, only the symbol table for this load object is displayed. The
2744 \fB::nm\fR dcmd also recognizes the following options:
2746 .ne 2
2748 \fB\fB-D\fR\fR
2750 .RS 27n
2751 Prints \fB\&.dynsym\fR (dynamic symbol table) instead of \fB\&.symtab\fR.
2755 .ne 2
2757 \fB\fB-P\fR\fR
2759 .RS 27n
2760 Prints the private symbol table instead of \fB\&.symtab\fR.
2764 .ne 2
2766 \fB\fB-d\fR\fR
2768 .RS 27n
2769 Prints value and size fields in decimal.
2773 .ne 2
2775 \fB\fB-g\fR\fR
2777 .RS 27n
2778 Prints only global symbols.
2782 .ne 2
2784 \fB\fB-h\fR\fR
2786 .RS 27n
2787 Suppresses the header line.
2791 .ne 2
2793 \fB\fB-n\fR\fR
2795 .RS 27n
2796 Sorts symbols by name.
2800 .ne 2
2802 \fB\fB-o\fR\fR
2804 .RS 27n
2805 Prints value and size fields in octal.
2809 .ne 2
2811 \fB\fB-p\fR\fR
2813 .RS 27n
2814 Prints symbols as a series of \fB::nmadd\fR commands. This option can be used
2815 with \fB-P\fR to produce a macro file that can be subsequently read into the
2816 debugger with \fB$<\fR.
2820 .ne 2
2822 \fB\fB-u\fR\fR
2824 .RS 27n
2825 Prints only undefined symbols.
2829 .ne 2
2831 \fB\fB-v\fR\fR
2833 .RS 27n
2834 Sorts symbols by value.
2838 .ne 2
2840 \fB\fB-x\fR\fR
2842 .RS 27n
2843 Prints value and size fields in hexadecimal.
2847 .ne 2
2849 \fB\fB-t\fR \fItype\fR[,\fItype\fR ... ]\fR
2851 .RS 27n
2852 Prints only symbols of the specified type(s). The valid \fItype\fR argument
2853 strings are:
2855 .ne 2
2857 \fB\fBnoty\fR\fR
2859 .RS 8n
2860 \fISTT_NOTYPE\fR
2864 .ne 2
2866 \fB\fBobjt\fR\fR
2868 .RS 8n
2869 \fISTT_OBJECT\fR
2873 .ne 2
2875 \fB\fBfunc\fR\fR
2877 .RS 8n
2878 \fISTT_FUNC\fR
2882 .ne 2
2884 \fB\fBsect\fR\fR
2886 .RS 8n
2887 \fISTT_SECTION\fR
2891 .ne 2
2893 \fB\fBfile\fR\fR
2895 .RS 8n
2896 \fISTT_FILE\fR
2900 .ne 2
2902 \fB\fBcomm\fR\fR
2904 .RS 8n
2905 \fISTT_COMMON\fR
2909 .ne 2
2911 \fB\fBtls\fR\fR
2913 .RS 8n
2914 \fISTT_TLS\fR
2918 .ne 2
2920 \fB\fBregi\fR\fR
2922 .RS 8n
2923 \fISTT_SPARC_REGISTER\fR
2929 .ne 2
2931 \fB\fB-f\fR \fIformat\fR[,\fIformat\fR ... ]\fR
2933 .RS 27n
2934 Prints only the specified symbol information. The valid \fIformat\fR argument
2935 strings are:
2937 .ne 2
2939 \fB\fBndx\fR\fR
2941 .RS 9n
2942 symbol table index
2946 .ne 2
2948 \fB\fBval\fR\fR
2950 .RS 9n
2951 symbol value
2955 .ne 2
2957 \fB\fBsize\fR\fR
2959 .RS 9n
2960 size in bytes
2964 .ne 2
2966 \fB\fBtype\fR\fR
2968 .RS 9n
2969 symbol type
2973 .ne 2
2975 \fB\fBbind\fR\fR
2977 .RS 9n
2978 binding
2982 .ne 2
2984 \fB\fBoth\fR\fR
2986 .RS 9n
2987 other
2991 .ne 2
2993 \fB\fBshndx\fR\fR
2995 .RS 9n
2996 section index
3000 .ne 2
3002 \fB\fBname\fR\fR
3004 .RS 9n
3005 symbol name
3009 .ne 2
3011 \fB\fBctype\fR\fR
3013 .RS 9n
3014 C type for symbol (if known)
3018 .ne 2
3020 \fB\fBobj\fR\fR
3022 .RS 9n
3023 object which defines symbol
3031 .ne 2
3033 \fB\fIvalue\fR \fB::nmadd\fR [ \fB-fo\fR ] [ \fB-e\fR \fIend\fR ] [ \fB-s\fR
3034 \fIsize\fR ] \fIname \fR\fR
3036 .sp .6
3037 .RS 4n
3038 Add the specified symbol \fIname\fR to the private symbol table. \fBmdb\fR
3039 provides a private, configurable symbol table that can be used to interpose on
3040 the target's symbol table, as described under \fBSymbol Name Resolution\fR
3041 above. The \fB::nmadd\fR dcmd also recognizes the following options:
3043 .ne 2
3045 \fB\fB-e\fR\fR
3047 .RS 6n
3048 Sets the size of the symbol to \fIend\fR - \fIvalue\fR.
3052 .ne 2
3054 \fB\fB-f\fR\fR
3056 .RS 6n
3057 Sets the type of the symbol to \fBSTT_FUNC\fR.
3061 .ne 2
3063 \fB\fB-o\fR\fR
3065 .RS 6n
3066 Sets the type of the symbol to \fBSTT_OBJECT\fR.
3070 .ne 2
3072 \fB\fB-s\fR\fR
3074 .RS 6n
3075 Sets the size of the symbol to \fIsize\fR.
3081 .ne 2
3083 \fB\fB::nmdel\fR \fIname\fR\fR
3085 .sp .6
3086 .RS 4n
3087 Delete the specified symbol \fIname\fR from the private symbol table.
3091 .ne 2
3093 \fB\fB::objects\fR [ \fB-v\fR ]\fR
3095 .sp .6
3096 .RS 4n
3097 Print a map of the target's virtual address space, showing only those mappings
3098 that correspond to the primary mapping (usually the text section) of each of
3099 the known load objects. The \fB-v\fR option displays the version of each load
3100 object. Version information is not available for all load objects. Load objects
3101 without version information is listed as having a version of "\fBUnknown\fR" in
3102 the output for the \fB-v\fR option.
3106 .ne 2
3108 \fB\fB::offsetof\fR \fItype member\fR\fR
3110 .sp .6
3111 .RS 4n
3112 Print the offset of the specified \fImember\fR of the specified \fItype\fR. The
3113 \fItype\fR should be the name of a C structure. The offset is printed in bytes,
3114 unless the member is a bit-field, in which case the offset can be printed in
3115 bits. The output is always suffixed with the appropriate units for clarity. The
3116 type name can use the backquote (\fB`\fR) scoping operator described under
3117 \fBSymbol Name Resolution\fR, above. The \fB::offsetof\fR dcmd can only be used
3118 with objects that contain symbolic debugging information designed for use with
3119 \fBmdb\fR. Refer to NOTES, \fBSymbolic Debugging Information\fR, below for more
3120 information.
3124 .ne 2
3126 \fB\fIaddress\fR \fB::print\fR [ \fB-aCdiLptx\fR ] [ \fB-c\fR \fIlim\fR ]\fR
3130 \fB#sp;#sp;[ \fB-l\fR \fIlim\fR ] [ \fItype\fR [ \fImember\fR ... ] ]\fR
3132 .sp .6
3133 .RS 4n
3134 Print the data structure at the specified virtual \fIaddress\fR using the given
3135 \fItype\fR information. The \fItype\fR parameter can name a C struct, union,
3136 enum, fundamental integer type, or a pointer to any of these types. If the type
3137 name contains whitespace (for example, "\fBstruct foo\fR"), it must be enclosed
3138 in single or double quotes. The type name can use the backquote (\fB`\fR)
3139 scoping operator described under \fBSymbol Name Resolution\fR, above. If the
3140 type is a structured type, the \fB::print\fR dcmd recursively prints each
3141 member of the struct or union. If the \fItype\fR argument is not present and a
3142 static or global \fISTT_OBJECT\fR symbol matches the address, \fB::print\fR
3143 infers the appropriate type automatically. If the \fItype\fR argument is
3144 specified, it can be followed by an optional list of \fImember\fR expressions,
3145 in which case only those members and submembers of the specified \fItype\fR are
3146 displayed. If \fItype\fR contains other structured types, each member string
3147 can refer to a sub-structure element by forming a list of member names
3148 separated by period ('\fB\&.\fR') delimiters. The \fB::print\fR dcmd can only
3149 be used with objects that contain symbolic debugging information designed for
3150 use with \fBmdb\fR. Refer to NOTES, \fBSymbolic Debugging Information\fR, below
3151 for more information. After displaying the data structure, \fB::print\fR
3152 increments dot by the size of \fItype\fR in bytes.
3154 If the \fB-a\fR option is present, the address of each member is displayed. If
3155 the \fB-p\fR option is present, \fB::print\fR interprets \fIaddress\fR as a
3156 physical memory address instead of a virtual memory address. If the \fB-t\fR
3157 option is present, the type of each member is displayed. If the \fB-d\fR or
3158 \fB-x\fR options are present, all integers are displayed in decimal (\fB-d\fR)
3159 or hexadecimal (\fB-x\fR). By default, a heuristic is used to determine if the
3160 value should be displayed in decimal or hexadecimal. The number of characters
3161 in a character array that is read and displayed as a string can be limited with
3162 the \fB-c\fR option. If the \fB-C\fR option is present, no limit is enforced.
3163 The number of elements in a standard array that is read and displayed can be
3164 limited with the \fB-l\fR option. If the \fB-L\fR option is present, no limit
3165 is enforced and all array elements are shown. The default values for \fB-c\fR
3166 and \fB-l\fR can be modified using \fB::set\fR or the \fB-o\fR command-line
3167 option as described under OPTIONS.
3169 If the \fB-i\fR option is specified, the address value is interpreted as an
3170 immediate value to be printed. You must give a type with which to interpret the
3171 value. If the type is smaller than 64 bits, the immediate value is interpreted
3172 as if it were the size of the type. The \fB-i\fR option cannot be used in
3173 conjunction with the \fB-p\fR option. If the \fB-a\fR option is given, the
3174 addresses shown are byte offsets starting at zero.
3178 .ne 2
3180 \fB\fB::quit\fR\fR
3184 \fB\fB$q\fR\fR
3186 .sp .6
3187 .RS 4n
3188 Quit the debugger.
3192 .ne 2
3194 \fB[ \fIthread\fR ] \fB::regs\fR\fR
3198 \fB[ \fIthread\fR ] \fB$r\fR\fR
3200 .sp .6
3201 .RS 4n
3202 Print the general purpose register set of the representative thread. If a
3203 thread is specified, the general purpose register set of that thread is
3204 displayed. The thread expression should be one of the thread identifiers
3205 described under \fBThread Support\fR, above.
3209 .ne 2
3211 \fB\fB::release\fR [ \fB-a\fR ]\fR
3215 \fB\fB:R\fR [ \fB-a\fR ]\fR
3217 .sp .6
3218 .RS 4n
3219 Release the previously attached process or core file. If the \fB-a\fR option is
3220 present, the process is released and left stopped and abandoned. It can
3221 subsequently be continued by \fBprun\fR(1) (see \fBproc\fR(1)) or it can be
3222 resumed by applying \fBmdb\fR or another debugger. By default, a released
3223 process is forcibly terminated if it was created by \fBmdb\fR using
3224 \fB::run\fR, or it is released and set running if it was attached to by
3225 \fBmdb\fR using the \fB-p\fR option or using the \fB::attach\fR or \fB:A\fR
3226 dcmds.
3230 .ne 2
3232 \fB\fB::run\fR [ \fIargs\fR ... ]\fR
3236 \fB\fB:r\fR [ \fIargs\fR ... ]\fR
3238 .sp .6
3239 .RS 4n
3240 Start a new target program running with the specified arguments and attach to
3241 it. The arguments are not interpreted by the shell. If the debugger is already
3242 examining a live running program, it first detaches from this program as if by
3243 \fB::release\fR.
3247 .ne 2
3249 \fB\fB::set\fR [ \fB-wF\fR ] [ \fB-/\fR\fB-o\fR \fIoption\fR ] [ \fB-s\fR
3250 \fIdistance\fR ] [ \fB-I\fR \fIpath\fR ]\fR
3254 \fB#sp;#sp;[ \fB-L\fR \fIpath\fR ] [ \fB-P\fR \fIprompt\fR ]\fR
3256 .sp .6
3257 .RS 4n
3258 Get or set miscellaneous debugger properties. If no options are specified, the
3259 current set of debugger properties is displayed. The \fB::set\fR dcmd
3260 recognizes the following options:
3262 .ne 2
3264 \fB\fB-F\fR\fR
3266 .RS 6n
3267 Forcibly takes over the next user process that \fB::attach\fR is applied to, as
3268 if \fBmdb\fR had been executed with the \fB-F\fR option on the command line.
3272 .ne 2
3274 \fB\fB-I\fR\fR
3276 .RS 6n
3277 Sets the default path for locating macro files. The path argument can contain
3278 any of the special tokens described for the \fB-I\fR command-line option under
3279 OPTIONS.
3283 .ne 2
3285 \fB\fB-L\fR\fR
3287 .RS 6n
3288 Sets the default path for locating debugger modules. The path argument can
3289 contain any of the special tokens described for the \fB-I\fR command-line
3290 option under OPTIONS.
3294 .ne 2
3296 \fB\fB-o\fR\fR
3298 .RS 6n
3299 Enables the specified debugger option. If the \fB-o\fR form is used, the option
3300 is disabled. The option strings are described along with the \fB-o\fR
3301 command-line option under OPTIONS.
3305 .ne 2
3307 \fB\fB-P\fR\fR
3309 .RS 6n
3310 Sets the command prompt to the specified prompt string.
3314 .ne 2
3316 \fB\fB-s\fR\fR
3318 .RS 6n
3319 Sets the symbol matching distance to the specified distance. Refer to the
3320 description of the \fB-s\fR command-line option under OPTIONS for more
3321 information.
3325 .ne 2
3327 \fB\fB-w\fR\fR
3329 .RS 6n
3330 Re-opens the target for writing, as if \fBmdb\fR had been executed with the
3331 \fB-w\fR option on the command line.
3337 .ne 2
3339 \fB\fB::showrev\fR [ \fB-pv\fR ]\fR
3341 .sp .6
3342 .RS 4n
3343 Display revision information for the hardware and software. With no options
3344 specified, general system information is displayed. The \fB-v\fR option
3345 displays version information for all load objects, whereas the \fB-p\fR option
3346 displays the version information only for the load objects that have been
3347 installed on the system as part of a patch. Version information is not
3348 available for all load objects. Load objects without version information is
3349 omitted from the output for the \fB-p\fR option and is listed as having a
3350 version of "\fBUnknown\fR" in the output for the \fB-v\fR option.
3354 .ne 2
3356 \fB[\fIsignal\fR] \fB::sigbp\fR [\fB-/\fR\fB-dDestT\fR] [\fB-c\fR \fIcmd\fR]
3357 [\fB-n\fR \fIcount\fR] \fISIG\fR ...\fR
3361 \fB[\fIsignal\fR] \fB:t\fR [\fB-/\fR\fB-dDestT\fR] [\fB-c\fR \fIcmd\fR]
3362 [\fB-n\fR \fIcount\fR] \fISIG\fR ...\fR
3364 .sp .6
3365 .RS 4n
3366 Trace delivery of the specified signals. The signals are identified using an
3367 optional signal number preceding the dcmd, or a list of signal names or numbers
3368 (see \fBsignal.h\fR(3HEAD)) following the dcmd. The \fB-d\fR, \fB-D\fR,
3369 \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and \fB-n\fR options have the
3370 same meaning as they do for the \fB::evset\fR dcmd. Initially, the set of
3371 signals that cause the process to dump core by default (see
3372 \fBsignal.h\fR(3HEAD)) and \fBSIGINT\fR are traced.
3376 .ne 2
3378 \fB\fB::sizeof\fR \fItype\fR \fR
3380 .sp .6
3381 .RS 4n
3382 Print the size of the specified \fItype\fR in bytes. The \fItype\fR parameter
3383 can name a C struct, union, enum, fundamental integer type, or a pointer to any
3384 of these types. The type name can use the backquote (\fB`\fR) scoping operator
3385 described under \fBSymbol Name Resolution\fR, above. The \fB::sizeof\fR dcmd
3386 can only be used with objects that contain symbolic debugging information
3387 designed for use with \fBmdb\fR. Refer to NOTES, \fBSymbolic Debugging
3388 Information\fR, below for more information.
3392 .ne 2
3394 \fB[ \fIaddress\fR ] \fB::stack \fR [ \fIcount\fR ]\fR
3398 \fB[ \fI address\fR ] \fB$c\fR [ \fIcount\fR ]\fR
3400 .sp .6
3401 .RS 4n
3402 Print a C stack backtrace. If the dcmd is preceded by an explicit
3403 \fIaddress\fR, a backtrace beginning at this virtual memory address is
3404 displayed. Otherwise the stack of the representative thread is displayed. If an
3405 optional count value is given as an argument, no more than \fIcount\fR
3406 arguments are displayed for each stack frame in the output.
3410 .ne 2
3412 \fB\fB::status\fR\fR
3414 .sp .6
3415 .RS 4n
3416 Print a summary of information related to the current target.
3420 .ne 2
3422 \fB\fB::step\fR [ \fBover\fR | \fBout\fR ] [ \fISIG\fR ]\fR
3426 \fB\fB:s\fR [ \fISIG\fR ]\fR
3430 \fB\fB:u\fR [ \fISIG\fR ]\fR
3432 .sp .6
3433 .RS 4n
3434 Step the target program one instruction. If an optional signal name or number
3435 (see \fBsignal.h\fR(3HEAD)) is specified as an argument, the signal is
3436 immediately delivered to the target as part of resuming its execution. If the
3437 optional "\fBover\fR" argument is specified, \fB::step\fR steps over subroutine
3438 calls. The \fB::step\fR \fBover\fR argument is the same as the \fB::next\fR
3439 dcmd. If the optional "\fBout\fR" argument is specified, the target program
3440 continues until the representative thread returns from the current function. If
3441 no target program is currently running, \fB::step\fR \fBout\fR starts a new
3442 program running as if by \fB::run\fR and stop at the first instruction. The
3443 \fB:s\fR dcmd is the same as \fB::step\fR. The \fB:u\fR dcmd is the same as
3444 \fB::step\fR \fBout\fR.
3448 .ne 2
3450 \fB[ \fIsyscall\fR ] \fB::sysbp\fR [ \fB-/\fR\fB-dDestT\fR ] [ \fB-io\fR ] [
3451 \fB-c\fR \fIcmd\fR ]\fR
3455 \fB#sp;#sp;[ \fB-n\fR \fIcount\fR ] \fIsyscall\fR...\fR
3457 .sp .6
3458 .RS 4n
3459 Trace entry to or exit from the specified system calls. The system calls are
3460 identified using an optional system call number preceding the dcmd, or a list
3461 of system call names or numbers (see \fB<sys/syscall.h>\fR) following the dcmd.
3462 If the \fB-i\fR option is specified (the default), the event specifiers trigger
3463 on entry into the kernel for each system call. If the \fB-o\fR option is
3464 specified, the event specifiers trigger on exit out from the kernel. The
3465 \fB-d\fR, \fB-D\fR, \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR, \fB-c\fR, and
3466 \fB-n\fR options have the same meaning as they do for the \fB::evset\fR dcmd.
3470 .ne 2
3472 \fB\fIthread\fR \fB::tls\fR \fIsymbol\fR\fR
3474 .sp .6
3475 .RS 4n
3476 Print the address of the storage for the specified thread-local storage
3477 (\fBTLS\fR) symbol in the context of the specified thread. The thread
3478 expression should be one of the thread identifiers described under \fBThread
3479 Support\fR, above. The symbol name can use any of the scoping operators
3480 described under \fBSymbol Name Resolution\fR, above.
3484 .ne 2
3486 \fB\fB::typeset\fR [ \fB-/\fR\fB-t\fR] \fIvariable-name\fR ...\fR
3488 .sp .6
3489 .RS 4n
3490 Set attributes for named variables. If one or more variable names are
3491 specified, they are defined and set to the value of dot. If the \fB-t\fR option
3492 is present, the user-defined tag associated with each variable is set. If the
3493 \fB-t\fR option is present, the tag is cleared. If no variable names are
3494 specified, the list of variables and their values is printed.
3498 .ne 2
3500 \fB\fB::unload\fR \fImodule-name\fR\fR
3502 .sp .6
3503 .RS 4n
3504 Unload the specified dmod. The list of active dmods can be printed using the
3505 \fB::dmods\fR dcmd. Built-in modules can not be unloaded. Modules that are busy
3506 (that is, provide dcmds that are currently executing) can not be unloaded.
3510 .ne 2
3512 \fB\fB::unset\fR \fIvariable-name\fR ...\fR
3514 .sp .6
3515 .RS 4n
3516 Unset (remove) the specified variable(s) from the list of defined variables.
3517 Some variables exported by \fBmdb\fR are marked as persistent, and can not be
3518 unset by the user.
3522 .ne 2
3524 \fB\fB::vars\fR [ \fB-npt\fR] \fR
3526 .sp .6
3527 .RS 4n
3528 Print a listing of named variables. If the \fB-n\fR option is present, the
3529 output is restricted to variables that currently have non-zero values. If the
3530 \fB-p\fR option is present, the variables are printed in a form suitable for
3531 re-processing by the debugger using the \fB$<\fR dcmd. This option can be used
3532 to record the variables to a macro file and then restore these values later. If
3533 the \fB-t\fR option is present, only the tagged variables are printed.
3534 Variables can be tagged using the \fB-t\fR option of the \fB::typeset\fR dcmd.
3538 .ne 2
3540 \fB\fB::version\fR\fR
3542 .sp .6
3543 .RS 4n
3544 Print the debugger version number.
3548 .ne 2
3550 \fB\fIaddress\fR \fB::vtop\fR [\fB-a\fR \fIas\fR]\fR
3552 .sp .6
3553 .RS 4n
3554 Print the physical address mapping for the specified virtual address, if
3555 possible. The \fB::vtop\fR dcmd is only available when examining a kernel
3556 target, or when examining a user process inside a kernel crash dump (after a
3557 \fB::context\fR dcmd has been issued).
3559 When examining a kernel target from the kernel context, the \fB-a\fR option can
3560 be used to specify the address (\fIas\fR) of an alternate address space
3561 structure that should be used for the virtual to physical translation. By
3562 default, the kernel's address space is used for translation. This option is
3563 available for active address spaces even when the dump content only contains
3564 kernel pages.
3568 .ne 2
3570 \fB[ \fIaddress\fR ] \fB::walk\fR \fIwalker-name\fR [ \fIvariable-name\fR ]\fR
3572 .sp .6
3573 .RS 4n
3574 Walk through the elements of a data structure using the specified walker. The
3575 available walkers can be listed using the \fB::walkers\fR dcmd. Some walkers
3576 operate on a global data structure and do not require a starting address. For
3577 example, walk the list of proc structures in the kernel. Other walkers operate
3578 on a specific data structure whose address must be specified explicitly. For
3579 example, given a pointer to an address space, walk the list of segments. When
3580 used interactively, the \fB::walk\fR dcmd prints the address of each element of
3581 the data structure in the default base. The dcmd can also be used to provide a
3582 list of addresses for a pipeline. The walker name can use the backquote
3583 (\fB`\fR) scoping operator described under \fBdcmd and Walker Name
3584 Resolution\fR, above. If the optional \fIvariable-name\fR is specified, the
3585 specified variable is assigned the value returned at each step of the walk when
3586 \fBmdb\fR invokes the next stage of the pipeline.
3590 .ne 2
3592 \fB\fB::walkers\fR\fR
3594 .sp .6
3595 .RS 4n
3596 List the available walkers and print a brief description for each one.
3600 .ne 2
3602 \fB\fB::whence\fR [ \fB-v\fR ] \fIname\fR ...\fR
3606 \fB\fB::which\fR [ \fB-v\fR ] \fIname\fR ...\fR
3608 .sp .6
3609 .RS 4n
3610 Print the dmod that exports the specified dcmds and walkers. These dcmds can be
3611 used to determine which dmod is currently providing the global definition of
3612 the given dcmd or walker. Refer to the section on \fBdcmd and Walker Name
3613 Resolution\fR above for more information on global name resolution. The
3614 \fB-v\fR option causes the dcmd to print the alternate definitions of each dcmd
3615 and walker in order of precedence.
3619 .ne 2
3621 \fB\fIaddr\fR [ ,\fIlen\fR ]\fB::wp\fR  [ \fB-/\fR\fB-dDestT\fR ] [ \fB-rwx\fR
3622 ] [ \fB-c\fR \fIcmd\fR ]\fR
3626 \fB#sp;#sp; [ \fB-n\fR \fIcount\fR ]\fR
3630 \fB\fIaddr\fR [ ,\fIlen\fR ] \fB:a\fR [ \fIcmd\fR ... ]\fR
3634 \fB\fIaddr\fR [ ,\fIlen\fR ] \fB:p\fR [ \fIcmd\fR ... ]\fR
3638 \fB\fIaddr\fR [ ,\fIlen\fR ] \fB:w\fR [ \fIcmd\fR ... ]\fR
3640 .sp .6
3641 .RS 4n
3642 Set a watchpoint at the specified address. The length in bytes of the watched
3643 region can be set by specifying an optional repeat count preceding the dcmd. If
3644 no length is explicitly set, the default is one byte. The \fB::wp\fR dcmd
3645 allows the watchpoint to be configured to trigger on any combination of read
3646 (\fB-r\fR option), write (\fB-w\fR option), or execute (\fB-x\fR option)
3647 access. The \fB-d\fR, \fB-D\fR, \fB-e\fR, \fB-s\fR, \fB-t\fR, \fB-T\fR,
3648 \fB-c\fR, and \fB-n\fR options have the same meaning as they do for the
3649 \fB::evset\fR dcmd. The \fB:a\fR dcmd sets a read access watchpoint at the
3650 specified address. The \fB:p\fR dcmd sets an execute access watchpoint at the
3651 specified address. The \fB:w\fR dcmd sets a write access watchpoint at the
3652 specified address. The arguments following the \fB:a\fR, \fB:p\fR, and \fB:w\fR
3653 dcmds are concatenated together to form the callback string. If this string
3654 contains meta-characters, it must be quoted.
3658 .ne 2
3660 \fB\fB::xdata\fR\fR
3662 .sp .6
3663 .RS 4n
3664 List the external data buffers exported by the current target. External data
3665 buffers represent information associated with the target that can not be
3666 accessed through standard target facilities (that is, an address space, symbol
3667 table, or register set). These buffers can be consumed by dcmds; for more
3668 information, refer to the \fIModular Debugger Guide\fR.
3672 .ne 2
3674 \fB\fB:z\fR\fR
3676 .sp .6
3677 .RS 4n
3678 Delete all event specifiers from the list of traced software events. Event
3679 specifiers can also be deleted using \fB::delete\fR.
3682 .SH OPTIONS
3684 The following options are supported:
3686 .ne 2
3688 \fB\fB-A\fR\fR
3690 .RS 15n
3691 Disables automatic loading of \fBmdb\fR modules. By default, \fBmdb\fR attempts
3692 to load debugger modules corresponding to the active shared libraries in a user
3693 process or core file, or to the loaded kernel modules in the live operating
3694 system or an operating system crash dump.
3698 .ne 2
3700 \fB\fB-e\fR \fIexpr\fR\fR
3702 .RS 15n
3703 Causes \fBmdb\fR to ignore standard input and instead evaluate the \fBmdb\fR
3704 expression \fIexpr\fR. Upon completing evaluation, \fBmdb\fR terminates and
3705 returns a status code. A non-zero return code from \fBmdb\fR indicates that
3706 either \fBmdb\fR or the evaluation of \fIexpr\fR failed.
3710 .ne 2
3712 \fB\fB-f\fR\fR
3714 .RS 15n
3715 Forces raw file debugging mode. By default, \fBmdb\fR attempts to infer whether
3716 the object and core file operands refer to a user executable and core dump or
3717 to a pair of operating system crash dump files. If the file type cannot be
3718 inferred, the debugger defaults to examining the files as plain binary data.
3719 The \fB-f\fR option forces \fBmdb\fR to interpret the arguments as a set of raw
3720 files to examine.
3724 .ne 2
3726 \fB\fB-F\fR\fR
3728 .RS 15n
3729 Forcibly takes over the specified user process, if necessary. By default,
3730 \fBmdb\fR refuses to attach to a user process that is already under the control
3731 of another debugging tool, such as \fBtruss\fR(1). With the \fB-F\fR option,
3732 \fBmdb\fR attaches to these processes anyway. This can produce unexpected
3733 interactions between \fBmdb\fR and the other tools attempting to control the
3734 process.
3738 .ne 2
3740 \fB\fB-I\fR \fIpath\fR\fR
3742 .RS 15n
3743 Sets default path for locating macro files. Macro files are read using the
3744 \fB$<\fR or \fB$<<\fR dcmds. The path is a sequence of directory names
3745 delimited by colon (\fB:\fR) characters. The \fB-I\fR \fBinclude\fR path and
3746 \fB-L\fR \fBlibrary\fR path (see below) can also contain any of the following
3747 tokens:
3749 .ne 2
3751 \fB%i\fR
3753 .RS 6n
3754 Expands to the current instruction set architecture (\fBISA\fR) name
3755 ('sparc', 'sparcv9', or 'i386').
3759 .ne 2
3761 \fB%o\fR
3763 .RS 6n
3764 Expands to the old value of the path being modified. This is useful for
3765 appending or prepending directories to an existing path.
3769 .ne 2
3771 \fB%p\fR
3773 .RS 6n
3774 Expands to the current platform string (either \fBuname\fR \fB-i\fR or the
3775 platform string stored in the process core file or crash dump).
3779 .ne 2
3781 \fB%r\fR
3783 .RS 6n
3784 Expands to the pathname of the root directory. An alternate root directory can
3785 be specified using the \fB-R\fR option. If no \fB-R\fR option is present, the
3786 root directory is derived dynamically from the path to the \fBmdb\fR executable
3787 itself. For example, if \fB/bin/mdb\fR is executed, the root directory is
3788 \fB/\fR. If \fB/net/hostname/bin/mdb\fR were executed, the root directory would
3789 be derived as \fB/net/hostname\fR.
3793 .ne 2
3795 \fB%t\fR
3797 .RS 6n
3798 Expands to the name of the current target. This is either be the literal
3799 string '\fBproc\fR' (a user process or user process core file), '\fBkvm\fR' (a kernel
3800 crash dump or the live operating system), or '\fBraw\fR' (a raw file).
3803 The default include path for 32-bit \fBmdb\fR is:
3805 .in +2
3807 %r/usr/platform/%p/lib/adb:%r/usr/lib/adb
3809 .in -2
3812 The default include path for 64-bit \fBmdb\fR is:
3814 .in +2
3816 %r/usr/platform/%p/lib/adb/%i:%r/usr/lib/adb/%i
3818 .in -2
3824 .ne 2
3826 \fB\fB-k\fR\fR
3828 .RS 15n
3829 Forces kernel debugging mode. By default, \fBmdb\fR attempts to infer whether
3830 the object and core file operands refer to a user executable and core dump, or
3831 to a pair of operating system crash dump files. The \fB-k\fR option forces
3832 \fBmdb\fR to assume these files are operating system crash dump files. If no
3833 object or core operand is specified, but the \fB-k\fR option is specified,
3834 \fBmdb\fR defaults to an object file of \fB/dev/ksyms\fR and a core file of
3835 \fB/dev/kmem\fR. Read access to \fB/dev/kmem\fR is restricted to group sys.
3836 Write access requires ALL privileges.
3840 .ne 2
3842 \fB\fB-K\fR\fR
3844 .RS 15n
3845 Load \fBkmdb\fR, stop the live running operating system kernel, and proceed to
3846 the \fBkmdb\fR debugger prompt. This option should only be used on the system
3847 console, as the subsequent \fBkmdb\fR prompt appears on the system console.
3851 .ne 2
3853 \fB\fB-L\fR \fIpath\fR\fR
3855 .RS 15n
3856 Sets default path for locating debugger modules. Modules are loaded
3857 automatically on startup or using the \fB::load\fR dcmd. The path is a sequence
3858 of directory names delimited by colon (\fB:\fR) characters. The \fB-L\fR
3859 library path can also contain any of the tokens shown for \fB-I\fR above.
3863 .ne 2
3865 \fB\fB-m\fR\fR
3867 .RS 15n
3868 Disables demand-loading of kernel module symbols. By default, \fBmdb\fR
3869 processes the list of loaded kernel modules and performs demand loading of
3870 per-module symbol tables. If the \fB-m\fR option is specified, \fBmdb\fR does
3871 not attempt to process the kernel module list or provide per-module symbol
3872 tables. As a result, \fBmdb\fR modules corresponding to active kernel modules
3873 are not loaded on startup.
3877 .ne 2
3879 \fB\fB-M\fR\fR
3881 .RS 15n
3882 Preloads all kernel module symbols. By default, \fBmdb\fR performs
3883 demand-loading for kernel module symbols: the complete symbol table for a
3884 module is read when an address is that module's text or data section is
3885 referenced. With the \fB-M\fR option, \fBmdb\fR loads the complete symbol table
3886 of all kernel modules during startup.
3890 .ne 2
3892 \fB\fB-o\fR \fIoption\fR\fR
3894 .RS 15n
3895 Enables the specified debugger option. If the \fB-o\fR form of the option is
3896 used, the specified \fIoption\fR is disabled. Unless noted below, each option
3897 is off by default. \fBmdb\fR recognizes the following \fIoption\fR arguments:
3899 .ne 2
3901 \fB\fBadb\fR\fR
3903 .RS 25n
3904 Enables stricter \fBadb\fR(1) compatibility. The prompt is set to the empty
3905 string and many \fBmdb\fR features, such as the output pager, is disabled.
3909 .ne 2
3911 \fB\fBarray_mem_limit=\fR\fIlimit\fR\fR
3913 .RS 25n
3914 Sets the default limit on the number of array members that \fB::print\fR
3915 displays. If \fIlimit\fR is the special token \fBnone\fR, all array members are
3916 displayed by default.
3920 .ne 2
3922 \fB\fBarray_str_limit=\fR\fIlimit\fR\fR
3924 .RS 25n
3925 Sets the default limit on the number of characters that \fB::print\fR attempts
3926 to display as an ASCII string when printing a char array. If \fIlimit\fR is the
3927 special token \fBnone\fR, the entire char array is displayed as a string by
3928 default.
3932 .ne 2
3934 \fB\fBfollow_exec_mode=\fR\fImode\fR\fR
3936 .RS 25n
3937 Sets the debugger behavior for following an \fBexec\fR(2) system call. The
3938 \fImode\fR should be one of the following named constants:
3940 .ne 2
3942 \fB\fBask\fR\fR
3944 .RS 10n
3945 If stdout is a terminal device, the debugger stops after the \fBexec\fR(2)
3946 system call has returned and then prompts the user to decide whether to follow
3947 the exec or stop. If stdout is not a terminal device, the \fBask\fR mode
3948 defaults to \fBstop\fR.
3952 .ne 2
3954 \fB\fBfollow\fR\fR
3956 .RS 10n
3957 The debugger follows the exec by automatically continuing the target process
3958 and resetting all of its mappings and symbol tables based on the new
3959 executable. The \fBfollow\fR behavior is discussed in more detail under NOTES,
3960 \fBInteraction with Exec\fR, below.
3964 .ne 2
3966 \fB\fBstop\fR\fR
3968 .RS 10n
3969 The debugger stops following return from the exec system call. The \fBstop\fR
3970 behavior is discussed in more detail under NOTES, \fBInteraction with Exec\fR,
3971 below.
3977 .ne 2
3979 \fB\fBfollow_fork_mode=\fR\fImode\fR\fR
3981 .RS 25n
3982 Sets the debugger behavior for following a \fBfork\fR(2), \fBfork1\fR(2), or
3983 \fBvfork\fR(2) system call. The \fImode\fR should be one of the following named
3984 constants:
3986 .ne 2
3988 \fB\fBask\fR\fR
3990 .RS 10n
3991 If stdout is a terminal device, the debugger stops after the \fBfork\fR(2)
3992 system call has returned and then prompts the user to decide whether to follow
3993 the parent or child. If stdout is not a terminal device, the \fBask\fR mode
3994 defaults to \fBparent\fR.
3998 .ne 2
4000 \fB\fBparent\fR\fR
4002 .RS 10n
4003 The debugger follows the parent process, and detaches from the child process
4004 and sets it running.
4008 .ne 2
4010 \fB\fBchild\fR\fR
4012 .RS 10n
4013 The debugger follows the child process, and detaches from the parent process
4014 and sets it running.
4020 .ne 2
4022 \fB\fBignoreeof\fR\fR
4024 .RS 25n
4025 The debugger does not exit when an \fBEOF\fR sequence (\fB^D\fR) is entered at
4026 the terminal. The \fB::quit\fR dcmd must be used to quit.
4030 .ne 2
4032 \fB\fBnostop\fR\fR
4034 .RS 25n
4035 Does not stop a user process when attaching to it when the \fB-p\fR option is
4036 specified or when the \fB::attach\fR or \fB:A\fR dcmds are applied. The
4037 \fBnostop\fR behavior is described in more detail under NOTES, \fBProcess
4038 Attach and Release\fR, below.
4042 .ne 2
4044 \fB\fBpager\fR\fR
4046 .RS 25n
4047 Enables the output pager (default).
4051 .ne 2
4053 \fB\fBrepeatlast\fR\fR
4055 .RS 25n
4056 If a \fINEWLINE\fR is entered as the complete command at the terminal,
4057 \fBmdb\fR repeats the previous command with the current value of dot. This
4058 option is implied by \fB-o\fR \fBadb\fR.
4062 .ne 2
4064 \fB\fBshowlmid\fR\fR
4066 .RS 25n
4067 \fBmdb\fR provides support for symbol naming and identification in user
4068 applications that make use of link maps other than \fILM_ID_BASE\fR and
4069 \fILM_ID_LDSO\fR, as described in \fBSymbol Name Resolution\fR, above. Symbols
4070 on link maps other than \fILM_ID_BASE\fR or \fILM_ID_LDSO\fR is shown as
4071 \fBLMlmid`library`symbol\fR, where \fBlmid\fR is the link-map \fBID\fR in the
4072 default output radix (16). The user can optionally configure \fBmdb\fR to show
4073 the link-map \fBID\fR scope of all symbols and objects, including those
4074 associated with \fILM_ID_BASE\fR and \fILM_ID_LDSO\fR, by enabling the
4075 \fBshowlmid\fR option. Built-in dcmds that deal with object file names displays
4076 link-map \fBID\fRs according to the value of \fBshowlmid\fR above, including
4077 \fB::nm\fR, \fB::mappings\fR, \fB$m\fR, and \fB::objects\fR.
4083 .ne 2
4085 \fB\fB-p\fR \fIpid\fR\fR
4087 .RS 15n
4088 Attaches to and stops the specified process-id. \fBmdb\fR uses the
4089 \fB/proc/\fIpid\fR/object/a.out\fR file as the executable file pathname.
4093 .ne 2
4095 \fB\fB-P\fR \fIprompt\fR\fR
4097 .RS 15n
4098 Sets the command prompt. The default prompt is '\fB>\fR '.
4102 .ne 2
4104 \fB\fB-R\fR \fIroot\fR\fR
4106 .RS 15n
4107 Sets root directory for pathname expansion. By default, the root directory is
4108 derived from the pathname of the \fBmdb\fR executable itself. The root
4109 directory is substituted in place of the \fB%r\fR token during pathname
4110 expansion.
4114 .ne 2
4116 \fB\fB-s\fR \fIdistance\fR\fR
4118 .RS 15n
4119 Sets the symbol matching distance for address-to-symbol-name conversions to the
4120 specified \fIdistance\fR. By default, \fBmdb\fR sets the distance to zero,
4121 which enables a smart-matching mode. Each \fBELF\fR symbol table entry includes
4122 a value V and size S, representing the size of the function or data object in
4123 bytes. In smart mode, \fBmdb\fR matches an address A with the given symbol if A
4124 is in the range [ V, V + S ). If any non-zero distance is specified, the same
4125 algorithm is used, but S in the expression above is always the specified
4126 absolute distance and the symbol size is ignored.
4130 .ne 2
4132 \fB\fB-S\fR\fR
4134 .RS 15n
4135 Suppresses processing of the user's \fB~/.mdbrc\fR file. By default, \fBmdb\fR
4136 reads and processes the macro file \fB\&.mdbrc\fR if one is present in the
4137 user's home directory, as defined by $\fBHOME\fR. If the \fB-S\fR option is
4138 present, this file is not read.
4142 .ne 2
4144 \fB\fB-u\fR\fR
4146 .RS 15n
4147 Forces user debugging mode. By default, \fBmdb\fR attempts to infer whether the
4148 object and core file operands refer to a user executable and core dump, or to a
4149 pair of operating system crash dump files. The \fB-u\fR option forces \fBmdb\fR
4150 to assume these files are not operating system crash dump files.
4154 .ne 2
4156 \fB\fB-U\fR\fR
4158 .RS 15n
4159 Unload \fBkmdb\fR if it is loaded. You should unload \fBkmdb\fR when it is not
4160 in use to release the memory used by the kernel debugger back to the free
4161 memory available to the operating system.
4165 .ne 2
4167 \fB\fB-V\fR \fIversion\fR\fR
4169 .RS 15n
4170 Sets disassembler version. By default, \fBmdb\fR attempts to infer the
4171 appropriate disassembler version for the debug target. The disassembler can be
4172 set explicitly using the \fB-V\fR option. The \fB::disasms\fR dcmd lists the
4173 available disassembler versions.
4177 .ne 2
4179 \fB\fB-w\fR\fR
4181 .RS 15n
4182 Opens the specified object and core files for writing.
4186 .ne 2
4188 \fB\fB-W\fR\fR
4190 .RS 15n
4191 Permit access to memory addresses that are mapped to I/O devices. By default,
4192 \fBmdb\fR does not allow such access because many devices do not provide
4193 hardware protection against invalid software manipulations. Use this option
4194 only when debugging device drivers and with caution.
4198 .ne 2
4200 \fB\fB-y\fR\fR
4202 .RS 15n
4203 Sends explicit terminal initialization sequences for tty mode. Some legacy
4204 terminal emulators require explicit initialization sequences to switch
4205 into a tty mode. Without this initialization sequence, terminal features such
4206 as standout mode will not be available to \fBmdb\fR.
4209 .SH OPERANDS
4211 The following operands are supported:
4213 .ne 2
4215 \fB\fIobject\fR\fR
4217 .RS 10n
4218 Specifies an \fBELF\fR format object file to examine. \fBmdb\fR provides the
4219 ability to examine and edit \fBELF\fR format executables (\fBET_EXEC\fR),
4220 \fBELF\fR dynamic library files (\fBET_DYN\fR), \fBELF\fR relocatable object
4221 files (\fBET_REL\fR), and operating system unix.X symbol table files.
4225 .ne 2
4227 \fB\fIcore\fR\fR
4229 .RS 10n
4230 Specifies an \fBELF\fR process core file (\fBET_CORE\fR), or an operating
4231 system crash dump vmcore.X file. If an \fBELF\fR core file operand is provided
4232 without a corresponding object file, \fBmdb\fR attempts to infer the name of
4233 the executable file that produced the core using several different algorithms.
4234 If no executable is found, \fBmdb\fR still executes, but some symbol
4235 information can be unavailable.
4239 .ne 2
4241 \fB\fIsuffix\fR\fR
4243 .RS 10n
4244 Specifies the numerical suffix representing a pair of operating system crash
4245 dump files. For example, if the suffix is '\fB3\fR', \fBmdb\fR infers that it
4246 should examine the files '\fBunix.3\fR' and '\fBvmcore.3\fR'. The string of
4247 digits are not interpreted as a suffix if an actual file of the same name is
4248 present in the current directory.
4251 .SH EXIT STATUS
4253 The following exit values are returned:
4255 .ne 2
4257 \fB\fB0\fR\fR
4259 .RS 5n
4260 Debugger completed execution successfully.
4264 .ne 2
4266 \fB\fB1\fR\fR
4268 .RS 5n
4269 A fatal error occurred.
4273 .ne 2
4275 \fB\fB2\fR\fR
4277 .RS 5n
4278 Invalid command line options were specified.
4281 .SH ENVIRONMENT VARIABLES
4282 .ne 2
4284 \fB\fBHISTSIZE\fR\fR
4286 .RS 12n
4287 This variable is used to determine the maximum length of the command history
4288 list. If this variable is not present, the default length is \fB128\fR.
4292 .ne 2
4294 \fB\fBHOME\fR\fR
4296 .RS 12n
4297 This variable is used to determine the pathname of the user's home directory,
4298 where a \fB\&.mdbrc\fR file can reside. If this variable is not present, no
4299 \fB\&.mdbrc\fR processing occurs.
4303 .ne 2
4305 \fB\fBSHELL\fR\fR
4307 .RS 12n
4308 This variable is used to determine the pathname of the shell used to process
4309 shell escapes requested using the \fB!\fR meta-character. If this variable is
4310 not present, \fB/bin/sh\fR is used.
4313 .SH FILES
4314 .ne 2
4316 \fB\fB$HOME/.mdbrc\fR\fR
4318 .sp .6
4319 .RS 4n
4320 User \fBmdb\fR initialization file. The \fB\&.mdbrc\fR file, if present, is
4321 processed after the debug target has been initialized, but before module
4322 auto-loading is performed or any commands have been read from standard input.
4326 .ne 2
4328 \fB\fB/dev/kmem\fR\fR
4330 .sp .6
4331 .RS 4n
4332 Kernel virtual memory image device. This device special file is used as the
4333 core file when examining the live operating system.
4337 .ne 2
4339 \fB\fB/dev/ksyms\fR\fR
4341 .sp .6
4342 .RS 4n
4343 Kernel symbol table device. This device special file is used as the object file
4344 when examining the live operating system.
4348 .ne 2
4350 \fB\fB/proc/\fIpid\fR/*\fR\fR
4352 .sp .6
4353 .RS 4n
4354 Process information files that are read when examining and controlling user
4355 processes.
4359 .ne 2
4361 \fB\fB/usr/lib/adb\fR\fR
4365 \fB\fB/usr/platform/\fIplatform-name\fR/lib/adb\fR\fR
4367 .sp .6
4368 .RS 4n
4369 Default directories for macro files that are read with the \fB$<\fR and
4370 \fB$<<\fR dcmds. \fIplatform-name\fR is the name of the platform, derived
4371 either from information in a core file or crash dump, or from the current
4372 machine as if by \fBuname\fR \fB-i\fR (see \fBuname\fR(1)).
4376 .ne 2
4378 \fB\fB/usr/lib/mdb\fR\fR
4382 \fB\fB/usr/platform/\fIplatform-name\fR/lib/mdb\fR\fR
4384 .sp .6
4385 .RS 4n
4386 Default directories for debugger modules that are loaded using the \fB::load\fR
4387 dcmd. \fIplatform-name\fR is the name of the platform, derived either from
4388 information in a core file or crash dump, or from the current machine as if by
4389 \fBuname\fR \fB-i\fR (see \fBuname\fR(1)).
4392 .SH ATTRIBUTES
4394 See \fBattributes\fR(5) for descriptions of the following attributes:
4399 box;
4400 c | c
4401 l | l .
4402 ATTRIBUTE TYPE  ATTRIBUTE VALUE
4404 Interface Stability     Evolving
4407 .SH SEE ALSO
4409 \fBadb\fR(1), \fBgcore\fR(1), \fBproc\fR(1), \fBpgrep\fR(1),
4410 \fBps\fR(1), \fBstty\fR(1), \fBtruss\fR(1), \fBuname\fR(1), \fBcoreadm\fR(8),
4411 \fBdumpadm\fR(8), \fBsavecore\fR(8), \fBexec\fR(2),
4412 \fBfork\fR(2), \fB_lwp_self\fR(2), \fBpipe\fR(2), \fBvfork\fR(2),
4413 \fBdlopen\fR(3C), \fBelf\fR(3ELF), \fBlibc_db\fR(3LIB), \fBlibkvm\fR(3LIB),
4414 \fBlibthread\fR(3LIB), \fBsignal\fR(3C), \fBsignal.h\fR(3HEAD),
4415 \fBthr_self\fR(3C), \fBcore\fR(4), \fBproc\fR(4), \fBattributes\fR(5),
4416 \fBthreads\fR(5), \fBksyms\fR(7D), \fBmem\fR(7D)
4419 \fILinker and Libraries Guide\fR
4422 \fIModular Debugger Guide\fR:
4425 https://illumos.org/books/mdb/
4426 .SH WARNINGS
4427 .SS "Use of the Error Recovery Mechanism"
4429 The debugger and its dmods execute in the same address space, and thus it is
4430 quite possible that a buggy dmod can cause \fBmdb\fR to dump core or otherwise
4431 misbehave. The \fBmdb\fR resume capability, described above under \fBSignal
4432 Handling\fR, provides a limited recovery mechanism for these situations.
4433 However, it is not possible for \fBmdb\fR to know definitively whether the dmod
4434 in question has corrupted only its own state, or the debugger's global state.
4435 Therefore a resume operation cannot be guaranteed to be safe, or to prevent a
4436 subsequent crash of the debugger. The safest course of action following a
4437 resume is to save any important debug information, and then quit and restart
4438 the debugger.
4439 .SS "Use of the Debugger to Modify the Live Operating System"
4441 The use of the debugger to modify (that is, write to) the address space of live
4442 running operating system is extremely dangerous, and can result in a system
4443 panic in the event the user damages a kernel data structure.
4444 .SH NOTES
4445 .SS "Limitations on Examining Process Core Files"
4447 \fBmdb\fR does not provide support for examining process core files that were
4448 generated by a release of Solaris preceding Solaris 2.6. When debugging core
4449 files generated by a release of Solaris 9 or an earlier release, symbol
4450 information might not be available. Since the text section and read-only data
4451 is not present in those core files, the symbol information might not match the
4452 data present in the process at the time it dumped core. In releases later than
4453 Solaris 9, text sections and read-only data are included in core files by
4454 default. Users can configure their processes to exclude that information from
4455 core files using \fBcoreadm\fR(8). Thus, the information presented by
4456 \fBmdb\fR for those core files can not match the data that was present at the
4457 time the process dumped core. Core files from x86 systems can not be
4458 examined on SPARC systems, and vice-versa.
4459 .SS "Limitations on Examining Crash Dump Files"
4461 Crash dumps from Solaris 7 and earlier releases can only be examined with the
4462 aid of the libkvm from the corresponding operating system release. If a crash
4463 dump from one operating system release is examined using the dmods from a
4464 different operating system release, changes in the kernel implementation can
4465 prevent some dcmds or walkers from working properly. \fBmdb\fR issues a warning
4466 message if it detects this condition. Crash dumps from x86 systems can
4467 not be examined on SPARC systems, and vice-versa.
4468 .SS "Relationship Between 32-bit and 64-bit Debugger"
4470 \fBmdb\fR provides support for debugging both 32-bit and 64-bit programs. Once
4471 it has examined the target and determined its data model, \fBmdb\fR
4472 automatically re-executes the \fBmdb\fR binary that has the same data model as
4473 the target, if necessary. This approach simplifies the task of writing debugger
4474 modules, because the modules that are loaded use the same data model as the
4475 primary target. Only the 64-bit debugger can be used to debug 64-bit target
4476 programs. The 64-bit debugger can only be used on a system that is running the
4477 64-bit operating environment.
4480 The debugger can also need to re-execute itself when debugging a 32-bit process
4481 that execs a 64-bit process, or vice-versa. The handling of this situation is
4482 discussed in more detail under \fBInteraction with Exec\fR, below.
4483 .SS "Interaction with Exec"
4485 When a controlled process performs a successful \fBexec\fR(2), the behavior of
4486 the debugger is controlled by the \fB::set\fR \fB-o\fR \fBfollow_exec_mode\fR
4487 option, as described above. If the debugger and victim process have the same
4488 data model, then the "\fBstop\fR" and "\fBfollow\fR" modes determine whether
4489 \fBmdb\fR automatically continues the target or returns to the debugger prompt
4490 following the exec. If the debugger and victim process have a different data
4491 model, then the "\fBfollow\fR" behavior causes \fBmdb\fR to automatically
4492 re-exec the \fBmdb\fR binary with the appropriate data model and to re-attach
4493 to the process, still stopped on return from the exec. Not all debugger state
4494 is preserved across this re-exec.
4497 If a 32-bit victim process execs a 64-bit program, then "\fBstop\fR" returns to
4498 the command prompt, but the debugger is no longer able to examine the process
4499 because it is now using the 64-bit data model. To resume debugging, execute the
4500 \fB::release\fR \fB-a\fR dcmd, quit \fBmdb\fR, and then execute \fBmdb\fR
4501 \fB-p\fR \fIpid\fR to re-attach the 64-bit debugger to the process.
4504 If a 64-bit victim process execs a 32-bit program, then "\fBstop\fR" returns to
4505 the command prompt, but the debugger only provides limited capabilities for
4506 examining the new process. All built-in dcmds work as advertised, but loadable
4507 dcmds do not since they do not perform data model conversion of structures. The
4508 user should release and re-attach the debugger to the process as described
4509 above in order to restore full debugging capabilities.
4510 .SS "Interaction with Job Control"
4512 If the debugger is attached to a process that is stopped by job control (that
4513 is, it stopped in response to \fBSIGTSTP\fR, \fBSIGTTIN\fR, or \fBSIGTTOU\fR),
4514 the process can not be able to be set running again when it is continued by a
4515 continue dcmd. If the victim process is a member of the same session (that is,
4516 it shares the same controlling terminal as \fBmdb\fR), \fBmdb\fR attempts to
4517 bring the associated process group to the foreground and to continue the
4518 process with \fBSIGCONT\fR to resume it from job control stop. When \fBmdb\fR
4519 is detached from such a process, it restores the process group to the
4520 background before exiting. If the victim process is not a member of the same
4521 session, \fBmdb\fR cannot safely bring the process group to the foreground, so
4522 it continues the process with respect to the debugger, but the process remains
4523 stopped by job control. \fBmdb\fR prints a warning in this case, and the user
4524 must issue an "\fBfg\fR" command from the appropriate shell in order to resume
4525 the process.
4526 .SS "Process Attach and Release"
4528 When \fBmdb\fR attaches to a running process, the process is stopped and
4529 remains stopped until one of the continue dcmds is applied, or the debugger
4530 quits. If the \fB-o\fR \fBnostop\fR option is enabled prior to attaching the
4531 debugger to a process with \fB-p\fR, or prior to issuing an \fB::attach\fR or
4532 \fB:A\fR command, \fBmdb\fR attaches to the process but does not stop it. While
4533 the process is still running, it can be inspected as usual (albeit with
4534 inconsistent results) and breakpoints or other tracing flags might be enabled.
4535 If the \fB:c\fR or \fB::cont\fR dcmds are executed while the process is
4536 running, the debugger waits for the process to stop. If no traced software
4537 events occur, the user can send an interrupt (\fB^C\fR) after \fB:c\fR or
4538 \fB::cont\fR to force the process to stop and return control to the debugger.
4541 \fBmdb\fR releases the current running process (if any) when the \fB:R\fR,
4542 \fB::release\fR, \fB:r\fR, \fB::run\fR, \fB$q\fR, or \fB::quit\fR dcmds are
4543 executed, or when the debugger terminates as the result of an \fBEOF\fR or
4544 signal. If the process was originally created by the debugger using \fB:r\fR or
4545 \fB::run\fR, it is forcibly terminated as if by \fBSIGKILL\fR when it is
4546 released. If the process was already running prior to attaching \fBmdb\fR to
4547 it, it is set running again when it is released. A process can be released and
4548 left stopped and abandoned using the \fB::release\fR \fB-a\fR option.
4549 .SS "Symbolic Debugging Information"
4551 The \fB::list\fR, \fB::offsetof\fR, \fB::print\fR, and \fB::sizeof\fR dcmds
4552 require that one or more load objects contain compressed symbolic debugging
4553 information suitable for use with \fBmdb\fR. This information is currently only
4554 available for certain kernel modules.
4555 .SS "Developer Information"
4557 The \fIModular Debugger Guide\fR provides a more detailed description
4558 of \fBmdb\fR features, as well as information for debugger module developers.
4561 The header file \fB<sys/mdb_modapi.h>\fR contains prototypes for the functions
4562 in the MDB Module \fBAPI\fR.