This is an archive of the discontinued LLVM Phabricator instance.

[lldb/DWARF] Don't treat class declarations with children as definitions
ClosedPublic

Authored by labath on Jul 7 2020, 6:52 AM.

Details

Summary

This effectively reverts r188124, which added code to handle
(DW_AT_)declarations of structures with some kinds of children as
definitions. The commit message claims this is a workaround for some
kind of debug info produced by gcc. However, it does not go into
specifics, so it's hard to reproduce or verify that this is indeed still a
problem.

Having this code is definitely a problem though, because it mistakenly
declares incomplete dwarf declarations to be complete. Both clang (with
-flimit-debug-info) and gcc (by default) generate DW_AT_declarations of
structs with children. This happens when full debug info for a class is
not emitted in a given compile unit (e.g. because of vtable homing), but
the class has inline methods which are used in the given compile unit.
In that case, the compilers emit a DW_AT_declaration of a class, but
add a DW_TAG_subprogram child to it to describe the inlined instance of
the method.

Even though the class tag has some children, it definitely does not
contain enough information to construct a full class definition (most
notably, it lacks any members). Keeping the class as incomplete allows
us to search for a real definition in other modules, helping the
-flimit-debug-info flow. And in case the definition is not found we can
display a error message saying that, instead of just showing an empty
struct.

Diff Detail

Event Timeline

labath created this revision.Jul 7 2020, 6:52 AM
Herald added a project: Restricted Project. · View Herald Transcript

The commit message claims this is a workaround for some kind of debug info produced by gcc. However, it does not go into specifics, so it's hard to reproduce or verify that this is indeed still a problem.

Speaking for Darwin — while we try our best to not needlessly break compatibility with it, we don't really support it either, so if this exists without tests and makes maintenance hard, I don't see a reason to keep the workaround around.

I tried to do some radar archeology for more context, but I could neither find a radar mentioning that commit, nor a mention of a radar in that commit.

aprantl accepted this revision.Jul 9 2020, 10:51 AM
This revision is now accepted and ready to land.Jul 9 2020, 10:51 AM
clayborg accepted this revision.Jul 9 2020, 1:38 PM

I am all for unblocking support for -flimit-debug-info. The trade off here seems worth it IMHO.

I tried to do some radar archeology for more context, but I could neither find a radar mentioning that commit, nor a mention of a radar in that commit.

Thanks for the effort.

This revision was automatically updated to reflect the committed changes.

Fixed stale+unused DW_AT_object_pointer+DW_AT_specification by rGfa89f641cf9f.

Fixed stale+unused DW_AT_object_pointer+DW_AT_specification by rGfa89f641cf9f.

Thanks for catching that. I've re-added the attributes with the correct values in dfb226632. I must've thought the test the test would be too unrealistic since I left them in (but then forgot to update them...)