<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="margin-left:.5in">Do you want to be able to debug from your main code, and step into the JITed code?<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">Do you want to be able to set breakpoints, list callstacks, etc in the JITed code?<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">Do you want to, from a crash, identify where in your JITed code it went wrong?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
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.<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Conceptually this is not terribly different from having a debugger know what to do with a dynamically loaded library. The trick is having the debug info somewhere
that the debugger can find it. I'm not sure our JITs even generate debug info from the metadata.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--paulr<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org]
<b>On Behalf Of </b>mats petersson via llvm-dev<br>
<b>Sent:</b> Friday, January 19, 2018 7:03 AM<br>
<b>To:</b> bjoern.gaier@horiba.com<br>
<b>Cc:</b> llvm-dev<br>
<b>Subject:</b> Re: [llvm-dev] [JIT] Evaluating Debug-Metadata in bitcode<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hi Björn,<br>
<br>
I'm not sure I understand what you are actually trying to achieve.<o:p></o:p></p>
</div>
<p class="MsoNormal">Do you want to be able to debug from your main code, and step into the JITed code?<o:p></o:p></p>
</div>
<p class="MsoNormal">Do you want to be able to set breakpoints, list callstacks, etc in the JITed code?<o:p></o:p></p>
</div>
<p class="MsoNormal">Do you want to, from a crash, identify where in your JITed code it went wrong?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">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.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">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.
<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">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.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">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.<o:p></o:p></p>
</div>
<p class="MsoNormal">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>
--<o:p></o:p></p>
</div>
<p class="MsoNormal">Mats<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On 19 January 2018 at 14:17, via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Hello LLVM-People,</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">I'm still a beginner with the LLVM, but I really like the concept and the possibilities with the JIT.</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","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.</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","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).</span> <br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","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?</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Kind regards</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Björn Gaier</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","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>
</span><br>
_______________________________________________<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" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>