From e0e451d9278e12f5d6411565e0cb17b9c57362ce Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 22 Dec 2016 22:44:27 +0000 Subject: [ObjectYAML] Support for DWARF debug_info section This patch adds support for YAML<->DWARF for debug_info sections. This re-lands r290147, reverted in 290148, re-landed in r290204 after fixing the issue that caused bots to fail (thank you UBSan!), and reverted again in r290209 due to failures on big endian systems. After adding support for preserving endianness, this should be good now. llvm-svn: 290386 --- llvm/lib/ObjectYAML/DWARFYAML.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'llvm/lib/ObjectYAML') diff --git a/llvm/lib/ObjectYAML/DWARFYAML.cpp b/llvm/lib/ObjectYAML/DWARFYAML.cpp index 3d647b0b0b1..42a448a7bdf 100644 --- a/llvm/lib/ObjectYAML/DWARFYAML.cpp +++ b/llvm/lib/ObjectYAML/DWARFYAML.cpp @@ -22,8 +22,9 @@ bool DWARFYAML::Data::isEmpty() const { namespace yaml { -void MappingTraits::mapping( - IO &IO, DWARFYAML::Data &DWARF) { +void MappingTraits::mapping(IO &IO, DWARFYAML::Data &DWARF) { + auto oldContext = IO.getContext(); + IO.setContext(&DWARF); IO.mapOptional("debug_str", DWARF.DebugStrings); IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls); if(!DWARF.ARanges.empty() || !IO.outputting()) @@ -36,10 +37,12 @@ void MappingTraits::mapping( IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames); if(!DWARF.GNUPubTypes.Entries.empty() || !IO.outputting()) IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes); + IO.mapOptional("debug_info", DWARF.CompileUnits); + IO.setContext(&oldContext); } -void MappingTraits::mapping( - IO &IO, DWARFYAML::Abbrev &Abbrev) { +void MappingTraits::mapping(IO &IO, + DWARFYAML::Abbrev &Abbrev) { IO.mapRequired("Code", Abbrev.Code); IO.mapRequired("Tag", Abbrev.Tag); IO.mapRequired("Children", Abbrev.Children); @@ -90,6 +93,28 @@ void MappingTraits::mapping( IO.setContext(OldContext); } +void MappingTraits::mapping(IO &IO, DWARFYAML::Unit &Unit) { + IO.mapRequired("Length", Unit.Length); + IO.mapRequired("Version", Unit.Version); + IO.mapRequired("AbbrOffset", Unit.AbbrOffset); + IO.mapRequired("AddrSize", Unit.AddrSize); + IO.mapOptional("Entries", Unit.Entries); +} + +void MappingTraits::mapping(IO &IO, DWARFYAML::Entry &Entry) { + IO.mapRequired("AbbrCode", Entry.AbbrCode); + IO.mapRequired("Values", Entry.Values); +} + +void MappingTraits::mapping(IO &IO, + DWARFYAML::FormValue &FormValue) { + IO.mapOptional("Value", FormValue.Value); + if(!FormValue.CStr.empty() || !IO.outputting()) + IO.mapOptional("CStr", FormValue.CStr); + if(!FormValue.BlockData.empty() || !IO.outputting()) + IO.mapOptional("BlockData", FormValue.BlockData); +} + } // namespace llvm::yaml } // namespace llvm -- cgit v1.2.3