Solaris mdb使用简介

13.2. MDB Command Syntax

The MDB debugger lets us interact with the target program and the memory image of the target. The syntax is an enhanced form of that used with debuggers like adb, in which basic form is expressed as value and a command.

[value] [,count ] command

The language syntax is designed around the concept of computing the value of an expression (typically a memory address in the target), and applying a command to that expression. A command in MDB can be of several forms. It can be a macro file, a metacharacter, or a dcmd pipeline. A simple command is a metacharacter or dcmd followed by a sequence of zero or more blank-separated words. The words are typically passed as arguments. Each command returns an exit status that indicates it succeeded, failed, or was invoked with invalid arguments.

For example, if we wanted to display the contents of the word at address fec4b8d0, we could use the / metacharacter with the word X as a format specifier, and optionally a count specifying the number of iterations.

> fec4b8d0 /X
lotsfree:
lotsfree: f5e
> fec4b8d0,4 /X
lotsfree:
lotsfree: f5e 7af 3d7 28

MDB retains the notion of dot (.) as the current address or value, retained from the last successful command. A command with no supplied expression uses the value of dot for its argument.

> /X
lotsfree:
lotsfree: f5e
> . /X
lotsfree:
lotsfree: f5e

A pipeline is a sequence of one or more simple commands separated by |. Unlike the shell, dcmds in MDB pipelines are not executed as separate processes. After the pipeline has been parsed, each dcmd is invoked in order from left to right. The full definition of a command involving pipelines is as follows.

[expr] [,count ] pipeline [words...]

Each dcmd's output is processed and stored as described in "dcmd Pipelines" in Section 13.2.8. After the left-hand dcmd is complete, its processed output is used as input for the next dcmd in the pipeline. If any dcmd does not return a successful exit status, the pipeline is aborted.

For reference, Table 13.1 lists the full set of expression and pipeline combinations that form commands.

Table 13.1. General MDB Command Syntax

Command

Description

pipeline [!word...] [;]

basic

expr pipeline [!word...] [;]

set dot, run once

expr, expr pipeline [!word...] [;]

set dot, repeat

, expr pipeline [!word...] [;]

repeat

expr [!word...] [;]

set dot, last pipeline, run once

, expr [!word...] [;]

last pipeline, repeat

expr, expr [!word...] [;]

set dot, last pipeline, repeat

!word... [;]

shell escape


13.2.1. Expressions

Arithmetic expansion is performed when an MDB command is preceded by an optional expression representing a numerical argument for a dcmd. A list of common expressions is summarized in Tables 13.2, 13.3, and 13.4.

Table 13.2. Arithmetic Expressions

Operator

Expression

integer

0i binary
0o octal
0t decimal
0x hex

0t[0-9]+/.[0-9]+

IEEE floating point

'cccccccc'

little-endian character const

<identifier

variable lookup

identifier

symbol lookup

(expr)

the value of expr

.

the value of dot

&

last dot used by dcmd

+

dot+increment

^

dot-increment (increment is effected by the last formatting dcmd)


Table 13.3. Unary Operators

Operator

Expression

#expr

logical NOT

~expr

bitwise NOT

-expr

integer negation

%expr

object-file pointer dereference

%/[csil]/expr

object-file typed dereference

%/[1248]/expr

object-file sized dereference

*expr

virtual-address pointer dereference

*/[csil]/expr

virtual-address typed dereference

*/[1248]/expr

virtual-address sized dereference

[csil] is char-, short-, int-, or long-sized

 


Table 13.4. Binary Operators

Operator

Description

expr * expr

integer multiplication

expr % expr

integer division

left # right

left rounded up to next right multiple

expr + expr

integer addition

expr - expr

integer subtraction

expr << expr

bitwise left shift

expr >> expr

bitwise right shift (logical)

expr == expr

logical equality

expr != expr

logical inequality

expr & expr

bitwise AND

expr ^ expr

bitwise XOR

expr | expr

bitwise OR


An example of a simple expression is adding an integer to an address.

> d7c662e0+0t8/X
0xd7c662e8: d2998b80
> d7c662e0+0t8::print int
0xd7c662e8: d2998b80

13.2.2. Symbols

MDB can reference memory or objects according to the value of a symbol of the target. A symbol is the name of either a function or a global variable in the target.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值