This is an archive of the discontinued LLVM Phabricator instance.

[DWARF5][Debuginfo] Not matching compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit)
ClosedPublic

Authored by avl on Dec 1 2019, 2:21 PM.

Details

Summary

That patch fixes "incompatible compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit)" error.

cat split-dwarf.cpp

int main()
{
int a = 1;
return 0;
}

clang++ -O -g -gsplit-dwarf -gdwarf-5 split-dwarf.cpp; llvm-dwarfdump --verify ./a.out | grep skeleton

error: Compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit) do not match.

According to "3.1.2 Skeleton Compilation Unit Entries" part of "DWARF Debugging Information Format Version 5"
: "When generating a split DWARF object file (see Section 7.3.2 on page 187), the
compilation unit in the .debug_info section is a "skeleton" compilation unit with
the tag DW_TAG_skeleton_unit".

The fix is to change DW_TAG_compile_unit into DW_TAG_skeleton_unit tag when skeleton file is generated.

Diff Detail

Event Timeline

avl created this revision.Dec 1 2019, 2:21 PM
aprantl accepted this revision.Dec 2 2019, 1:19 PM

Seems good to me. @dblaikie, do all the relevant non-llvm-tools that implement pre-standard fission know how to deal with DW_TAG_skeleton_unit?

llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
57

//

This revision is now accepted and ready to land.Dec 2 2019, 1:19 PM

Seems good to me. @dblaikie, do all the relevant non-llvm-tools that implement pre-standard fission know how to deal with DW_TAG_skeleton_unit?

Oh, I think there's a bunch of tools/most things can't handle DWARFv5 split or non-split right now, so I'm mostly happy for us to just keep implementing the standard here & with the expectation that other people (or the same people when they have time/as they schedule things) will be implementing support on the consumer side.

@avl - are you planning to do the DW_TAG_split_compile/DW_TAG_split_type tags required by DWARFv5 too in separate patches?

llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
106–109 ↗(On Diff #231624)

Rather than adding this field - I think it'd be cleaner to pass the boolean (maybe use an enum class UnitKind { Skeleton, Full } to make it more readable) into the DwarfCompileUnit ctor directly. The two callers know statically which kind of unit they are constructing, so there would be no need for branching/conditionals/dynamic computation of the unit type by doing it that way.

(& probably add it as a default argument ("Full") to the end, then only the Skeleton unit construction gets the extra argument)

Oh, I think there's a bunch of tools/most things can't handle DWARFv5 split or non-split right now, so I'm mostly happy for us to just keep implementing the standard here & with the expectation that other people (or the same people when they have time/as they schedule things) will be implementing support on the consumer side.

Sounds good!

avl marked an inline comment as done.Dec 3 2019, 2:22 PM

@avl - are you planning to do the DW_TAG_split_compile/DW_TAG_split_type tags required by DWARFv5 too in separate patches?

My understanding is that everything is already done here. There is no DW_TAG_split_compile/DW_TAG_split_type tags. There should be used DW_TAG_compile_unit+DW_UT_split_compile and DW_TAG_type_unit+DW_UT_split_type. It looks like these already are set correctly.

llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
106–109 ↗(On Diff #231624)

I did not clearly get the idea...

  1. add a parameter of enum class UnitKind to DwarfCompileUnit ctor.
  1. add a method like this into DwarfFile:
UnitKind DwarfFile::GetCompileUnitType(){
  if (Asm->getDwarfDebug()->getDwarfVersion() >= 5 && IsSkeleton)
    return UnitKind::Skeleton;

  return UnitKind::Full;
}
  1. call GetCompileUnitType when creating DwarfCompileUnit.

is that correct?

In D70880#1767924, @avl wrote:

@avl - are you planning to do the DW_TAG_split_compile/DW_TAG_split_type tags required by DWARFv5 too in separate patches?

My understanding is that everything is already done here. There is no DW_TAG_split_compile/DW_TAG_split_type tags. There should be used DW_TAG_compile_unit+DW_UT_split_compile and DW_TAG_type_unit+DW_UT_split_type. It looks like these already are set correctly.

Ah, right you are - my mistake!

llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
106–109 ↗(On Diff #231624)

Not quite what I had in mind

  1. - yep, add the extra (let's say defaulted) DwarfCompileUnit ctor parameter
  2. pass the Skeleton UnitKind to the DwarfCompileUnit construction in DwarfDebug::constructSkeletonCU

& then in the implementation of (1) I guess something like:

DwarfUnit(Kind == UnitKind::Skeleton && Asm->getDwarfDebug()->getDwarfVersion() >= 5 ? dwarf::DW_TAG_skeleton_unit : dwarf::DW_TAG_compile_unit, Node, A, DW, DWU)

(or a utility function to pick between the two unit tags in the same way, if you like - but not sure it's worth it)

avl updated this revision to Diff 232102.Dec 4 2019, 5:56 AM

addressed comments.

dblaikie accepted this revision.Dec 4 2019, 9:49 AM

Looks good - thanks!

This revision was automatically updated to reflect the committed changes.