This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: offsets of stack variables with optimizations enabled in GCC

On Mon, 2003-08-25 at 18:51, Tao Zhang wrote:
> Without
> optimizations, the offsets are all negative. With optimizations, the
> offsets become all positive.

That is probably due to the result of frame pointer elimination, e.g. fp
relative offsets are negative, but sp relative offsets are positive. 
Frame pointer elimination usually only happens with optimization. Stabs
doesn't really have support for this.  There is the DEBUGGER_AUTO_OFFSET
macro which can be used to try to convert one offset to the other, but
most ports don't bother.  There could perhaps be code in gdb to
disassemble the prologue, figure out whether there is an FP, and then
interpret the offsets relative to either FP or SP.  Or this could just
be broken for the xscale (arm) port.

The DWARF2 debug info doesn't have this problem.  It can indicate
whether offsets are FP or SP relative.

Inside gcc, you can check the frame_pointer_needed flag.
Jim Wilson, GNU Tools Support,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]