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/ADT/Optional.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 <vector>
28
29namespace llvm {
30namespace codeview {
31class DebugStringTableSubsection;
32}
33namespace pdb {
34
35namespace yaml {
36struct SerializationContext;
37
38struct MSFHeaders {
39  msf::SuperBlock SuperBlock;
40  uint32_t NumDirectoryBlocks = 0;
41  std::vector<uint32_t> DirectoryBlocks;
42  uint32_t NumStreams = 0;
43  uint32_t FileSize = 0;
44};
45
46struct StreamBlockList {
47  std::vector<uint32_t> Blocks;
48};
49
50struct NamedStreamMapping {
51  StringRef StreamName;
52  uint32_t StreamNumber;
53};
54
55struct PdbInfoStream {
56  PdbRaw_ImplVer Version = PdbImplVC70;
57  uint32_t Signature = 0;
58  uint32_t Age = 1;
59  codeview::GUID Guid;
60  std::vector<PdbRaw_FeatureSig> Features;
61  std::vector<NamedStreamMapping> NamedStreams;
62};
63
64struct PdbModiStream {
65  uint32_t Signature;
66  std::vector<CodeViewYAML::SymbolRecord> Symbols;
67};
68
69struct PdbDbiModuleInfo {
70  StringRef Obj;
71  StringRef Mod;
72  std::vector<StringRef> SourceFiles;
73  std::vector<CodeViewYAML::YAMLDebugSubsection> Subsections;
74  Optional<PdbModiStream> Modi;
75};
76
77struct PdbDbiStream {
78  PdbRaw_DbiVer VerHeader = PdbDbiV70;
79  uint32_t Age = 1;
80  uint16_t BuildNumber = 0;
81  uint32_t PdbDllVersion = 0;
82  uint16_t PdbDllRbld = 0;
83  uint16_t Flags = 1;
84  PDB_Machine MachineType = PDB_Machine::x86;
85
86  std::vector<PdbDbiModuleInfo> ModInfos;
87};
88
89struct PdbTpiStream {
90  PdbRaw_TpiVer Version = PdbTpiV80;
91  std::vector<CodeViewYAML::LeafRecord> Records;
92};
93
94struct PdbPublicsStream {
95  std::vector<CodeViewYAML::SymbolRecord> PubSyms;
96};
97
98struct PdbObject {
99  explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}
100
101  Optional<MSFHeaders> Headers;
102  Optional<std::vector<uint32_t>> StreamSizes;
103  Optional<std::vector<StreamBlockList>> StreamMap;
104  Optional<PdbInfoStream> PdbStream;
105  Optional<PdbDbiStream> DbiStream;
106  Optional<PdbTpiStream> TpiStream;
107  Optional<PdbTpiStream> IpiStream;
108  Optional<PdbPublicsStream> PublicsStream;
109
110  Optional<std::vector<StringRef>> StringTable;
111
112  BumpPtrAllocator &Allocator;
113};
114}
115}
116}
117
118LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbObject)
119LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::MSFHeaders)
120LLVM_YAML_DECLARE_MAPPING_TRAITS(msf::SuperBlock)
121LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::StreamBlockList)
122LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream)
123LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream)
124LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream)
125LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbPublicsStream)
126LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping)
127LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream)
128LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo)
129
130#endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
131