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 PdbObject { PdbObjectPdbObject96 explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {} 97 98 Optional<MSFHeaders> Headers; 99 Optional<std::vector<uint32_t>> StreamSizes; 100 Optional<std::vector<StreamBlockList>> StreamMap; 101 Optional<PdbInfoStream> PdbStream; 102 Optional<PdbDbiStream> DbiStream; 103 Optional<PdbTpiStream> TpiStream; 104 Optional<PdbTpiStream> IpiStream; 105 106 Optional<std::vector<StringRef>> StringTable; 107 108 BumpPtrAllocator &Allocator; 109 }; 110 } 111 } 112 } 113 114 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbObject) 115 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::MSFHeaders) 116 LLVM_YAML_DECLARE_MAPPING_TRAITS(msf::SuperBlock) 117 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::StreamBlockList) 118 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream) 119 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream) 120 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream) 121 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping) 122 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream) 123 LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo) 124 125 #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H 126