ModuleDebugStream.h revision 327952
1128032Stjr//===- ModuleDebugStream.h - PDB Module Info Stream Access ------*- C++ -*-===//
2102050Stjr//
3102050Stjr//                     The LLVM Compiler Infrastructure
4102050Stjr//
5102050Stjr// This file is distributed under the University of Illinois Open Source
6102050Stjr// License. See LICENSE.TXT for details.
7102050Stjr//
8102050Stjr//===----------------------------------------------------------------------===//
9102050Stjr
10102050Stjr#ifndef LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
11102050Stjr#define LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
12102050Stjr
13102050Stjr#include "llvm/ADT/iterator_range.h"
14102050Stjr#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
15102050Stjr#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
16102050Stjr#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
17102050Stjr#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
18102050Stjr#include "llvm/Support/BinaryStreamRef.h"
19102050Stjr#include "llvm/Support/Error.h"
20102050Stjr#include <cstdint>
21102050Stjr#include <memory>
22102050Stjr
23102050Stjrnamespace llvm {
24102050Stjrnamespace pdb {
25102050Stjr
26132497Stjrclass DbiModuleDescriptor;
27102050Stjr
28102050Stjrclass ModuleDebugStreamRef {
29102050Stjr  using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator;
30132497Stjr
31132497Stjrpublic:
32102050Stjr  ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
33102050Stjr                       std::unique_ptr<msf::MappedBlockStream> Stream);
34102050Stjr  ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;
35102050Stjr  ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default;
36102050Stjr  ~ModuleDebugStreamRef();
37102050Stjr
38107392Sru  Error reload();
39107392Sru
40107392Sru  uint32_t signature() const { return Signature; }
41107392Sru
42132497Stjr  iterator_range<codeview::CVSymbolArray::Iterator>
43132497Stjr  symbols(bool *HadError) const;
44132497Stjr
45132497Stjr  const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
46132497Stjr
47102050Stjr  BinarySubstreamRef getSymbolsSubstream() const;
48102050Stjr  BinarySubstreamRef getC11LinesSubstream() const;
49102050Stjr  BinarySubstreamRef getC13LinesSubstream() const;
50102050Stjr  BinarySubstreamRef getGlobalRefsSubstream() const;
51102050Stjr
52102050Stjr  ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = default;
53102050Stjr
54102050Stjr  iterator_range<DebugSubsectionIterator> subsections() const;
55107392Sru  codeview::DebugSubsectionArray getSubsectionsArray() const {
56102050Stjr    return Subsections;
57102050Stjr  }
58107392Sru
59107392Sru  bool hasDebugSubsections() const;
60102050Stjr
61102050Stjr  Error commit();
62102050Stjr
63102050Stjr  Expected<codeview::DebugChecksumsSubsectionRef>
64102050Stjr  findChecksumsSubsection() const;
65102050Stjr
66102050Stjrprivate:
67102050Stjr  const DbiModuleDescriptor &Mod;
68102050Stjr
69102050Stjr  uint32_t Signature;
70102050Stjr
71102050Stjr  std::shared_ptr<msf::MappedBlockStream> Stream;
72102050Stjr
73102050Stjr  codeview::CVSymbolArray SymbolArray;
74102050Stjr
75107392Sru  BinarySubstreamRef SymbolsSubstream;
76102050Stjr  BinarySubstreamRef C11LinesSubstream;
77102050Stjr  BinarySubstreamRef C13LinesSubstream;
78102050Stjr  BinarySubstreamRef GlobalRefsSubstream;
79102050Stjr
80107392Sru  codeview::DebugSubsectionArray Subsections;
81102050Stjr};
82102050Stjr
83102050Stjr} // end namespace pdb
84102050Stjr} // end namespace llvm
85102050Stjr
86102050Stjr#endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
87102050Stjr