]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/ObjectYAML/DWARFYAML.h
Merge ^/head r311812 through r311939.
[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 Data {
89   bool IsLittleEndian;
90   std::vector<Abbrev> AbbrevDecls;
91   std::vector<StringRef> DebugStrings;
92   std::vector<ARange> ARanges;
93   PubSection PubNames;
94   PubSection PubTypes;
95
96   PubSection GNUPubNames;
97   PubSection GNUPubTypes;
98   
99   std::vector<Unit> CompileUnits;
100
101   bool isEmpty() const;
102 };
103
104 } // namespace llvm::DWARFYAML
105 } // namespace llvm
106
107 LLVM_YAML_IS_SEQUENCE_VECTOR(uint8_t)
108 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::StringRef)
109 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::Hex8)
110 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::AttributeAbbrev)
111 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Abbrev)
112 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARangeDescriptor)
113 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::ARange)
114 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::PubEntry)
115 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Unit)
116 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::FormValue)
117 LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::DWARFYAML::Entry)
118
119 namespace llvm {
120 namespace yaml {
121
122 template <> struct MappingTraits<DWARFYAML::Data> {
123   static void mapping(IO &IO, DWARFYAML::Data &DWARF);
124 };
125
126 template <> struct MappingTraits<DWARFYAML::Abbrev> {
127   static void mapping(IO &IO, DWARFYAML::Abbrev &Abbrev);
128 };
129
130 template <> struct MappingTraits<DWARFYAML::AttributeAbbrev> {
131   static void mapping(IO &IO, DWARFYAML::AttributeAbbrev &AttAbbrev);
132 };
133
134 template <> struct MappingTraits<DWARFYAML::ARangeDescriptor> {
135   static void mapping(IO &IO, DWARFYAML::ARangeDescriptor &Descriptor);
136 };
137
138 template <> struct MappingTraits<DWARFYAML::ARange> {
139   static void mapping(IO &IO, DWARFYAML::ARange &Range);
140 };
141
142 template <> struct MappingTraits<DWARFYAML::PubEntry> {
143   static void mapping(IO &IO, DWARFYAML::PubEntry &Entry);
144 };
145
146 template <> struct MappingTraits<DWARFYAML::PubSection> {
147   static void mapping(IO &IO, DWARFYAML::PubSection &Section);
148 };
149
150 template <> struct MappingTraits<DWARFYAML::Unit> {
151   static void mapping(IO &IO, DWARFYAML::Unit &Unit);
152 };
153
154 template <> struct MappingTraits<DWARFYAML::Entry> {
155   static void mapping(IO &IO, DWARFYAML::Entry &Entry);
156 };
157
158 template <> struct MappingTraits<DWARFYAML::FormValue> {
159   static void mapping(IO &IO, DWARFYAML::FormValue &FormValue);
160 };
161
162 #define HANDLE_DW_TAG(unused, name)                                            \
163   io.enumCase(value, "DW_TAG_" #name, dwarf::DW_TAG_##name);
164
165 template <> struct ScalarEnumerationTraits<dwarf::Tag> {
166   static void enumeration(IO &io, dwarf::Tag &value) {
167 #include "llvm/Support/Dwarf.def"
168     io.enumFallback<Hex16>(value);
169   }
170 };
171
172 #define HANDLE_DW_AT(unused, name)                                             \
173   io.enumCase(value, "DW_AT_" #name, dwarf::DW_AT_##name);
174
175 template <> struct ScalarEnumerationTraits<dwarf::Attribute> {
176   static void enumeration(IO &io, dwarf::Attribute &value) {
177 #include "llvm/Support/Dwarf.def"
178     io.enumFallback<Hex16>(value);
179   }
180 };
181
182 #define HANDLE_DW_FORM(unused, name)                                           \
183   io.enumCase(value, "DW_FORM_" #name, dwarf::DW_FORM_##name);
184
185 template <> struct ScalarEnumerationTraits<dwarf::Form> {
186   static void enumeration(IO &io, dwarf::Form &value) {
187 #include "llvm/Support/Dwarf.def"
188     io.enumFallback<Hex16>(value);
189   }
190 };
191
192 template <> struct ScalarEnumerationTraits<dwarf::Constants> {
193   static void enumeration(IO &io, dwarf::Constants &value) {
194     io.enumCase(value, "DW_CHILDREN_no", dwarf::DW_CHILDREN_no);
195     io.enumCase(value, "DW_CHILDREN_yes", dwarf::DW_CHILDREN_yes);
196     io.enumFallback<Hex16>(value);
197   }
198 };
199
200 } // namespace llvm::yaml
201 } // namespace llvm
202
203 #endif