ModuleDebugStream.h revision 360660
1//===- ModuleDebugStream.h - PDB Module Info Stream 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_MODULEDEBUGSTREAM_H
10#define LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
11
12#include "llvm/ADT/iterator_range.h"
13#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
14#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
15#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
16#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
17#include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
18#include "llvm/Support/BinaryStreamRef.h"
19#include "llvm/Support/Error.h"
20#include <cstdint>
21#include <memory>
22
23namespace llvm {
24namespace pdb {
25
26class DbiModuleDescriptor;
27
28class ModuleDebugStreamRef {
29  using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator;
30
31public:
32  ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
33                       std::unique_ptr<msf::MappedBlockStream> Stream);
34  ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;
35  ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default;
36  ~ModuleDebugStreamRef();
37
38  Error reload();
39
40  uint32_t signature() const { return Signature; }
41
42  iterator_range<codeview::CVSymbolArray::Iterator>
43  symbols(bool *HadError) const;
44
45  const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
46  const codeview::CVSymbolArray
47  getSymbolArrayForScope(uint32_t ScopeBegin) const;
48
49  BinarySubstreamRef getSymbolsSubstream() const;
50  BinarySubstreamRef getC11LinesSubstream() const;
51  BinarySubstreamRef getC13LinesSubstream() const;
52  BinarySubstreamRef getGlobalRefsSubstream() const;
53
54  ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = delete;
55
56  codeview::CVSymbol readSymbolAtOffset(uint32_t Offset) const;
57
58  iterator_range<DebugSubsectionIterator> subsections() const;
59  codeview::DebugSubsectionArray getSubsectionsArray() const {
60    return Subsections;
61  }
62
63  bool hasDebugSubsections() const;
64
65  Error commit();
66
67  Expected<codeview::DebugChecksumsSubsectionRef>
68  findChecksumsSubsection() const;
69
70private:
71  Error reloadSerialize(BinaryStreamReader &Reader);
72
73  DbiModuleDescriptor Mod;
74
75  uint32_t Signature;
76
77  std::shared_ptr<msf::MappedBlockStream> Stream;
78
79  codeview::CVSymbolArray SymbolArray;
80
81  BinarySubstreamRef SymbolsSubstream;
82  BinarySubstreamRef C11LinesSubstream;
83  BinarySubstreamRef C13LinesSubstream;
84  BinarySubstreamRef GlobalRefsSubstream;
85
86  codeview::DebugSubsectionArray Subsections;
87};
88
89} // end namespace pdb
90} // end namespace llvm
91
92#endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
93