This is the mail archive of the gcc-patches@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: PR debug/26881 (dwarf2out, cgraph and local statics)


Mark Mitchell wrote:
> Andrew Pinski wrote:
>> On May 11, 2006, at 9:02 AM, Jan Hubicka wrote:
>>> Also when optimizing, the cccc gets optimized out and there is no
>>> debug info
>>> produced.  Is this an supposed behaviour?  (I hope so - we behave same
>>> way for
>>> global statics too).
>>>
>>> int main(int argc, char **argv)
>>> {
>>>  if (0)
>>>  {
>>>    static union{} u;
>>>    typedef char tt;
>>>    static tt cccc[8];
>>>    return cccc[0] == 0x01 && cccc[1] == 0x02;
>>>  }
>>> }
>> Yes because cccc is not touched or even used in this function.
> 
> I think that the ideal debugging output -- assuming the debug format
> provides sufficient expressivity -- would be to admit the existence of
> the variable, but to indicate that it has no address, i.e., has been
> optimized away.  (I'd even be like to be able to do:
> 
>   break N
>   cond X cccc[0] == 'a'
> 
> where N is the line number for the return statement.  I'd also be happy
> if the debugger then told me "that line seems to have been optimized
> away; this breakpoint will never trigger.")
> 
> However, even if others agree, fixing that is a very low priority.
>
I agree, but only because it's not too hard,  in theory, to do.
Generate debug info *first* before optimizing, except leave all variable
locations as "optimized out".
After optimization, walk back over the variables that still exist and
fill in their locations.

Though it may not let you place a cond on an optimized-out variable (it
may just say that though, i don't think it will pretend it no longer
exists).

--Dan



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