EPCDebugObjectRegistrar.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- EPCDebugObjectRegistrar.h - EPC-based debug registration -*- 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. //
  14. // ExecutorProcessControl based registration of debug objects.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
  18. #define LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
  19. #include "llvm/ExecutionEngine/JITSymbol.h"
  20. #include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
  21. #include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
  22. #include "llvm/Support/Error.h"
  23. #include "llvm/Support/Memory.h"
  24. #include <cstdint>
  25. #include <memory>
  26. #include <vector>
  27. namespace llvm {
  28. namespace orc {
  29. class ExecutionSession;
  30. /// Abstract interface for registering debug objects in the executor process.
  31. class DebugObjectRegistrar {
  32. public:
  33. virtual Error registerDebugObject(ExecutorAddrRange TargetMem) = 0;
  34. virtual ~DebugObjectRegistrar() = default;
  35. };
  36. /// Use ExecutorProcessControl to register debug objects locally or in a remote
  37. /// executor process.
  38. class EPCDebugObjectRegistrar : public DebugObjectRegistrar {
  39. public:
  40. EPCDebugObjectRegistrar(ExecutionSession &ES, ExecutorAddr RegisterFn)
  41. : ES(ES), RegisterFn(RegisterFn) {}
  42. Error registerDebugObject(ExecutorAddrRange TargetMem) override;
  43. private:
  44. ExecutionSession &ES;
  45. ExecutorAddr RegisterFn;
  46. };
  47. /// Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug
  48. /// objects to the GDB JIT interface. This will use the EPC's lookupSymbols
  49. /// method to find the registration/deregistration funciton addresses by name.
  50. ///
  51. /// If RegistrationFunctionsDylib is non-None then it will be searched to find
  52. /// the registration functions. If it is None then the process dylib will be
  53. /// loaded to find the registration functions.
  54. Expected<std::unique_ptr<EPCDebugObjectRegistrar>> createJITLoaderGDBRegistrar(
  55. ExecutionSession &ES,
  56. std::optional<ExecutorAddr> RegistrationFunctionDylib = std::nullopt);
  57. } // end namespace orc
  58. } // end namespace llvm
  59. #endif // LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
  60. #ifdef __GNUC__
  61. #pragma GCC diagnostic pop
  62. #endif