The combination of libjava/include/posix-threads.h and libjava/posix-threads.cc
combine to produce broken dwarf2 output when compiled with optimization and -g.
(This can be seen by bootstrapping, installing, then running a recent gdb on
either gij, or libgcj.so)

The cause is this:
in posix-threads.h:

inline _Jv_Thread_t *
_Jv_ThreadCurrentData (void)
{
  extern pthread_key_t _Jv_ThreadDataKey;
  return (_Jv_Thread_t *) pthread_getspecific (_Jv_ThreadDataKey);
}


in posix-threads.cc

pthread_key_t _Jv_ThreadDataKey;

We end up with calls to _Jv_ThreadCurrentData before we get to output debug info
for _Jv_ThreadDataKey (which is a perfectly reasonable turn of events).

We end up generating a full die for _Jv_ThreadDataKey inside 
_Jv_ThreadCurrentData

We then go to output the global, and mark it as having an abstract origin of the
DIE inside the inlined function.
This is backwards.

I'm not sure how easy/hard this will be to fix. 
The obvious thing to do is to drive global variable debug output using cgraph,
but that seems a bit invasive for 4.0.
I'm also sure this patch exposed by one of my patches to mark blocks properly,
which in turn fixed other regressions, so I don't believe we should simply
revert them.

It's possible that the DECL_ABSTRACT_ORIGIN's aren't set up properly, and that
is the real cause here.  I would have expected we would have seen that the
declaration inside the inline had an abstract origin of the one outside the
inline, and thus, we wouldn't have tried to output a full die for it, but this
isn't what appears to happen.

-- 
           Summary: GCC produces wrong dwarf2 output that breaks gdb
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: debug
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dberlin at gcc dot gnu dot org
                CC: drow at false dot org,gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19769

Reply via email to