Yesterday I was debugging another instance of the Ref > InputDIE.getOffset() assertion failing in dsymutil. Interestingly, the issue was totally unrelated to D138176. I narrowed down the issue to a DIE being marked as kept while its parent wasn't. That should never happen and is easy to diagnose. To verify my hypothesis, I wrote a little verifier function. Given the complexity of the algorithm that looks for DIEs to keep, I think it's useful to keep it around and do the verification when asserts are enabled.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Here's what the output looks like for the bug I'm currently working on:
error: Found invalid link in keep chain between 0x6ac5 and 0x6aec
Parent:
0x00006ac5: DW_TAG_module
DW_AT_name ("C")
DW_AT_LLVM_config_macros ("...")
DW_AT_LLVM_include_path ("...")
{
AddrAdjust: 0
Ctxt: 0x0000000000000000
Clone: 0x0000000000000000
ParentIdx: 558
Keep: 0
InDebugMap: 0
Prune: 1
Incomplete: 0
InModuleScope: 1
ODRMarkingDone: 0
}
Child:
0x00006aec: DW_TAG_module
DW_AT_name ("stddef")
DW_AT_LLVM_config_macros ("...")
DW_AT_LLVM_include_path ("...")
{
AddrAdjust: 0
Ctxt: 0x0000000000000000
Clone: 0x0000000000000000
ParentIdx: 581
Keep: 1
InDebugMap: 0
Prune: 0
Incomplete: 0
InModuleScope: 1
ODRMarkingDone: 0
}
LLVM ERROR: invalid keep chainLGTM with minor nit
| llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
|---|---|---|
| 889 | Should this be errs()? Same thing right below. | |
| llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
|---|---|---|
| 2597 | Since dsymutil accepts --verify should this maybe be in all builds and enable by that flag? | |
| llvm/lib/DWARFLinker/DWARFLinker.cpp | ||
|---|---|---|
| 2597 | The verify option checks the validity of the input and/or output dwarf. The verification done here is strictly enforcing an implementation variant, like an assert. I think that besides the name there's not enough overlap to make it part of that. | |
it looks not neccessary to reverse here.