ModuleDebugStream.h revision 353358
11590Srgrimes//===- ModuleDebugStream.h - PDB Module Info Stream Access ------*- C++ -*-===//
21590Srgrimes//
31590Srgrimes// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
41590Srgrimes// See https://llvm.org/LICENSE.txt for license information.
51590Srgrimes// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61590Srgrimes//
71590Srgrimes//===----------------------------------------------------------------------===//
81590Srgrimes
91590Srgrimes#ifndef LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
101590Srgrimes#define LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
111590Srgrimes
121590Srgrimes#include "llvm/ADT/iterator_range.h"
131590Srgrimes#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
141590Srgrimes#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
151590Srgrimes#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
161590Srgrimes#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
171590Srgrimes#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
181590Srgrimes#include "llvm/Support/BinaryStreamRef.h"
191590Srgrimes#include "llvm/Support/Error.h"
201590Srgrimes#include <cstdint>
211590Srgrimes#include <memory>
221590Srgrimes
231590Srgrimesnamespace llvm {
241590Srgrimesnamespace pdb {
251590Srgrimes
261590Srgrimesclass DbiModuleDescriptor;
271590Srgrimes
281590Srgrimesclass ModuleDebugStreamRef {
291590Srgrimes  using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator;
301590Srgrimes
311590Srgrimespublic:
321590Srgrimes  ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
331590Srgrimes                       std::unique_ptr<msf::MappedBlockStream> Stream);
341590Srgrimes  ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;
3527315Scharnier  ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default;
361590Srgrimes  ~ModuleDebugStreamRef();
3727315Scharnier
3827315Scharnier  Error reload();
3950477Speter
401590Srgrimes  uint32_t signature() const { return Signature; }
411590Srgrimes
421590Srgrimes  iterator_range<codeview::CVSymbolArray::Iterator>
431590Srgrimes  symbols(bool *HadError) const;
4427315Scharnier
451590Srgrimes  const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
461590Srgrimes  const codeview::CVSymbolArray
471590Srgrimes  getSymbolArrayForScope(uint32_t ScopeBegin) const;
481590Srgrimes
491590Srgrimes  BinarySubstreamRef getSymbolsSubstream() const;
501590Srgrimes  BinarySubstreamRef getC11LinesSubstream() const;
511590Srgrimes  BinarySubstreamRef getC13LinesSubstream() const;
521590Srgrimes  BinarySubstreamRef getGlobalRefsSubstream() const;
531590Srgrimes
541590Srgrimes  ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = delete;
551590Srgrimes
561590Srgrimes  codeview::CVSymbol readSymbolAtOffset(uint32_t Offset) const;
571590Srgrimes
5830921Sache  iterator_range<DebugSubsectionIterator> subsections() const;
591590Srgrimes  codeview::DebugSubsectionArray getSubsectionsArray() const {
601590Srgrimes    return Subsections;
611590Srgrimes  }
621590Srgrimes
631590Srgrimes  bool hasDebugSubsections() const;
6427315Scharnier
651590Srgrimes  Error commit();
661590Srgrimes
6727315Scharnier  Expected<codeview::DebugChecksumsSubsectionRef>
681590Srgrimes  findChecksumsSubsection() const;
691590Srgrimes
701590Srgrimesprivate:
711590Srgrimes  Error reloadSerialize(BinaryStreamReader &Reader);
721590Srgrimes
731590Srgrimes  DbiModuleDescriptor Mod;
741590Srgrimes
751590Srgrimes  uint32_t Signature;
761590Srgrimes
771590Srgrimes  std::shared_ptr<msf::MappedBlockStream> Stream;
781590Srgrimes
791590Srgrimes  codeview::CVSymbolArray SymbolArray;
801590Srgrimes
811590Srgrimes  BinarySubstreamRef SymbolsSubstream;
8287203Smarkm  BinarySubstreamRef C11LinesSubstream;
831590Srgrimes  BinarySubstreamRef C13LinesSubstream;
8487203Smarkm  BinarySubstreamRef GlobalRefsSubstream;
851590Srgrimes
861590Srgrimes  codeview::DebugSubsectionArray Subsections;
871590Srgrimes};
881590Srgrimes
891590Srgrimes} // end namespace pdb
9080290Sobrien} // end namespace llvm
9180290Sobrien
921590Srgrimes#endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
931590Srgrimes