[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:50 PST 2023


================
@@ -494,6 +496,70 @@ TEST_F(OrcCAPITestBase, AddObjectBuffer) {
   ASSERT_TRUE(!!SumAddr);
 }
 
+// This must be kept in sync with gdb/gdb/jit.h .
+extern "C" {
+
+typedef enum {
+  JIT_NOACTION = 0,
+  JIT_REGISTER_FN,
+  JIT_UNREGISTER_FN
+} jit_actions_t;
+
+struct jit_code_entry {
+  struct jit_code_entry *next_entry;
+  struct jit_code_entry *prev_entry;
+  const char *symfile_addr;
+  uint64_t symfile_size;
+};
+
+struct jit_descriptor {
+  uint32_t version;
+  // This should be jit_actions_t, but we want to be specific about the
+  // bit-width.
+  uint32_t action_flag;
+  struct jit_code_entry *relevant_entry;
+  struct jit_code_entry *first_entry;
+};
+
+// We put information about the JITed function in this global, which the
+// debugger reads.  Make sure to specify the version statically, because the
+// debugger checks the version before we can set it during runtime.
+extern "C" struct jit_descriptor __jit_debug_descriptor;
+}
+
+#if defined(_AIX)
+TEST_F(OrcCAPITestBase, DISABLED_RegisterJITLoaderGDB) {
+#else
+TEST_F(OrcCAPITestBase, RegisterJITLoaderGDB) {
+#endif
+  LLVMOrcObjectLayerRef ObjLayer = LLVMOrcLLJITGetObjLinkingLayer(Jit);
+  auto *ObjLinkingLayer = cast<orc::ObjectLinkingLayer>(unwrap(ObjLayer));
+  ASSERT_TRUE(ObjLinkingLayer);
----------------
weliveindetail wrote:

I have to change this, because we may get the legacy `RTDyldObjectLinkingLayer` for some platforms right? And we cannot add the plugin there. What is the best way to express this?
(1) Exit early? Then the test would succeed without actually testing the registration. Might be confusing.
(2) Explicitly enable the test for the platforms we know? And add an XFAIL test for all others?

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


More information about the llvm-commits mailing list