ModuleDebugStream.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ModuleDebugStream.h - PDB Module Info Stream Access ------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
  14. #define LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
  15. #include "llvm/ADT/iterator_range.h"
  16. #include "llvm/DebugInfo/CodeView/CVRecord.h"
  17. #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
  18. #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
  19. #include "llvm/Support/BinaryStreamRef.h"
  20. #include "llvm/Support/Error.h"
  21. #include <cstdint>
  22. #include <memory>
  23. namespace llvm {
  24. class BinaryStreamReader;
  25. namespace codeview {
  26. class DebugChecksumsSubsectionRef;
  27. }
  28. namespace msf {
  29. class MappedBlockStream;
  30. }
  31. namespace pdb {
  32. class ModuleDebugStreamRef {
  33. using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator;
  34. public:
  35. ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
  36. std::unique_ptr<msf::MappedBlockStream> Stream);
  37. ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;
  38. ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default;
  39. ~ModuleDebugStreamRef();
  40. Error reload();
  41. uint32_t signature() const { return Signature; }
  42. iterator_range<codeview::CVSymbolArray::Iterator>
  43. symbols(bool *HadError) const;
  44. const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
  45. const codeview::CVSymbolArray
  46. getSymbolArrayForScope(uint32_t ScopeBegin) const;
  47. BinarySubstreamRef getSymbolsSubstream() const;
  48. BinarySubstreamRef getC11LinesSubstream() const;
  49. BinarySubstreamRef getC13LinesSubstream() const;
  50. BinarySubstreamRef getGlobalRefsSubstream() const;
  51. ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = delete;
  52. codeview::CVSymbol readSymbolAtOffset(uint32_t Offset) const;
  53. iterator_range<DebugSubsectionIterator> subsections() const;
  54. codeview::DebugSubsectionArray getSubsectionsArray() const {
  55. return Subsections;
  56. }
  57. bool hasDebugSubsections() const;
  58. Error commit();
  59. Expected<codeview::DebugChecksumsSubsectionRef>
  60. findChecksumsSubsection() const;
  61. private:
  62. Error reloadSerialize(BinaryStreamReader &Reader);
  63. DbiModuleDescriptor Mod;
  64. uint32_t Signature;
  65. std::shared_ptr<msf::MappedBlockStream> Stream;
  66. codeview::CVSymbolArray SymbolArray;
  67. BinarySubstreamRef SymbolsSubstream;
  68. BinarySubstreamRef C11LinesSubstream;
  69. BinarySubstreamRef C13LinesSubstream;
  70. BinarySubstreamRef GlobalRefsSubstream;
  71. codeview::DebugSubsectionArray Subsections;
  72. };
  73. } // end namespace pdb
  74. } // end namespace llvm
  75. #endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
  76. #ifdef __GNUC__
  77. #pragma GCC diagnostic pop
  78. #endif