• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- ModuleDebugStream.h - PDB Module Info Stream Access ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
11 #define LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
12 
13 #include "llvm/ADT/iterator_range.h"
14 #include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
15 #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
16 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
17 #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
18 #include "llvm/Support/BinaryStreamRef.h"
19 #include "llvm/Support/Error.h"
20 #include <cstdint>
21 #include <memory>
22 
23 namespace llvm {
24 namespace pdb {
25 
26 class DbiModuleDescriptor;
27 
28 class ModuleDebugStreamRef {
29   using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator;
30 
31 public:
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 
signature()40   uint32_t signature() const { return Signature; }
41 
42   iterator_range<codeview::CVSymbolArray::Iterator>
43   symbols(bool *HadError) const;
44 
getSymbolArray()45   const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
46 
47   BinarySubstreamRef getSymbolsSubstream() const;
48   BinarySubstreamRef getC11LinesSubstream() const;
49   BinarySubstreamRef getC13LinesSubstream() const;
50   BinarySubstreamRef getGlobalRefsSubstream() const;
51 
52   ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = delete;
53 
54   iterator_range<DebugSubsectionIterator> subsections() const;
getSubsectionsArray()55   codeview::DebugSubsectionArray getSubsectionsArray() const {
56     return Subsections;
57   }
58 
59   bool hasDebugSubsections() const;
60 
61   Error commit();
62 
63   Expected<codeview::DebugChecksumsSubsectionRef>
64   findChecksumsSubsection() const;
65 
66 private:
67   const DbiModuleDescriptor &Mod;
68 
69   uint32_t Signature;
70 
71   std::shared_ptr<msf::MappedBlockStream> Stream;
72 
73   codeview::CVSymbolArray SymbolArray;
74 
75   BinarySubstreamRef SymbolsSubstream;
76   BinarySubstreamRef C11LinesSubstream;
77   BinarySubstreamRef C13LinesSubstream;
78   BinarySubstreamRef GlobalRefsSubstream;
79 
80   codeview::DebugSubsectionArray Subsections;
81 };
82 
83 } // end namespace pdb
84 } // end namespace llvm
85 
86 #endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
87