Go to main content

Oracle® Solaris Modular Debugger Guide

Exit Print View

Updated: October 2019
 
 

Arithmetic Expansion in MDB

Arithmetic expansion is performed to determine the value of an expression. MDB commands can be preceded by expressions that represent a start address or a repeat count. Arithmetic expansion can also be performed to compute a numeric argument for a dcmd. An expression can appear in an argument list enclosed in square brackets preceded by a dollar sign ($[expr]). In this case, the expression is replaced by its arithmetic value.

Expressions can contain any of the following special words:

integer

The specified integer value. Integer values can be prefixed with 0i or 0I to indicate binary values, 0o or 0O to indicate octal values, 0t or 0T to indicate decimal values, and 0x or 0X to indicate hexadecimal values (the default).

0[tT][0-9]+.[0-9]+

The specified decimal floating point value, converted to its IEEE double-precision floating point representation.

'cccccccc'

The integer value computed by converting each character to a byte equal to its ASCII value. Up to eight characters can be specified in a character constant. Characters are packed into the integer in reverse order (right-to-left), beginning at the least significant byte.

<identifier

The value of the variable named by identifier.

identifier

The value of the symbol named by identifier.

(expression)

The value of expression.

.

The value of dot.

&

The most recent value of dot used to execute a dcmd.

+

The value of dot incremented by the current increment.

^

The value of dot decremented by the current increment.

The increment is a global variable that stores the total bytes read by the last formatting dcmd. For more information about the increment, refer to the discussion of Dcmd Formatting Characters.

Unary Operators in MDB

Unary operators are right associative and have higher precedence than binary operators. The unary operators are:

#expression

Logical negation

~expression

Bitwise complement

-expression

Integer negation

%expression

Value of a pointer-sized quantity at the object file location corresponding to virtual address expression in the target's virtual address space

%/[csil]/expression

Value of a char-sized, short-sized, int-sized, or long-sized quantity at the object file location corresponding to virtual address expression in the target's virtual address space

%/[1248]/expression

Value of a one-byte, two-byte, four-byte, or eight-byte quantity at the object file location corresponding to virtual address expression in the target's virtual address space

<%/var/expression

Value from the object file location corresponding to virtual address expression. The size of the value is read from the variable var.

*expression

Value of a pointer-sized quantity at virtual address expression in the target's virtual address space

*/[csil]/expression

Value of a char-sized, short-sized, int-sized, or long-sized quantity at virtual address expression in the target's virtual address space

*/[1248]/expression

Value of a one-byte, two-byte, four-byte, or eight-byte quantity at virtual address expression in the target's virtual address space

*/type member/expression

Value of the data structure member from the target's virtual address space corresponding to virtual address expression. The size and offset that are read are specified by member. For example, to list all processes in a kernel that do not have a UID of zero (0):

> ::walk proc | ::grep '*/proc p_cred->cr_uid/.!=0'
<*/var/expression

Value from the target's virtual address space corresponding to virtual address expression. The size of the value is read from the variable var.

Binary Operators in MDB

Binary operators are left associative and have lower precedence than unary operators. The binary operators, in order of precedence from highest to lowest, are:

*

Integer multiplication

%

Integer division

#

Left-hand side rounded up to next multiple of right-hand side

+

Integer addition

-

Integer subtraction

<<

Bitwise shift left

>>

Bitwise shift right

==

Logical equality

!=

Logical inequality

&

Bitwise AND

^

Bitwise exclusive OR

|

Bitwise inclusive OR