<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 30, 2011, at 3:47 AM, Eli Bendersky wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">Hello,<br><br>I'm interested in debugging code JITted by LLVM at runtime. For that, I should naturally have some way to emit DWARF that faithfully describes the JITted code into memory along with the JITted code itself and point the debugger to it. Let's assume that the bridge with the debugger is taken care of (e.g. <a href="http://llvm.org/docs/DebuggingJITedCode.html">http://llvm.org/docs/DebuggingJITedCode.html</a>) - my concern in this question is solely with the LLVM side.<br>

<br>AFAIU, LLVM currently includes very partial support for emitting DWARF info with JIT, in the JITDwarfEmitter class. What it has is just a way to emit stack frame information (symbols and DWARF CFA), to allow meaningful core dumps from JITted code, with stack information. This is useful, but obviously very far from full debugging support.<br>

<br></div></blockquote><div><br></div><div>Quite.</div><br><blockquote type="cite"><div dir="ltr">So where should I look for adding such support? Is MC JIT the direction? Does it purport to emit DWARF as well as executable code? Any pointers to relevant places in the code would be most appreciated.<br><br></div></blockquote><div><br></div><div>MC JIT is the direction that the JIT will be going in the future. Right now any debugging emission is minimal at best. My ideas here would be to emit the debug info as a section in memory and point the debugger at that.</div><br><blockquote type="cite"><div dir="ltr">Note: I'm aware there's an alternative approach - generating a "true" shared lib with LLVM's toolchain dynamically and loading it. It has its pros and cons vs. generating DWARF directly with the JITted code, and in this question I'm focusing on the latter.<br></div></blockquote></div><br><div>*nod* Ultimately I think the two will be similar, just the destination of the jitted code - static in memory or shared on disk. It's just a matter of communicating to the debugger where the debug information resides and having the code emitter output the debug information.</div><div><br></div><div>With MC JIT I don't think getting it to emit the debug information will be particularly hard so you might want to look into it.</div><div><br></div><div>-eric</div></body></html>