@@ -531,6 +531,7 @@ void DWARFDebugLine::Sequence::reset() {
531531 FirstRowIndex = 0 ;
532532 LastRowIndex = 0 ;
533533 Empty = true ;
534+ StmtSeqOffset = UINT64_MAX;
534535}
535536
536537DWARFDebugLine::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