Skip to content

Commit f1837c7

Browse files
committed
[DebugInfo] Handle missed DW_FORM_addrx3 and DW_FORM_strx3 cases
This fixes a few places where the addrx3 and strx3 forms were missed. Previously this meant if one of these forms appeared somewhere various errors could occur. This now also adds an extra test case for the addrx3 form (which previously failed). Differential Revision: https://reviews.llvm.org/D143488
1 parent 04f4c4c commit f1837c7

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

llvm/lib/BinaryFormat/Dwarf.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ std::optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
737737
return 2;
738738

739739
case DW_FORM_strx3:
740+
case DW_FORM_addrx3:
740741
return 3;
741742

742743
case DW_FORM_data4:

llvm/lib/CodeGen/AsmPrinter/DIE.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ void DIEInteger::emitValue(const AsmPrinter *Asm, dwarf::Form Form) const {
385385
case dwarf::DW_FORM_strx2:
386386
case dwarf::DW_FORM_addrx2:
387387
case dwarf::DW_FORM_strx3:
388+
case dwarf::DW_FORM_addrx3:
388389
case dwarf::DW_FORM_strp:
389390
case dwarf::DW_FORM_ref4:
390391
case dwarf::DW_FORM_data4:

llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ bool DWARFFormValue::skipValue(dwarf::Form Form, DataExtractor DebugInfoData,
160160
case DW_FORM_ref_sup8:
161161
case DW_FORM_strx1:
162162
case DW_FORM_strx2:
163+
case DW_FORM_strx3:
163164
case DW_FORM_strx4:
164165
case DW_FORM_addrx1:
165166
case DW_FORM_addrx2:
167+
case DW_FORM_addrx3:
166168
case DW_FORM_addrx4:
167169
case DW_FORM_sec_offset:
168170
case DW_FORM_strp:
@@ -300,6 +302,7 @@ bool DWARFFormValue::extractValue(const DWARFDataExtractor &Data,
300302
Value.uval = Data.getU16(OffsetPtr, &Err);
301303
break;
302304
case DW_FORM_strx3:
305+
case DW_FORM_addrx3:
303306
Value.uval = Data.getU24(OffsetPtr, &Err);
304307
break;
305308
case DW_FORM_data4:

llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void TestAllForms() {
5151
const AddrType AddrxValue = (AddrType)0x4231abcd4231abcdULL;
5252
const AddrType Addrx1Value = (AddrType)0x0000aaaabbbbccccULL;
5353
const AddrType Addrx2Value = (AddrType)0xf00123f00456f000ULL;
54+
const AddrType Addrx3Value = (AddrType)0xABABA000B111C222ULL;
5455
const AddrType Addrx4Value = (AddrType)0xa1b2c3d4e5f6e5d4ULL;
5556

5657
const uint8_t BlockData[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
@@ -100,14 +101,14 @@ void TestAllForms() {
100101
const auto Attr_DW_FORM_addrx = static_cast<dwarf::Attribute>(Attr++);
101102
const auto Attr_DW_FORM_addrx1 = static_cast<dwarf::Attribute>(Attr++);
102103
const auto Attr_DW_FORM_addrx2 = static_cast<dwarf::Attribute>(Attr++);
103-
// TODO: Add Attr_DW_FORM_addrx3 test (this form type is currently
104-
// unsupported)
104+
const auto Attr_DW_FORM_addrx3 = static_cast<dwarf::Attribute>(Attr++);
105105
const auto Attr_DW_FORM_addrx4 = static_cast<dwarf::Attribute>(Attr++);
106106

107107
if (Version >= 5) {
108108
CUDie.addAttribute(Attr_DW_FORM_addrx, DW_FORM_addrx, AddrxValue);
109109
CUDie.addAttribute(Attr_DW_FORM_addrx1, DW_FORM_addrx1, Addrx1Value);
110110
CUDie.addAttribute(Attr_DW_FORM_addrx2, DW_FORM_addrx2, Addrx2Value);
111+
CUDie.addAttribute(Attr_DW_FORM_addrx3, DW_FORM_addrx3, Addrx3Value);
111112
CUDie.addAttribute(Attr_DW_FORM_addrx4, DW_FORM_addrx4, Addrx4Value);
112113
}
113114

@@ -275,6 +276,10 @@ void TestAllForms() {
275276
EXPECT_TRUE(ExtractedAddrx2Value.has_value());
276277
EXPECT_EQ(Addrx2Value, *ExtractedAddrx2Value);
277278

279+
auto ExtractedAddrx3Value = toAddress(DieDG.find(Attr_DW_FORM_addrx3));
280+
EXPECT_TRUE(ExtractedAddrx3Value.has_value());
281+
EXPECT_EQ(Addrx3Value, *ExtractedAddrx3Value);
282+
278283
auto ExtractedAddrx4Value = toAddress(DieDG.find(Attr_DW_FORM_addrx4));
279284
EXPECT_TRUE(ExtractedAddrx1Value.has_value());
280285
EXPECT_EQ(Addrx4Value, *ExtractedAddrx4Value);

llvm/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,11 @@ INSTANTIATE_TEST_SUITE_P(
232232
ParamType(DW_FORM_ref_sup8, 0, 0, DWARF32, SampleU32, 8, true),
233233
ParamType(DW_FORM_strx1, 0, 0, DWARF32, SampleU32, 1, true),
234234
ParamType(DW_FORM_strx2, 0, 0, DWARF32, SampleU32, 2, true),
235+
ParamType(DW_FORM_strx3, 0, 0, DWARF32, SampleU32, 3, true),
235236
ParamType(DW_FORM_strx4, 0, 0, DWARF32, SampleU32, 4, true),
236237
ParamType(DW_FORM_addrx1, 0, 0, DWARF32, SampleU32, 1, true),
237238
ParamType(DW_FORM_addrx2, 0, 0, DWARF32, SampleU32, 2, true),
239+
ParamType(DW_FORM_addrx3, 0, 0, DWARF32, SampleU32, 3, true),
238240
ParamType(DW_FORM_addrx4, 0, 0, DWARF32, SampleU32, 4, true),
239241
ParamType(DW_FORM_sec_offset, 0, 1, DWARF32, SampleU32, 0, false),
240242
ParamType(DW_FORM_sec_offset, 1, 0, DWARF32, SampleU32, 0, false),

0 commit comments

Comments
 (0)