LLVM  8.0.1
DWARFYAML.cpp
Go to the documentation of this file.
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 
16 
17 namespace llvm {
18 
20  return 0 == DebugStrings.size() + AbbrevDecls.size();
21 }
22 
23 namespace yaml {
24 
26  auto oldContext = IO.getContext();
27  IO.setContext(&DWARF);
28  IO.mapOptional("debug_str", DWARF.DebugStrings);
29  IO.mapOptional("debug_abbrev", DWARF.AbbrevDecls);
30  if (!DWARF.ARanges.empty() || !IO.outputting())
31  IO.mapOptional("debug_aranges", DWARF.ARanges);
32  if (!DWARF.PubNames.Entries.empty() || !IO.outputting())
33  IO.mapOptional("debug_pubnames", DWARF.PubNames);
34  if (!DWARF.PubTypes.Entries.empty() || !IO.outputting())
35  IO.mapOptional("debug_pubtypes", DWARF.PubTypes);
36  if (!DWARF.GNUPubNames.Entries.empty() || !IO.outputting())
37  IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);
38  if (!DWARF.GNUPubTypes.Entries.empty() || !IO.outputting())
39  IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);
40  IO.mapOptional("debug_info", DWARF.CompileUnits);
41  IO.mapOptional("debug_line", DWARF.DebugLines);
42  IO.setContext(&oldContext);
43 }
44 
46  DWARFYAML::Abbrev &Abbrev) {
47  IO.mapRequired("Code", Abbrev.Code);
48  IO.mapRequired("Tag", Abbrev.Tag);
49  IO.mapRequired("Children", Abbrev.Children);
50  IO.mapRequired("Attributes", Abbrev.Attributes);
51 }
52 
54  IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev) {
55  IO.mapRequired("Attribute", AttAbbrev.Attribute);
56  IO.mapRequired("Form", AttAbbrev.Form);
57  if(AttAbbrev.Form == dwarf::DW_FORM_implicit_const)
58  IO.mapRequired("Value", AttAbbrev.Value);
59 }
60 
62  IO &IO, DWARFYAML::ARangeDescriptor &Descriptor) {
63  IO.mapRequired("Address", Descriptor.Address);
64  IO.mapRequired("Length", Descriptor.Length);
65 }
66 
68  DWARFYAML::ARange &Range) {
69  IO.mapRequired("Length", Range.Length);
70  IO.mapRequired("Version", Range.Version);
71  IO.mapRequired("CuOffset", Range.CuOffset);
72  IO.mapRequired("AddrSize", Range.AddrSize);
73  IO.mapRequired("SegSize", Range.SegSize);
74  IO.mapRequired("Descriptors", Range.Descriptors);
75 }
76 
78  DWARFYAML::PubEntry &Entry) {
79  IO.mapRequired("DieOffset", Entry.DieOffset);
80  if (reinterpret_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle)
81  IO.mapRequired("Descriptor", Entry.Descriptor);
82  IO.mapRequired("Name", Entry.Name);
83 }
84 
86  IO &IO, DWARFYAML::PubSection &Section) {
87  auto OldContext = IO.getContext();
88  IO.setContext(&Section);
89 
90  IO.mapRequired("Length", Section.Length);
91  IO.mapRequired("Version", Section.Version);
92  IO.mapRequired("UnitOffset", Section.UnitOffset);
93  IO.mapRequired("UnitSize", Section.UnitSize);
94  IO.mapRequired("Entries", Section.Entries);
95 
96  IO.setContext(OldContext);
97 }
98 
100  IO.mapRequired("Length", Unit.Length);
101  IO.mapRequired("Version", Unit.Version);
102  if (Unit.Version >= 5)
103  IO.mapRequired("UnitType", Unit.Type);
104  IO.mapRequired("AbbrOffset", Unit.AbbrOffset);
105  IO.mapRequired("AddrSize", Unit.AddrSize);
106  IO.mapOptional("Entries", Unit.Entries);
107 }
108 
110  IO.mapRequired("AbbrCode", Entry.AbbrCode);
111  IO.mapRequired("Values", Entry.Values);
112 }
113 
115  IO &IO, DWARFYAML::FormValue &FormValue) {
116  IO.mapOptional("Value", FormValue.Value);
117  if (!FormValue.CStr.empty() || !IO.outputting())
118  IO.mapOptional("CStr", FormValue.CStr);
119  if (!FormValue.BlockData.empty() || !IO.outputting())
120  IO.mapOptional("BlockData", FormValue.BlockData);
121 }
122 
124  IO.mapRequired("Name", File.Name);
125  IO.mapRequired("DirIdx", File.DirIdx);
126  IO.mapRequired("ModTime", File.ModTime);
127  IO.mapRequired("Length", File.Length);
128 }
129 
131  IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode) {
132  IO.mapRequired("Opcode", LineTableOpcode.Opcode);
133  if (LineTableOpcode.Opcode == dwarf::DW_LNS_extended_op) {
134  IO.mapRequired("ExtLen", LineTableOpcode.ExtLen);
135  IO.mapRequired("SubOpcode", LineTableOpcode.SubOpcode);
136  }
137 
138  if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
139  IO.mapOptional("UnknownOpcodeData", LineTableOpcode.UnknownOpcodeData);
140  if (!LineTableOpcode.UnknownOpcodeData.empty() || !IO.outputting())
141  IO.mapOptional("StandardOpcodeData", LineTableOpcode.StandardOpcodeData);
142  if (!LineTableOpcode.FileEntry.Name.empty() || !IO.outputting())
143  IO.mapOptional("FileEntry", LineTableOpcode.FileEntry);
144  if (LineTableOpcode.Opcode == dwarf::DW_LNS_advance_line || !IO.outputting())
145  IO.mapOptional("SData", LineTableOpcode.SData);
146  IO.mapOptional("Data", LineTableOpcode.Data);
147 }
148 
150  IO &IO, DWARFYAML::LineTable &LineTable) {
151  IO.mapRequired("Length", LineTable.Length);
152  IO.mapRequired("Version", LineTable.Version);
153  IO.mapRequired("PrologueLength", LineTable.PrologueLength);
154  IO.mapRequired("MinInstLength", LineTable.MinInstLength);
155  if(LineTable.Version >= 4)
156  IO.mapRequired("MaxOpsPerInst", LineTable.MaxOpsPerInst);
157  IO.mapRequired("DefaultIsStmt", LineTable.DefaultIsStmt);
158  IO.mapRequired("LineBase", LineTable.LineBase);
159  IO.mapRequired("LineRange", LineTable.LineRange);
160  IO.mapRequired("OpcodeBase", LineTable.OpcodeBase);
161  IO.mapRequired("StandardOpcodeLengths", LineTable.StandardOpcodeLengths);
162  IO.mapRequired("IncludeDirs", LineTable.IncludeDirs);
163  IO.mapRequired("Files", LineTable.Files);
164  IO.mapRequired("Opcodes", LineTable.Opcodes);
165 }
166 
168  IO &IO, DWARFYAML::InitialLength &InitialLength) {
169  IO.mapRequired("TotalLength", InitialLength.TotalLength);
170  if (InitialLength.isDWARF64())
171  IO.mapRequired("TotalLength64", InitialLength.TotalLength64);
172 }
173 
174 } // end namespace yaml
175 
176 } // end namespace llvm
llvm::dwarf::Constants Children
Definition: DWARFYAML.h:57
PubSection PubNames
Definition: DWARFYAML.h:149
std::vector< AttributeAbbrev > Attributes
Definition: DWARFYAML.h:58
This class represents lattice values for constants.
Definition: AllocatorList.h:24
llvm::dwarf::UnitType Type
Definition: DWARFYAML.h:104
dwarf::LineNumberExtendedOps SubOpcode
Definition: DWARFYAML.h:120
dwarf::LineNumberOps Opcode
Definition: DWARFYAML.h:118
bool isEmpty() const
Definition: DWARFYAML.cpp:19
std::vector< Abbrev > AbbrevDecls
Definition: DWARFYAML.h:146
InitialLength Length
Definition: DWARFYAML.h:67
std::vector< uint8_t > StandardOpcodeLengths
Definition: DWARFYAML.h:138
std::vector< PubEntry > Entries
Definition: DWARFYAML.h:87
std::vector< ARangeDescriptor > Descriptors
Definition: DWARFYAML.h:72
PubSection GNUPubNames
Definition: DWARFYAML.h:152
std::vector< ARange > ARanges
Definition: DWARFYAML.h:148
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
std::vector< Unit > CompileUnits
Definition: DWARFYAML.h:155
std::vector< llvm::yaml::Hex8 > BlockData
Definition: DWARFYAML.h:93
llvm::yaml::Hex32 Code
Definition: DWARFYAML.h:55
InitialLength Length
Definition: DWARFYAML.h:102
std::vector< File > Files
Definition: DWARFYAML.h:140
llvm::yaml::Hex32 DieOffset
Definition: DWARFYAML.h:76
std::vector< LineTable > DebugLines
Definition: DWARFYAML.h:157
struct UnitT Unit
std::vector< StringRef > IncludeDirs
Definition: DWARFYAML.h:139
std::vector< Entry > Entries
Definition: DWARFYAML.h:107
llvm::yaml::Hex64 Value
Definition: DWARFYAML.h:91
std::vector< FormValue > Values
Definition: DWARFYAML.h:98
llvm::yaml::Hex8 Descriptor
Definition: DWARFYAML.h:77
llvm::dwarf::Attribute Attribute
Definition: DWARFYAML.h:49
PubSection PubTypes
Definition: DWARFYAML.h:150
std::vector< StringRef > DebugStrings
Definition: DWARFYAML.h:147
llvm::yaml::Hex32 AbbrCode
Definition: DWARFYAML.h:97
PubSection GNUPubTypes
Definition: DWARFYAML.h:153
std::vector< llvm::yaml::Hex8 > UnknownOpcodeData
Definition: DWARFYAML.h:124
This file declares classes for handling the YAML representation of DWARF Debug Info.
std::vector< llvm::yaml::Hex64 > StandardOpcodeData
Definition: DWARFYAML.h:125
std::vector< LineTableOpcode > Opcodes
Definition: DWARFYAML.h:141
llvm::dwarf::Tag Tag
Definition: DWARFYAML.h:56