Skip to content

Commit 1271cde

Browse files
committed
[DebugInfo][test] Adjust line table unit length to account for contents
Previously, if a debug line Prologue was created via createBasicPrologue, its TotalLength field did not account for any contents in the table itself. This change fixes this issue. Reviewed by: probinson Differential Revision: https://reviews.llvm.org/D73772
1 parent 9adbb6c commit 1271cde

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,9 +549,8 @@ TEST_F(DebugLineBasicFixture, ErrorForUnitLengthTooLarge) {
549549
LT.addStandardOpcode(DW_LNS_const_add_pc, {});
550550
LT.addExtendedOpcode(1, DW_LNE_end_sequence, {});
551551
DWARFDebugLine::Prologue Prologue = LT.createBasicPrologue();
552-
// Set the total length to 1 higher than the actual length. The program body
553-
// has size 5.
554-
Prologue.TotalLength += 6;
552+
// Set the total length to 1 higher than the actual length.
553+
++Prologue.TotalLength;
555554
LT.setPrologue(Prologue);
556555

557556
generate();

llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ DWARFDebugLine::Prologue dwarfgen::LineTable::createBasicPrologue() const {
175175
P.TotalLength += 4;
176176
P.FormParams.Format = DWARF64;
177177
}
178+
P.TotalLength += Contents.size();
178179
P.FormParams.Version = Version;
179180
P.MinInstLength = 1;
180181
P.MaxOpsPerInst = 1;

0 commit comments

Comments
 (0)