[PATCH] D70537: [clang] CGDebugInfo asserts `!DT.isNull()` when compiling with debug symbols

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 16 16:53:46 PST 2019


dblaikie added subscribers: JDevlieghere, aprantl.
dblaikie added a comment.

Yeah, GCC's debug info for this is... not good. I don't think it's anything we'd need to be inspired by. Here's the tags and names:

  DW_TAG_compile_unit
    DW_AT_name   ("templ2.cpp")
    DW_TAG_structure_type
      DW_AT_name ("type")
    DW_TAG_variable
      DW_AT_name ("variable")
    DW_TAG_base_type
      DW_AT_name ("int")
    DW_TAG_variable
      DW_AT_name ("variable")
    DW_TAG_base_type
      DW_AT_name ("float")
    DW_TAG_subprogram
      DW_AT_name ("main")
      DW_TAG_variable
        DW_AT_name       ("t")
      DW_TAG_variable
        DW_AT_name       ("i")
      DW_TAG_variable
        DW_AT_name       ("f")

The structure_type has no child DIEs and no mention of the variable template instantiations - the global variables are both called "global" but with different types. No mention of the scope they were actually declared in. I guess maybe at least this "works" for free in some ways, but probably makes it impossible to refer to one or the other variable or with the right name.

@aprantl @probinson @echristo @JDevlieghere - So my proposal is that the 'right' DWARF for this is:

  DW_TAG_structure_type
    DW_AT_name ("type")
    DW_TAG_member
      DW_AT_name ("variable<int>")
      DW_AT_declaration (true)
    DW_TAG_member
      DW_AT_name ("variable<float>")
      DW_AT_declaration (true)
  DW_TAG_variable
    DW_AT_specification (0x.... "variable<int>")
    DW_AT_location
    DW_AT_linkage_name ("_ZN4type1iE")
  DW_TAG_base_type
    DW_AT_name ("int")
  DW_TAG_variable
    DW_AT_specification (0x.... "variable<float>")
    DW_AT_location
    DW_AT_linkage_name ("_ZN4type1fE")
  DW_TAG_base_type
    DW_AT_name ("float")

And the LLVM IR should be done the same way as member function templates - never appear in the member list, but appear otherwise the same - a DIGlobalVariable named "variable<int>" for the definition with a 'declaration:' attribute that refers to a DIDerivedType DW_TAG_member for the declaration of "variable<int>" where the 'scope:' attribute of the DW_TAG_member refers to the DW_TAG_structure_type, but that structure_type's member list does not contain this member. (same as functions - DISubprogram definition -declaration-> DISubprogram declaration -scope-> DW_TAG_structure_type but doesn't appear in the member list of the structure_type)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70537/new/

https://reviews.llvm.org/D70537





More information about the cfe-commits mailing list