]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/llvm-pdbutil/PdbYaml.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / llvm-pdbutil / 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/ObjectYAML/CodeViewYAMLDebugSections.h"
23 #include "llvm/ObjectYAML/CodeViewYAMLSymbols.h"
24 #include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
25 #include "llvm/Support/Endian.h"
26 #include "llvm/Support/YAMLTraits.h"
27
28 #include <vector>
29
30 namespace llvm {
31 namespace codeview {
32 class DebugStringTableSubsection;
33 }
34 namespace pdb {
35
36 namespace yaml {
37 struct SerializationContext;
38
39 struct MSFHeaders {
40   msf::SuperBlock SuperBlock;
41   uint32_t NumDirectoryBlocks = 0;
42   std::vector<uint32_t> DirectoryBlocks;
43   uint32_t NumStreams = 0;
44   uint32_t FileSize = 0;
45 };
46
47 struct StreamBlockList {
48   std::vector<uint32_t> Blocks;
49 };
50
51 struct NamedStreamMapping {
52   StringRef StreamName;
53   uint32_t StreamNumber;
54 };
55
56 struct PdbInfoStream {
57   PdbRaw_ImplVer Version = PdbImplVC70;
58   uint32_t Signature = 0;
59   uint32_t Age = 1;
60   codeview::GUID Guid;
61   std::vector<PdbRaw_FeatureSig> Features;
62   std::vector<NamedStreamMapping> NamedStreams;
63 };
64
65 struct PdbModiStream {
66   uint32_t Signature;
67   std::vector<CodeViewYAML::SymbolRecord> Symbols;
68 };
69
70 struct PdbDbiModuleInfo {
71   StringRef Obj;
72   StringRef Mod;
73   std::vector<StringRef> SourceFiles;
74   std::vector<CodeViewYAML::YAMLDebugSubsection> Subsections;
75   Optional<PdbModiStream> Modi;
76 };
77
78 struct PdbDbiStream {
79   PdbRaw_DbiVer VerHeader = PdbDbiV70;
80   uint32_t Age = 1;
81   uint16_t BuildNumber = 0;
82   uint32_t PdbDllVersion = 0;
83   uint16_t PdbDllRbld = 0;
84   uint16_t Flags = 1;
85   PDB_Machine MachineType = PDB_Machine::x86;
86
87   std::vector<PdbDbiModuleInfo> ModInfos;
88 };
89
90 struct PdbTpiStream {
91   PdbRaw_TpiVer Version = PdbTpiV80;
92   std::vector<CodeViewYAML::LeafRecord> Records;
93 };
94
95 struct PdbPublicsStream {
96   std::vector<CodeViewYAML::SymbolRecord> PubSyms;
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   Optional<PdbPublicsStream> PublicsStream;
110
111   Optional<std::vector<StringRef>> StringTable;
112
113   BumpPtrAllocator &Allocator;
114 };
115 }
116 }
117 }
118
119 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbObject)
120 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::MSFHeaders)
121 LLVM_YAML_DECLARE_MAPPING_TRAITS(msf::SuperBlock)
122 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::StreamBlockList)
123 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream)
124 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream)
125 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream)
126 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbPublicsStream)
127 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping)
128 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream)
129 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo)
130
131 #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H