]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-pdbdump/PdbYaml.h
Merge ^/head r312720 through r312893.
[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/PDBTypes.h"
20 #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
21 #include "llvm/DebugInfo/PDB/Raw/RawConstants.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;
36   std::vector<uint32_t> DirectoryBlocks;
37   uint32_t NumStreams;
38   uint32_t FileSize;
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;
52   uint32_t Signature;
53   uint32_t Age;
54   PDB_UniqueId Guid;
55   std::vector<NamedStreamMapping> NamedStreams;
56 };
57
58 struct PdbSymbolRecord {
59   codeview::CVSymbol Record;
60 };
61
62 struct PdbModiStream {
63   uint32_t Signature;
64   std::vector<PdbSymbolRecord> Symbols;
65 };
66
67 struct PdbDbiModuleInfo {
68   StringRef Obj;
69   StringRef Mod;
70   std::vector<StringRef> SourceFiles;
71   Optional<PdbModiStream> Modi;
72 };
73
74 struct PdbDbiStream {
75   PdbRaw_DbiVer VerHeader;
76   uint32_t Age;
77   uint16_t BuildNumber;
78   uint32_t PdbDllVersion;
79   uint16_t PdbDllRbld;
80   uint16_t Flags;
81   PDB_Machine MachineType;
82
83   std::vector<PdbDbiModuleInfo> ModInfos;
84 };
85
86 struct PdbTpiRecord {
87   codeview::CVType Record;
88 };
89
90 struct PdbTpiFieldListRecord {
91   codeview::CVMemberRecord Record;
92 };
93
94 struct PdbTpiStream {
95   PdbRaw_TpiVer Version;
96   std::vector<PdbTpiRecord> Records;
97 };
98
99 struct PdbObject {
100   explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}
101
102   Optional<MSFHeaders> Headers;
103   Optional<std::vector<uint32_t>> StreamSizes;
104   Optional<std::vector<StreamBlockList>> StreamMap;
105   Optional<PdbInfoStream> PdbStream;
106   Optional<PdbDbiStream> DbiStream;
107   Optional<PdbTpiStream> TpiStream;
108   Optional<PdbTpiStream> IpiStream;
109
110   BumpPtrAllocator &Allocator;
111 };
112 }
113 }
114 }
115
116 namespace llvm {
117 namespace yaml {
118
119 template <> struct MappingTraits<pdb::yaml::PdbObject> {
120   static void mapping(IO &IO, pdb::yaml::PdbObject &Obj);
121 };
122
123 template <> struct MappingTraits<pdb::yaml::MSFHeaders> {
124   static void mapping(IO &IO, pdb::yaml::MSFHeaders &Obj);
125 };
126
127 template <> struct MappingTraits<msf::SuperBlock> {
128   static void mapping(IO &IO, msf::SuperBlock &SB);
129 };
130
131 template <> struct MappingTraits<pdb::yaml::StreamBlockList> {
132   static void mapping(IO &IO, pdb::yaml::StreamBlockList &SB);
133 };
134
135 template <> struct MappingTraits<pdb::yaml::PdbInfoStream> {
136   static void mapping(IO &IO, pdb::yaml::PdbInfoStream &Obj);
137 };
138
139 template <> struct MappingTraits<pdb::yaml::PdbDbiStream> {
140   static void mapping(IO &IO, pdb::yaml::PdbDbiStream &Obj);
141 };
142
143 template <>
144 struct MappingContextTraits<pdb::yaml::PdbTpiStream, llvm::BumpPtrAllocator> {
145   static void mapping(IO &IO, pdb::yaml::PdbTpiStream &Obj,
146                       llvm::BumpPtrAllocator &Allocator);
147 };
148
149 template <> struct MappingTraits<pdb::yaml::NamedStreamMapping> {
150   static void mapping(IO &IO, pdb::yaml::NamedStreamMapping &Obj);
151 };
152
153 template <> struct MappingTraits<pdb::yaml::PdbSymbolRecord> {
154   static void mapping(IO &IO, pdb::yaml::PdbSymbolRecord &Obj);
155 };
156
157 template <> struct MappingTraits<pdb::yaml::PdbModiStream> {
158   static void mapping(IO &IO, pdb::yaml::PdbModiStream &Obj);
159 };
160
161 template <> struct MappingTraits<pdb::yaml::PdbDbiModuleInfo> {
162   static void mapping(IO &IO, pdb::yaml::PdbDbiModuleInfo &Obj);
163 };
164
165 template <>
166 struct MappingContextTraits<pdb::yaml::PdbTpiRecord,
167                             pdb::yaml::SerializationContext> {
168   static void mapping(IO &IO, pdb::yaml::PdbTpiRecord &Obj,
169                       pdb::yaml::SerializationContext &Context);
170 };
171 }
172 }
173
174 #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H