This is the mail archive of the gcc@gcc.gnu.org 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


Tao Zhang wrote:
Otherwise, the offsets are not correct or I can't figure out how to
use the offsets extracted from the GCC RTL. I think although GCC
can dump debug information with optimizations enabled, the
GDB debugger can't debug an optimized binary. Maybe the
debugger doesn't know how to use the offsets either?

It isn't clear what you are doing.


Note that the stabs format (from dbxout) is not sufficiently flexible to fully describe an optimized executable. So the debug info we emit is a compromise.

dwarf2/3 can do better, but we don't have full support for all of its features (e.g. location lists) yet, and so internally we don't have as much info as we'd like.

Internally to gcc, the stack offsets must obviously be correct, otherwise we would not be able to emit correct code.

When optimizing, a variable does not necessarily live in the stack slot allocated to it. It might be sometimes in a register and sometimes in the stack slot. When it is in the stack slot, it doesn't necessarily have the value that you expect it to have from reading the source, because various optimizations could have been applied to it.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com



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