ModuleDebugStream.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/DebugChecksumsSubsection.h"
  17. #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
  18. #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
  19. #include "llvm/DebugInfo/MSF/MappedBlockStream.h"
  20. #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"
  21. #include "llvm/Support/BinaryStreamRef.h"
  22. #include "llvm/Support/Error.h"
  23. #include <cstdint>
  24. #include <memory>
  25. namespace llvm {
  26. namespace pdb {
  27. class DbiModuleDescriptor;
  28. class ModuleDebugStreamRef {
  29. using DebugSubsectionIterator = codeview::DebugSubsectionArray::Iterator;
  30. public:
  31. ModuleDebugStreamRef(const DbiModuleDescriptor &Module,
  32. std::unique_ptr<msf::MappedBlockStream> Stream);
  33. ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;
  34. ModuleDebugStreamRef(const ModuleDebugStreamRef &Other) = default;
  35. ~ModuleDebugStreamRef();
  36. Error reload();
  37. uint32_t signature() const { return Signature; }
  38. iterator_range<codeview::CVSymbolArray::Iterator>
  39. symbols(bool *HadError) const;
  40. const codeview::CVSymbolArray &getSymbolArray() const { return SymbolArray; }
  41. const codeview::CVSymbolArray
  42. getSymbolArrayForScope(uint32_t ScopeBegin) const;
  43. BinarySubstreamRef getSymbolsSubstream() const;
  44. BinarySubstreamRef getC11LinesSubstream() const;
  45. BinarySubstreamRef getC13LinesSubstream() const;
  46. BinarySubstreamRef getGlobalRefsSubstream() const;
  47. ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = delete;
  48. codeview::CVSymbol readSymbolAtOffset(uint32_t Offset) const;
  49. iterator_range<DebugSubsectionIterator> subsections() const;
  50. codeview::DebugSubsectionArray getSubsectionsArray() const {
  51. return Subsections;
  52. }
  53. bool hasDebugSubsections() const;
  54. Error commit();
  55. Expected<codeview::DebugChecksumsSubsectionRef>
  56. findChecksumsSubsection() const;
  57. private:
  58. Error reloadSerialize(BinaryStreamReader &Reader);
  59. DbiModuleDescriptor Mod;
  60. uint32_t Signature;
  61. std::shared_ptr<msf::MappedBlockStream> Stream;
  62. codeview::CVSymbolArray SymbolArray;
  63. BinarySubstreamRef SymbolsSubstream;
  64. BinarySubstreamRef C11LinesSubstream;
  65. BinarySubstreamRef C13LinesSubstream;
  66. BinarySubstreamRef GlobalRefsSubstream;
  67. codeview::DebugSubsectionArray Subsections;
  68. };
  69. } // end namespace pdb
  70. } // end namespace llvm
  71. #endif // LLVM_DEBUGINFO_PDB_NATIVE_MODULEDEBUGSTREAM_H
  72. #ifdef __GNUC__
  73. #pragma GCC diagnostic pop
  74. #endif