DbiStream.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DbiStream.h - PDB Dbi Stream (Stream 3) Access -----------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAM_H
  14. #define LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAM_H
  15. #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
  16. #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
  17. #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
  18. #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
  19. #include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
  20. #include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
  21. #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
  22. #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
  23. #include "llvm/DebugInfo/PDB/PDBTypes.h"
  24. #include "llvm/Support/BinaryStreamArray.h"
  25. #include "llvm/Support/BinaryStreamRef.h"
  26. #include "llvm/Support/Endian.h"
  27. #include "llvm/Support/Error.h"
  28. namespace llvm {
  29. namespace object {
  30. struct FpoData;
  31. struct coff_section;
  32. }
  33. namespace pdb {
  34. class DbiStreamBuilder;
  35. class PDBFile;
  36. class ISectionContribVisitor;
  37. class DbiStream {
  38. friend class DbiStreamBuilder;
  39. public:
  40. explicit DbiStream(std::unique_ptr<BinaryStream> Stream);
  41. ~DbiStream();
  42. Error reload(PDBFile *Pdb);
  43. PdbRaw_DbiVer getDbiVersion() const;
  44. uint32_t getAge() const;
  45. uint16_t getPublicSymbolStreamIndex() const;
  46. uint16_t getGlobalSymbolStreamIndex() const;
  47. uint16_t getFlags() const;
  48. bool isIncrementallyLinked() const;
  49. bool hasCTypes() const;
  50. bool isStripped() const;
  51. uint16_t getBuildNumber() const;
  52. uint16_t getBuildMajorVersion() const;
  53. uint16_t getBuildMinorVersion() const;
  54. uint16_t getPdbDllRbld() const;
  55. uint32_t getPdbDllVersion() const;
  56. uint32_t getSymRecordStreamIndex() const;
  57. PDB_Machine getMachineType() const;
  58. const DbiStreamHeader *getHeader() const { return Header; }
  59. BinarySubstreamRef getSectionContributionData() const;
  60. BinarySubstreamRef getSecMapSubstreamData() const;
  61. BinarySubstreamRef getModiSubstreamData() const;
  62. BinarySubstreamRef getFileInfoSubstreamData() const;
  63. BinarySubstreamRef getTypeServerMapSubstreamData() const;
  64. BinarySubstreamRef getECSubstreamData() const;
  65. /// If the given stream type is present, returns its stream index. If it is
  66. /// not present, returns InvalidStreamIndex.
  67. uint32_t getDebugStreamIndex(DbgHeaderType Type) const;
  68. const DbiModuleList &modules() const;
  69. FixedStreamArray<object::coff_section> getSectionHeaders() const;
  70. bool hasOldFpoRecords() const;
  71. FixedStreamArray<object::FpoData> getOldFpoRecords() const;
  72. bool hasNewFpoRecords() const;
  73. const codeview::DebugFrameDataSubsectionRef &getNewFpoRecords() const;
  74. FixedStreamArray<SecMapEntry> getSectionMap() const;
  75. void visitSectionContributions(ISectionContribVisitor &Visitor) const;
  76. Expected<StringRef> getECName(uint32_t NI) const;
  77. private:
  78. Error initializeSectionContributionData();
  79. Error initializeSectionHeadersData(PDBFile *Pdb);
  80. Error initializeSectionMapData();
  81. Error initializeOldFpoRecords(PDBFile *Pdb);
  82. Error initializeNewFpoRecords(PDBFile *Pdb);
  83. Expected<std::unique_ptr<msf::MappedBlockStream>>
  84. createIndexedStreamForHeaderType(PDBFile *Pdb, DbgHeaderType Type) const;
  85. std::unique_ptr<BinaryStream> Stream;
  86. PDBStringTable ECNames;
  87. BinarySubstreamRef SecContrSubstream;
  88. BinarySubstreamRef SecMapSubstream;
  89. BinarySubstreamRef ModiSubstream;
  90. BinarySubstreamRef FileInfoSubstream;
  91. BinarySubstreamRef TypeServerMapSubstream;
  92. BinarySubstreamRef ECSubstream;
  93. DbiModuleList Modules;
  94. FixedStreamArray<support::ulittle16_t> DbgStreams;
  95. PdbRaw_DbiSecContribVer SectionContribVersion =
  96. PdbRaw_DbiSecContribVer::DbiSecContribVer60;
  97. FixedStreamArray<SectionContrib> SectionContribs;
  98. FixedStreamArray<SectionContrib2> SectionContribs2;
  99. FixedStreamArray<SecMapEntry> SectionMap;
  100. std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream;
  101. FixedStreamArray<object::coff_section> SectionHeaders;
  102. std::unique_ptr<msf::MappedBlockStream> OldFpoStream;
  103. FixedStreamArray<object::FpoData> OldFpoRecords;
  104. std::unique_ptr<msf::MappedBlockStream> NewFpoStream;
  105. codeview::DebugFrameDataSubsectionRef NewFpoRecords;
  106. const DbiStreamHeader *Header;
  107. };
  108. }
  109. }
  110. #endif
  111. #ifdef __GNUC__
  112. #pragma GCC diagnostic pop
  113. #endif