]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/ObjectYAML/DWARFYAML.h
MFV r316860: 7545 zdb should disable reference tracking
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / ObjectYAML / DWARFYAML.h
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 /// \brief This file declares classes for handling the YAML representation
12 /// of DWARF Debug Info.
13 ///
14 //===----------------------------------------------------------------------===//
15
16
17 #ifndef LLVM_OBJECTYAML_DWARFYAML_H
18 #define LLVM_OBJECTYAML_DWARFYAML_H
19
20 #include "llvm/ObjectYAML/YAML.h"
21 #include "llvm/Support/Dwarf.h"
22
23 namespace llvm {
24 namespace DWARFYAML {
25
26 struct AttributeAbbrev {
27   llvm::dwarf::Attribute Attribute;
28   llvm::dwarf::Form Form;
29 };
30
31 struct Abbrev {
32   llvm::yaml::Hex32 Code;
33   llvm::dwarf::Tag Tag;
34   llvm::dwarf::Constants Children;
35   std::vector<AttributeAbbrev> Attributes;
36 };
37
38 struct ARangeDescriptor {
39   llvm::yaml::Hex64 Address;
40   uint64_t Length;
41 };
42
43 struct ARange {
44   uint32_t Length;
45   uint16_t Version;
46   uint32_t CuOffset;
47   uint8_t AddrSize;
48   uint8_t SegSize;
49   std::vector<ARangeDescriptor> Descriptors;
50 };
51
52 struct PubEntry {
53   llvm::yaml::Hex32 DieOffset;
54   llvm::yaml::Hex8 Descriptor;
55   StringRef Name;
56 };
57
58 struct PubSection {
59   PubSection() : IsGNUStyle(false) {}
60
61   uint32_t Length;
62   uint16_t Version;
63   uint32_t UnitOffset;
64   uint32_t UnitSize;
65   bool IsGNUStyle;
66   std::vector<PubEntry> Entries;
67 };
68
69 struct FormValue {
70   llvm::yaml::Hex64 Value;
71   StringRef CStr;
72   std::vector<llvm::yaml::Hex8> BlockData;
73 };
74
75 struct Entry {
76   llvm::yaml::Hex32 AbbrCode;
77   std::vector<FormValue> Values;
78 };
79
80 struct Unit {
81   uint32_t Length;
82   uint16_t Version;
83   uint32_t AbbrOffset;
84   uint8_t AddrSize;
85   std::vector<Entry> Entries;
86 };
87
88 struct File {
89   StringRef Name;
90   uint64_t DirIdx;
91   uint64_t ModTime;
92   uint64_t Length;
93 };
94
95 struct LineTableOpcode {
96   dwarf::LineNumberOps Opcode;
97   uint64_t ExtLen;
98   dwarf::LineNumberExtendedOps SubOpcode;
99   uint64_t Data;
100   int64_t SData;
101   File FileEntry;
102   std::vector<llvm::yaml::Hex8> UnknownOpcodeData;
103   std::vector<llvm::yaml::Hex64> StandardOpcodeData;
104 };
105
106 struct LineTable {
107   uint32_t TotalLength;
108   uint64_t TotalLength64;
109   uint16_t Version;
110   uint64_t PrologueLength;
111   uint8_t MinInstLength;
112   uint8_t MaxOpsPerInst;
113   uint8_t DefaultIsStmt;
114   uint8_t LineBase;
115   uint8_t LineRange;
116   uint8_t OpcodeBase;
117   std::vector<uint8_t> StandardOpcodeLengths;
118   std::vector<StringRef> IncludeDirs;
119   std::vector<File> Files;
120   std::vector<LineTableOpcode> Opcodes;
121 };
122
123 struct Data {
124   bool IsLittleEndian;
125   std::vector<Abbrev> AbbrevDecls;
126   std::vector<StringRef> DebugStrings;
127   std::vector<ARange> ARanges;
128   PubSection PubNames;
129   PubSection PubTypes;
130
131   PubSection GNUPubNames;
132   PubSection GNUPubTypes;
133   
134   std::vector<Unit> CompileUnits;
135
136   std::vector<LineTable> DebugLines;
137
138   bool isEmpty() const;
139 };
140
141 } // namespace llvm::DWARFYAML
142 } // namespace llvm
143
144 LLVM_YAML_IS_SEQUENCE_VECTOR(uint8_t)
145 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex64)
146 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::StringRef)
147 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex8)
148 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev)
149 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)
150 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor)
151 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange)
152 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::PubEntry)
153 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Unit)
154 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::FormValue)
155 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Entry)
156 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::File)
157 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::LineTable)
158 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::LineTableOpcode)
159
160 namespace llvm {
161 namespace yaml {
162
163 template <> struct MappingTraits<DWARFYAML::Data> {
164   static void mapping(IO &IO, DWARFYAML::Data &DWARF);
165 };
166
167 template <> struct MappingTraits<DWARFYAML::Abbrev> {
168   static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev);
169 };
170
171 template <> struct MappingTraits<DWARFYAML::AttributeAbbrev> {
172   static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev);
173 };
174
175 template <> struct MappingTraits<DWARFYAML::ARangeDescriptor> {
176   static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor);
177 };
178
179 template <> struct MappingTraits<DWARFYAML::ARange> {
180   static void mapping(IO &IO, DWARFYAML::ARange &Range);
181 };
182
183 template <> struct MappingTraits<DWARFYAML::PubEntry> {
184   static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);
185 };
186
187 template <> struct MappingTraits<DWARFYAML::PubSection> {
188   static void mapping(IO &IO, DWARFYAML::PubSection &Section);
189 };
190
191 template <> struct MappingTraits<DWARFYAML::Unit> {
192   static void mapping(IO &IO, DWARFYAML::Unit &Unit);
193 };
194
195 template <> struct MappingTraits<DWARFYAML::Entry> {
196   static void mapping(IO &IO, DWARFYAML::Entry &Entry);
197 };
198
199 template <> struct MappingTraits<DWARFYAML::FormValue> {
200   static void mapping(IO &IO, DWARFYAML::FormValue &FormValue);
201 };
202
203 template <> struct MappingTraits<DWARFYAML::File> {
204   static void mapping(IO &IO, DWARFYAML::File &File);
205 };
206   
207 template <> struct MappingTraits<DWARFYAML::LineTableOpcode> {
208   static void mapping(IO &IO, DWARFYAML::LineTableOpcode &LineTableOpcode);
209 };
210
211 template <> struct MappingTraits<DWARFYAML::LineTable> {
212   static void mapping(IO &IO, DWARFYAML::LineTable &LineTable);
213 };
214
215 #define HANDLE_DW_TAG(unused, name)                                            \
216   io.enumCase(value, "DW_TAG_" #name, dwarf::DW_TAG_##name);
217
218 template <> struct ScalarEnumerationTraits<dwarf::Tag> {
219   static void enumeration(IO &io, dwarf::Tag &value) {
220 #include "llvm/Support/Dwarf.def"
221     io.enumFallback<Hex16>(value);
222   }
223 };
224
225 #define HANDLE_DW_LNS(unused, name)                                            \
226   io.enumCase(value, "DW_LNS_" #name, dwarf::DW_LNS_##name);
227
228 template <> struct ScalarEnumerationTraits<dwarf::LineNumberOps> {
229   static void enumeration(IO &io, dwarf::LineNumberOps &value) {
230 #include "llvm/Support/Dwarf.def"
231     io.enumFallback<Hex8>(value);
232   }
233 };
234
235 #define HANDLE_DW_LNE(unused, name)                                            \
236   io.enumCase(value, "DW_LNE_" #name, dwarf::DW_LNE_##name);
237
238 template <> struct ScalarEnumerationTraits<dwarf::LineNumberExtendedOps> {
239   static void enumeration(IO &io, dwarf::LineNumberExtendedOps &value) {
240 #include "llvm/Support/Dwarf.def"
241     io.enumFallback<Hex16>(value);
242   }
243 };
244
245 #define HANDLE_DW_AT(unused, name)                                             \
246   io.enumCase(value, "DW_AT_" #name, dwarf::DW_AT_##name);
247
248 template <> struct ScalarEnumerationTraits<dwarf::Attribute> {
249   static void enumeration(IO &io, dwarf::Attribute &value) {
250 #include "llvm/Support/Dwarf.def"
251     io.enumFallback<Hex16>(value);
252   }
253 };
254
255 #define HANDLE_DW_FORM(unused, name)                                           \
256   io.enumCase(value, "DW_FORM_" #name, dwarf::DW_FORM_##name);
257
258 template <> struct ScalarEnumerationTraits<dwarf::Form> {
259   static void enumeration(IO &io, dwarf::Form &value) {
260 #include "llvm/Support/Dwarf.def"
261     io.enumFallback<Hex16>(value);
262   }
263 };
264
265 template <> struct ScalarEnumerationTraits<dwarf::Constants> {
266   static void enumeration(IO &io, dwarf::Constants &value) {
267     io.enumCase(value, "DW_CHILDREN_no", dwarf::DW_CHILDREN_no);
268     io.enumCase(value, "DW_CHILDREN_yes", dwarf::DW_CHILDREN_yes);
269     io.enumFallback<Hex16>(value);
270   }
271 };
272
273 } // namespace llvm::yaml
274 } // namespace llvm
275
276 #endif