1515
1616#include " llvm/ADT/StringRef.h"
1717#include " llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
18+ #include " llvm/ExecutionEngine/Orc/DylibManager.h"
1819#include " llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
1920#include " llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
2021#include " llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
@@ -32,7 +33,6 @@ namespace llvm {
3233namespace orc {
3334
3435class ExecutionSession ;
35- class SymbolLookupSet ;
3636
3737// / ExecutorProcessControl supports interaction with a JIT target process.
3838class ExecutorProcessControl {
@@ -172,14 +172,6 @@ class ExecutorProcessControl {
172172 }
173173 };
174174
175- // / A pair of a dylib and a set of symbols to be looked up.
176- struct LookupRequest {
177- LookupRequest (tpctypes::DylibHandle Handle, const SymbolLookupSet &Symbols)
178- : Handle(Handle), Symbols(Symbols) {}
179- tpctypes::DylibHandle Handle;
180- const SymbolLookupSet &Symbols;
181- };
182-
183175 // / Contains the address of the dispatch function and context that the ORC
184176 // / runtime can use to call functions in the JIT.
185177 struct JITDispatchInfo {
@@ -229,6 +221,12 @@ class ExecutorProcessControl {
229221 return *MemMgr;
230222 }
231223
224+ // / Return the DylibManager for the target process.
225+ DylibManager &getDylibMgr () const {
226+ assert (DylibMgr && " No DylibMgr object set" );
227+ return *DylibMgr;
228+ }
229+
232230 // / Returns the bootstrap map.
233231 const StringMap<std::vector<char >> &getBootstrapMap () const {
234232 return BootstrapMap;
@@ -277,38 +275,6 @@ class ExecutorProcessControl {
277275 return Error::success ();
278276 }
279277
280- // / Load the dynamic library at the given path and return a handle to it.
281- // / If LibraryPath is null this function will return the global handle for
282- // / the target process.
283- virtual Expected<tpctypes::DylibHandle> loadDylib (const char *DylibPath) = 0;
284-
285- // / Search for symbols in the target process.
286- // /
287- // / The result of the lookup is a 2-dimensional array of target addresses
288- // / that correspond to the lookup order. If a required symbol is not
289- // / found then this method will return an error. If a weakly referenced
290- // / symbol is not found then it be assigned a '0' value.
291- Expected<std::vector<tpctypes::LookupResult>>
292- lookupSymbols (ArrayRef<LookupRequest> Request) {
293- std::promise<MSVCPExpected<std::vector<tpctypes::LookupResult>>> RP;
294- auto RF = RP.get_future ();
295- lookupSymbolsAsync (Request,
296- [&RP](auto Result) { RP.set_value (std::move (Result)); });
297- return RF.get ();
298- }
299-
300- using SymbolLookupCompleteFn =
301- unique_function<void (Expected<std::vector<tpctypes::LookupResult>>)>;
302-
303- // / Search for symbols in the target process.
304- // /
305- // / The result of the lookup is a 2-dimensional array of target addresses
306- // / that correspond to the lookup order. If a required symbol is not
307- // / found then this method will return an error. If a weakly referenced
308- // / symbol is not found then it be assigned a '0' value.
309- virtual void lookupSymbolsAsync (ArrayRef<LookupRequest> Request,
310- SymbolLookupCompleteFn F) = 0;
311-
312278 // / Run function with a main-like signature.
313279 virtual Expected<int32_t > runAsMain (ExecutorAddr MainFnAddr,
314280 ArrayRef<std::string> Args) = 0;
@@ -426,6 +392,7 @@ class ExecutorProcessControl {
426392 JITDispatchInfo JDI;
427393 MemoryAccess *MemAccess = nullptr ;
428394 jitlink::JITLinkMemoryManager *MemMgr = nullptr ;
395+ DylibManager *DylibMgr = nullptr ;
429396 StringMap<std::vector<char >> BootstrapMap;
430397 StringMap<ExecutorAddr> BootstrapSymbols;
431398};
@@ -474,15 +441,6 @@ class UnsupportedExecutorProcessControl : public ExecutorProcessControl,
474441 this ->MemAccess = this ;
475442 }
476443
477- Expected<tpctypes::DylibHandle> loadDylib (const char *DylibPath) override {
478- llvm_unreachable (" Unsupported" );
479- }
480-
481- void lookupSymbolsAsync (ArrayRef<LookupRequest> Request,
482- SymbolLookupCompleteFn F) override {
483- llvm_unreachable (" Unsupported" );
484- }
485-
486444 Expected<int32_t > runAsMain (ExecutorAddr MainFnAddr,
487445 ArrayRef<std::string> Args) override {
488446 llvm_unreachable (" Unsupported" );
@@ -507,7 +465,8 @@ class UnsupportedExecutorProcessControl : public ExecutorProcessControl,
507465
508466// / A ExecutorProcessControl implementation targeting the current process.
509467class SelfExecutorProcessControl : public ExecutorProcessControl ,
510- private InProcessMemoryAccess {
468+ private InProcessMemoryAccess,
469+ private DylibManager {
511470public:
512471 SelfExecutorProcessControl (
513472 std::shared_ptr<SymbolStringPool> SSP, std::unique_ptr<TaskDispatcher> D,
@@ -524,11 +483,6 @@ class SelfExecutorProcessControl : public ExecutorProcessControl,
524483 std::unique_ptr<TaskDispatcher> D = nullptr ,
525484 std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr = nullptr );
526485
527- Expected<tpctypes::DylibHandle> loadDylib (const char *DylibPath) override ;
528-
529- void lookupSymbolsAsync (ArrayRef<LookupRequest> Request,
530- SymbolLookupCompleteFn F) override ;
531-
532486 Expected<int32_t > runAsMain (ExecutorAddr MainFnAddr,
533487 ArrayRef<std::string> Args) override ;
534488
@@ -547,6 +501,11 @@ class SelfExecutorProcessControl : public ExecutorProcessControl,
547501 jitDispatchViaWrapperFunctionManager (void *Ctx, const void *FnTag,
548502 const char *Data, size_t Size);
549503
504+ Expected<tpctypes::DylibHandle> loadDylib (const char *DylibPath) override ;
505+
506+ void lookupSymbolsAsync (ArrayRef<LookupRequest> Request,
507+ SymbolLookupCompleteFn F) override ;
508+
550509 std::unique_ptr<jitlink::JITLinkMemoryManager> OwnedMemMgr;
551510 char GlobalManglingPrefix = 0 ;
552511};
0 commit comments