[llvm-dev] Moving to ORCv2 - Compiling debuggable code?

84 views
Skip to first unread message

Geoff Levner via llvm-dev

unread,
Dec 19, 2019, 10:31:47 AM12/19/19
to llvm-dev
I too am in the process of porting our ORC code to ORC v2 and LLJIT. The new API allows me to remove much of our own code, which can only be a good thing. I sometimes get crashes, however, when executing my JIT compiled function, so I thought I would use gdb to try to figure out what is going wrong. And I am dismayed to see that there seems to be no way to provide an event listener to register compiled functions with gdb. LLJIT creates an object linking layer with no listeners, and no way to add listeners afterwards that I can see.

Am I missing something? Is there another way to debug JIT compiled code?

Geoff

David Blaikie via llvm-dev

unread,
Dec 19, 2019, 2:51:01 PM12/19/19
to Geoff Levner, Lang Hames, llvm-dev
+Lang Hames  the author/owner of the ORC JIT - though he's out of teh office at the moment I think, so might not get a reply until the new year I'd expect. Perhaps other folks familiar with it might chime in, though.

_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Praveen Velliengiri via llvm-dev

unread,
Dec 19, 2019, 3:02:06 PM12/19/19
to David Blaikie, llvm-dev
Dear Geoff,
As for as ORCv2 is concerned, there is no event listener facility available as of now.

Thanks

River Riddle via llvm-dev

unread,
Dec 19, 2019, 6:19:49 PM12/19/19
to Praveen Velliengiri, llvm-dev
If you are creating your own object linking layer via LLJITBuilder, you could add the notification yourself. For RTDyldObjectLinkingLayer, you can use `setNotifyLoaded`. For ObjectLinkingLayer, I think you would need to use a `ObjectLinkingLayer::Plugin`. I was able to hook the existing GDB registration listener this way.

-- River

Geoff Levner via llvm-dev

unread,
Dec 20, 2019, 3:47:37 AM12/20/19
to River Riddle, llvm-dev
Hmm, the things of which you speak (LLJITBuilder, setNotifyLoaded(),
ObjectLinkingLayer) do not seem to exist in LLVM 8. We may have to
jump directly from LLVM 7 to LLVM 9 then....

Thanks,
Geoff

Geoff Levner via llvm-dev

unread,
Dec 20, 2019, 7:52:30 AM12/20/19
to River Riddle, llvm-dev
For anyone interested, the reason our JIT compiled code was crashing is that, in LLVM 8, LLJIT::addIRModule() does not record constructors, so global variables were not constructed. (LLLazyJIT does record constructors, but we don't need LLLazyJIT.) The solution was to derive a subclass of LLJIT and provide an addIRModule() method that records constructors and destructors. Perhaps this was fixed in more recent versions of LLVM...

Geoff

Stefan Gränitz via llvm-dev

unread,
Dec 20, 2019, 7:05:00 PM12/20/19
to Geoff Levner, River Riddle, llvm-dev
Hi Geoff

There's been an API change from 8 to 9, but it should work with both
versions. LLJIT is only one possible implementation and doesn't provide
all functionality. Make your own. Hope it helps.

Release 8: https://github.com/weliveindetail/JitFromScratch/commit/4e858ef
Release 9: https://github.com/weliveindetail/JitFromScratch/commit/a4b88a0

Best,
Stefan

--
https://flowcrypt.com/pub/stefan....@gmail.com

Reply all
Reply to author
Forward
0 new messages