354
By the time the bytecode interpreter reaches the end of the expression, the value of the expression
should be the only value left on the stack. For tracing applications,
sion will have recorded the necessary data, and the value on the stack may be discarded. For other
applications, like conditional breakpoints, the value may be useful.
Separate from the stack, the interpreter has two registers:
pc
The address of the next bytecode to execute.
start
The address of the start of the bytecode expression, necessary for interpreting the
instructions.
if_goto
Neither of these registers is directly visible to the bytecode language itself, but they are useful for
defining the meanings of the bytecode operations.
There are no instructions to perform side effects on the running program, or call the program's func-
tions; we assume that these expressions are only used for unobtrusive debugging, not for patching the
running code.
Most bytecode instructions do not distinguish between the various sizes of values, and operate on
full-width values; the upper bits of the values are simply ignored, since they do not usually make a
difference to the value computed. The exceptions to this rule are:
memory reference instructions (
There are distinct instructions to fetch different word sizes from memory. Once on the stack,
however, the values are treated as full-size integers. They may need to be sign-extended; the
instruction exists for this purpose.
the sign-extension instruction (
These clearly need to know which portion of their operand is to be extended to occupy the full
length of the word.
If the interpreter is unable to evaluate an expression completely for some reason (a memory location
is inaccessible, or a divisor is zero, for example), we say that interpretation "terminates with an error".
This means that the problem is reported back to the interpreter's caller in some helpful way. In general,
code using agent expressions should assume that they may attempt to divide by zero, fetch arbitrary
memory locations, and misbehave in other ways.
Even complicated C expressions compile to a few bytecode instructions; for example, the expression
would typically produce code like the following, assuming that
x + y * z
and
is a global variable holding a 32-bit
z
reg 1
reg 2
const32 address of z
ref32
ext 32
mul
add
end
In detail, these mean:
Appendix E. The GDB Agent Expression Mechanism
)
refn
)
ext n
:
int
bytecodes in the expres-
trace
and
live in registers,
x
y
and
goto
ext
Need help?
Do you have a question about the ENTERPRISE LINUX 3 - DEBUGGING WITH GDB and is the answer not in the manual?
Questions and answers