LLVM  8.0.1
DWARFYAML.h
Go to the documentation of this file.
1 //===- DWARFYAML.h - DWARF YAMLIO implementation ----------------*- C++ -*-===//
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 /// \file
11 /// This file declares classes for handling the YAML representation
12 /// of DWARF Debug Info.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_OBJECTYAML_DWARFYAML_H
17 #define LLVM_OBJECTYAML_DWARFYAML_H
18 
19 #include "llvm/ADT/StringRef.h"
22 #include <cstdint>
23 #include <vector>
24 
25 namespace llvm {
26 namespace DWARFYAML {
27 
28 struct InitialLength {
30  uint64_t TotalLength64;
31 
32  bool isDWARF64() const { return TotalLength == UINT32_MAX; }
33 
34  uint64_t getLength() const {
35  return isDWARF64() ? TotalLength64 : TotalLength;
36  }
37 
38  void setLength(uint64_t Len) {
39  if (Len >= (uint64_t)UINT32_MAX) {
40  TotalLength64 = Len;
41  TotalLength = UINT32_MAX;
42  } else {
43  TotalLength = Len;
44  }
45  }
46 };
47 
51  llvm::yaml::Hex64 Value; // Some DWARF5 attributes have values
52 };
53 
54 struct Abbrev {
55  llvm::yaml::Hex32 Code;
58  std::vector<AttributeAbbrev> Attributes;
59 };
60 
62  llvm::yaml::Hex64 Address;
63  uint64_t Length;
64 };
65 
66 struct ARange {
68  uint16_t Version;
70  uint8_t AddrSize;
71  uint8_t SegSize;
72  std::vector<ARangeDescriptor> Descriptors;
73 };
74 
75 struct PubEntry {
76  llvm::yaml::Hex32 DieOffset;
77  llvm::yaml::Hex8 Descriptor;
79 };
80 
81 struct PubSection {
83  uint16_t Version;
86  bool IsGNUStyle = false;
87  std::vector<PubEntry> Entries;
88 };
89 
90 struct FormValue {
91  llvm::yaml::Hex64 Value;
93  std::vector<llvm::yaml::Hex8> BlockData;
94 };
95 
96 struct Entry {
97  llvm::yaml::Hex32 AbbrCode;
98  std::vector<FormValue> Values;
99 };
100 
101 struct Unit {
103  uint16_t Version;
104  llvm::dwarf::UnitType Type; // Added in DWARF 5
106  uint8_t AddrSize;
107  std::vector<Entry> Entries;
108 };
109 
110 struct File {
112  uint64_t DirIdx;
113  uint64_t ModTime;
114  uint64_t Length;
115 };
116 
119  uint64_t ExtLen;
121  uint64_t Data;
122  int64_t SData;
124  std::vector<llvm::yaml::Hex8> UnknownOpcodeData;
125  std::vector<llvm::yaml::Hex64> StandardOpcodeData;
126 };
127 
128 struct LineTable {
130  uint16_t Version;
131  uint64_t PrologueLength;
132  uint8_t MinInstLength;
133  uint8_t MaxOpsPerInst;
134  uint8_t DefaultIsStmt;
135  uint8_t LineBase;
136  uint8_t LineRange;
137  uint8_t OpcodeBase;
138  std::vector<uint8_t> StandardOpcodeLengths;
139  std::vector<StringRef> IncludeDirs;
140  std::vector<File> Files;
141  std::vector<LineTableOpcode> Opcodes;
142 };
143 
144 struct Data {
146  std::vector<Abbrev> AbbrevDecls;
147  std::vector<StringRef> DebugStrings;
148  std::vector<ARange> ARanges;
151 
154 
155  std::vector<Unit> CompileUnits;
156 
157  std::vector<LineTable> DebugLines;
158 
159  bool isEmpty() const;
160 };
161 
162 } // end namespace DWARFYAML
163 } // end namespace llvm
164 
165 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex64)
166 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex8)
167 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev)
168 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)
169 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor)
170 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange)
171 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::PubEntry)
172 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Unit)
173 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::FormValue)
174 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Entry)
175 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::File)
176 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::LineTable)
177 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::LineTableOpcode)
178 
179 namespace llvm {
180 namespace yaml {
181 
182 template <> struct MappingTraits<DWARFYAML::Data> {
183  static void mapping(IO &IO, DWARFYAML::Data &DWARF);
184 };
185 
186 template <> struct MappingTraits<DWARFYAML::Abbrev> {
187  static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev);
188 };
189 
190 template <> struct MappingTraits<DWARFYAML::AttributeAbbrev> {
191  static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev);
192 };
193 
194 template <> struct MappingTraits<DWARFYAML::ARangeDescriptor> {
195  static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor);
196 };
197 
198 template <> struct MappingTraits<DWARFYAML::ARange> {
199  static void mapping(IO &IO, DWARFYAML::ARange &Range);
200 };
201 
202 template <> struct MappingTraits<DWARFYAML::PubEntry> {
203  static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);
204 };
205 
206 template <> struct MappingTraits<DWARFYAML::PubSection> {
207  static void mapping(IO &IO, DWARFYAML::PubSection &Section);
208 };
209 
210 template <> struct MappingTraits<DWARFYAML::Unit> {
211  static void mapping(IO &IO, DWARFYAML::Unit &Unit);
212 };
213 
214 template <> struct MappingTraits<DWARFYAML::Entry> {
215  static void mapping(IO &IO, DWARFYAML::Entry &Entry);
216 };
217 
218 template <> struct MappingTraits<DWARFYAML::FormValue> {
219  static void mapping(IO &IO, DWARFYAML::FormValue &FormValue);
220 };
221 
222 template <> struct MappingTraits<DWARFYAML::File> {
223  static void mapping(IO &IO, DWARFYAML::File &File);
224 };
225 
226 template <> struct MappingTraits<DWARFYAML::LineTableOpcode> {
227  static void mapping(IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode);
228 };
229 
230 template <> struct MappingTraits<DWARFYAML::LineTable> {
231  static void mapping(IO &IO, DWARFYAML::LineTable &LineTable);
232 };
233 
234 template <> struct MappingTraits<DWARFYAML::InitialLength> {
235  static void mapping(IO &IO, DWARFYAML::InitialLength &DWARF);
236 };
237 
238 #define HANDLE_DW_TAG(unused, name, unused2, unused3) \
239  io.enumCase(value, "DW_TAG_" #name, dwarf::DW_TAG_##name);
240 
241 template <> struct ScalarEnumerationTraits<dwarf::Tag> {
242  static void enumeration(IO &io, dwarf::Tag &value) {
243 #include "llvm/BinaryFormat/Dwarf.def"
244  io.enumFallback<Hex16>(value);
245  }
246 };
247 
248 #define HANDLE_DW_LNS(unused, name) \
249  io.enumCase(value, "DW_LNS_" #name, dwarf::DW_LNS_##name);
250 
251 template <> struct ScalarEnumerationTraits<dwarf::LineNumberOps> {
252  static void enumeration(IO &io, dwarf::LineNumberOps &value) {
253 #include "llvm/BinaryFormat/Dwarf.def"
254  io.enumFallback<Hex8>(value);
255  }
256 };
257 
258 #define HANDLE_DW_LNE(unused, name) \
259  io.enumCase(value, "DW_LNE_" #name, dwarf::DW_LNE_##name);
260 
261 template <> struct ScalarEnumerationTraits<dwarf::LineNumberExtendedOps> {
262  static void enumeration(IO &io, dwarf::LineNumberExtendedOps &value) {
263 #include "llvm/BinaryFormat/Dwarf.def"
264  io.enumFallback<Hex16>(value);
265  }
266 };
267 
268 #define HANDLE_DW_AT(unused, name, unused2, unused3) \
269  io.enumCase(value, "DW_AT_" #name, dwarf::DW_AT_##name);
270 
271 template <> struct ScalarEnumerationTraits<dwarf::Attribute> {
272  static void enumeration(IO &io, dwarf::Attribute &value) {
273 #include "llvm/BinaryFormat/Dwarf.def"
274  io.enumFallback<Hex16>(value);
275  }
276 };
277 
278 #define HANDLE_DW_FORM(unused, name, unused2, unused3) \
279  io.enumCase(value, "DW_FORM_" #name, dwarf::DW_FORM_##name);
280 
281 template <> struct ScalarEnumerationTraits<dwarf::Form> {
282  static void enumeration(IO &io, dwarf::Form &value) {
283 #include "llvm/BinaryFormat/Dwarf.def"
284  io.enumFallback<Hex16>(value);
285  }
286 };
287 
288 #define HANDLE_DW_UT(unused, name) \
289  io.enumCase(value, "DW_UT_" #name, dwarf::DW_UT_##name);
290 
291 template <> struct ScalarEnumerationTraits<dwarf::UnitType> {
292  static void enumeration(IO &io, dwarf::UnitType &value) {
293 #include "llvm/BinaryFormat/Dwarf.def"
294  io.enumFallback<Hex8>(value);
295  }
296 };
297 
298 template <> struct ScalarEnumerationTraits<dwarf::Constants> {
299  static void enumeration(IO &io, dwarf::Constants &value) {
300  io.enumCase(value, "DW_CHILDREN_no", dwarf::DW_CHILDREN_no);
301  io.enumCase(value, "DW_CHILDREN_yes", dwarf::DW_CHILDREN_yes);
302  io.enumFallback<Hex16>(value);
303  }
304 };
305 
306 } // end namespace yaml
307 } // end namespace llvm
308 
309 #endif // LLVM_OBJECTYAML_DWARFYAML_H
llvm::dwarf::Constants Children
Definition: DWARFYAML.h:57
PubSection PubNames
Definition: DWARFYAML.h:149
std::vector< AttributeAbbrev > Attributes
Definition: DWARFYAML.h:58
LineNumberOps
Line Number Standard Opcode Encodings.
Definition: Dwarf.h:231
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
Attribute
Attributes.
Definition: Dwarf.h:115
static void enumeration(IO &io, dwarf::LineNumberOps &value)
Definition: DWARFYAML.h:252
std::vector< Abbrev > AbbrevDecls
Definition: DWARFYAML.h:146
InitialLength Length
Definition: DWARFYAML.h:67
static void enumeration(IO &io, dwarf::LineNumberExtendedOps &value)
Definition: DWARFYAML.h:262
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
static void enumeration(IO &io, dwarf::Form &value)
Definition: DWARFYAML.h:282
uint64_t getLength() const
Definition: DWARFYAML.h:34
PubSection GNUPubNames
Definition: DWARFYAML.h:152
std::vector< ARange > ARanges
Definition: DWARFYAML.h:148
std::vector< Unit > CompileUnits
Definition: DWARFYAML.h:155
std::vector< llvm::yaml::Hex8 > BlockData
Definition: DWARFYAML.h:93
static void enumeration(IO &io, dwarf::UnitType &value)
Definition: DWARFYAML.h:292
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
static void enumeration(IO &io, dwarf::Tag &value)
Definition: DWARFYAML.h:242
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
LineNumberExtendedOps
Line Number Extended Opcode Encodings.
Definition: Dwarf.h:237
UnitType
Constants for unit types in DWARF v5.
Definition: Dwarf.h:330
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
This file contains constants used for implementing Dwarf debug support.
std::vector< llvm::yaml::Hex8 > UnknownOpcodeData
Definition: DWARFYAML.h:124
static void enumeration(IO &io, dwarf::Attribute &value)
Definition: DWARFYAML.h:272
std::vector< llvm::yaml::Hex64 > StandardOpcodeData
Definition: DWARFYAML.h:125
std::vector< LineTableOpcode > Opcodes
Definition: DWARFYAML.h:141
void setLength(uint64_t Len)
Definition: DWARFYAML.h:38
llvm::dwarf::Tag Tag
Definition: DWARFYAML.h:56
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static void enumeration(IO &io, dwarf::Constants &value)
Definition: DWARFYAML.h:299