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