This is an archive of the discontinued LLVM Phabricator instance.

[dwarfdump] Add verifier check to find DIEs with DW_CHILDREN_yes but without children.
ClosedPublic

Authored by JDevlieghere on Sep 21 2020, 2:41 PM.

Details

Summary

Flag DIEs that have DW_CHILDREN_yes set in their abbreviation but don't actually have any children.

rdar://59809554

Diff Detail

Event Timeline

JDevlieghere created this revision.Sep 21 2020, 2:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2020, 2:41 PM
JDevlieghere requested review of this revision.Sep 21 2020, 2:41 PM
JDevlieghere edited the summary of this revision. (Show Details)Sep 21 2020, 2:41 PM

does this classify as a warning? Is there a distinction between ill-formed DWARF and "this is valid, but unlikely to be great"?

does this classify as a warning? Is there a distinction between ill-formed DWARF and "this is valid, but unlikely to be great"?

I was on the fence myself, I couldn't find anything conclusive in the standard. I've made it a warning.

maybe slightly long test case - could do this with the CU DIE itself? (perhaps a case where hand-crafted/substantially hand-modified assembly is OK, because it can be made /so/ simple - or maybe yaml2obj dwarf support is adequate for this use case?)

maybe slightly long test case - could do this with the CU DIE itself? (perhaps a case where hand-crafted/substantially hand-modified assembly is OK, because it can be made /so/ simple - or maybe yaml2obj dwarf support is adequate for this use case?)

Hi, currently, obj2yaml doesn't work properly when dumping the .debug_abbrev/__debug_abbrev section. We might not be able to get the correct output when there are multiple DIEs in one abbrev table. D87179 has fixed it but hasn't been landed yet. I've created one test case for this patch. Hope it works :-)

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
DWARF:
  debug_abbrev:
    - Table:
        - Tag:      DW_TAG_compile_unit
          Children: DW_CHILDREN_yes
          Attributes:
            - Attribute: DW_AT_low_pc
              Form:      DW_FORM_data4
  debug_info:
    - Version: 4
      Entries:
        - AbbrCode: 1
          Values:
            - Value: 0x1234
        - AbbrCode: 0   ## Terminator for the current DIE.

However, it seems that the assertion isValid() && "must check validity prior to calling" is triggered when the DIE isn't terminated.

--- !ELF
FileHeader:
  Class: ELFCLASS64
  Data:  ELFDATA2LSB
  Type:  ET_EXEC
DWARF:
  debug_abbrev:
    - Table:
        - Tag:      DW_TAG_compile_unit
          Children: DW_CHILDREN_yes
          Attributes:
            - Attribute: DW_AT_low_pc
              Form:      DW_FORM_data4
  debug_info:
    - Version: 4
      Entries:
        - AbbrCode: 1
          Values:
            - Value: 0x1234

See my inline comments.

Higuoxing added inline comments.Sep 21 2020, 7:58 PM
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
176
aprantl accepted this revision.Sep 22 2020, 9:13 AM

Warning seems fine to me since it's more an inefficient encoding (an empty list of children) than malformed.

LGTM once everyone else is happy.

This revision is now accepted and ready to land.Sep 22 2020, 9:13 AM

maybe slightly long test case - could do this with the CU DIE itself? (perhaps a case where hand-crafted/substantially hand-modified assembly is OK, because it can be made /so/ simple - or maybe yaml2obj dwarf support is adequate for this use case?)

Hi, currently, obj2yaml doesn't work properly when dumping the .debug_abbrev/__debug_abbrev section. We might not be able to get the correct output when there are multiple DIEs in one abbrev table. D87179 has fixed it but hasn't been landed yet. I've created one test case for this patch. Hope it works :-)

(I forgot to submit the comment before landing this)

Awesome, thanks a lot, that's a great test case! :-)