Skip to content

Commit 0bd48c3

Browse files
Sterling-Augustinedwblaikie
authored andcommitted
[DebugInfo] Support file-level include directories when generating DWARFv5 LineTable prologues.
Differential Revision: https://reviews.llvm.org/D74249
1 parent c1adb88 commit 0bd48c3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/unittests/DebugInfo/DWARF/DWARFDebugLineTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void checkDefaultPrologue(uint16_t Version, DwarfFormat Format,
180180
UnitLength = PrologueLength + 2;
181181
break;
182182
case 5:
183-
PrologueLength = 39;
183+
PrologueLength = 42;
184184
UnitLength = PrologueLength + 4;
185185
EXPECT_EQ(Prologue.getAddressSize(), 8u);
186186
EXPECT_EQ(Prologue.SegSelectorSize, 0u);
@@ -204,6 +204,7 @@ void checkDefaultPrologue(uint16_t Version, DwarfFormat Format,
204204
EXPECT_STREQ(*Prologue.IncludeDirectories[0].getAsCString(), "a dir");
205205
ASSERT_EQ(Prologue.FileNames.size(), 1u);
206206
ASSERT_EQ(Prologue.FileNames[0].Name.getForm(), DW_FORM_string);
207+
ASSERT_EQ(Prologue.FileNames[0].DirIdx, 0u);
207208
EXPECT_STREQ(*Prologue.FileNames[0].Name.getAsCString(), "a file");
208209
}
209210

llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ DWARFDebugLine::Prologue dwarfgen::LineTable::createBasicPrologue() const {
164164
P.PrologueLength = 36;
165165
break;
166166
case 5:
167-
P.TotalLength = 47;
168-
P.PrologueLength = 39;
167+
P.TotalLength = 50;
168+
P.PrologueLength = 42;
169169
P.FormParams.AddrSize = AddrSize;
170170
break;
171171
default:
@@ -343,13 +343,16 @@ static void writeV5IncludeAndFileTable(const DWARFDebugLine::Prologue &Prologue,
343343
writeCString(*Include.getAsCString(), Asm);
344344
}
345345

346-
Asm.emitInt8(1); // file_name_entry_format_count.
346+
Asm.emitInt8(2); // file_name_entry_format_count.
347347
Asm.EmitULEB128(DW_LNCT_path);
348348
Asm.EmitULEB128(DW_FORM_string);
349+
Asm.EmitULEB128(DW_LNCT_directory_index);
350+
Asm.EmitULEB128(DW_FORM_data1);
349351
Asm.EmitULEB128(Prologue.FileNames.size());
350352
for (auto File : Prologue.FileNames) {
351353
assert(File.Name.getAsCString() && "expected a string form for file name");
352354
writeCString(*File.Name.getAsCString(), Asm);
355+
Asm.emitInt8(File.DirIdx);
353356
}
354357
}
355358

0 commit comments

Comments
 (0)