[llvm-dev] Debugging JIT'ed code with ORC JIT?

Stefan Gränitz via llvm-dev llvm-dev at lists.llvm.org
Sun Oct 15 12:08:21 PDT 2017


Am 11.10.17 um 19:44 schrieb Yichao Yu via llvm-dev:
> So while I totally believe one can use
> `JITEventListener::createGDBRegistrationListener()` to hook the JIT
> with the the gdb registration function, it won't work without writing
> code to explicitly do that 
Implementing the GDB JIT Interface for an ORC-based JIT is pretty
straightforward. For 5.0 you need that tiny workaround, fixed on trunk:
https://github.com/weliveindetail/JitFromScratch/commit/d4b6778d8d462299674e103d8ecdec1140a45cfe

It will work out-of-the box on Linux, as the native object format is
ELF. It does not work with other object formats, because no one else
implements LoadedObjectInfo::getObjectForDebug():
https://github.com/llvm-mirror/llvm/blob/a5204d048729eef09b162dd12622c4afefb4978a/include/llvm/ExecutionEngine/RuntimeDyld.h#L79

Am 07.10.17 um 23:12 schrieb Connor Gray via llvm-dev:
> I’m wondering if it’s possible to debug code JIT’ed with the newer ORC
> JIT. The LLVM documentation has a page at
> llvm.org/docs/DebuggingJITedCode.html
> <http://llvm.org/docs/DebuggingJITedCode.html>
So bascially: yes. I think you could use ELF on any OS (like Julia
does), but depending on your use-case you will need to workaround other
issues. If you have requirements that restrict you to your OS's native
object format, you need to implement getObjectForDebug(). I guess with
COFF on Windows it will be complicated, but possible with the newly
added PDB support. I'd be surprised about major issues for MachO on Mac.

I heard that request from other parties, so at some point it's gonna be
worth a "common endeavor" :)

Cheers
Stefan

Am 11.10.17 um 21:34 schrieb Yichao Yu via llvm-dev:
>> RTDyldObjectLinkingLayer has a NotifyObjectLoaded hook that you can use to
>>> call NotifyObjectEmitted on your GDBRegistrationListener.
>> but not well documented anywhere yet. :/
> Right. That's exactly what we (julia) do although we don't use
> `GDBRegistrationListener` directly. I just mean that this has to be
> done manually (so no "builtin" support for some meaning of "builtin")
> and it can't be accomplished just by reading the mcjit doc. :/
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-- 
https://weliveindetail.github.io/blog/
https://cryptup.org/pub/stefan.graenitz@gmail.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171015/d383bdcf/attachment.html>


More information about the llvm-dev mailing list