Formatting Dcmds
The /, \, ?, and = metacharacters are used to denote the special
output formatting dcmds. Each of these dcmds accepts an argument list consisting of one
or more format characters, repeat counts, or quoted strings. A format character is
one of the ASCII characters described below.
Format characters are used to read and format data from the target. A
repeat count is a positive integer preceding the format character that is always
interpreted in base 10 (decimal). A repeat count can also be specified as
an expression enclosed in square brackets preceded by a dollar sign ($[ ]).
A string argument must be enclosed in double quotation marks (" "). No blanks
are necessary between format arguments.
The formatting dcmds are:
- /
Display data from the target's virtual address space starting at the virtual address specified by dot.
- \
Display data from the target's physical address space starting at the physical address specified by dot.
- ?
Display data from the target's primary object file starting at the object file location corresponding to the virtual address specified by dot.
- =
Display the value of dot in each of the specified data formats. The = dcmd is useful for converting between bases and performing arithmetic.
In addition to dot, MDB keeps track of another global value called the
increment. The increment represents the distance between dot and the address following all
the data read by the last formatting dcmd.
For example, let dot equal address addr, where addr displays as a 4-byte
integer. After a formatting dcmd is executed with dot equal to addr, the increment
is set to 4. The plus (+) operator, described in Arithmetic Expansion, would now evaluate
to the value A+4, and could be used to reset dot to the
address of the next data object for a subsequent dcmd.
Most format characters increase the value of the increment by the number of
bytes corresponding to the size of the data format. The number of bytes
in various data formats are shown below. Use the ::formats dcmd to display
the list of format characters from within MDB.
The format characters are:
- +
Increment dot by the count (variable size)
- -
Decrement dot by the count (variable size)
- B
Hexadecimal int (1 byte)
- C
Character using C character notation (1 byte)
- D
Decimal signed int (4 bytes)
- E
Decimal unsigned long long (8 bytes)
- F
Double (8 bytes)
- G
Octal unsigned long long (8 bytes)
- H
Swap bytes and shorts (4 bytes)
- I
Address and disassembled instruction (variable size)
- J
Hexadecimal long long (8 bytes)
- K
Hexadecimal uintptr_t (4 or 8 bytes)
- N
Newline
- O
Octal unsigned int (4 bytes)
- P
Symbol (4 or 8 bytes)
- Q
Octal signed int (4 bytes)
- R
Binary int (8 bytes)
- S
String using C string notation (variable size)
- T
Horizontal tab
- U
Decimal unsigned int (4 bytes)
- V
Decimal unsigned int (1 byte)
- W
Default radix unsigned int (4 bytes)
- X
Hexadecimal int (4 bytes)
- Y
Decoded time32_t (4 bytes)
- Z
Hexadecimal long long (8 bytes)
- ^
Decrement dot by increment * count (variable size)
- a
Dot as symbol+offset
- b
Octal unsigned int (1 byte)
- c
Character (1 byte)
- d
Decimal signed short (2 bytes)
- e
Decimal signed long long (8 bytes)
- f
Float (4 bytes)
- g
Octal signed long long (8 bytes)
- h
Swap bytes (2 bytes)
- i
Disassembled instruction (variable size)
- n
Newline
- o
Octal unsigned short (2 bytes)
- p
Symbol (4 or 8 bytes)
- q
Octal signed short (2 bytes)
- r
Whitespace
- s
Raw string (variable size)
- t
Horizontal tab
- u
Decimal unsigned short (2 bytes)
- v
Decimal signed int (1 byte)
- w
Default radix unsigned short (2 bytes)
- x
Hexadecimal short (2 bytes)
- y
Decoded time64_t (8 bytes)
You can also use the /, \, and ? formatting dcmds to write
to the target's virtual address space, physical address space, or object file. First
specify one of the following modifiers as the first format character, and then
specify a list of words. The words in the list are either immediate
values or expressions enclosed in square brackets preceded by a dollar sign ($[ ]).
The write modifiers are:
- v
Write the lowest byte of the value of each expression to the target beginning at the location specified by dot
- w
Write the lowest 2 bytes of the value of each expression to the target beginning at the location specified by dot
- W
Write the lowest 4 bytes of the value of each expression to the target beginning at the location specified by dot
- Z
Write the complete 8 bytes of the value of each expression to the target beginning at the location specified by dot
You can also use the /, \, and ? formatting dcmds to search
for a particular integer value in the target's virtual address space, physical address
space, and object file, respectively. First specify one of the following modifiers as
the first format character, and then specify a value and optional mask. The
value and mask are each either immediate values or expressions enclosed in square
brackets preceded by a dollar sign.
If only a value is specified, MDB reads integers of the appropriate size
and stops at the address that contains the matching value. If a
value V and mask M are specified, MDB reads integers of the appropriate
size and stops at the address that contains a value X where
(X & M) == V. At the completion of the dcmd, dot is updated to the address
of the match. If no match is found, dot is left at the
last address that was read.
The search modifiers are:
- l
Search for the specified 2-byte value
- L
Search for the specified 4-byte value
- M
Search for the specified 8-byte value
For both user and kernel targets, an address space is typically composed of
a set of discontiguous segments. It is not legal to read from
an address that does not have a corresponding segment. If a search reaches
a segment boundary without finding a match, the search aborts when the read past
the end of the segment boundary fails.