IA32: printing FP register variables
Ben Combee
bcombee@metrowerks.com
Fri Jul 9 14:00:00 GMT 1999
> > At each instruction, the invariant that a is 0 from the bottom and b is
1
> > from the bottom holds. Note, the bottom of the stack can be known by
the
> > debugger via scanning the FPU tag word from the TOP element looking for
a FP
> > register that is empty. All this info is provided by an FSAVE or
FSTENV.
>
> That could work, but what if you happen to have all eight registers in
> use?
Then the scan code sees that there are no empty registers, so the eighth
register is the bottom of the stack. The IA32 FPU itself uses this logic --
if you push something on the stack such that TOP gets incremented to point
to a non-empty value, you get a stack overflow.
Of course, all this is also based on the assumption, explicit in the Win32
ABI, that the FPU stack is empty on entry to a function. I think this holds
for the x86 Linux ABI as well -- I can't see any logical other way to do it
since you don't generally know how many levels of nesting there are when
your function is called.
More information about the Gdb
mailing list