[PATCH] D47543: DWARFAcceleratorTable: fix equal_range iterators

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 30 10:06:09 PDT 2018


labath created this revision.
labath added reviewers: JDevlieghere, aprantl, dblaikie.
Herald added a subscriber: mgrang.

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).


Repository:
  rL LLVM

https://reviews.llvm.org/D47543

Files:
  lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
  test/tools/llvm-dwarfdump/X86/debug-names-multi-find.s
  test/tools/llvm-dwarfdump/X86/find.test
  tools/llvm-dwarfdump/llvm-dwarfdump.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47543.149151.patch
Type: text/x-patch
Size: 9233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180530/9f6c4570/attachment.bin>


More information about the llvm-commits mailing list