This is an archive of the discontinued LLVM Phabricator instance.

DWARFAcceleratorTable: fix equal_range iterators
ClosedPublic

Authored by labath on May 30 2018, 10:06 AM.

Details

Summary

Both (Apple and DWARF5) implementations of the iterators had bugs which
resulted in crashes if one attempted to iterate through the accelerator
tables all the way.

For the Apple tables, the issue was that we did not clear the DataOffset
field when we reached the end, which made our iterator compare unequal
to the "end" iterator. For the Dwarf5 tables, the problem was that we
incremented the CurrentIndex pointer and then used the incremented
(possibly invalid) pointer to check whether we have reached the end of
the index list.

The reason these bugs went undetected is because their only user
(dwarfdump) only ever searched for the first match. Besides allowing us
to test this fix, changing llvm-dwarfdump --find to display all matches
seems like a good improvement (it makes the behavior consistent with the
--name option), so I change llvm-dwarfdump to do that.

The existing tests would be sufficient to test this fix with the new
llvm-dwarfdump behavior, but I add a special test that demonstrates that
the tool indeed displays multiple results. The find.test test needed to
be tweaked a bit as the tool now does not print the ".debug_info
contents" header (also consistent with how --name works).

Diff Detail

Event Timeline

labath created this revision.May 30 2018, 10:06 AM
JDevlieghere accepted this revision.May 30 2018, 10:46 AM

LGTM, thanks!

This revision is now accepted and ready to land.May 30 2018, 10:46 AM
This revision was automatically updated to reflect the committed changes.