Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:44

0001 //===- DbiStream.h - PDB Dbi Stream (Stream 3) Access -----------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAM_H
0010 #define LLVM_DEBUGINFO_PDB_NATIVE_DBISTREAM_H
0011 
0012 #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h"
0013 #include "llvm/DebugInfo/PDB/Native/DbiModuleList.h"
0014 #include "llvm/DebugInfo/PDB/Native/PDBStringTable.h"
0015 #include "llvm/DebugInfo/PDB/Native/RawConstants.h"
0016 #include "llvm/DebugInfo/PDB/PDBTypes.h"
0017 #include "llvm/Support/BinaryStreamArray.h"
0018 #include "llvm/Support/BinaryStreamRef.h"
0019 #include "llvm/Support/Endian.h"
0020 #include "llvm/Support/Error.h"
0021 
0022 namespace llvm {
0023 class BinaryStream;
0024 namespace object {
0025 struct FpoData;
0026 struct coff_section;
0027 }
0028 namespace msf {
0029 class MappedBlockStream;
0030 }
0031 namespace pdb {
0032 struct DbiStreamHeader;
0033 struct SecMapEntry;
0034 struct SectionContrib2;
0035 struct SectionContrib;
0036 class PDBFile;
0037 class ISectionContribVisitor;
0038 
0039 class DbiStream {
0040   friend class DbiStreamBuilder;
0041 
0042 public:
0043   explicit DbiStream(std::unique_ptr<BinaryStream> Stream);
0044   ~DbiStream();
0045   Error reload(PDBFile *Pdb);
0046 
0047   PdbRaw_DbiVer getDbiVersion() const;
0048   uint32_t getAge() const;
0049   uint16_t getPublicSymbolStreamIndex() const;
0050   uint16_t getGlobalSymbolStreamIndex() const;
0051 
0052   uint16_t getFlags() const;
0053   bool isIncrementallyLinked() const;
0054   bool hasCTypes() const;
0055   bool isStripped() const;
0056 
0057   uint16_t getBuildNumber() const;
0058   uint16_t getBuildMajorVersion() const;
0059   uint16_t getBuildMinorVersion() const;
0060 
0061   uint16_t getPdbDllRbld() const;
0062   uint32_t getPdbDllVersion() const;
0063 
0064   uint32_t getSymRecordStreamIndex() const;
0065 
0066   PDB_Machine getMachineType() const;
0067 
0068   const DbiStreamHeader *getHeader() const { return Header; }
0069 
0070   BinarySubstreamRef getSectionContributionData() const;
0071   BinarySubstreamRef getSecMapSubstreamData() const;
0072   BinarySubstreamRef getModiSubstreamData() const;
0073   BinarySubstreamRef getFileInfoSubstreamData() const;
0074   BinarySubstreamRef getTypeServerMapSubstreamData() const;
0075   BinarySubstreamRef getECSubstreamData() const;
0076 
0077   /// If the given stream type is present, returns its stream index. If it is
0078   /// not present, returns InvalidStreamIndex.
0079   uint32_t getDebugStreamIndex(DbgHeaderType Type) const;
0080 
0081   const DbiModuleList &modules() const;
0082 
0083   FixedStreamArray<object::coff_section> getSectionHeaders() const;
0084 
0085   bool hasOldFpoRecords() const;
0086   FixedStreamArray<object::FpoData> getOldFpoRecords() const;
0087   bool hasNewFpoRecords() const;
0088   const codeview::DebugFrameDataSubsectionRef &getNewFpoRecords() const;
0089 
0090   FixedStreamArray<SecMapEntry> getSectionMap() const;
0091   void visitSectionContributions(ISectionContribVisitor &Visitor) const;
0092 
0093   Expected<StringRef> getECName(uint32_t NI) const;
0094 
0095 private:
0096   Error initializeSectionContributionData();
0097   Error initializeSectionHeadersData(PDBFile *Pdb);
0098   Error initializeSectionMapData();
0099   Error initializeOldFpoRecords(PDBFile *Pdb);
0100   Error initializeNewFpoRecords(PDBFile *Pdb);
0101 
0102   Expected<std::unique_ptr<msf::MappedBlockStream>>
0103   createIndexedStreamForHeaderType(PDBFile *Pdb, DbgHeaderType Type) const;
0104 
0105   std::unique_ptr<BinaryStream> Stream;
0106 
0107   PDBStringTable ECNames;
0108 
0109   BinarySubstreamRef SecContrSubstream;
0110   BinarySubstreamRef SecMapSubstream;
0111   BinarySubstreamRef ModiSubstream;
0112   BinarySubstreamRef FileInfoSubstream;
0113   BinarySubstreamRef TypeServerMapSubstream;
0114   BinarySubstreamRef ECSubstream;
0115 
0116   DbiModuleList Modules;
0117 
0118   FixedStreamArray<support::ulittle16_t> DbgStreams;
0119 
0120   PdbRaw_DbiSecContribVer SectionContribVersion =
0121       PdbRaw_DbiSecContribVer::DbiSecContribVer60;
0122   FixedStreamArray<SectionContrib> SectionContribs;
0123   FixedStreamArray<SectionContrib2> SectionContribs2;
0124   FixedStreamArray<SecMapEntry> SectionMap;
0125 
0126   std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream;
0127   FixedStreamArray<object::coff_section> SectionHeaders;
0128 
0129   std::unique_ptr<msf::MappedBlockStream> OldFpoStream;
0130   FixedStreamArray<object::FpoData> OldFpoRecords;
0131   
0132   std::unique_ptr<msf::MappedBlockStream> NewFpoStream;
0133   codeview::DebugFrameDataSubsectionRef NewFpoRecords;
0134 
0135   const DbiStreamHeader *Header;
0136 };
0137 }
0138 }
0139 
0140 #endif