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 | |
12 | #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" |
13 | #include "llvm/DebugInfo/PDB/Native/DbiModuleList.h" |
14 | #include "llvm/DebugInfo/PDB/Native/PDBStringTable.h" |
15 | #include "llvm/DebugInfo/PDB/Native/RawConstants.h" |
16 | #include "llvm/DebugInfo/PDB/PDBTypes.h" |
17 | #include "llvm/Support/BinaryStreamArray.h" |
18 | #include "llvm/Support/BinaryStreamRef.h" |
19 | #include "llvm/Support/Compiler.h" |
20 | #include "llvm/Support/Endian.h" |
21 | #include "llvm/Support/Error.h" |
22 | |
23 | namespace llvm { |
24 | class BinaryStream; |
25 | namespace object { |
26 | struct FpoData; |
27 | struct coff_section; |
28 | } |
29 | namespace msf { |
30 | class MappedBlockStream; |
31 | } |
32 | namespace pdb { |
33 | struct DbiStreamHeader; |
34 | struct SecMapEntry; |
35 | struct SectionContrib2; |
36 | struct SectionContrib; |
37 | class PDBFile; |
38 | class ISectionContribVisitor; |
39 | |
40 | class DbiStream { |
41 | friend class DbiStreamBuilder; |
42 | |
43 | public: |
44 | LLVM_ABI explicit DbiStream(std::unique_ptr<BinaryStream> Stream); |
45 | LLVM_ABI ~DbiStream(); |
46 | LLVM_ABI Error reload(PDBFile *Pdb); |
47 | |
48 | LLVM_ABI PdbRaw_DbiVer getDbiVersion() const; |
49 | LLVM_ABI uint32_t getAge() const; |
50 | LLVM_ABI uint16_t getPublicSymbolStreamIndex() const; |
51 | LLVM_ABI uint16_t getGlobalSymbolStreamIndex() const; |
52 | |
53 | LLVM_ABI uint16_t getFlags() const; |
54 | LLVM_ABI bool isIncrementallyLinked() const; |
55 | LLVM_ABI bool hasCTypes() const; |
56 | LLVM_ABI bool isStripped() const; |
57 | |
58 | LLVM_ABI uint16_t getBuildNumber() const; |
59 | LLVM_ABI uint16_t getBuildMajorVersion() const; |
60 | LLVM_ABI uint16_t getBuildMinorVersion() const; |
61 | |
62 | LLVM_ABI uint16_t getPdbDllRbld() const; |
63 | LLVM_ABI uint32_t getPdbDllVersion() const; |
64 | |
65 | LLVM_ABI uint32_t getSymRecordStreamIndex() const; |
66 | |
67 | LLVM_ABI PDB_Machine getMachineType() const; |
68 | |
69 | const DbiStreamHeader *getHeader() const { return Header; } |
70 | |
71 | LLVM_ABI BinarySubstreamRef getSectionContributionData() const; |
72 | LLVM_ABI BinarySubstreamRef getSecMapSubstreamData() const; |
73 | LLVM_ABI BinarySubstreamRef getModiSubstreamData() const; |
74 | LLVM_ABI BinarySubstreamRef getFileInfoSubstreamData() const; |
75 | LLVM_ABI BinarySubstreamRef getTypeServerMapSubstreamData() const; |
76 | LLVM_ABI BinarySubstreamRef getECSubstreamData() const; |
77 | |
78 | /// If the given stream type is present, returns its stream index. If it is |
79 | /// not present, returns InvalidStreamIndex. |
80 | LLVM_ABI uint32_t getDebugStreamIndex(DbgHeaderType Type) const; |
81 | |
82 | LLVM_ABI const DbiModuleList &modules() const; |
83 | |
84 | LLVM_ABI FixedStreamArray<object::coff_section> getSectionHeaders() const; |
85 | |
86 | LLVM_ABI bool hasOldFpoRecords() const; |
87 | LLVM_ABI FixedStreamArray<object::FpoData> getOldFpoRecords() const; |
88 | LLVM_ABI bool hasNewFpoRecords() const; |
89 | LLVM_ABI const codeview::DebugFrameDataSubsectionRef & |
90 | getNewFpoRecords() const; |
91 | |
92 | LLVM_ABI FixedStreamArray<SecMapEntry> getSectionMap() const; |
93 | LLVM_ABI void |
94 | visitSectionContributions(ISectionContribVisitor &Visitor) const; |
95 | |
96 | LLVM_ABI Expected<StringRef> getECName(uint32_t NI) const; |
97 | |
98 | private: |
99 | Error initializeSectionContributionData(); |
100 | Error initializeSectionHeadersData(PDBFile *Pdb); |
101 | Error initializeSectionMapData(); |
102 | Error initializeOldFpoRecords(PDBFile *Pdb); |
103 | Error initializeNewFpoRecords(PDBFile *Pdb); |
104 | |
105 | Expected<std::unique_ptr<msf::MappedBlockStream>> |
106 | createIndexedStreamForHeaderType(PDBFile *Pdb, DbgHeaderType Type) const; |
107 | |
108 | std::unique_ptr<BinaryStream> Stream; |
109 | |
110 | PDBStringTable ECNames; |
111 | |
112 | BinarySubstreamRef SecContrSubstream; |
113 | BinarySubstreamRef SecMapSubstream; |
114 | BinarySubstreamRef ModiSubstream; |
115 | BinarySubstreamRef FileInfoSubstream; |
116 | BinarySubstreamRef TypeServerMapSubstream; |
117 | BinarySubstreamRef ECSubstream; |
118 | |
119 | DbiModuleList Modules; |
120 | |
121 | FixedStreamArray<support::ulittle16_t> DbgStreams; |
122 | |
123 | PdbRaw_DbiSecContribVer SectionContribVersion = |
124 | PdbRaw_DbiSecContribVer::DbiSecContribVer60; |
125 | FixedStreamArray<SectionContrib> SectionContribs; |
126 | FixedStreamArray<SectionContrib2> SectionContribs2; |
127 | FixedStreamArray<SecMapEntry> SectionMap; |
128 | |
129 | std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream; |
130 | FixedStreamArray<object::coff_section> SectionHeaders; |
131 | |
132 | std::unique_ptr<msf::MappedBlockStream> OldFpoStream; |
133 | FixedStreamArray<object::FpoData> OldFpoRecords; |
134 | |
135 | std::unique_ptr<msf::MappedBlockStream> NewFpoStream; |
136 | codeview::DebugFrameDataSubsectionRef NewFpoRecords; |
137 | |
138 | const DbiStreamHeader *Header; |
139 | }; |
140 | } |
141 | } |
142 | |
143 | #endif |
144 |