[llvm] [llvm-c] Expose debug object registration in Orc C-API bindings (PR #73257)

Stefan Gränitz via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 23 10:42:51 PST 2023


================
@@ -863,6 +866,31 @@ void LLVMOrcObjectLayerEmit(LLVMOrcObjectLayerRef ObjLayer,
       std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer)));
 }
 
+LLVMErrorRef
+LLVMOrcObjectLayerRegisterPluginJITLoaderGDB(LLVMOrcObjectLayerRef ObjLayer,
+                                             LLVMBool RequireDebugSectionsFlag,
+                                             LLVMBool AutoRegisterCodeFlag) {
+  ExecutionSession &ES = unwrap(ObjLayer)->getExecutionSession();
+  auto Registrar = createJITLoaderGDBRegistrar(ES);
+  if (!Registrar)
+    return wrap(Registrar.takeError());
+
+  auto *ObjLinkingLayer = cast<ObjectLinkingLayer>(unwrap(ObjLayer));
+  if (!ObjLinkingLayer)
+    return wrap(
+        createStringError(inconvertibleErrorCode(),
+                          "No debug support for given object layer type"));
+
+  ObjLinkingLayer->addPlugin(std::make_unique<DebugObjectManagerPlugin>(
+      ES, std::move(*Registrar), RequireDebugSectionsFlag,
+      AutoRegisterCodeFlag));
+
+  auto TargetProcessFn = &llvm_orc_registerJITLoaderGDBWrapper;
+  (void)TargetProcessFn;
----------------
weliveindetail wrote:

This would make sure that the `llvm_orc_registerJITLoaderGDBWrapper()` function is available in the final binary. It would spare in-process users the burden of understanding the details, but I just realize that it creates a dependency from OrcJIT to OrcTargetProcess and we cannot do that. We don't want to move it to OrcShared either right?

https://github.com/llvm/llvm-project/pull/73257


More information about the llvm-commits mailing list