LLVM 22.0.0git
PDBFile.h
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_DEBUGINFO_PDB_NATIVE_PDBFILE_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_PDBFILE_H
11
17#include "llvm/Support/Endian.h"
18#include "llvm/Support/Error.h"
19
20#include <memory>
21
22namespace llvm {
23
24class BinaryStream;
25
26namespace msf {
27class MappedBlockStream;
28}
29
30namespace pdb {
31class DbiStream;
32class GlobalsStream;
33class InfoStream;
34class InjectedSourceStream;
35class PDBStringTable;
36class PDBFileBuilder;
37class PublicsStream;
38class SymbolStream;
39class TpiStream;
40
42 friend PDBFileBuilder;
43
44public:
45 PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
47 ~PDBFile() override;
48
49 StringRef getFileDirectory() const;
50 StringRef getFilePath() const;
51
52 uint32_t getFreeBlockMapBlock() const;
53 uint32_t getUnknown1() const;
54
55 uint32_t getBlockSize() const override;
56 uint32_t getBlockCount() const override;
57 uint32_t getNumDirectoryBytes() const;
58 uint32_t getBlockMapIndex() const;
59 uint32_t getNumDirectoryBlocks() const;
60 uint64_t getBlockMapOffset() const;
61
62 uint32_t getNumStreams() const override;
63 uint32_t getMaxStreamSize() const;
64 uint32_t getStreamByteSize(uint32_t StreamIndex) const override;
66 getStreamBlockList(uint32_t StreamIndex) const override;
67 uint64_t getFileSize() const;
68
69 Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex,
70 uint32_t NumBytes) const override;
71 Error setBlockData(uint32_t BlockIndex, uint32_t Offset,
72 ArrayRef<uint8_t> Data) const override;
73
75 return ContainerLayout.StreamSizes;
76 }
78 return ContainerLayout.StreamMap;
79 }
80
81 const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; }
82 BinaryStreamRef getMsfBuffer() const { return *Buffer; }
83
84 ArrayRef<support::ulittle32_t> getDirectoryBlockArray() const;
85
86 std::unique_ptr<msf::MappedBlockStream>
87 createIndexedStream(uint16_t SN) const;
89 safelyCreateIndexedStream(uint32_t StreamIndex) const;
91 safelyCreateNamedStream(StringRef Name);
92
93 msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const;
94 msf::MSFStreamLayout getFpmStreamLayout() const;
95
96 Error parseFileHeaders();
97 Error parseStreamData();
98
99 Expected<InfoStream &> getPDBInfoStream();
100 Expected<DbiStream &> getPDBDbiStream();
101 Expected<GlobalsStream &> getPDBGlobalsStream();
102 Expected<TpiStream &> getPDBTpiStream();
103 Expected<TpiStream &> getPDBIpiStream();
104 Expected<PublicsStream &> getPDBPublicsStream();
105 Expected<SymbolStream &> getPDBSymbolStream();
106 Expected<PDBStringTable &> getStringTable();
107 Expected<InjectedSourceStream &> getInjectedSourceStream();
108
110
111 bool hasPDBDbiStream() const;
112 bool hasPDBGlobalsStream();
113 bool hasPDBInfoStream() const;
114 bool hasPDBIpiStream() const;
115 bool hasPDBPublicsStream();
116 bool hasPDBSymbolStream();
117 bool hasPDBTpiStream() const;
118 bool hasPDBStringTable();
119 bool hasPDBInjectedSourceStream();
120
122
123private:
124 std::string FilePath;
126
127 std::unique_ptr<BinaryStream> Buffer;
128
129 msf::MSFLayout ContainerLayout;
130
131 std::unique_ptr<GlobalsStream> Globals;
132 std::unique_ptr<InfoStream> Info;
133 std::unique_ptr<DbiStream> Dbi;
134 std::unique_ptr<TpiStream> Tpi;
135 std::unique_ptr<TpiStream> Ipi;
136 std::unique_ptr<PublicsStream> Publics;
137 std::unique_ptr<SymbolStream> Symbols;
138 std::unique_ptr<msf::MappedBlockStream> DirectoryStream;
139 std::unique_ptr<msf::MappedBlockStream> StringTableStream;
140 std::unique_ptr<InjectedSourceStream> InjectedSources;
141 std::unique_ptr<PDBStringTable> Strings;
142};
143}
144}
145
146#endif
This file defines the BumpPtrAllocator interface.
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define LLVM_ABI
Definition: Compiler.h:213
static std::optional< TypeSize > getPointerSize(const Value *V, const DataLayout &DL, const TargetLibraryInfo &TLI, const Function *F)
std::string Name
uint64_t Offset
Definition: ELF_riscv.cpp:478
Basic Register Allocator
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
BinaryStreamRef is to BinaryStream what ArrayRef is to an Array.
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Tagged union holding either a T or a Error.
Definition: Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Describes the layout of a stream in an MSF layout.
Definition: MSFCommon.h:78
ArrayRef< support::ulittle32_t > getStreamSizes() const
Definition: PDBFile.h:74
const msf::MSFLayout & getMsfLayout() const
Definition: PDBFile.h:81
BinaryStreamRef getMsfBuffer() const
Definition: PDBFile.h:82
ArrayRef< ArrayRef< support::ulittle32_t > > getStreamMap() const
Definition: PDBFile.h:77
~PDBFile() override
BumpPtrAllocator & getAllocator()
Definition: PDBFile.h:109
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18