This is an archive of the discontinued LLVM Phabricator instance.

Fix DWARFDie::getDeclFile(...) to work with DW_AT_specification.
ClosedPublic

Authored by clayborg on Aug 20 2021, 12:17 PM.

Details

Summary

DWARFDie::getDeclFile(...) previously only supported getting the DW_AT_decl_file if the DIE itself contained the DW_AT_decl_file attribute, or if the DIE had a DW_AT_abstract_origin that pointed to another DIE that had a DW_AT_decl_file. This patch allows the function to get the right attribute value if there is a DW_AT_specification that points to another DIE. We also test that if a DW_AT_abtract_origin or DW_AT_specification points to a DIE in another CU with a DW_FORM_ref_addr, that the right line table is used to extract the file index.

Full tests were added for the following cases:

  • DIE has a DW_AT_decl_file attribute
  • DIE has a DW_AT_abtract_origin that points to another die in the same CU
  • DIE has a DW_AT_abtract_origin that points to another die in another CU
  • DIE has a DW_AT_specification that points to another die in the same CU
  • DIE has a DW_AT_specification that points to another die in another CU

Diff Detail

Event Timeline

clayborg created this revision.Aug 20 2021, 12:17 PM
clayborg requested review of this revision.Aug 20 2021, 12:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2021, 12:17 PM

Given the textual overhead of DWARF unit test yaml at the moment, I think it might be reasonable to put the various examples in one test file/one YAML rather than multiple separate tests with all the overhead of describing standalone DWARF in each test. Or, at least, trimming them down substantially to just the bare necessities.

llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
114–135

Could probably strip most of this out - keep just the DW_TAG_compile_unit's DW_AT_stmt_list, and the DW_TAG_subprogram's DW_AT_decl_file?

174–202

Can this all be stripped, or does it have to be here for some reason? (maybe it can just be the single end_sequence?)

clayborg updated this revision to Diff 367918.Aug 20 2021, 3:27 PM

Reduced DWARF yaml to absolute minimum needed as suggested in review.

dblaikie accepted this revision.Aug 20 2021, 6:02 PM

Sounds alright

This revision is now accepted and ready to land.Aug 20 2021, 6:02 PM
kyulee added a subscriber: kyulee.Aug 23 2021, 9:49 AM
This revision was landed with ongoing or failed builds.Aug 23 2021, 3:43 PM
This revision was automatically updated to reflect the committed changes.