[llvm] b3c9ced - [ORC] Allow EPCDebugObjectRegistrar clients to specify registration fn dylib.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 08:50:35 PDT 2022


Author: Lang Hames
Date: 2022-10-25T08:50:27-07:00
New Revision: b3c9ced93cbc4a497ea350737f80e4d108a7fa53

URL: https://github.com/llvm/llvm-project/commit/b3c9ced93cbc4a497ea350737f80e4d108a7fa53
DIFF: https://github.com/llvm/llvm-project/commit/b3c9ced93cbc4a497ea350737f80e4d108a7fa53.diff

LOG: [ORC] Allow EPCDebugObjectRegistrar clients to specify registration fn dylib.

Similar to the EPCEHFrameRegistrar change in c977251ef6f, this allows clients
who have sourced a dylib handle via a side-channel to search that dylib to
find the registration functions.

This patch defaults to the existing behavior in the case where the client does
not specify a handle to use.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
    llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
index 241453320ad5..7aa59d792468 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h
@@ -50,9 +50,15 @@ class EPCDebugObjectRegistrar : public DebugObjectRegistrar {
 };
 
 /// Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug
-/// objects to the GDB JIT interface.
-Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
-createJITLoaderGDBRegistrar(ExecutionSession &ES);
+/// objects to the GDB JIT interface. This will use the EPC's lookupSymbols
+/// method to find the registration/deregistration  funciton addresses by name.
+///
+/// If RegistrationFunctionsDylib is non-None then it will be searched to find
+/// the registration functions. If it is None then the process dylib will be
+/// loaded to find the registration functions.
+Expected<std::unique_ptr<EPCDebugObjectRegistrar>> createJITLoaderGDBRegistrar(
+    ExecutionSession &ES,
+    Optional<ExecutorAddr> RegistrationFunctionDylib = None);
 
 } // end namespace orc
 } // end namespace llvm

diff  --git a/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp b/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
index c591acdd646b..b980b5055cc6 100644
--- a/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
@@ -17,11 +17,16 @@ namespace llvm {
 namespace orc {
 
 Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
-createJITLoaderGDBRegistrar(ExecutionSession &ES) {
+createJITLoaderGDBRegistrar(ExecutionSession &ES,
+                            Optional<ExecutorAddr> RegistrationFunctionDylib) {
   auto &EPC = ES.getExecutorProcessControl();
-  auto ProcessHandle = EPC.loadDylib(nullptr);
-  if (!ProcessHandle)
-    return ProcessHandle.takeError();
+
+  if (!RegistrationFunctionDylib) {
+    if (auto D = EPC.loadDylib(nullptr))
+      RegistrationFunctionDylib = *D;
+    else
+      return D.takeError();
+  }
 
   SymbolStringPtr RegisterFn =
       EPC.getTargetTriple().isOSBinFormatMachO()
@@ -31,7 +36,8 @@ createJITLoaderGDBRegistrar(ExecutionSession &ES) {
   SymbolLookupSet RegistrationSymbols;
   RegistrationSymbols.add(RegisterFn);
 
-  auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
+  auto Result =
+      EPC.lookupSymbols({{*RegistrationFunctionDylib, RegistrationSymbols}});
   if (!Result)
     return Result.takeError();
 


        


More information about the llvm-commits mailing list