[Dwarf-Discuss] Does gcc optimization impacts retriving Dwarf information?
M. Mohan Kumar
mohan at in.ibm.com
Thu May 28 03:35:23 PDT 2009
Thank you very much for the response.
> 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
> longer exist.
> 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.
Let me check the code and verify it.
> > 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,
> not desirable.
Obviously we can't ask for compiling the kernel without optimization. Also
we can't make changes to the function just to retain the local variables
info for later debugging :)
> 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
So we assume that our implementation is correct and works fine.
M. Mohan Kumar.
More information about the Dwarf-Discuss