]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-pdbdump/PdbYaml.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304222, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / llvm-pdbdump / PdbYaml.h
1 //===- PdbYAML.h ---------------------------------------------- *- 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 #ifndef LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
11 #define LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
12
13 #include "OutputStyle.h"
14
15 #include "llvm/ADT/Optional.h"
16 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
17 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
18 #include "llvm/DebugInfo/MSF/MSFCommon.h"
19 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
20 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
21 #include "llvm/DebugInfo/PDB/PDBTypes.h"
22 #include "llvm/Support/Endian.h"
23 #include "llvm/Support/YAMLTraits.h"
24
25 #include <vector>
26
27 namespace llvm {
28 namespace pdb {
29
30 namespace yaml {
31 struct SerializationContext;
32
33 struct MSFHeaders {
34   msf::SuperBlock SuperBlock;
35   uint32_t NumDirectoryBlocks = 0;
36   std::vector<uint32_t> DirectoryBlocks;
37   uint32_t NumStreams = 0;
38   uint32_t FileSize = 0;
39 };
40
41 struct StreamBlockList {
42   std::vector<uint32_t> Blocks;
43 };
44
45 struct NamedStreamMapping {
46   StringRef StreamName;
47   uint32_t StreamNumber;
48 };
49
50 struct PdbInfoStream {
51   PdbRaw_ImplVer Version = PdbImplVC70;
52   uint32_t Signature = 0;
53   uint32_t Age = 1;
54   PDB_UniqueId Guid;
55   std::vector<PdbRaw_FeatureSig> Features;
56   std::vector<NamedStreamMapping> NamedStreams;
57 };
58
59 struct PdbSymbolRecord {
60   codeview::CVSymbol Record;
61 };
62
63 struct PdbModiStream {
64   uint32_t Signature;
65   std::vector<PdbSymbolRecord> Symbols;
66 };
67
68 struct PdbSourceLineEntry {
69   uint32_t Offset;
70   uint32_t LineStart;
71   uint32_t EndDelta;
72   bool IsStatement;
73 };
74
75 struct PdbSourceColumnEntry {
76   uint16_t StartColumn;
77   uint16_t EndColumn;
78 };
79
80 struct PdbSourceLineBlock {
81   StringRef FileName;
82   std::vector<PdbSourceLineEntry> Lines;
83   std::vector<PdbSourceColumnEntry> Columns;
84 };
85
86 struct HexFormattedString {
87   std::vector<uint8_t> Bytes;
88 };
89
90 struct PdbSourceFileChecksumEntry {
91   StringRef FileName;
92   codeview::FileChecksumKind Kind;
93   HexFormattedString ChecksumBytes;
94 };
95
96 struct PdbSourceLineInfo {
97   uint32_t RelocOffset;
98   uint32_t RelocSegment;
99   codeview::LineFlags Flags;
100   uint32_t CodeSize;
101
102   std::vector<PdbSourceLineBlock> Blocks;
103 };
104
105 struct PdbInlineeSite {
106   codeview::TypeIndex Inlinee;
107   StringRef FileName;
108   uint32_t SourceLineNum;
109   std::vector<StringRef> ExtraFiles;
110 };
111
112 struct PdbInlineeInfo {
113   bool HasExtraFiles;
114   std::vector<PdbInlineeSite> Sites;
115 };
116
117 struct PdbSourceFileInfo {
118   std::vector<PdbSourceFileChecksumEntry> FileChecksums;
119   std::vector<PdbSourceLineInfo> LineFragments;
120   std::vector<PdbInlineeInfo> Inlinees;
121 };
122
123 struct PdbDbiModuleInfo {
124   StringRef Obj;
125   StringRef Mod;
126   std::vector<StringRef> SourceFiles;
127   Optional<PdbSourceFileInfo> FileLineInfo;
128   Optional<PdbModiStream> Modi;
129 };
130
131 struct PdbDbiStream {
132   PdbRaw_DbiVer VerHeader = PdbDbiV70;
133   uint32_t Age = 1;
134   uint16_t BuildNumber = 0;
135   uint32_t PdbDllVersion = 0;
136   uint16_t PdbDllRbld = 0;
137   uint16_t Flags = 1;
138   PDB_Machine MachineType = PDB_Machine::x86;
139
140   std::vector<PdbDbiModuleInfo> ModInfos;
141 };
142
143 struct PdbTpiRecord {
144   codeview::CVType Record;
145 };
146
147 struct PdbTpiFieldListRecord {
148   codeview::CVMemberRecord Record;
149 };
150
151 struct PdbTpiStream {
152   PdbRaw_TpiVer Version = PdbTpiV80;
153   std::vector<PdbTpiRecord> Records;
154 };
155
156 struct PdbObject {
157   explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}
158
159   Optional<MSFHeaders> Headers;
160   Optional<std::vector<uint32_t>> StreamSizes;
161   Optional<std::vector<StreamBlockList>> StreamMap;
162   Optional<PdbInfoStream> PdbStream;
163   Optional<PdbDbiStream> DbiStream;
164   Optional<PdbTpiStream> TpiStream;
165   Optional<PdbTpiStream> IpiStream;
166
167   Optional<std::vector<StringRef>> StringTable;
168
169   BumpPtrAllocator &Allocator;
170 };
171 }
172 }
173 }
174
175 namespace llvm {
176 namespace yaml {
177
178 template <> struct MappingTraits<pdb::yaml::PdbObject> {
179   static void mapping(IO &IO, pdb::yaml::PdbObject &Obj);
180 };
181
182 template <> struct MappingTraits<pdb::yaml::MSFHeaders> {
183   static void mapping(IO &IO, pdb::yaml::MSFHeaders &Obj);
184 };
185
186 template <> struct MappingTraits<msf::SuperBlock> {
187   static void mapping(IO &IO, msf::SuperBlock &SB);
188 };
189
190 template <> struct MappingTraits<pdb::yaml::StreamBlockList> {
191   static void mapping(IO &IO, pdb::yaml::StreamBlockList &SB);
192 };
193
194 template <> struct MappingTraits<pdb::yaml::PdbInfoStream> {
195   static void mapping(IO &IO, pdb::yaml::PdbInfoStream &Obj);
196 };
197
198 template <> struct MappingContextTraits<pdb::yaml::PdbDbiStream, pdb::yaml::SerializationContext> {
199   static void mapping(IO &IO, pdb::yaml::PdbDbiStream &Obj, pdb::yaml::SerializationContext &Context);
200 };
201
202 template <>
203 struct MappingContextTraits<pdb::yaml::PdbTpiStream, pdb::yaml::SerializationContext> {
204   static void mapping(IO &IO, pdb::yaml::PdbTpiStream &Obj,
205     pdb::yaml::SerializationContext &Context);
206 };
207
208 template <> struct MappingTraits<pdb::yaml::NamedStreamMapping> {
209   static void mapping(IO &IO, pdb::yaml::NamedStreamMapping &Obj);
210 };
211
212 template <> struct MappingContextTraits<pdb::yaml::PdbSymbolRecord, pdb::yaml::SerializationContext> {
213   static void mapping(IO &IO, pdb::yaml::PdbSymbolRecord &Obj, pdb::yaml::SerializationContext &Context);
214 };
215
216 template <> struct MappingContextTraits<pdb::yaml::PdbModiStream, pdb::yaml::SerializationContext> {
217   static void mapping(IO &IO, pdb::yaml::PdbModiStream &Obj, pdb::yaml::SerializationContext &Context);
218 };
219
220 template <> struct MappingContextTraits<pdb::yaml::PdbDbiModuleInfo, pdb::yaml::SerializationContext> {
221   static void mapping(IO &IO, pdb::yaml::PdbDbiModuleInfo &Obj, pdb::yaml::SerializationContext &Context);
222 };
223
224 template <>
225 struct MappingContextTraits<pdb::yaml::PdbSourceLineEntry,
226                             pdb::yaml::SerializationContext> {
227   static void mapping(IO &IO, pdb::yaml::PdbSourceLineEntry &Obj,
228                       pdb::yaml::SerializationContext &Context);
229 };
230
231 template <>
232 struct MappingContextTraits<pdb::yaml::PdbSourceColumnEntry,
233                             pdb::yaml::SerializationContext> {
234   static void mapping(IO &IO, pdb::yaml::PdbSourceColumnEntry &Obj,
235                       pdb::yaml::SerializationContext &Context);
236 };
237
238 template <>
239 struct MappingContextTraits<pdb::yaml::PdbSourceLineBlock,
240                             pdb::yaml::SerializationContext> {
241   static void mapping(IO &IO, pdb::yaml::PdbSourceLineBlock &Obj,
242                       pdb::yaml::SerializationContext &Context);
243 };
244
245 template <>
246 struct MappingContextTraits<pdb::yaml::PdbSourceFileChecksumEntry,
247                             pdb::yaml::SerializationContext> {
248   static void mapping(IO &IO, pdb::yaml::PdbSourceFileChecksumEntry &Obj,
249                       pdb::yaml::SerializationContext &Context);
250 };
251
252 template <> struct ScalarTraits<pdb::yaml::HexFormattedString> {
253   static void output(const pdb::yaml::HexFormattedString &Value, void *ctx,
254                      llvm::raw_ostream &Out);
255   static StringRef input(StringRef Scalar, void *ctxt,
256                          pdb::yaml::HexFormattedString &Value);
257   static bool mustQuote(StringRef) { return false; }
258 };
259
260 template <>
261 struct MappingContextTraits<pdb::yaml::PdbSourceLineInfo,
262                             pdb::yaml::SerializationContext> {
263   static void mapping(IO &IO, pdb::yaml::PdbSourceLineInfo &Obj,
264                       pdb::yaml::SerializationContext &Context);
265 };
266
267 template <>
268 struct MappingContextTraits<pdb::yaml::PdbSourceFileInfo,
269                             pdb::yaml::SerializationContext> {
270   static void mapping(IO &IO, pdb::yaml::PdbSourceFileInfo &Obj,
271                       pdb::yaml::SerializationContext &Context);
272 };
273
274 template <>
275 struct MappingContextTraits<pdb::yaml::PdbInlineeInfo,
276                             pdb::yaml::SerializationContext> {
277   static void mapping(IO &IO, pdb::yaml::PdbInlineeInfo &Obj,
278                       pdb::yaml::SerializationContext &Context);
279 };
280
281 template <>
282 struct MappingContextTraits<pdb::yaml::PdbInlineeSite,
283                             pdb::yaml::SerializationContext> {
284   static void mapping(IO &IO, pdb::yaml::PdbInlineeSite &Obj,
285                       pdb::yaml::SerializationContext &Context);
286 };
287
288 template <>
289 struct MappingContextTraits<pdb::yaml::PdbTpiRecord,
290                             pdb::yaml::SerializationContext> {
291   static void mapping(IO &IO, pdb::yaml::PdbTpiRecord &Obj,
292                       pdb::yaml::SerializationContext &Context);
293 };
294 }
295 }
296
297 #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H