IPDBSession.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- IPDBSession.h - base interface for a PDB symbol context --*- 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_IPDBSESSION_H
  14. #define LLVM_DEBUGINFO_PDB_IPDBSESSION_H
  15. #include "PDBSymbol.h"
  16. #include "PDBTypes.h"
  17. #include "llvm/ADT/StringRef.h"
  18. #include "llvm/Support/Casting.h"
  19. #include <memory>
  20. namespace llvm {
  21. namespace pdb {
  22. class PDBSymbolCompiland;
  23. class PDBSymbolExe;
  24. /// IPDBSession defines an interface used to provide a context for querying
  25. /// debug information from a debug data source (for example, a PDB).
  26. class IPDBSession {
  27. public:
  28. virtual ~IPDBSession();
  29. virtual uint64_t getLoadAddress() const = 0;
  30. virtual bool setLoadAddress(uint64_t Address) = 0;
  31. virtual std::unique_ptr<PDBSymbolExe> getGlobalScope() = 0;
  32. virtual std::unique_ptr<PDBSymbol>
  33. getSymbolById(SymIndexId SymbolId) const = 0;
  34. virtual bool addressForVA(uint64_t VA, uint32_t &Section,
  35. uint32_t &Offset) const = 0;
  36. virtual bool addressForRVA(uint32_t RVA, uint32_t &Section,
  37. uint32_t &Offset) const = 0;
  38. template <typename T>
  39. std::unique_ptr<T> getConcreteSymbolById(SymIndexId SymbolId) const {
  40. return unique_dyn_cast_or_null<T>(getSymbolById(SymbolId));
  41. }
  42. virtual std::unique_ptr<PDBSymbol> findSymbolByAddress(uint64_t Address,
  43. PDB_SymType Type) = 0;
  44. virtual std::unique_ptr<PDBSymbol> findSymbolByRVA(uint32_t RVA,
  45. PDB_SymType Type) = 0;
  46. virtual std::unique_ptr<PDBSymbol>
  47. findSymbolBySectOffset(uint32_t Sect, uint32_t Offset, PDB_SymType Type) = 0;
  48. virtual std::unique_ptr<IPDBEnumLineNumbers>
  49. findLineNumbers(const PDBSymbolCompiland &Compiland,
  50. const IPDBSourceFile &File) const = 0;
  51. virtual std::unique_ptr<IPDBEnumLineNumbers>
  52. findLineNumbersByAddress(uint64_t Address, uint32_t Length) const = 0;
  53. virtual std::unique_ptr<IPDBEnumLineNumbers>
  54. findLineNumbersByRVA(uint32_t RVA, uint32_t Length) const = 0;
  55. virtual std::unique_ptr<IPDBEnumLineNumbers>
  56. findLineNumbersBySectOffset(uint32_t Section, uint32_t Offset,
  57. uint32_t Length) const = 0;
  58. virtual std::unique_ptr<IPDBEnumSourceFiles>
  59. findSourceFiles(const PDBSymbolCompiland *Compiland, llvm::StringRef Pattern,
  60. PDB_NameSearchFlags Flags) const = 0;
  61. virtual std::unique_ptr<IPDBSourceFile>
  62. findOneSourceFile(const PDBSymbolCompiland *Compiland,
  63. llvm::StringRef Pattern,
  64. PDB_NameSearchFlags Flags) const = 0;
  65. virtual std::unique_ptr<IPDBEnumChildren<PDBSymbolCompiland>>
  66. findCompilandsForSourceFile(llvm::StringRef Pattern,
  67. PDB_NameSearchFlags Flags) const = 0;
  68. virtual std::unique_ptr<PDBSymbolCompiland>
  69. findOneCompilandForSourceFile(llvm::StringRef Pattern,
  70. PDB_NameSearchFlags Flags) const = 0;
  71. virtual std::unique_ptr<IPDBEnumSourceFiles> getAllSourceFiles() const = 0;
  72. virtual std::unique_ptr<IPDBEnumSourceFiles>
  73. getSourceFilesForCompiland(const PDBSymbolCompiland &Compiland) const = 0;
  74. virtual std::unique_ptr<IPDBSourceFile>
  75. getSourceFileById(uint32_t FileId) const = 0;
  76. virtual std::unique_ptr<IPDBEnumDataStreams> getDebugStreams() const = 0;
  77. virtual std::unique_ptr<IPDBEnumTables> getEnumTables() const = 0;
  78. virtual std::unique_ptr<IPDBEnumInjectedSources>
  79. getInjectedSources() const = 0;
  80. virtual std::unique_ptr<IPDBEnumSectionContribs>
  81. getSectionContribs() const = 0;
  82. virtual std::unique_ptr<IPDBEnumFrameData>
  83. getFrameData() const = 0;
  84. };
  85. } // namespace pdb
  86. } // namespace llvm
  87. #endif
  88. #ifdef __GNUC__
  89. #pragma GCC diagnostic pop
  90. #endif