<div dir="ltr"><div><div><div><div><div><div><div><div><div>Hi Björn,<br><br>I'm not sure I understand what you are actually trying to achieve.<br><br></div>Do you want to be able to debug from your main code, and step into the JITed code?<br></div>Do you want to be able to set breakpoints, list callstacks, etc in the JITed code?<br></div>Do you want to, from a crash, identify where in your JITed code it went wrong?<br></div><div></div><div><br></div>The first two are definitely one or more order(s) of magnitude harder to solve than the third one, since you basically have to tell your debugger that "I've now added some more code here, come here to see the symbols", and would require a fair amount of extra work to make any existing debugger understand this concept, never mind the exact implementation details.<br><br></div>A post-mortem analysis is much less complicated, since all you'd have to do is walk through the debug symbols and relate the generated locations to the actual locations in the code. <br><br></div>Another aspect is local variables (and arguments into functions), although I'm not sure it's that much of complication above and beyond the solution of the above parts.<br><br></div>I suspect there are parts of code that can be used, from llc and lld that can be used to generate dwarf info, but you will probably still have to deal with tying that back into your generated code.<br><br></div>In my Pascal compiler, which generates real executable code, adding debug symbols is trivial from the perspective of making it work in a debugger, but hard in the sense of generating the debug data for the line, file, function and variable information - all that I need to do to make it go into the executable file is append -g to the linker options when building. But since JIT-generated code isn't an executable that you can just apply debug symbols into, this makes it a fair bit harder (I think, I haven't actually tried).<br><br>--<br></div>Mats<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 January 2018 at 14:17, via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font size="2" face="sans-serif">Hello LLVM-People,</font>
<br>
<br><font size="2" face="sans-serif">I'm still a beginner with the LLVM,
but I really like the concept and the possibilities with the JIT.</font>
<br>
<br><font size="2" face="sans-serif">Currently I compile simple functions
with clang-cl into bitcode files. After this I use another program to JIT
this bitcode files and execute functions of it - like lli.</font>
<br><font size="2" face="sans-serif">Thanks to a lot of mails and so on,
I understood that a bitcode file is in fact still IR-Code, but with another
representation - so when I JIT this file with my application, I'm acting
like a compiler (like llc).</font>
<br>
<br><font size="2" face="sans-serif">But what does happen to the debug information?
When I generate the files in human readable code I can easily discover
the metadata and understand them. So I want to extend my application, that
it can debug the code, which was jitted. This seems difficult. When I get
the address of a debug break, I can only identify the function where the
exception occurred. I don't see a way to connect the metadata to the offset
I could calculate from the exception and the function. Also I don't know
how to progress the metadata when it's in its bitcode form. So - how can
I start with this task?</font>
<br>
<br><font size="2" face="sans-serif">Kind regards</font>
<br><font size="2" face="sans-serif">Björn Gaier</font>
<br>
<br><font size="2" face="sans-serif"><br>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br>
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.<br>
<br>
</font><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>