LLVM 20.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
16#include "llvm/Support/Endian.h"
17#include "llvm/Support/Error.h"
18
19#include <memory>
20
21namespace llvm {
22
23class BinaryStream;
24
25namespace msf {
26class MappedBlockStream;
27}
28
29namespace pdb {
30class DbiStream;
31class GlobalsStream;
32class InfoStream;
33class InjectedSourceStream;
34class PDBStringTable;
35class PDBFileBuilder;
36class PublicsStream;
37class SymbolStream;
38class TpiStream;
39
40class PDBFile : public msf::IMSFFile {
41 friend PDBFileBuilder;
42
43public:
44 PDBFile(StringRef Path, std::unique_ptr<BinaryStream> PdbFileBuffer,
45 BumpPtrAllocator &Allocator);
46 ~PDBFile() override;
47
49 StringRef getFilePath() const;
50
52 uint32_t getUnknown1() const;
53
54 uint32_t getBlockSize() const override;
55 uint32_t getBlockCount() const override;
60
61 uint32_t getNumStreams() const override;
63 uint32_t getStreamByteSize(uint32_t StreamIndex) const override;
65 getStreamBlockList(uint32_t StreamIndex) const override;
66 uint64_t getFileSize() const;
67
69 uint32_t NumBytes) const override;
71 ArrayRef<uint8_t> Data) const override;
72
74 return ContainerLayout.StreamSizes;
75 }
77 return ContainerLayout.StreamMap;
78 }
79
80 const msf::MSFLayout &getMsfLayout() const { return ContainerLayout; }
81 BinaryStreamRef getMsfBuffer() const { return *Buffer; }
82
84
85 std::unique_ptr<msf::MappedBlockStream>
88 safelyCreateIndexedStream(uint32_t StreamIndex) const;
91
94
97
107
109
110 bool hasPDBDbiStream() const;
111 bool hasPDBGlobalsStream();
112 bool hasPDBInfoStream() const;
113 bool hasPDBIpiStream() const;
114 bool hasPDBPublicsStream();
115 bool hasPDBSymbolStream();
116 bool hasPDBTpiStream() const;
117 bool hasPDBStringTable();
119
121
122private:
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<InjectedSourceStream> InjectedSources;
140 std::unique_ptr<PDBStringTable> Strings;
141};
142}
143}
144
145#endif
This file defines the BumpPtrAllocator interface.
std::string Name
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:66
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Describes the layout of a stream in an MSF layout.
Definition: MSFCommon.h:77
ArrayRef< support::ulittle32_t > getStreamSizes() const
Definition: PDBFile.h:73
const msf::MSFLayout & getMsfLayout() const
Definition: PDBFile.h:80
uint32_t getNumDirectoryBlocks() const
Definition: PDBFile.cpp:74
Error parseStreamData()
Definition: PDBFile.cpp:179
bool hasPDBInjectedSourceStream()
Definition: PDBFile.cpp:469
Expected< InjectedSourceStream & > getInjectedSourceStream()
Definition: PDBFile.cpp:383
Expected< GlobalsStream & > getPDBGlobalsStream()
Definition: PDBFile.cpp:256
uint32_t getPointerSize()
Definition: PDBFile.cpp:401
Expected< TpiStream & > getPDBIpiStream()
Definition: PDBFile.cpp:313
uint32_t getBlockSize() const override
Definition: PDBFile.cpp:54
Expected< std::unique_ptr< msf::MappedBlockStream > > safelyCreateIndexedStream(uint32_t StreamIndex) const
Wrapper around MappedBlockStream::createIndexedStream() that checks if a stream with that index actua...
Definition: PDBFile.cpp:487
uint32_t getUnknown1() const
Definition: PDBFile.cpp:72
uint32_t getBlockMapIndex() const
Definition: PDBFile.cpp:68
Expected< DbiStream & > getPDBDbiStream()
Definition: PDBFile.cpp:287
Expected< InfoStream & > getPDBInfoStream()
Definition: PDBFile.cpp:274
BinaryStreamRef getMsfBuffer() const
Definition: PDBFile.h:81
bool hasPDBTpiStream() const
Definition: PDBFile.cpp:454
bool hasPDBSymbolStream()
Definition: PDBFile.cpp:447
bool hasPDBPublicsStream()
Definition: PDBFile.cpp:438
uint32_t getBlockCount() const override
Definition: PDBFile.cpp:60
bool hasPDBGlobalsStream()
Definition: PDBFile.cpp:415
StringRef getFileDirectory() const
Definition: PDBFile.cpp:50
uint32_t getMaxStreamSize() const
Definition: PDBFile.cpp:88
msf::MSFStreamLayout getFpmStreamLayout() const
Definition: PDBFile.cpp:252
Expected< PublicsStream & > getPDBPublicsStream()
Definition: PDBFile.cpp:329
ArrayRef< ArrayRef< support::ulittle32_t > > getStreamMap() const
Definition: PDBFile.h:76
Error setBlockData(uint32_t BlockIndex, uint32_t Offset, ArrayRef< uint8_t > Data) const override
Definition: PDBFile.cpp:113
Expected< TpiStream & > getPDBTpiStream()
Definition: PDBFile.cpp:300
msf::MSFStreamLayout getStreamLayout(uint32_t StreamIdx) const
Definition: PDBFile.cpp:244
bool hasPDBIpiStream() const
Definition: PDBFile.cpp:427
Expected< SymbolStream & > getPDBSymbolStream()
Definition: PDBFile.cpp:347
uint64_t getBlockMapOffset() const
Definition: PDBFile.cpp:79
Error parseFileHeaders()
Definition: PDBFile.cpp:119
~PDBFile() override
uint64_t getFileSize() const
Definition: PDBFile.cpp:101
Expected< ArrayRef< uint8_t > > getBlockData(uint32_t BlockIndex, uint32_t NumBytes) const override
Definition: PDBFile.cpp:103
uint32_t getFreeBlockMapBlock() const
Definition: PDBFile.cpp:56
BumpPtrAllocator & getAllocator()
Definition: PDBFile.h:108
uint32_t getStreamByteSize(uint32_t StreamIndex) const override
Definition: PDBFile.cpp:92
uint32_t getNumStreams() const override
Definition: PDBFile.cpp:84
bool hasPDBInfoStream() const
Definition: PDBFile.cpp:425
StringRef getFilePath() const
Definition: PDBFile.cpp:48
ArrayRef< support::ulittle32_t > getStreamBlockList(uint32_t StreamIndex) const override
Definition: PDBFile.cpp:97
uint32_t getNumDirectoryBytes() const
Definition: PDBFile.cpp:64
bool hasPDBDbiStream() const
Definition: PDBFile.cpp:411
Expected< std::unique_ptr< msf::MappedBlockStream > > safelyCreateNamedStream(StringRef Name)
Definition: PDBFile.cpp:495
ArrayRef< support::ulittle32_t > getDirectoryBlockArray() const
Definition: PDBFile.cpp:232
bool hasPDBStringTable()
Definition: PDBFile.cpp:456
Expected< PDBStringTable & > getStringTable()
Definition: PDBFile.cpp:366
std::unique_ptr< msf::MappedBlockStream > createIndexedStream(uint16_t SN) const
Definition: PDBFile.cpp:237
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ArrayRef< support::ulittle32_t > StreamSizes
Definition: MSFCommon.h:67
std::vector< ArrayRef< support::ulittle32_t > > StreamMap
Definition: MSFCommon.h:68