File indexing completed on 2026-05-10 08:43:45
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_PDBFILE_H
0010 #define LLVM_DEBUGINFO_PDB_NATIVE_PDBFILE_H
0011
0012 #include "llvm/DebugInfo/MSF/IMSFFile.h"
0013 #include "llvm/DebugInfo/MSF/MSFCommon.h"
0014 #include "llvm/Support/Allocator.h"
0015 #include "llvm/Support/BinaryStreamRef.h"
0016 #include "llvm/Support/Endian.h"
0017 #include "llvm/Support/Error.h"
0018
0019 #include <memory>
0020
0021 namespace llvm {
0022
0023 class BinaryStream;
0024
0025 namespace msf {
0026 class MappedBlockStream;
0027 }
0028
0029 namespace pdb {
0030 class DbiStream;
0031 class GlobalsStream;
0032 class InfoStream;
0033 class InjectedSourceStream;
0034 class PDBStringTable;
0035 class PDBFileBuilder;
0036 class PublicsStream;
0037 class SymbolStream;
0038 class TpiStream;
0039
0040 class PDBFile : public msf::IMSFFile {
0041 friend PDBFileBuilder;
0042
0043 public:
0044 PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
0045 BumpPtrAllocator &Allocator);
0046 ~PDBFile() override;
0047
0048 StringRef getFileDirectory() const;
0049 StringRef getFilePath() const;
0050
0051 uint32_t getFreeBlockMapBlock() const;
0052 uint32_t getUnknown1() const;
0053
0054 uint32_t getBlockSize() const override;
0055 uint32_t getBlockCount() const override;
0056 uint32_t getNumDirectoryBytes() const;
0057 uint32_t getBlockMapIndex() const;
0058 uint32_t getNumDirectoryBlocks() const;
0059 uint64_t getBlockMapOffset() const;
0060
0061 uint32_t getNumStreams() const override;
0062 uint32_t getMaxStreamSize() const;
0063 uint32_t getStreamByteSize(uint32_t StreamIndex) const override;
0064 ArrayRef<support::ulittle32_t>
0065 getStreamBlockList(uint32_t StreamIndex) const override;
0066 uint64_t getFileSize() const;
0067
0068 Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex,
0069 uint32_t NumBytes) const override;
0070 Error setBlockData(uint32_t BlockIndex, uint32_t Offset,
0071 ArrayRef<uint8_t> Data) const override;
0072
0073 ArrayRef<support::ulittle32_t> getStreamSizes() const {
0074 return ContainerLayout.StreamSizes;
0075 }
0076 ArrayRef<ArrayRef<support::ulittle32_t>> getStreamMap() const {
0077 return ContainerLayout.StreamMap;
0078 }
0079
0080 const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; }
0081 BinaryStreamRef getMsfBuffer() const { return *Buffer; }
0082
0083 ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
0084
0085 std::unique_ptr<msf::MappedBlockStream>
0086 createIndexedStream(uint16_t SN) const;
0087 Expected<std::unique_ptr<msf::MappedBlockStream>>
0088 safelyCreateIndexedStream(uint32_t StreamIndex) const;
0089 Expected<std::unique_ptr<msf::MappedBlockStream>>
0090 safelyCreateNamedStream(StringRef Name);
0091
0092 msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const;
0093 msf::MSFStreamLayout getFpmStreamLayout() const;
0094
0095 Error parseFileHeaders();
0096 Error parseStreamData();
0097
0098 Expected<InfoStream &> getPDBInfoStream();
0099 Expected<DbiStream &> getPDBDbiStream();
0100 Expected<GlobalsStream &> getPDBGlobalsStream();
0101 Expected<TpiStream &> getPDBTpiStream();
0102 Expected<TpiStream &> getPDBIpiStream();
0103 Expected<PublicsStream &> getPDBPublicsStream();
0104 Expected<SymbolStream &> getPDBSymbolStream();
0105 Expected<PDBStringTable &> getStringTable();
0106 Expected<InjectedSourceStream &> getInjectedSourceStream();
0107
0108 BumpPtrAllocator &getAllocator() { return Allocator; }
0109
0110 bool hasPDBDbiStream() const;
0111 bool hasPDBGlobalsStream();
0112 bool hasPDBInfoStream() const;
0113 bool hasPDBIpiStream() const;
0114 bool hasPDBPublicsStream();
0115 bool hasPDBSymbolStream();
0116 bool hasPDBTpiStream() const;
0117 bool hasPDBStringTable();
0118 bool hasPDBInjectedSourceStream();
0119
0120 uint32_t getPointerSize();
0121
0122 private:
0123 std::string FilePath;
0124 BumpPtrAllocator &Allocator;
0125
0126 std::unique_ptr<BinaryStream> Buffer;
0127
0128 msf::MSFLayout ContainerLayout;
0129
0130 std::unique_ptr<GlobalsStream> Globals;
0131 std::unique_ptr<InfoStream> Info;
0132 std::unique_ptr<DbiStream> Dbi;
0133 std::unique_ptr<TpiStream> Tpi;
0134 std::unique_ptr<TpiStream> Ipi;
0135 std::unique_ptr<PublicsStream> Publics;
0136 std::unique_ptr<SymbolStream> Symbols;
0137 std::unique_ptr<msf::MappedBlockStream> DirectoryStream;
0138 std::unique_ptr<msf::MappedBlockStream> StringTableStream;
0139 std::unique_ptr<InjectedSourceStream> InjectedSources;
0140 std::unique_ptr<PDBStringTable> Strings;
0141 };
0142 }
0143 }
0144
0145 #endif