PdbYaml.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. #ifndef LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
  9. #define LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
  10. #include "OutputStyle.h"
  11. #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
  12. #include "llvm/DebugInfo/CodeView/TypeRecord.h"
  13. #include "llvm/DebugInfo/MSF/MSFCommon.h"
  14. #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
  15. #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
  16. #include "llvm/DebugInfo/PDB/PDBTypes.h"
  17. #include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h"
  18. #include "llvm/ObjectYAML/CodeViewYAMLSymbols.h"
  19. #include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
  20. #include "llvm/Support/Endian.h"
  21. #include "llvm/Support/YAMLTraits.h"
  22. #include <optional>
  23. #include <vector>
  24. namespace llvm {
  25. namespace pdb {
  26. namespace yaml {
  27. struct MSFHeaders {
  28. msf::SuperBlock SuperBlock;
  29. uint32_t NumDirectoryBlocks = 0;
  30. std::vector<uint32_t> DirectoryBlocks;
  31. uint32_t NumStreams = 0;
  32. uint64_t FileSize = 0;
  33. };
  34. struct StreamBlockList {
  35. std::vector<uint32_t> Blocks;
  36. };
  37. struct NamedStreamMapping {
  38. StringRef StreamName;
  39. uint32_t StreamNumber;
  40. };
  41. struct PdbInfoStream {
  42. PdbRaw_ImplVer Version = PdbImplVC70;
  43. uint32_t Signature = 0;
  44. uint32_t Age = 1;
  45. codeview::GUID Guid;
  46. std::vector<PdbRaw_FeatureSig> Features;
  47. std::vector<NamedStreamMapping> NamedStreams;
  48. };
  49. struct PdbModiStream {
  50. uint32_t Signature;
  51. std::vector<CodeViewYAML::SymbolRecord> Symbols;
  52. };
  53. struct PdbDbiModuleInfo {
  54. StringRef Obj;
  55. StringRef Mod;
  56. std::vector<StringRef> SourceFiles;
  57. std::vector<CodeViewYAML::YAMLDebugSubsection> Subsections;
  58. std::optional<PdbModiStream> Modi;
  59. };
  60. struct PdbDbiStream {
  61. PdbRaw_DbiVer VerHeader = PdbDbiV70;
  62. uint32_t Age = 1;
  63. uint16_t BuildNumber = 0;
  64. uint32_t PdbDllVersion = 0;
  65. uint16_t PdbDllRbld = 0;
  66. uint16_t Flags = 1;
  67. PDB_Machine MachineType = PDB_Machine::x86;
  68. std::vector<PdbDbiModuleInfo> ModInfos;
  69. };
  70. struct PdbTpiStream {
  71. PdbRaw_TpiVer Version = PdbTpiV80;
  72. std::vector<CodeViewYAML::LeafRecord> Records;
  73. };
  74. struct PdbPublicsStream {
  75. std::vector<CodeViewYAML::SymbolRecord> PubSyms;
  76. };
  77. struct PdbObject {
  78. explicit PdbObject(BumpPtrAllocator &Allocator) : Allocator(Allocator) {}
  79. std::optional<MSFHeaders> Headers;
  80. std::optional<std::vector<uint32_t>> StreamSizes;
  81. std::optional<std::vector<StreamBlockList>> StreamMap;
  82. std::optional<PdbInfoStream> PdbStream;
  83. std::optional<PdbDbiStream> DbiStream;
  84. std::optional<PdbTpiStream> TpiStream;
  85. std::optional<PdbTpiStream> IpiStream;
  86. std::optional<PdbPublicsStream> PublicsStream;
  87. std::optional<std::vector<StringRef>> StringTable;
  88. BumpPtrAllocator &Allocator;
  89. };
  90. }
  91. }
  92. }
  93. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbObject)
  94. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::MSFHeaders)
  95. LLVM_YAML_DECLARE_MAPPING_TRAITS(msf::SuperBlock)
  96. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::StreamBlockList)
  97. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbInfoStream)
  98. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiStream)
  99. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbTpiStream)
  100. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbPublicsStream)
  101. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::NamedStreamMapping)
  102. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbModiStream)
  103. LLVM_YAML_DECLARE_MAPPING_TRAITS(pdb::yaml::PdbDbiModuleInfo)
  104. #endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H