LLVM  14.0.0git
DbiStream.h
Go to the documentation of this file.
1 //===- DbiStream.h - PDB Dbi Stream (Stream 3) Access -----------*- 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_DBISTREAM_H
10 #define LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAM_H
11 
23 #include "llvm/Support/Endian.h"
24 #include "llvm/Support/Error.h"
25 
26 namespace llvm {
27 namespace object {
28 struct FpoData;
29 struct coff_section;
30 }
31 
32 namespace pdb {
33 class DbiStreamBuilder;
34 class PDBFile;
35 class ISectionContribVisitor;
36 
37 class DbiStream {
38  friend class DbiStreamBuilder;
39 
40 public:
41  explicit DbiStream(std::unique_ptr<BinaryStream> Stream);
42  ~DbiStream();
43  Error reload(PDBFile *Pdb);
44 
46  uint32_t getAge() const;
49 
50  uint16_t getFlags() const;
51  bool isIncrementallyLinked() const;
52  bool hasCTypes() const;
53  bool isStripped() const;
54 
55  uint16_t getBuildNumber() const;
58 
59  uint16_t getPdbDllRbld() const;
60  uint32_t getPdbDllVersion() const;
61 
63 
65 
66  const DbiStreamHeader *getHeader() const { return Header; }
67 
74 
75  /// If the given stream type is present, returns its stream index. If it is
76  /// not present, returns InvalidStreamIndex.
78 
79  const DbiModuleList &modules() const;
80 
82 
83  bool hasOldFpoRecords() const;
85  bool hasNewFpoRecords() const;
87 
90 
92 
93 private:
94  Error initializeSectionContributionData();
95  Error initializeSectionHeadersData(PDBFile *Pdb);
96  Error initializeSectionMapData();
97  Error initializeOldFpoRecords(PDBFile *Pdb);
98  Error initializeNewFpoRecords(PDBFile *Pdb);
99 
101  createIndexedStreamForHeaderType(PDBFile *Pdb, DbgHeaderType Type) const;
102 
103  std::unique_ptr<BinaryStream> Stream;
104 
105  PDBStringTable ECNames;
106 
107  BinarySubstreamRef SecContrSubstream;
108  BinarySubstreamRef SecMapSubstream;
109  BinarySubstreamRef ModiSubstream;
110  BinarySubstreamRef FileInfoSubstream;
111  BinarySubstreamRef TypeServerMapSubstream;
112  BinarySubstreamRef ECSubstream;
113 
114  DbiModuleList Modules;
115 
117 
118  PdbRaw_DbiSecContribVer SectionContribVersion =
120  FixedStreamArray<SectionContrib> SectionContribs;
121  FixedStreamArray<SectionContrib2> SectionContribs2;
123 
124  std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream;
126 
127  std::unique_ptr<msf::MappedBlockStream> OldFpoStream;
128  FixedStreamArray<object::FpoData> OldFpoRecords;
129 
130  std::unique_ptr<msf::MappedBlockStream> NewFpoStream;
132 
133  const DbiStreamHeader *Header;
134 };
135 }
136 }
137 
138 #endif
llvm::pdb::DbiStream::hasOldFpoRecords
bool hasOldFpoRecords() const
Definition: DbiStream.cpp:205
llvm::pdb::DbiStream::isStripped
bool isStripped() const
Definition: DbiStream.cpp:172
llvm::pdb::DbiSecContribVer60
@ DbiSecContribVer60
Definition: RawConstants.h:68
RawConstants.h
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
RawTypes.h
llvm::pdb::DbiStream::visitSectionContributions
void visitSectionContributions(ISectionContribVisitor &Visitor) const
Definition: DbiStream.cpp:223
DbiModuleDescriptor.h
llvm::pdb::ISectionContribVisitor
Definition: ISectionContribVisitor.h:18
llvm::pdb::DbiStream::getPublicSymbolStreamIndex
uint16_t getPublicSymbolStreamIndex() const
Definition: DbiStream.cpp:154
llvm::codeview::DebugFrameDataSubsectionRef
Definition: DebugFrameDataSubsection.h:20
Error.h
llvm::pdb::DbiStream::getFlags
uint16_t getFlags() const
Definition: DbiStream.cpp:162
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::pdb::DbiStream::getOldFpoRecords
FixedStreamArray< object::FpoData > getOldFpoRecords() const
Definition: DbiStream.cpp:207
llvm::pdb::DbiStream::getSectionContributionData
BinarySubstreamRef getSectionContributionData() const
Definition: DbiStream.cpp:343
llvm::pdb::DbiStream
Definition: DbiStream.h:37
llvm::pdb::DbiStream::getDbiVersion
PdbRaw_DbiVer getDbiVersion() const
Definition: DbiStream.cpp:147
llvm::FixedStreamArray
FixedStreamArray is similar to VarStreamArray, except with each record having a fixed-length.
Definition: BinaryStreamArray.h:262
llvm::pdb::DbiStreamHeader
The fixed size header that appears at the beginning of the DBI Stream.
Definition: RawTypes.h:119
llvm::pdb::DbiStream::getECName
Expected< StringRef > getECName(uint32_t NI) const
Definition: DbiStream.cpp:236
llvm::pdb::DbiStream::getNewFpoRecords
const codeview::DebugFrameDataSubsectionRef & getNewFpoRecords() const
Definition: DbiStream.cpp:213
llvm::pdb::DbiModuleList
Definition: DbiModuleList.h:69
llvm::pdb::DbiStream::getECSubstreamData
BinarySubstreamRef getECSubstreamData() const
Definition: DbiStream.cpp:363
llvm::pdb::DbiStreamBuilder
Definition: DbiStreamBuilder.h:43
llvm::BinarySubstreamRef
Definition: BinaryStreamRef.h:200
llvm::pdb::DbiStream::getBuildNumber
uint16_t getBuildNumber() const
Definition: DbiStream.cpp:176
llvm::pdb::DbiStream::hasNewFpoRecords
bool hasNewFpoRecords() const
Definition: DbiStream.cpp:211
llvm::pdb::DbiStream::getSectionHeaders
FixedStreamArray< object::coff_section > getSectionHeaders() const
Definition: DbiStream.cpp:201
PDBTypes.h
llvm::pdb::DbiStream::getFileInfoSubstreamData
BinarySubstreamRef getFileInfoSubstreamData() const
Definition: DbiStream.cpp:355
llvm::pdb::DbiStream::getSymRecordStreamIndex
uint32_t getSymRecordStreamIndex() const
Definition: DbiStream.cpp:192
llvm::pdb::DbiStream::getSectionMap
FixedStreamArray< SecMapEntry > getSectionMap() const
Definition: DbiStream.cpp:219
DebugSubsection.h
llvm::pdb::DbiStream::isIncrementallyLinked
bool isIncrementallyLinked() const
Definition: DbiStream.cpp:164
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::pdb::DbiStream::~DbiStream
~DbiStream()
llvm::pdb::PdbRaw_DbiSecContribVer
PdbRaw_DbiSecContribVer
Definition: RawConstants.h:67
BinaryStreamArray.h
llvm::pdb::DbiStream::getModiSubstreamData
BinarySubstreamRef getModiSubstreamData() const
Definition: DbiStream.cpp:351
MappedBlockStream.h
llvm::pdb::DbiStream::getPdbDllRbld
uint16_t getPdbDllRbld() const
Definition: DbiStream.cpp:188
llvm::pdb::DbiStream::getBuildMajorVersion
uint16_t getBuildMajorVersion() const
Definition: DbiStream.cpp:178
llvm::pdb::DbiStream::hasCTypes
bool hasCTypes() const
Definition: DbiStream.cpp:168
llvm::pdb::PDBStringTable
Definition: PDBStringTable.h:32
llvm::pdb::DbiStream::getMachineType
PDB_Machine getMachineType() const
Definition: DbiStream.cpp:196
llvm::pdb::PdbRaw_DbiVer
PdbRaw_DbiVer
Definition: RawConstants.h:51
llvm::pdb::PDB_Machine
PDB_Machine
Definition: PDBTypes.h:125
BinaryStreamRef.h
uint32_t
llvm::pdb::DbiStream::reload
Error reload(PDBFile *Pdb)
Definition: DbiStream.cpp:52
llvm::pdb::DbiStream::getPdbDllVersion
uint32_t getPdbDllVersion() const
Definition: DbiStream.cpp:190
llvm::pdb::DbiStream::getAge
uint32_t getAge() const
Definition: DbiStream.cpp:152
llvm::pdb::DbiStream::DbiStream
DbiStream(std::unique_ptr< BinaryStream > Stream)
Definition: DbiStream.cpp:47
uint16_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::pdb::DbiStream::getGlobalSymbolStreamIndex
uint16_t getGlobalSymbolStreamIndex() const
Definition: DbiStream.cpp:158
llvm::pdb::DbiStream::getTypeServerMapSubstreamData
BinarySubstreamRef getTypeServerMapSubstreamData() const
Definition: DbiStream.cpp:359
PDBStringTable.h
llvm::pdb::PDBFile
Definition: PDBFile.h:42
llvm::pdb::DbiStream::getBuildMinorVersion
uint16_t getBuildMinorVersion() const
Definition: DbiStream.cpp:183
DebugFrameDataSubsection.h
llvm::pdb::DbgHeaderType
DbgHeaderType
Definition: RawConstants.h:86
llvm::pdb::DbiStream::getHeader
const DbiStreamHeader * getHeader() const
Definition: DbiStream.h:66
DbiModuleList.h
llvm::pdb::DbiStream::getSecMapSubstreamData
BinarySubstreamRef getSecMapSubstreamData() const
Definition: DbiStream.cpp:347
Endian.h
llvm::pdb::DbiStream::getDebugStreamIndex
uint32_t getDebugStreamIndex(DbgHeaderType Type) const
If the given stream type is present, returns its stream index.
Definition: DbiStream.cpp:378
llvm::pdb::DbiStream::modules
const DbiModuleList & modules() const
Definition: DbiStream.cpp:217