[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
This commit is contained in:
James Henderson
2020-01-31 10:51:10 +00:00
parent 9adbb6c468
commit 1271cde474
2 changed files with 3 additions and 3 deletions

View File

@@ -549,9 +549,8 @@ TEST_F(DebugLineBasicFixture, ErrorForUnitLengthTooLarge) {
LT.addStandardOpcode(DW_LNS_const_add_pc, {});
LT.addExtendedOpcode(1, DW_LNE_end_sequence, {});
DWARFDebugLine::Prologue Prologue = LT.createBasicPrologue();
// Set the total length to 1 higher than the actual length. The program body
// has size 5.
Prologue.TotalLength += 6;
// Set the total length to 1 higher than the actual length.
++Prologue.TotalLength;
LT.setPrologue(Prologue);
generate();

View File

@@ -175,6 +175,7 @@ DWARFDebugLine::Prologue dwarfgen::LineTable::createBasicPrologue() const {
P.TotalLength += 4;
P.FormParams.Format = DWARF64;
}
P.TotalLength += Contents.size();
P.FormParams.Version = Version;
P.MinInstLength = 1;
P.MaxOpsPerInst = 1;