Skip to content

Commit ad1d1d0

Browse files
committed
Address Comments #1
1 parent 658a02c commit ad1d1d0

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class DWARFDebugLine {
210210
bool Empty;
211211

212212
/// The offset into the line table where this sequence begins
213-
uint64_t Offset = 0;
213+
uint64_t StmtSeqOffset = UINT64_MAX;
214214

215215
void reset();
216216

@@ -227,6 +227,8 @@ class DWARFDebugLine {
227227
return SectionIndex == PC.SectionIndex &&
228228
(LowPC <= PC.Address && PC.Address < HighPC);
229229
}
230+
231+
void SetSequenceOffset(uint64_t Offset) { StmtSeqOffset = Offset; }
230232
};
231233

232234
struct LineTable {
@@ -403,16 +405,8 @@ class DWARFDebugLine {
403405
ParsingState(struct LineTable *LT, uint64_t TableOffset,
404406
function_ref<void(Error)> ErrorHandler);
405407

406-
void resetRowAndSequence();
407-
408-
/// Append the current Row to the LineTable's matrix of rows and update the
409-
/// current Sequence information.
410-
///
411-
/// \param LineTableOffset - the offset into the line table where the
412-
/// current sequence of rows begins. This offset is stored in the Sequence
413-
/// to allow filtering rows based on their originating sequence when a
414-
/// DW_AT_LLVM_stmt_sequence attribute is present.
415-
void appendRowToMatrix(uint64_t LineTableOffset);
408+
void resetRowAndSequence(uint64_t Offset = UINT64_MAX);
409+
void appendRowToMatrix();
416410

417411
struct AddrOpIndexDelta {
418412
uint64_t AddrOffset;

llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ void DWARFDebugLine::Sequence::reset() {
531531
FirstRowIndex = 0;
532532
LastRowIndex = 0;
533533
Empty = true;
534+
StmtSeqOffset = UINT64_MAX;
534535
}
535536

536537
DWARFDebugLine::LineTable::LineTable() { clear(); }
@@ -565,14 +566,16 @@ DWARFDebugLine::ParsingState::ParsingState(
565566
resetRowAndSequence();
566567
}
567568

568-
void DWARFDebugLine::ParsingState::resetRowAndSequence() {
569+
void DWARFDebugLine::ParsingState::resetRowAndSequence(uint64_t Offset) {
569570
Row.reset(LineTable->Prologue.DefaultIsStmt);
570571
Sequence.reset();
572+
if (Offset != UINT64_MAX) {
573+
Sequence.SetSequenceOffset(Offset);
574+
}
571575
}
572576

573-
void DWARFDebugLine::ParsingState::appendRowToMatrix(uint64_t LineTableOffset) {
577+
void DWARFDebugLine::ParsingState::appendRowToMatrix() {
574578
unsigned RowNumber = LineTable->Rows.size();
575-
Sequence.Offset = LineTableOffset;
576579
if (Sequence.Empty) {
577580
// Record the beginning of instruction sequence.
578581
Sequence.Empty = false;
@@ -849,7 +852,9 @@ Error DWARFDebugLine::LineTable::parse(
849852
*OS << '\n';
850853
Row::dumpTableHeader(*OS, /*Indent=*/Verbose ? 12 : 0);
851854
}
852-
uint64_t LineTableSeqOffset = *OffsetPtr;
855+
// *OffsetPtr points to the end of the prologue - i.e. the start of the first
856+
// sequence. So initialize the first sequence offset accordingly.
857+
State.Sequence.SetSequenceOffset(*OffsetPtr);
853858

854859
bool TombstonedAddress = false;
855860
auto EmitRow = [&] {
@@ -860,7 +865,7 @@ Error DWARFDebugLine::LineTable::parse(
860865
}
861866
if (OS)
862867
State.Row.dump(*OS);
863-
State.appendRowToMatrix(LineTableSeqOffset);
868+
State.appendRowToMatrix();
864869
}
865870
};
866871
while (*OffsetPtr < EndOffset) {
@@ -915,10 +920,9 @@ Error DWARFDebugLine::LineTable::parse(
915920
// into this code path - if it were invalid, the default case would be
916921
// followed.
917922
EmitRow();
918-
State.resetRowAndSequence();
919923
// Cursor now points to right after the end_sequence opcode - so points
920924
// to the start of the next sequence - if one exists.
921-
LineTableSeqOffset = Cursor.tell();
925+
State.resetRowAndSequence(Cursor.tell());
922926
break;
923927

924928
case DW_LNE_set_address:
@@ -1419,7 +1423,7 @@ bool DWARFDebugLine::LineTable::lookupAddressRangeImpl(
14191423

14201424
// Skip sequences that don't match our stmt_sequence offset if one was
14211425
// provided
1422-
if (StmtSequenceOffset && CurSeq.Offset != *StmtSequenceOffset) {
1426+
if (StmtSequenceOffset && CurSeq.StmtSeqOffset != *StmtSequenceOffset) {
14231427
++SeqPos;
14241428
continue;
14251429
}

0 commit comments

Comments
 (0)