[Dwarf-Discuss] Does gcc optimization impacts retriving Dwarf information?
Thu May 28 09:57:08 GMT 2009
M. Mohan Kumar wrote:
> When checked with gdb,
> (gdb) bt full
> #0 0xc00000000003b118 in pseries_dedicated_idle_sleep () at
> cpu = <value optimized out>
> start_snooze = 1
> This problem (unable to retrieve variable values) raises two questions:
> 1. Does it mean that compiling with -O2 option removes some of the
> information needed by DWARF library functions?
The optimizations invoked by -O2 are removing variables like
'cpu' from the generated code. There is no missing DWARF info
which should describe where to find their values, since they no
To confirm this, look at the generated code and see if the local
variables like 'cpu' are allocated either on the stack or in a
register. If this is the case, it's possible that your compiler
is generating incorrect DWARF. But the more likely situation is
simply that the local variables have been either evaluated or
incorporated into expressions and no longer exist.
> 2. Does it require handling it differently in our implementation?
Well, yes and no. You can compile without optimizations, so the
local variables are not removed. That's generally not desirable.
You can make changes to the source so that the local variables are
not eliminated, such as making them static or volatile. Again,
DIEs for variables which do not have DW_AT_location attributes
do not have physical locations. Your crash dump utility should
not attempt to find the locations or print the values for these
Michael Eager eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077
More information about the Dwarf-discuss