LLVM  8.0.1
PDBFile.h
Go to the documentation of this file.
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"
16 #include "llvm/Support/Allocator.h"
18 #include "llvm/Support/Endian.h"
19 #include "llvm/Support/Error.h"
21 
22 #include <memory>
23 
24 namespace llvm {
25 
26 class BinaryStream;
27 
28 namespace msf {
29 class MappedBlockStream;
30 }
31 
32 namespace pdb {
33 class DbiStream;
34 class GlobalsStream;
35 class InfoStream;
36 class PDBStringTable;
37 class PDBFileBuilder;
38 class PublicsStream;
39 class SymbolStream;
40 class TpiStream;
41 
42 class PDBFile : public msf::IMSFFile {
43  friend PDBFileBuilder;
44 
45 public:
46  PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
48  ~PDBFile() override;
49 
50  StringRef getFileDirectory() const;
51  StringRef getFilePath() const;
52 
53  uint32_t getFreeBlockMapBlock() const;
54  uint32_t getUnknown1() const;
55 
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;
62 
63  uint32_t getNumStreams() const override;
64  uint32_t getMaxStreamSize() const;
65  uint32_t getStreamByteSize(uint32_t StreamIndex) const override;
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 
76  return ContainerLayout.StreamSizes;
77  }
79  return ContainerLayout.StreamMap;
80  }
81 
82  const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; }
83  BinaryStreamRef getMsfBuffer() const { return *Buffer; }
84 
85  ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
86 
87  std::unique_ptr<msf::MappedBlockStream> createIndexedStream(uint16_t SN);
88 
89  msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const;
91 
92  Error parseFileHeaders();
93  Error parseStreamData();
94 
95  Expected<InfoStream &> getPDBInfoStream();
96  Expected<DbiStream &> getPDBDbiStream();
97  Expected<GlobalsStream &> getPDBGlobalsStream();
98  Expected<TpiStream &> getPDBTpiStream();
99  Expected<TpiStream &> getPDBIpiStream();
100  Expected<PublicsStream &> getPDBPublicsStream();
101  Expected<SymbolStream &> getPDBSymbolStream();
102  Expected<PDBStringTable &> getStringTable();
103 
105 
106  bool hasPDBDbiStream() const;
107  bool hasPDBGlobalsStream();
108  bool hasPDBInfoStream() const;
109  bool hasPDBIpiStream() const;
110  bool hasPDBPublicsStream();
111  bool hasPDBSymbolStream();
112  bool hasPDBTpiStream() const;
113  bool hasPDBStringTable();
114 
116 
117 private:
119  safelyCreateIndexedStream(const msf::MSFLayout &Layout,
120  BinaryStreamRef MsfData,
121  uint32_t StreamIndex) const;
122 
123  std::string FilePath;
125 
126  std::unique_ptr<BinaryStream> Buffer;
127 
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
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
Describes the layout of a stream in an MSF layout.
Definition: MSFCommon.h:78
MSFStreamLayout getFpmStreamLayout(const MSFLayout &Msf, bool IncludeUnusedFpmData=false, bool AltFpm=false)
Determine the layout of the FPM stream, given the MSF layout.
Definition: MSFCommon.cpp:63
Tagged union holding either a T or a Error.
Definition: CachePruning.h:23
static uint64_t getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, const Function *F)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
BinaryStreamRef getMsfBuffer() const
Definition: PDBFile.h:83
Analysis containing CSE Info
Definition: CSEInfo.cpp:21
BumpPtrAllocator & getAllocator()
Definition: PDBFile.h:104
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:141
ArrayRef< support::ulittle32_t > getStreamSizes() const
Definition: PDBFile.h:75
Basic Register Allocator
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
ArrayRef< ArrayRef< support::ulittle32_t > > getStreamMap() const
Definition: PDBFile.h:78
const msf::MSFLayout & getMsfLayout() const
Definition: PDBFile.h:82
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49