Appendix E. The GDB Agent Expression Mechanism
355
reg 1
Push the value of register 1 (presumably holding
x
) onto the stack.
reg 2
Push the value of register 2 (holding
y
).
const32
address of z
Push the address of
z
onto the stack.
ref32
Fetch a 32-bit word from the address at the top of the stack; replace the address on the stack with
the value. Thus, we replace the address of
z
with
z
’s value.
ext 32
Sign-extend the value on the top of the stack from 32 bits to full length. This is necessary because
z
is a signed integer.
mul
Pop the top two numbers on the stack, multiply them, and push their product. Now the top of the
stack contains the value of the expression
y * z
.
add
Pop the top two numbers, add them, and push the sum. Now the top of the stack contains the
value of
x + y * z
.
end
Stop executing; the value left on the stack top is the value to be recorded.
E.2. Bytecode Descriptions
Each bytecode description has the following form:
add
(0x02):
a b
=>
a+b
Pop the top two stack items,
a
and
b
, as integers; push their sum, as an integer.
In this example,
add
is the name of the bytecode, and
(0x02)
is the one-byte value used to encode
the bytecode, in hexidecimal. The phrase "
a b
=>
a+b
" shows the stack before and after the bytecode
executes. Beforehand, the stack must contain at least two values,
a
and
b
; since the top of the stack
is to the right,
b
is on the top of the stack, and
a
is underneath it. After execution, the bytecode will
have popped
a
and
b
from the stack, and replaced them with a single value,
a+b
. There may be other
values on the stack below those shown, but the bytecode affects only those shown.
Here is another example:
const8
(0x22)
n
: =>
n
Push the 8-bit integer constant
n
on the stack, without sign extension.
In this example, the bytecode
const8
takes an operand
n
directly from the bytecode stream; the
operand follows the
const8
bytecode itself. We write any such operands immediately after the name
of the bytecode, before the colon, and describe the exact encoding of the operand in the bytecode
stream in the body of the bytecode description.
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......