This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Added check that verifies that no abbreviation declaration has more than one attribute with the same name.
ClosedPublic

Authored by sgravani on Jul 19 2017, 2:01 PM.

Details

Summary

This patch adds a verification check on the abbreviation declarations in the .debug_abbrev section.
The check makes sure that no abbreviation declaration has more than one attributes with the same name.

Diff Detail

Repository
rL LLVM

Event Timeline

sgravani created this revision.Jul 19 2017, 2:01 PM
sgravani edited the summary of this revision. (Show Details)Jul 19 2017, 2:05 PM
sgravani added a subscriber: llvm-commits.
friss added inline comments.Jul 19 2017, 2:15 PM
lib/DebugInfo/DWARF/DWARFVerifier.cpp
97–105 ↗(On Diff #107370)

While this is really simple, I feel like it's also really overkill to build a set for every DIE. Every DIE using the same abbreviation number will expose the same issue. Can we somehow prevent the duplicated work?

test/tools/llvm-dwarfdump/X86/verify_debug_info.s
84 ↗(On Diff #107370)

By adding this just to the abrrev table, I think you completely break the DIE tree decoding. Wouldn't it be better to add it to the debug_info section as well?

aprantl added inline comments.Jul 19 2017, 2:27 PM
include/llvm/DebugInfo/DWARF/DWARFVerifier.h
60 ↗(On Diff #107370)

separate commit and perhaps use the opportunity to document verifyUnitContents? (no need for separate review)

lib/DebugInfo/DWARF/DWARFVerifier.cpp
97–105 ↗(On Diff #107370)

Could we iterate over the abbreviations instead of the DIEs?
It also may be faster to use a SmallDenseSet over a std::set since the number of attributes will be typically very small.

sgravani updated this revision to Diff 107420.Jul 19 2017, 5:07 PM
sgravani marked 2 inline comments as done.
sgravani retitled this revision from [DWARF] Added check that verifies that no debugging information entry has more than one attribute with the same name. to [DWARF] Added check that verifies that no abbreviation declaration has more than one attribute with the same name..
sgravani edited the summary of this revision. (Show Details)

Moved verification check from DIEs to Abbreviation Declarations.

lib/DebugInfo/DWARF/DWARFVerifier.cpp
97–105 ↗(On Diff #107370)

Done; verifying .debug_abbrev instead.

test/tools/llvm-dwarfdump/X86/verify_debug_info.s
84 ↗(On Diff #107370)

I'm not sure what you mean.. Can you explain?

aprantl added inline comments.Jul 19 2017, 5:25 PM
lib/DebugInfo/DWARF/DWARFContext.cpp
417 ↗(On Diff #107420)

Shorter alterntive:
Success &= verifier.handleDebugAbbrev();

lib/DebugInfo/DWARF/DWARFVerifier.cpp
119 ↗(On Diff #107420)

does a range-based for work here?
for (auto AbbrDecl : AbbrDecls) ...

aprantl edited edge metadata.Jul 19 2017, 5:26 PM

I think this looks fine now, but I'll let Fred do the final sign off.

probinson edited edge metadata.Jul 19 2017, 5:28 PM

Wouldn't you also want to verify .debug_abbrev.dwo?

sgravani updated this revision to Diff 107427.Jul 19 2017, 5:39 PM

Minor code style changes to previous diff.

Wouldn't you also want to verify .debug_abbrev.dwo?

Ideally, yes (as well as other sections from the split dwarf5 proposal).
So far I've focused on verifications for/related to the .debug_info section.
Is it the case that we may need abbreviation declarations for .debug_info section from .debug_abbrev.dwo?

friss accepted this revision.Jul 19 2017, 5:52 PM
friss added inline comments.
test/tools/llvm-dwarfdump/X86/verify_debug_info.s
84 ↗(On Diff #107370)

Sorry, I thought this was an insertion, but now I see that you replaced an attribute with one with a equivalent form. This LGTM, thanks!

This revision is now accepted and ready to land.Jul 19 2017, 5:52 PM
This revision was automatically updated to reflect the committed changes.
dblaikie edited edge metadata.Jul 19 2017, 8:07 PM

Wouldn't you also want to verify .debug_abbrev.dwo?

Ideally, yes (as well as other sections from the split dwarf5 proposal).
So far I've focused on verifications for/related to the .debug_info section.

I'll +1 Paul's comment - seems worthwhile generalizing things across .dwo/non-.dwo where it's convenient/easy - otherwise we'll end up with a weirdly inconsistent verification coverage.

Is it the case that we may need abbreviation declarations for .debug_info section from .debug_abbrev.dwo?

No, .debug_abbrev.dwo would only apply to .debug_info.dwo - but pretty much any check you can do for .debug_info you should be able to do for .debug_info.dwo

I am pretty sure that any verification you want to do on .debug_abbrev would be equally applicable to .debug_abbrev.dwo; I suspect we could also verify that .debug_abbrev.dwo did not use certain forms, e.g. DW_FORM_addr, but that would be a bonus.

Wouldn't you also want to verify .debug_abbrev.dwo?

Ideally, yes (as well as other sections from the split dwarf5 proposal).
So far I've focused on verifications for/related to the .debug_info section.

I'll +1 Paul's comment - seems worthwhile generalizing things across .dwo/non-.dwo where it's convenient/easy - otherwise we'll end up with a weirdly inconsistent verification coverage.

Is it the case that we may need abbreviation declarations for .debug_info section from .debug_abbrev.dwo?

No, .debug_abbrev.dwo would only apply to .debug_info.dwo - but pretty much any check you can do for .debug_info you should be able to do for .debug_info.dwo

I went ahead with the generalization. https://reviews.llvm.org/D35698

Thanks for the feedback!

I am pretty sure that any verification you want to do on .debug_abbrev would be equally applicable to .debug_abbrev.dwo; I suspect we could also verify that .debug_abbrev.dwo did not use certain forms, e.g. DW_FORM_addr, but that would be a bonus.

I'll add this check in a future patch! Thanks :)