DbiStream.h 4.4 KB

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