[DWARFYAML] Add support for emitting multiple abbrev tables.

This patch adds support for emitting multiple abbrev tables. Currently,
compilation units will always reference the first abbrev table.

Reviewed By: jhenderson, labath

Differential Revision: https://reviews.llvm.org/D86194
This commit is contained in:
Xing GUO 2020-08-21 10:11:33 +08:00
parent 5257a60ee0
commit 290e399f96
30 changed files with 2335 additions and 2199 deletions

View File

@ -219,6 +219,7 @@ DWARF:
- argv - argv
- char - char
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -79,6 +79,7 @@ TEST(DWARFExpression, DW_OP_convert) {
/// Auxiliary debug info. /// Auxiliary debug info.
const char *yamldata = const char *yamldata =
"debug_abbrev:\n" "debug_abbrev:\n"
" - Table:\n"
" - Code: 0x00000001\n" " - Code: 0x00000001\n"
" Tag: DW_TAG_compile_unit\n" " Tag: DW_TAG_compile_unit\n"
" Children: DW_CHILDREN_yes\n" " Children: DW_CHILDREN_yes\n"

View File

@ -165,6 +165,7 @@ DWARF:
- char - char
- sum - sum
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -41,6 +41,7 @@ TEST_F(DWARFASTParserClangTests,
/// Auxiliary debug info. /// Auxiliary debug info.
const char *yamldata = const char *yamldata =
"debug_abbrev:\n" "debug_abbrev:\n"
" - Table:\n"
" - Code: 0x00000001\n" " - Code: 0x00000001\n"
" Tag: DW_TAG_compile_unit\n" " Tag: DW_TAG_compile_unit\n"
" Children: DW_CHILDREN_yes\n" " Children: DW_CHILDREN_yes\n"

View File

@ -38,6 +38,7 @@ TEST_F(XcodeSDKModuleTests, TestModuleGetXcodeSDK) {
debug_str: debug_str:
- MacOSX10.9.sdk - MacOSX10.9.sdk
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no

View File

@ -39,6 +39,10 @@ struct Abbrev {
std::vector<AttributeAbbrev> Attributes; std::vector<AttributeAbbrev> Attributes;
}; };
struct AbbrevTable {
std::vector<Abbrev> Table;
};
struct ARangeDescriptor { struct ARangeDescriptor {
llvm::yaml::Hex64 Address; llvm::yaml::Hex64 Address;
yaml::Hex64 Length; yaml::Hex64 Length;
@ -203,7 +207,7 @@ template <typename EntryType> struct ListTable {
struct Data { struct Data {
bool IsLittleEndian; bool IsLittleEndian;
bool Is64BitAddrSize; bool Is64BitAddrSize;
std::vector<Abbrev> AbbrevDecls; std::vector<AbbrevTable> DebugAbbrev;
std::vector<StringRef> DebugStrings; std::vector<StringRef> DebugStrings;
Optional<std::vector<StringOffsetsTable>> DebugStrOffsets; Optional<std::vector<StringOffsetsTable>> DebugStrOffsets;
Optional<std::vector<ARange>> DebugAranges; Optional<std::vector<ARange>> DebugAranges;
@ -231,6 +235,7 @@ struct Data {
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AbbrevTable)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange)
LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::RangeEntry) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::RangeEntry)
@ -264,6 +269,10 @@ template <> struct MappingTraits<DWARFYAML::Data> {
static void mapping(IO &IO, DWARFYAML::Data &DWARF); static void mapping(IO &IO, DWARFYAML::Data &DWARF);
}; };
template <> struct MappingTraits<DWARFYAML::AbbrevTable> {
static void mapping(IO &IO, DWARFYAML::AbbrevTable &AbbrevTable);
};
template <> struct MappingTraits<DWARFYAML::Abbrev> { template <> struct MappingTraits<DWARFYAML::Abbrev> {
static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev); static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev);
}; };

View File

@ -96,8 +96,10 @@ Error DWARFYAML::emitDebugStr(raw_ostream &OS, const DWARFYAML::Data &DI) {
Error DWARFYAML::emitDebugAbbrev(raw_ostream &OS, const DWARFYAML::Data &DI) { Error DWARFYAML::emitDebugAbbrev(raw_ostream &OS, const DWARFYAML::Data &DI) {
uint64_t AbbrevCode = 0; uint64_t AbbrevCode = 0;
for (auto AbbrevDecl : DI.AbbrevDecls) { for (const DWARFYAML::AbbrevTable &AbbrevTable : DI.DebugAbbrev) {
AbbrevCode = AbbrevDecl.Code ? (uint64_t)*AbbrevDecl.Code : AbbrevCode + 1; for (const DWARFYAML::Abbrev &AbbrevDecl : AbbrevTable.Table) {
AbbrevCode =
AbbrevDecl.Code ? (uint64_t)*AbbrevDecl.Code : AbbrevCode + 1;
encodeULEB128(AbbrevCode, OS); encodeULEB128(AbbrevCode, OS);
encodeULEB128(AbbrevDecl.Tag, OS); encodeULEB128(AbbrevDecl.Tag, OS);
OS.write(AbbrevDecl.Children); OS.write(AbbrevDecl.Children);
@ -111,9 +113,10 @@ Error DWARFYAML::emitDebugAbbrev(raw_ostream &OS, const DWARFYAML::Data &DI) {
encodeULEB128(0, OS); encodeULEB128(0, OS);
} }
// The abbreviations for a given compilation unit end with an entry consisting // The abbreviations for a given compilation unit end with an entry
// of a 0 byte for the abbreviation code. // consisting of a 0 byte for the abbreviation code.
OS.write_zeros(1); OS.write_zeros(1);
}
return Error::success(); return Error::success();
} }
@ -243,7 +246,7 @@ Error DWARFYAML::emitDebugGNUPubtypes(raw_ostream &OS, const Data &DI) {
/*IsGNUStyle=*/true); /*IsGNUStyle=*/true);
} }
static Expected<uint64_t> writeDIE(ArrayRef<DWARFYAML::Abbrev> AbbrevDecls, static Expected<uint64_t> writeDIE(ArrayRef<DWARFYAML::AbbrevTable> AbbrevTable,
const dwarf::FormParams &Params, const dwarf::FormParams &Params,
const DWARFYAML::Entry &Entry, const DWARFYAML::Entry &Entry,
raw_ostream &OS, bool IsLittleEndian) { raw_ostream &OS, bool IsLittleEndian) {
@ -253,6 +256,13 @@ static Expected<uint64_t> writeDIE(ArrayRef<DWARFYAML::Abbrev> AbbrevDecls,
if (AbbrCode == 0 || Entry.Values.empty()) if (AbbrCode == 0 || Entry.Values.empty())
return OS.tell() - EntryBegin; return OS.tell() - EntryBegin;
if (AbbrevTable.empty())
return createStringError(
errc::invalid_argument,
"non-empty compilation unit should have an associated abbrev table");
ArrayRef<DWARFYAML::Abbrev> AbbrevDecls(AbbrevTable[0].Table);
if (AbbrCode > AbbrevDecls.size()) if (AbbrCode > AbbrevDecls.size())
return createStringError( return createStringError(
errc::invalid_argument, errc::invalid_argument,
@ -394,7 +404,7 @@ Error DWARFYAML::emitDebugInfo(raw_ostream &OS, const DWARFYAML::Data &DI) {
for (const DWARFYAML::Entry &Entry : Unit.Entries) { for (const DWARFYAML::Entry &Entry : Unit.Entries) {
if (Expected<uint64_t> EntryLength = writeDIE( if (Expected<uint64_t> EntryLength = writeDIE(
DI.AbbrevDecls, Params, Entry, EntryBufferOS, DI.IsLittleEndian)) DI.DebugAbbrev, Params, Entry, EntryBufferOS, DI.IsLittleEndian))
Length += *EntryLength; Length += *EntryLength;
else else
return EntryLength.takeError(); return EntryLength.takeError();

View File

@ -32,7 +32,7 @@ SetVector<StringRef> DWARFYAML::Data::getNonEmptySectionNames() const {
SecNames.insert("debug_line"); SecNames.insert("debug_line");
if (!DebugAddr.empty()) if (!DebugAddr.empty())
SecNames.insert("debug_addr"); SecNames.insert("debug_addr");
if (!AbbrevDecls.empty()) if (!DebugAbbrev.empty())
SecNames.insert("debug_abbrev"); SecNames.insert("debug_abbrev");
if (!CompileUnits.empty()) if (!CompileUnits.empty())
SecNames.insert("debug_info"); SecNames.insert("debug_info");
@ -60,7 +60,7 @@ void MappingTraits<DWARFYAML::Data>::mapping(IO &IO, DWARFYAML::Data &DWARF) {
DWARFYAML::DWARFContext DWARFCtx; DWARFYAML::DWARFContext DWARFCtx;
IO.setContext(&DWARFCtx); IO.setContext(&DWARFCtx);
IO.mapOptional("debug_str", DWARF.DebugStrings); IO.mapOptional("debug_str", DWARF.DebugStrings);
IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls); IO.mapOptional("debug_abbrev", DWARF.DebugAbbrev);
IO.mapOptional("debug_aranges", DWARF.DebugAranges); IO.mapOptional("debug_aranges", DWARF.DebugAranges);
if (!DWARF.DebugRanges.empty() || !IO.outputting()) if (!DWARF.DebugRanges.empty() || !IO.outputting())
IO.mapOptional("debug_ranges", DWARF.DebugRanges); IO.mapOptional("debug_ranges", DWARF.DebugRanges);
@ -78,6 +78,11 @@ void MappingTraits<DWARFYAML::Data>::mapping(IO &IO, DWARFYAML::Data &DWARF) {
IO.setContext(OldContext); IO.setContext(OldContext);
} }
void MappingTraits<DWARFYAML::AbbrevTable>::mapping(
IO &IO, DWARFYAML::AbbrevTable &AbbrevTable) {
IO.mapOptional("Table", AbbrevTable.Table);
}
void MappingTraits<DWARFYAML::Abbrev>::mapping(IO &IO, void MappingTraits<DWARFYAML::Abbrev>::mapping(IO &IO,
DWARFYAML::Abbrev &Abbrev) { DWARFYAML::Abbrev &Abbrev) {
IO.mapOptional("Code", Abbrev.Code); IO.mapOptional("Code", Abbrev.Code);

View File

@ -275,6 +275,7 @@ DWARF:
- N - N
- t - t
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -264,6 +264,7 @@ DWARF:
- N - N
- t - t
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -275,6 +275,7 @@ LoadCommands:
reserved3: 0x00000000 reserved3: 0x00000000
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -310,6 +310,7 @@ LinkEditData:
- _main - _main
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -638,6 +639,7 @@ LoadCommands:
reserved3: 0x00000000 reserved3: 0x00000000
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no

View File

@ -323,6 +323,7 @@ DWARF:
- int - int
- char - char
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -169,6 +169,7 @@ DWARF:
- stripped2 - stripped2
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -277,6 +277,7 @@ DWARF:
debug_str: debug_str:
- World - World
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no

View File

@ -275,6 +275,7 @@ LoadCommands:
reserved3: 0x00000000 reserved3: 0x00000000
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -310,6 +310,7 @@ LinkEditData:
- _main - _main
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -640,6 +641,7 @@ LoadCommands:
reserved3: 0x00000000 reserved3: 0x00000000
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no

View File

@ -30,6 +30,7 @@ DWARF:
- main - main
- inline1 - inline1
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x0000000000000001 - Code: 0x0000000000000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -30,6 +30,7 @@ DWARF:
- main - main
- inline1 - inline1
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x0000000000000001 - Code: 0x0000000000000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -29,6 +29,7 @@ DWARF:
- '' - ''
- inline1 - inline1
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x0000000000000001 - Code: 0x0000000000000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -178,6 +178,7 @@ DWARF:
- main - main
- foo - foo
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -299,6 +299,7 @@ Slices:
- int - int
- char - char
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -777,6 +778,7 @@ Slices:
- int - int
- char - char
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -384,6 +384,7 @@ DWARF:
- argv - argv
- char - char
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -312,6 +312,7 @@ DWARF:
- bar - bar
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -4,7 +4,7 @@
# RUN: yaml2obj --docnum=1 %s -o %t1.o # RUN: yaml2obj --docnum=1 %s -o %t1.o
# RUN: llvm-readobj --sections --section-data %t1.o | \ # RUN: llvm-readobj --sections --section-data %t1.o | \
# RUN: FileCheck -DSIZE=39 -DADDRALIGN=1 %s --check-prefixes=SHDR,CONTENT # RUN: FileCheck -DSIZE=54 -DADDRALIGN=1 %s --check-prefixes=SHDR,CONTENT
# SHDR: Index: 1 # SHDR: Index: 1
# SHDR-NEXT: Name: .debug_abbrev (1) # SHDR-NEXT: Name: .debug_abbrev (1)
@ -42,9 +42,21 @@
## ^--- Form: invalid ULEB128 (0x81) ^--- Attribute: reserved ULEB128 (0x2020) ## ^--- Form: invalid ULEB128 (0x81) ^--- Attribute: reserved ULEB128 (0x2020)
## ^- Attribute: reserved ULEB128 ^- DW_FORM_implicit_const ULEB128 ## ^- Attribute: reserved ULEB128 ^- DW_FORM_implicit_const ULEB128
## ##
# CONTENT-NEXT: 0020: CEC2F105 000000 |.......| # CONTENT-NEXT: 0020: CEC2F105 00000001
## ^------- Value SLEB128 (12345678) ^--- attr terminator ## ^------- Value SLEB128 (12345678) ^--- attr terminator
## ^- abbrev terminator ## ^- abbrev terminator
## ^- abbreviation code ULEB128
# CONTENT: 1101250E 0000022E |..........%.....|
## ^- DW_TAG_compile_unit ULEB128 ^--- attr terminator
## ^- DW_CHILDREN_yes 1-byte ^- abbreviation code ULEB128
## ^- DW_AT_producer ULEB128 ^- DW_TAG_subprogram ULEB128
## ^- DW_FORM_strp ULEB128
# CONTENT-NEXT: 0030: 01110100 0000 |......|
## ^- DW_CHILDREN_yes 1-byte
## ^- DW_AT_low_pc ULEB128
## ^- DW_FORM_addr UELB128
## ^---- attr terminator
## ^- abbrev table terminator
# CONTENT-NEXT: ) # CONTENT-NEXT: )
--- !ELF --- !ELF
@ -54,6 +66,7 @@ FileHeader:
Type: ET_EXEC Type: ET_EXEC
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -90,6 +103,19 @@ DWARF:
## who is followed by a SLEB128 value. ## who is followed by a SLEB128 value.
Form: DW_FORM_implicit_const Form: DW_FORM_implicit_const
Value: 12345678 Value: 12345678
- Table:
- Code: 1
Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes
Attributes:
- Attribute: DW_AT_producer
Form: DW_FORM_strp
- Code: 2
Tag: DW_TAG_subprogram
Children: DW_CHILDREN_yes
Attributes:
- Attribute: DW_AT_low_pc
Form: DW_FORM_addr
## b) Generate the .debug_abbrev section from raw section content. ## b) Generate the .debug_abbrev section from raw section content.
@ -149,6 +175,7 @@ Sections:
Size: 0x10 Size: 0x10
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -170,6 +197,7 @@ Sections:
Content: "00" Content: "00"
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -229,6 +257,7 @@ Sections:
Type: SHT_STRTAB Type: SHT_STRTAB
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -256,6 +285,7 @@ FileHeader:
Type: ET_EXEC Type: ET_EXEC
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Tag: DW_TAG_compile_unit - Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
Attributes: [] Attributes: []

View File

@ -115,6 +115,7 @@ FileHeader:
Type: ET_EXEC Type: ET_EXEC
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -440,6 +441,7 @@ Sections:
Size: 0x10 Size: 0x10
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -467,6 +469,7 @@ Sections:
Content: "00" Content: "00"
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -532,6 +535,7 @@ Sections:
Type: SHT_STRTAB Type: SHT_STRTAB
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -597,6 +601,7 @@ FileHeader:
Type: ET_EXEC Type: ET_EXEC
DWARF: DWARF:
debug_abbrev: debug_abbrev:
- Table:
- Tag: DW_TAG_compile_unit - Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
Attributes: Attributes:
@ -647,6 +652,8 @@ FileHeader:
Data: ELFDATA2LSB Data: ELFDATA2LSB
Type: ET_EXEC Type: ET_EXEC
DWARF: DWARF:
debug_abbrev:
- Table: []
debug_info: debug_info:
- Length: 0x1234 - Length: 0x1234
Version: 5 Version: 5
@ -774,6 +781,7 @@ DWARF:
- "/home/v/x/llvm/playground" - "/home/v/x/llvm/playground"
- "main" - "main"
debug_abbrev: debug_abbrev:
- Table:
- Code: 1 - Code: 1
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -873,3 +881,24 @@ DWARF:
debug_info: debug_info:
- Version: 4 - Version: 4
AbbrOffset: 0x00 AbbrOffset: 0x00
## n) Test that yaml2obj emits an error message when a compilation unit has values but there is no associated abbrev table.
## RUN: not yaml2obj --docnum=16 %s 2>&1 | FileCheck %s --check-prefix=NO-ABBREV
# NO-ABBREV: yaml2obj: error: non-empty compilation unit should have an associated abbrev table
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
DWARF:
debug_info:
- Version: 4
AbbrOffset: 0x00
Entries:
- AbbrCode: 1
Values:
- Value: 0x1234

View File

@ -24,6 +24,7 @@ void dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) {
auto AbbrevSetPtr = DCtx.getDebugAbbrev(); auto AbbrevSetPtr = DCtx.getDebugAbbrev();
if (AbbrevSetPtr) { if (AbbrevSetPtr) {
for (auto AbbrvDeclSet : *AbbrevSetPtr) { for (auto AbbrvDeclSet : *AbbrevSetPtr) {
Y.DebugAbbrev.emplace_back();
for (auto AbbrvDecl : AbbrvDeclSet.second) { for (auto AbbrvDecl : AbbrvDeclSet.second) {
DWARFYAML::Abbrev Abbrv; DWARFYAML::Abbrev Abbrv;
Abbrv.Code = AbbrvDecl.getCode(); Abbrv.Code = AbbrvDecl.getCode();
@ -38,7 +39,7 @@ void dumpDebugAbbrev(DWARFContext &DCtx, DWARFYAML::Data &Y) {
AttAbrv.Value = Attribute.getImplicitConstValue(); AttAbrv.Value = Attribute.getImplicitConstValue();
Abbrv.Attributes.push_back(AttAbrv); Abbrv.Attributes.push_back(AttAbrv);
} }
Y.AbbrevDecls.push_back(Abbrv); Y.DebugAbbrev.back().Table.push_back(Abbrv);
} }
} }
} }

View File

@ -1363,6 +1363,7 @@ TEST(DWARFDebugInfo, TestChildIteratorsOnInvalidDie) {
TEST(DWARFDebugInfo, TestEmptyChildren) { TEST(DWARFDebugInfo, TestEmptyChildren) {
const char *yamldata = "debug_abbrev:\n" const char *yamldata = "debug_abbrev:\n"
" - Table:\n"
" - Code: 0x00000001\n" " - Code: 0x00000001\n"
" Tag: DW_TAG_compile_unit\n" " Tag: DW_TAG_compile_unit\n"
" Children: DW_CHILDREN_yes\n" " Children: DW_CHILDREN_yes\n"
@ -1885,6 +1886,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidCURef) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -1933,6 +1935,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRefAddr) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -1979,6 +1982,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRanges) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2016,6 +2020,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRnglists) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2053,6 +2058,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStmtList) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2089,6 +2095,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidStrp) {
debug_str: debug_str:
- '' - ''
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2122,6 +2129,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidRefAddrBetween) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2169,6 +2177,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineSequence) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2237,6 +2246,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineFileIndex) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2307,6 +2317,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidLineTablePorlogueDirIndex) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2378,6 +2389,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyDuplicateFileWarning) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2454,6 +2466,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyCUDontShareLineTable) {
- /tmp/main.c - /tmp/main.c
- /tmp/foo.c - /tmp/foo.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no
@ -2569,6 +2582,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyCURangesIncomplete) {
- '' - ''
- /tmp/main.c - /tmp/main.c
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2622,6 +2636,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyLexicalBlockRanges) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2687,6 +2702,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyOverlappingFunctionRanges) {
- main - main
- foo - foo
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2741,6 +2757,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyOverlappingLexicalBlockRanges) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2814,6 +2831,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyInvalidDIERange) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2866,6 +2884,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyElidedDoesntFail) {
- main - main
- elided - elided
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2928,6 +2947,7 @@ TEST(DWARFDebugInfo, TestDwarfVerifyNestedFunctions) {
- main - main
- nested - nested
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes

View File

@ -21,6 +21,7 @@ namespace {
TEST(DWARFDie, getLocations) { TEST(DWARFDie, getLocations) {
const char *yamldata = R"( const char *yamldata = R"(
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_no Children: DW_CHILDREN_no

View File

@ -1414,6 +1414,7 @@ TEST(GSYMTest, TestDWARFFunctionWithAddresses) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -1493,6 +1494,7 @@ TEST(GSYMTest, TestDWARFFunctionWithAddressAndOffset) {
- /tmp/main.c - /tmp/main.c
- main - main
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -1576,6 +1578,7 @@ TEST(GSYMTest, TestDWARFStructMethodNoMangled) {
- dump - dump
- this - this
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -1696,6 +1699,7 @@ TEST(GSYMTest, TestDWARFTextRanges) {
- dead_stripped - dead_stripped
- dead_stripped2 - dead_stripped2
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -1793,6 +1797,7 @@ TEST(GSYMTest, TestDWARFInlineInfo) {
- main - main
- inline1 - inline1
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2048,6 +2053,7 @@ TEST(GSYMTest, TestDWARFNoLines) {
- no_lines_no_decl - no_lines_no_decl
- no_lines_with_decl - no_lines_with_decl
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2293,7 +2299,6 @@ TEST(GSYMTest, TestDWARFDeadStripAddr4) {
// //
// 0x0000004e: NULL // 0x0000004e: NULL
StringRef yamldata = R"( StringRef yamldata = R"(
debug_str: debug_str:
- '' - ''
@ -2303,6 +2308,7 @@ TEST(GSYMTest, TestDWARFDeadStripAddr4) {
- stripped2 - stripped2
- stripped3 - stripped3
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes
@ -2445,6 +2451,7 @@ TEST(GSYMTest, TestDWARFDeadStripAddr8) {
- stripped2 - stripped2
- stripped3 - stripped3
debug_abbrev: debug_abbrev:
- Table:
- Code: 0x00000001 - Code: 0x00000001
Tag: DW_TAG_compile_unit Tag: DW_TAG_compile_unit
Children: DW_CHILDREN_yes Children: DW_CHILDREN_yes