diff options
author | Chris Bieneman <beanz@apple.com> | 2016-12-07 18:52:59 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2016-12-07 18:52:59 +0000 |
commit | c6c0e54d3d69ac297f0a0bb03bc0b5e792f85e12 (patch) | |
tree | b7b5e96c7e0b6713d6c1551cf2935159ab942a8d /llvm/tools | |
parent | a913f7ddbe4f920b52da988cf068595510d62e3d (diff) | |
download | bcm5719-llvm-c6c0e54d3d69ac297f0a0bb03bc0b5e792f85e12.tar.gz bcm5719-llvm-c6c0e54d3d69ac297f0a0bb03bc0b5e792f85e12.zip |
[ObjectYAML] Support for DWARF __debug_abbrev section
This patch adds support for round-tripping DWARF debug abbreviations through the obj<->yaml tools.
llvm-svn: 288955
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/obj2yaml/macho2yaml.cpp | 29 | ||||
-rw-r--r-- | llvm/tools/yaml2obj/yaml2macho.cpp | 12 |
2 files changed, 40 insertions, 1 deletions
diff --git a/llvm/tools/obj2yaml/macho2yaml.cpp b/llvm/tools/obj2yaml/macho2yaml.cpp index 0953d284e11..16f25fc4668 100644 --- a/llvm/tools/obj2yaml/macho2yaml.cpp +++ b/llvm/tools/obj2yaml/macho2yaml.cpp @@ -36,7 +36,10 @@ class MachODumper { void dumpExportTrie(std::unique_ptr<MachOYAML::Object> &Y); void dumpSymbols(std::unique_ptr<MachOYAML::Object> &Y); void dumpDWARF(std::unique_ptr<MachOYAML::Object> &Y); - void dumpDebugStrings(DWARFContextInMemory &DCtx, std::unique_ptr<MachOYAML::Object> &Y); + void dumpDebugAbbrev(DWARFContextInMemory &DCtx, + std::unique_ptr<MachOYAML::Object> &Y); + void dumpDebugStrings(DWARFContextInMemory &DCtx, + std::unique_ptr<MachOYAML::Object> &Y); public: MachODumper(const object::MachOObjectFile &O) : Obj(O) {} @@ -466,6 +469,7 @@ void MachODumper::dumpSymbols(std::unique_ptr<MachOYAML::Object> &Y) { void MachODumper::dumpDWARF(std::unique_ptr<MachOYAML::Object> &Y) { DWARFContextInMemory DICtx(Obj); dumpDebugStrings(DICtx, Y); + dumpDebugAbbrev(DICtx, Y); } void MachODumper::dumpDebugStrings(DWARFContextInMemory &DICtx, @@ -478,6 +482,29 @@ void MachODumper::dumpDebugStrings(DWARFContextInMemory &DICtx, } } +void MachODumper::dumpDebugAbbrev(DWARFContextInMemory &DCtx, + std::unique_ptr<MachOYAML::Object> &Y) { + auto AbbrevSetPtr = DCtx.getDebugAbbrev(); + if(AbbrevSetPtr) { + for(auto AbbrvDeclSet : *AbbrevSetPtr) { + for(auto AbbrvDecl : AbbrvDeclSet.second) { + MachOYAML::DWARFAbbrev Abbrv; + Abbrv.Code = AbbrvDecl.getCode(); + Abbrv.Tag = AbbrvDecl.getTag(); + Abbrv.Children = AbbrvDecl.hasChildren() ? dwarf::DW_CHILDREN_yes + : dwarf::DW_CHILDREN_no; + for(auto Attribute : AbbrvDecl.attributes()) { + MachOYAML::DWARFAttributeAbbrev AttAbrv; + AttAbrv.Attribute = Attribute.Attr; + AttAbrv.Form = Attribute.Form; + Abbrv.Attributes.push_back(AttAbrv); + } + Y->DWARF.AbbrevDecls.push_back(Abbrv); + } + } + } +} + Error macho2yaml(raw_ostream &Out, const object::MachOObjectFile &Obj) { MachODumper Dumper(Obj); Expected<std::unique_ptr<MachOYAML::Object>> YAML = Dumper.dump(); diff --git a/llvm/tools/yaml2obj/yaml2macho.cpp b/llvm/tools/yaml2obj/yaml2macho.cpp index 3312cd45fb7..48bd9e83ad3 100644 --- a/llvm/tools/yaml2obj/yaml2macho.cpp +++ b/llvm/tools/yaml2obj/yaml2macho.cpp @@ -393,6 +393,18 @@ Error MachOWriter::writeDWARFData(raw_ostream &OS, OS.write(Str.data(), Str.size()); OS.write('\0'); } + } else if (0 == strncmp(&Section.sectname[0], "__debug_abbrev", 16)) { + for (auto AbbrevDecl : Obj.DWARF.AbbrevDecls) { + encodeULEB128(AbbrevDecl.Code, OS); + encodeULEB128(AbbrevDecl.Tag, OS); + OS.write(AbbrevDecl.Children); + for (auto Attr : AbbrevDecl.Attributes) { + encodeULEB128(Attr.Attribute, OS); + encodeULEB128(Attr.Form, OS); + } + encodeULEB128(0, OS); + encodeULEB128(0, OS); + } } } return Error::success(); |