Appendix E. The GDB Agent Expression Mechanism
363
pointer will have when GDB generates the bytecode, so it cannot determine whether a particular
fetch will be aligned or not.
In particular, structure bitfields may be several bytes long, but follow no alignment rules; mem-
bers of packed structures are not necessarily aligned either.
In general, there are many cases where unaligned references occur in correct C code, either at
the programmer’s explicit request, or at the compiler’s discretion. Thus, it is simpler to make the
GDB agent bytecodes work correctly in all circumstances than to make GDB guess in each case
whether the compiler did the usual thing.
Why are there no side-effecting operators?
Because our current client doesn’t want them? That’s a cheap answer. I think the real answer
is that I’m afraid of implementing function calls. We should re-visit this issue after the present
contract is delivered.
Why aren’t the
goto
ops PC-relative?
The interpreter has the base address around anyway for PC bounds checking, and it seemed
simpler.
Why is there only one offset size for the
goto
ops?
Offsets are currently sixteen bits. I’m not happy with this situation either:
Suppose we have multiple branch ops with different offset sizes. As I generate code left-to-right,
all my jumps are forward jumps (there are no loops in expressions), so I never know the target
when I emit the jump opcode. Thus, I have to either always assume the largest offset size, or do
jump relaxation on the code after I generate it, which seems like a big waste of time.
I can imagine a reasonable expression being longer than 256 bytes. I can’t imagine one being
longer than 64k. Thus, we need 16-bit offsets. This kind of reasoning is so bogus, but relaxation
is pathetic.
The other approach would be to generate code right-to-left. Then I’d always know my offset size.
That might be fun.
Where is the function call bytecode?
When we add side-effects, we should add this.
Why does the
reg
bytecode take a 16-bit register number?
Intel’s IA-64 architecture has 128 general-purpose registers, and 128 floating-point registers, and
I’m sure it has some random control registers.
Why do we need
trace
and
trace_quick
?
Because GDB needs to record all the memory contents and registers an expression touches. If
the user wants to evaluate an expression
x-
l
y-
l
z
, the agent must record the values of
x
and
x-
l
y
as well as the value of
x-
l
y-
l
z
.
Don’t the
trace
bytecodes make the interpreter less general?
They do mean that the interpreter contains special-purpose code, but that doesn’t mean the inter-
preter can only be used for that purpose. If an expression doesn’t use the
trace
bytecodes, they
don’t get in its way.
Why doesn’t
trace_quick
consume its arguments the way everything else does?
In general, you do want your operators to consume their arguments; it’s consistent, and generally
reduces the amount of stack rearrangement necessary. However,
trace_quick
is a kludge to
save space; it only exists so we needn’t write
dup const8
SIZE
trace
before every memory
Summary of Contents for ENTERPRISE LINUX 3 - SECURITY GUIDE
Page 1: ...Red Hat Enterprise Linux 3 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: ......