[Alignment][NFC] Convert StoreInst to MaybeAlign
[llvm-complete.git] / include / llvm / DebugInfo / PDB / Native / PDBFile.h
blob56de4030167def22b0a554f072cd7df2852eac91
1 //===- PDBFile.h - Low level interface to a PDB file ------------*- 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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
10 #define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
12 #include "llvm/ADT/DenseMap.h"
13 #include "llvm/DebugInfo/MSF/IMSFFile.h"
14 #include "llvm/DebugInfo/MSF/MSFCommon.h"
15 #include "llvm/Support/Allocator.h"
16 #include "llvm/Support/BinaryStreamRef.h"
17 #include "llvm/Support/Endian.h"
18 #include "llvm/Support/Error.h"
19 #include "llvm/Support/MathExtras.h"
21 #include <memory>
23 namespace llvm {
25 class BinaryStream;
27 namespace msf {
28 class MappedBlockStream;
31 namespace pdb {
32 class DbiStream;
33 class GlobalsStream;
34 class InfoStream;
35 class InjectedSourceStream;
36 class PDBStringTable;
37 class PDBFileBuilder;
38 class PublicsStream;
39 class SymbolStream;
40 class TpiStream;
42 class PDBFile : public msf::IMSFFile {
43 friend PDBFileBuilder;
45 public:
46 PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
47 BumpPtrAllocator &Allocator);
48 ~PDBFile() override;
50 StringRef getFileDirectory() const;
51 StringRef getFilePath() const;
53 uint32_t getFreeBlockMapBlock() const;
54 uint32_t getUnknown1() const;
56 uint32_t getBlockSize() const override;
57 uint32_t getBlockCount() const override;
58 uint32_t getNumDirectoryBytes() const;
59 uint32_t getBlockMapIndex() const;
60 uint32_t getNumDirectoryBlocks() const;
61 uint64_t getBlockMapOffset() const;
63 uint32_t getNumStreams() const override;
64 uint32_t getMaxStreamSize() const;
65 uint32_t getStreamByteSize(uint32_t StreamIndex) const override;
66 ArrayRef<support::ulittle32_t>
67 getStreamBlockList(uint32_t StreamIndex) const override;
68 uint32_t getFileSize() const;
70 Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex,
71 uint32_t NumBytes) const override;
72 Error setBlockData(uint32_t BlockIndex, uint32_t Offset,
73 ArrayRef<uint8_t> Data) const override;
75 ArrayRef<support::ulittle32_t> getStreamSizes() const {
76 return ContainerLayout.StreamSizes;
78 ArrayRef<ArrayRef<support::ulittle32_t>> getStreamMap() const {
79 return ContainerLayout.StreamMap;
82 const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; }
83 BinaryStreamRef getMsfBuffer() const { return *Buffer; }
85 ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
87 std::unique_ptr<msf::MappedBlockStream>
88 createIndexedStream(uint16_t SN) const;
89 Expected<std::unique_ptr<msf::MappedBlockStream>>
90 safelyCreateIndexedStream(uint32_t StreamIndex) const;
91 Expected<std::unique_ptr<msf::MappedBlockStream>>
92 safelyCreateNamedStream(StringRef Name);
94 msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const;
95 msf::MSFStreamLayout getFpmStreamLayout() const;
97 Error parseFileHeaders();
98 Error parseStreamData();
100 Expected<InfoStream &> getPDBInfoStream();
101 Expected<DbiStream &> getPDBDbiStream();
102 Expected<GlobalsStream &> getPDBGlobalsStream();
103 Expected<TpiStream &> getPDBTpiStream();
104 Expected<TpiStream &> getPDBIpiStream();
105 Expected<PublicsStream &> getPDBPublicsStream();
106 Expected<SymbolStream &> getPDBSymbolStream();
107 Expected<PDBStringTable &> getStringTable();
108 Expected<InjectedSourceStream &> getInjectedSourceStream();
110 BumpPtrAllocator &getAllocator() { return Allocator; }
112 bool hasPDBDbiStream() const;
113 bool hasPDBGlobalsStream();
114 bool hasPDBInfoStream() const;
115 bool hasPDBIpiStream() const;
116 bool hasPDBPublicsStream();
117 bool hasPDBSymbolStream();
118 bool hasPDBTpiStream() const;
119 bool hasPDBStringTable();
120 bool hasPDBInjectedSourceStream();
122 uint32_t getPointerSize();
124 private:
125 std::string FilePath;
126 BumpPtrAllocator &Allocator;
128 std::unique_ptr<BinaryStream> Buffer;
130 msf::MSFLayout ContainerLayout;
132 std::unique_ptr<GlobalsStream> Globals;
133 std::unique_ptr<InfoStream> Info;
134 std::unique_ptr<DbiStream> Dbi;
135 std::unique_ptr<TpiStream> Tpi;
136 std::unique_ptr<TpiStream> Ipi;
137 std::unique_ptr<PublicsStream> Publics;
138 std::unique_ptr<SymbolStream> Symbols;
139 std::unique_ptr<msf::MappedBlockStream> DirectoryStream;
140 std::unique_ptr<msf::MappedBlockStream> StringTableStream;
141 std::unique_ptr<InjectedSourceStream> InjectedSources;
142 std::unique_ptr<PDBStringTable> Strings;
147 #endif