1 | //===- PdbYAML.h ---------------------------------------------- *- C++ --*-===// |
---|---|
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H |
10 | #define LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H |
11 | |
12 | #include "OutputStyle.h" |
13 | |
14 | #include "llvm/BinaryFormat/COFF.h" |
15 | #include "llvm/DebugInfo/CodeView/SymbolRecord.h" |
16 | #include "llvm/DebugInfo/CodeView/TypeRecord.h" |
17 | #include "llvm/DebugInfo/MSF/MSFCommon.h" |
18 | #include "llvm/DebugInfo/PDB/Native/PDBFile.h" |
19 | #include "llvm/DebugInfo/PDB/Native/RawConstants.h" |
20 | #include "llvm/DebugInfo/PDB/PDBTypes.h" |
21 | #include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h" |
22 | #include "llvm/ObjectYAML/CodeViewYAMLSymbols.h" |
23 | #include "llvm/ObjectYAML/CodeViewYAMLTypes.h" |
24 | #include "llvm/Support/Endian.h" |
25 | #include "llvm/Support/YAMLTraits.h" |
26 | |
27 | #include <optional> |
28 | #include <vector> |
29 | |
30 | namespace llvm { |
31 | namespace pdb { |
32 | |
33 | namespace yaml { |
34 | |
35 | struct MSFHeaders { |
36 | msf::SuperBlock SuperBlock; |
37 | uint32_t NumDirectoryBlocks = 0; |
38 | std::vector<uint32_t> DirectoryBlocks; |
39 | uint32_t NumStreams = 0; |
40 | uint64_t FileSize = 0; |
41 | }; |
42 | |
43 | struct StreamBlockList { |
44 | std::vector<uint32_t> Blocks; |
45 | }; |
46 | |
47 | struct NamedStreamMapping { |
48 | StringRef StreamName; |
49 | uint32_t StreamNumber; |
50 | }; |
51 | |
52 | struct PdbInfoStream { |
53 | PdbRaw_ImplVer Version = PdbImplVC70; |
54 | uint32_t Signature = 0; |
55 | uint32_t Age = 1; |
56 | codeview::GUID Guid; |
57 | std::vector<PdbRaw_FeatureSig> Features; |
58 | std::vector<NamedStreamMapping> NamedStreams; |
59 | }; |
60 | |
61 | struct PdbModiStream { |
62 | uint32_t Signature; |
63 | std::vector<CodeViewYAML::SymbolRecord> Symbols; |
64 | }; |
65 | |
66 | struct PdbDbiModuleInfo { |
67 | StringRef Obj; |
68 | StringRef Mod; |
69 | std::vector<StringRef> SourceFiles; |
70 | std::vector<CodeViewYAML::YAMLDebugSubsection> Subsections; |
71 | std::optional<PdbModiStream> Modi; |
72 | }; |
73 | |
74 | struct PdbDbiStream { |
75 | PdbRaw_DbiVer VerHeader = PdbDbiV70; |
76 | uint32_t Age = 1; |
77 | uint16_t BuildNumber = 0; |
78 | uint32_t PdbDllVersion = 0; |
79 | uint16_t PdbDllRbld = 0; |
80 | uint16_t Flags = 1; |
81 | PDB_Machine MachineType = PDB_Machine::x86; |
82 | |
83 | std::vector<PdbDbiModuleInfo> ModInfos; |
84 | COFF::header FakeHeader; |
85 | }; |
86 | |
87 | struct PdbTpiStream { |
88 | PdbRaw_TpiVer Version = PdbTpiV80; |
89 | std::vector<CodeViewYAML::LeafRecord> Records; |
90 | }; |
91 | |
92 | struct PdbPublicsStream { |
93 | std::vector<CodeViewYAML::SymbolRecord> PubSyms; |
94 | }; |
95 | |
96 | struct PdbObject { |
97 | explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {} |
98 | |
99 | std::optional<MSFHeaders> Headers; |
100 | std::optional<std::vector<uint32_t>> StreamSizes; |
101 | std::optional<std::vector<StreamBlockList>> StreamMap; |
102 | std::optional<PdbInfoStream> PdbStream; |
103 | std::optional<PdbDbiStream> DbiStream; |
104 | std::optional<PdbTpiStream> TpiStream; |
105 | std::optional<PdbTpiStream> IpiStream; |
106 | std::optional<PdbPublicsStream> PublicsStream; |
107 | |
108 | std::optional<std::vector<StringRef>> StringTable; |
109 | |
110 | BumpPtrAllocator &Allocator; |
111 | }; |
112 | } |
113 | } |
114 | } |
115 | |
116 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbObject) |
117 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::MSFHeaders) |
118 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(msf::SuperBlock) |
119 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::StreamBlockList) |
120 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbInfoStream) |
121 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbDbiStream) |
122 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbTpiStream) |
123 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbPublicsStream) |
124 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::NamedStreamMapping) |
125 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbModiStream) |
126 | LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(pdb::yaml::PdbDbiModuleInfo) |
127 | |
128 | #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H |
129 |