1 //===- EPCDebugObjectRegistrar.h - EPC-based debug registration -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // ExecutorProcessControl based registration of debug objects.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
14 #define LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
15 
16 #include "llvm/ExecutionEngine/JITSymbol.h"
17 #include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
18 #include "llvm/Support/Error.h"
19 #include "llvm/Support/Memory.h"
20 
21 #include <cstdint>
22 #include <memory>
23 #include <vector>
24 
25 using namespace llvm::orc::shared;
26 
27 namespace llvm {
28 namespace orc {
29 
30 class ExecutionSession;
31 
32 /// Abstract interface for registering debug objects in the executor process.
33 class DebugObjectRegistrar {
34 public:
35   virtual Error registerDebugObject(sys::MemoryBlock) = 0;
~DebugObjectRegistrar()36   virtual ~DebugObjectRegistrar() {}
37 };
38 
39 /// Use ExecutorProcessControl to register debug objects locally or in a remote
40 /// executor process.
41 class EPCDebugObjectRegistrar : public DebugObjectRegistrar {
42 public:
EPCDebugObjectRegistrar(ExecutionSession & ES,JITTargetAddress RegisterFn)43   EPCDebugObjectRegistrar(ExecutionSession &ES, JITTargetAddress RegisterFn)
44       : ES(ES), RegisterFn(RegisterFn) {}
45 
46   Error registerDebugObject(sys::MemoryBlock TargetMem) override;
47 
48 private:
49   ExecutionSession &ES;
50   JITTargetAddress RegisterFn;
51 };
52 
53 /// Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug
54 /// objects to the GDB JIT interface.
55 Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
56 createJITLoaderGDBRegistrar(ExecutionSession &ES);
57 
58 } // end namespace orc
59 } // end namespace llvm
60 
61 #endif // LLVM_EXECUTIONENGINE_ORC_EPCDEBUGOBJECTREGISTRAR_H
62