Nick Clifton wrote: > The reason for this behaviour is that the debug information is being > written out before the variables have been fully resolved. In > particular DECL_SET() for the second and third observer functions is > NULL when the debug info is generated, which is why they are being > given the DW_AT_const_value attribute.
See PR 21828 where some possible solutions for a related problem got discussed. Eventually, PR 21828 was fixed when Richard Henderson fixed something else and Mark Mitchell's patch for PR 18556 got reverted. This is discussed in the log. Meanwhile, there have been reports of some other related problems. There is a report from Apple near the end of PR 21828 that mentions stabs is still broken. This got rereported as PR 23190 and contains a patch similar to ones discussed in PR 21828. The interface between the front ends and cgraph really needs to be worked out here. Currently, the C and C++ front ends are calling some cgraph functions in different orders, and we are having lots of debug related problems. Maybe we need to move the calls to the debugging hooks from toplev into cgraph, so that they are only called when a variable is finalized? The right place to do this seems to be cgraph_varpool_assemble_pending_decls where it calls assemble_variable. And there is already a debug info hook there, but it is only used for static variables. So we need to get debug info for global variables emitted here, rather than in check_global_decls in toplev.c. You will need some magic variable to test in check_global_decls to prevent duplicate debug info, perhaps making the debug hook call here dependent on !flag_unit_at_a_time will work? -- Jim Wilson, GNU Tools Support, http://www.specifix.com