]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/PDB/Native/PDBFile.h
MFV r316864: 6392 zdb: introduce -V for verbatim import
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / PDB / Native / PDBFile.h
1 //===- PDBFile.h - Low level interface to a PDB file ------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
11 #define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
12
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/DebugInfo/MSF/IMSFFile.h"
15 #include "llvm/DebugInfo/MSF/MSFCommon.h"
16 #include "llvm/DebugInfo/MSF/MSFStreamLayout.h"
17 #include "llvm/Support/Allocator.h"
18 #include "llvm/Support/BinaryStreamRef.h"
19 #include "llvm/Support/Endian.h"
20 #include "llvm/Support/Error.h"
21 #include "llvm/Support/MathExtras.h"
22
23 #include <memory>
24
25 namespace llvm {
26
27 class BinaryStream;
28
29 namespace msf {
30 class MappedBlockStream;
31 }
32
33 namespace pdb {
34 class DbiStream;
35 class GlobalsStream;
36 class InfoStream;
37 class PDBStringTable;
38 class PDBFileBuilder;
39 class PublicsStream;
40 class SymbolStream;
41 class TpiStream;
42
43 class PDBFile : public msf::IMSFFile {
44   friend PDBFileBuilder;
45
46 public:
47   PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
48           BumpPtrAllocator &Allocator);
49   ~PDBFile() override;
50
51   StringRef getFileDirectory() const;
52   StringRef getFilePath() const;
53
54   uint32_t getFreeBlockMapBlock() const;
55   uint32_t getUnknown1() const;
56
57   uint32_t getBlockSize() const override;
58   uint32_t getBlockCount() const override;
59   uint32_t getNumDirectoryBytes() const;
60   uint32_t getBlockMapIndex() const;
61   uint32_t getNumDirectoryBlocks() const;
62   uint64_t getBlockMapOffset() const;
63
64   uint32_t getNumStreams() const override;
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;
69
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;
74
75   ArrayRef<uint32_t> getFpmPages() const { return FpmPages; }
76
77   ArrayRef<support::ulittle32_t> getStreamSizes() const {
78     return ContainerLayout.StreamSizes;
79   }
80   ArrayRef<ArrayRef<support::ulittle32_t>> getStreamMap() const {
81     return ContainerLayout.StreamMap;
82   }
83
84   const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; }
85   BinaryStreamRef getMsfBuffer() const { return *Buffer; }
86
87   ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
88
89   msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const;
90
91   Error parseFileHeaders();
92   Error parseStreamData();
93
94   Expected<InfoStream &> getPDBInfoStream();
95   Expected<DbiStream &> getPDBDbiStream();
96   Expected<GlobalsStream &> getPDBGlobalsStream();
97   Expected<TpiStream &> getPDBTpiStream();
98   Expected<TpiStream &> getPDBIpiStream();
99   Expected<PublicsStream &> getPDBPublicsStream();
100   Expected<SymbolStream &> getPDBSymbolStream();
101   Expected<PDBStringTable &> getStringTable();
102
103   BumpPtrAllocator &getAllocator() { return Allocator; }
104
105   bool hasPDBDbiStream() const;
106   bool hasPDBGlobalsStream();
107   bool hasPDBInfoStream();
108   bool hasPDBIpiStream() const;
109   bool hasPDBPublicsStream();
110   bool hasPDBSymbolStream();
111   bool hasPDBTpiStream() const;
112   bool hasPDBStringTable();
113
114   uint32_t getPointerSize();
115
116 private:
117   Expected<std::unique_ptr<msf::MappedBlockStream>>
118   safelyCreateIndexedStream(const msf::MSFLayout &Layout,
119                             BinaryStreamRef MsfData,
120                             uint32_t StreamIndex) const;
121
122   std::string FilePath;
123   BumpPtrAllocator &Allocator;
124
125   std::unique_ptr<BinaryStream> Buffer;
126
127   std::vector<uint32_t> FpmPages;
128   msf::MSFLayout ContainerLayout;
129
130   std::unique_ptr<GlobalsStream> Globals;
131   std::unique_ptr<InfoStream> Info;
132   std::unique_ptr<DbiStream> Dbi;
133   std::unique_ptr<TpiStream> Tpi;
134   std::unique_ptr<TpiStream> Ipi;
135   std::unique_ptr<PublicsStream> Publics;
136   std::unique_ptr<SymbolStream> Symbols;
137   std::unique_ptr<msf::MappedBlockStream> DirectoryStream;
138   std::unique_ptr<msf::MappedBlockStream> StringTableStream;
139   std::unique_ptr<PDBStringTable> Strings;
140 };
141 }
142 }
143
144 #endif