]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-pdbdump/PdbYaml.h
Merge lldb trunk r300422 and resolve conflicts.
[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 PdbDbiModuleInfo {
69   StringRef Obj;
70   StringRef Mod;
71   std::vector<StringRef> SourceFiles;
72   Optional<PdbModiStream> Modi;
73 };
74
75 struct PdbDbiStream {
76   PdbRaw_DbiVer VerHeader = PdbDbiV70;
77   uint32_t Age = 1;
78   uint16_t BuildNumber = 0;
79   uint32_t PdbDllVersion = 0;
80   uint16_t PdbDllRbld = 0;
81   uint16_t Flags = 1;
82   PDB_Machine MachineType = PDB_Machine::x86;
83
84   std::vector<PdbDbiModuleInfo> ModInfos;
85 };
86
87 struct PdbTpiRecord {
88   codeview::CVType Record;
89 };
90
91 struct PdbTpiFieldListRecord {
92   codeview::CVMemberRecord Record;
93 };
94
95 struct PdbTpiStream {
96   PdbRaw_TpiVer Version = PdbTpiV80;
97   std::vector<PdbTpiRecord> Records;
98 };
99
100 struct PdbObject {
101   explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}
102
103   Optional<MSFHeaders> Headers;
104   Optional<std::vector<uint32_t>> StreamSizes;
105   Optional<std::vector<StreamBlockList>> StreamMap;
106   Optional<PdbInfoStream> PdbStream;
107   Optional<PdbDbiStream> DbiStream;
108   Optional<PdbTpiStream> TpiStream;
109   Optional<PdbTpiStream> IpiStream;
110
111   Optional<std::vector<StringRef>> StringTable;
112
113   BumpPtrAllocator &Allocator;
114 };
115 }
116 }
117 }
118
119 namespace llvm {
120 namespace yaml {
121
122 template <> struct MappingTraits<pdb::yaml::PdbObject> {
123   static void mapping(IO &IO, pdb::yaml::PdbObject &Obj);
124 };
125
126 template <> struct MappingTraits<pdb::yaml::MSFHeaders> {
127   static void mapping(IO &IO, pdb::yaml::MSFHeaders &Obj);
128 };
129
130 template <> struct MappingTraits<msf::SuperBlock> {
131   static void mapping(IO &IO, msf::SuperBlock &SB);
132 };
133
134 template <> struct MappingTraits<pdb::yaml::StreamBlockList> {
135   static void mapping(IO &IO, pdb::yaml::StreamBlockList &SB);
136 };
137
138 template <> struct MappingTraits<pdb::yaml::PdbInfoStream> {
139   static void mapping(IO &IO, pdb::yaml::PdbInfoStream &Obj);
140 };
141
142 template <> struct MappingContextTraits<pdb::yaml::PdbDbiStream, pdb::yaml::SerializationContext> {
143   static void mapping(IO &IO, pdb::yaml::PdbDbiStream &Obj, pdb::yaml::SerializationContext &Context);
144 };
145
146 template <>
147 struct MappingContextTraits<pdb::yaml::PdbTpiStream, pdb::yaml::SerializationContext> {
148   static void mapping(IO &IO, pdb::yaml::PdbTpiStream &Obj,
149     pdb::yaml::SerializationContext &Context);
150 };
151
152 template <> struct MappingTraits<pdb::yaml::NamedStreamMapping> {
153   static void mapping(IO &IO, pdb::yaml::NamedStreamMapping &Obj);
154 };
155
156 template <> struct MappingContextTraits<pdb::yaml::PdbSymbolRecord, pdb::yaml::SerializationContext> {
157   static void mapping(IO &IO, pdb::yaml::PdbSymbolRecord &Obj, pdb::yaml::SerializationContext &Context);
158 };
159
160 template <> struct MappingContextTraits<pdb::yaml::PdbModiStream, pdb::yaml::SerializationContext> {
161   static void mapping(IO &IO, pdb::yaml::PdbModiStream &Obj, pdb::yaml::SerializationContext &Context);
162 };
163
164 template <> struct MappingContextTraits<pdb::yaml::PdbDbiModuleInfo, pdb::yaml::SerializationContext> {
165   static void mapping(IO &IO, pdb::yaml::PdbDbiModuleInfo &Obj, pdb::yaml::SerializationContext &Context);
166 };
167
168 template <>
169 struct MappingContextTraits<pdb::yaml::PdbTpiRecord,
170                             pdb::yaml::SerializationContext> {
171   static void mapping(IO &IO, pdb::yaml::PdbTpiRecord &Obj,
172                       pdb::yaml::SerializationContext &Context);
173 };
174 }
175 }
176
177 #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H