Page MenuHomePhabricator

[lldb/DWARF] Don't get confused by line sequences with tombstone values

Authored by labath on Jul 16 2020, 8:41 AM.



Recently, lld has started debug info resolving relocations to garbage-collected
symbols as -1 (instead of 0). For an unaware consumer this generated
sequences which seemingly wrap the address space -- their first entry
was 0xfffff, but all other entries were low numbers.

Lldb stores line sequences concatenated into one large vector, sorted by
the first entry, and searched with std::lower_bound. This resulted in
the low-value entries being placed at the end of the vector, which
utterly confused the lower_bound algorithm, and caused it to not find a
match. (Previously, these sequences would be at the start of the vector,
and normally would contain addresses that are far smaller than any real
address we want to look up, so std::lower_bound was fine.)

This patch makes lldb ignore these kinds of sequences completely. It
does that by changing the construction algorithm from iterating over the
rows (as parsed by llvm), to iterating over the sequences. This is
important because the llvm parsed performs validity checks when
constructing the sequence array, whereas the row array contains raw

Diff Detail

Event Timeline

labath created this revision.Jul 16 2020, 8:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 16 2020, 8:41 AM
Herald added a subscriber: aprantl. · View Herald Transcript
JDevlieghere accepted this revision.Jul 16 2020, 8:57 AM

LGTM. Thanks for fixing that!


Maybe add a short comment with a summary so we know to keep that scenario in mind if/when this code changes.

This revision is now accepted and ready to land.Jul 16 2020, 8:57 AM
MaskRay added a comment.EditedJul 16 2020, 5:41 PM

Recently, lld has started debug info resolving relocations to garbage-collected symbols as -1

Just mention D81784:)

(instead of 0).

This is not accurate. LLD resolved the dead relocation to r_addend. In many cases, r_addend is 0. However, for the following, a non-zero addend is possible.

__attribute__((section(".text.x"))) void f1() { }
__attribute__((section(".text.x"))) void f2() { } // DW_AT_low_pc has a non-zero addend
MaskRay accepted this revision.Jul 16 2020, 5:41 PM
MaskRay added inline comments.Jul 16 2020, 11:26 PM

While here, delete the initialization and move sequence = LineTable::CreateLineSequenceContainer() to the top of the loop body.

This revision was automatically updated to reflect the committed changes.
labath marked 3 inline comments as done.