Chris Bieneman | 79e60eb | 2016-12-07 21:26:32 +0000 | [diff] [blame] | 1 | //===- DWARFYAML.cpp - DWARF YAMLIO implementation ------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines classes for handling the YAML representation of DWARF Debug |
| 11 | // Info. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "llvm/ObjectYAML/DWARFYAML.h" |
| 16 | |
| 17 | namespace llvm { |
| 18 | |
Chris Bieneman | fbf7dfe | 2016-12-08 17:46:57 +0000 | [diff] [blame] | 19 | bool DWARFYAML::Data::isEmpty() const { |
Chris Bieneman | 79e60eb | 2016-12-07 21:26:32 +0000 | [diff] [blame] | 20 | return 0 == DebugStrings.size() + AbbrevDecls.size(); |
| 21 | } |
| 22 | |
| 23 | namespace yaml { |
| 24 | |
Chris Bieneman | abecaa2 | 2016-12-20 22:36:42 +0000 | [diff] [blame] | 25 | void MappingTraits<DWARFYAML::Data>::mapping( |
| 26 | IO &IO, DWARFYAML::Data &DWARF) { |
Chris Bieneman | 79e60eb | 2016-12-07 21:26:32 +0000 | [diff] [blame] | 27 | IO.mapOptional("debug_str", DWARF.DebugStrings); |
| 28 | IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls); |
Chris Bieneman | 313b326 | 2016-12-09 00:26:44 +0000 | [diff] [blame] | 29 | if(!DWARF.ARanges.empty() || !IO.outputting()) |
| 30 | IO.mapOptional("debug_aranges", DWARF.ARanges); |
Chris Bieneman | d943094 | 2016-12-19 22:22:12 +0000 | [diff] [blame] | 31 | if(!DWARF.PubNames.Entries.empty() || !IO.outputting()) |
| 32 | IO.mapOptional("debug_pubnames", DWARF.PubNames); |
| 33 | if(!DWARF.PubTypes.Entries.empty() || !IO.outputting()) |
| 34 | IO.mapOptional("debug_pubtypes", DWARF.PubTypes); |
| 35 | if(!DWARF.GNUPubNames.Entries.empty() || !IO.outputting()) |
| 36 | IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames); |
| 37 | if(!DWARF.GNUPubTypes.Entries.empty() || !IO.outputting()) |
| 38 | IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes); |
Chris Bieneman | 79e60eb | 2016-12-07 21:26:32 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Chris Bieneman | abecaa2 | 2016-12-20 22:36:42 +0000 | [diff] [blame] | 41 | void MappingTraits<DWARFYAML::Abbrev>::mapping( |
| 42 | IO &IO, DWARFYAML::Abbrev &Abbrev) { |
Chris Bieneman | 79e60eb | 2016-12-07 21:26:32 +0000 | [diff] [blame] | 43 | IO.mapRequired("Code", Abbrev.Code); |
| 44 | IO.mapRequired("Tag", Abbrev.Tag); |
| 45 | IO.mapRequired("Children", Abbrev.Children); |
| 46 | IO.mapRequired("Attributes", Abbrev.Attributes); |
| 47 | } |
| 48 | |
Chris Bieneman | fbf7dfe | 2016-12-08 17:46:57 +0000 | [diff] [blame] | 49 | void MappingTraits<DWARFYAML::AttributeAbbrev>::mapping( |
| 50 | IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev) { |
Chris Bieneman | 79e60eb | 2016-12-07 21:26:32 +0000 | [diff] [blame] | 51 | IO.mapRequired("Attribute", AttAbbrev.Attribute); |
| 52 | IO.mapRequired("Form", AttAbbrev.Form); |
| 53 | } |
| 54 | |
Chris Bieneman | 313b326 | 2016-12-09 00:26:44 +0000 | [diff] [blame] | 55 | void MappingTraits<DWARFYAML::ARangeDescriptor>::mapping( |
| 56 | IO &IO, DWARFYAML::ARangeDescriptor &Descriptor) { |
| 57 | IO.mapRequired("Address", Descriptor.Address); |
| 58 | IO.mapRequired("Length", Descriptor.Length); |
| 59 | } |
| 60 | |
| 61 | void MappingTraits<DWARFYAML::ARange>::mapping(IO &IO, |
| 62 | DWARFYAML::ARange &Range) { |
| 63 | IO.mapRequired("Length", Range.Length); |
| 64 | IO.mapRequired("Version", Range.Version); |
| 65 | IO.mapRequired("CuOffset", Range.CuOffset); |
| 66 | IO.mapRequired("AddrSize", Range.AddrSize); |
| 67 | IO.mapRequired("SegSize", Range.SegSize); |
| 68 | IO.mapRequired("Descriptors", Range.Descriptors); |
| 69 | } |
| 70 | |
Chris Bieneman | d943094 | 2016-12-19 22:22:12 +0000 | [diff] [blame] | 71 | void MappingTraits<DWARFYAML::PubEntry>::mapping(IO &IO, |
| 72 | DWARFYAML::PubEntry &Entry) { |
| 73 | IO.mapRequired("DieOffset", Entry.DieOffset); |
| 74 | if (reinterpret_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle) |
| 75 | IO.mapRequired("Descriptor", Entry.Descriptor); |
| 76 | IO.mapRequired("Name", Entry.Name); |
| 77 | } |
| 78 | |
| 79 | void MappingTraits<DWARFYAML::PubSection>::mapping( |
| 80 | IO &IO, DWARFYAML::PubSection &Section) { |
| 81 | auto OldContext = IO.getContext(); |
| 82 | IO.setContext(&Section); |
| 83 | |
| 84 | IO.mapRequired("Length", Section.Length); |
| 85 | IO.mapRequired("Version", Section.Version); |
| 86 | IO.mapRequired("UnitOffset", Section.UnitOffset); |
| 87 | IO.mapRequired("UnitSize", Section.UnitSize); |
| 88 | IO.mapRequired("Entries", Section.Entries); |
| 89 | |
| 90 | IO.setContext(OldContext); |
| 91 | } |
| 92 | |
Chris Bieneman | 79e60eb | 2016-12-07 21:26:32 +0000 | [diff] [blame] | 93 | } // namespace llvm::yaml |
| 94 | |
| 95 | } // namespace llvm |