<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)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Gothic";
        panose-1:2 11 6 9 7 2 5 8 2 4;}
@font-face
        {font-family:"MS Gothic";
        panose-1:2 11 6 9 7 2 5 8 2 4;}
@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;}
@font-face
        {font-family:"\@MS Gothic";
        panose-1:2 11 6 9 7 2 5 8 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"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">A .bc file contains a form of LLVM IR (internal representation), it does not contain machine code.  You cannot use debug information in IR to find variables
 on the stack, because variables have not been assigned stack locations or registers until after you finish compiling or JIT the IR.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The JIT will translate IR instructions to machine instructions, assigning stack locations and so forth as it does so.  I don't know whether the JIT also translates
 the IR debug info into DWARF or CodeView, but that would be the kind of translation you need in order to debug the code produced by the JIT.<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>via llvm-dev<br>
<b>Sent:</b> Thursday, January 18, 2018 12:04 AM<br>
<b>To:</b> Reid Kleckner<br>
<b>Cc:</b> LLVM Developers Mailing List<br>
<b>Subject:</b> Re: [llvm-dev] Dumping debug information from BC files<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Thank you for your reply.</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">When I'm running "llvm-readobj" on an .obj file I get a result like shown in my attachment. This is very easy to read. I don't know if this is the codeview format. I would like to get this kind
 of debug information form a .bc file too, because I JIT them and wanted to try to build a debugger. With the file from "llvm-readobj" I see no problem - but when using the metadata I have no clue how to find variables on the stack - there are only this intrinsics,
 but I don't know how to handle them. </span><br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Maybe I asked the wrong question :/</span>
<br>
<br>
<br>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5F5F5F">From:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>></span>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5F5F5F">To:        </span><span style="font-size:7.5pt;font-family:"MS Gothic"">陳韋任</span><span style="font-size:7.5pt;font-family:"Arial","sans-serif""> <<a href="mailto:chenwj.cs97g@g2.nctu.edu.tw">chenwj.cs97g@g2.nctu.edu.tw</a>></span>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5F5F5F">Cc:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif""><a href="mailto:bjoern.gaier@horiba.com">bjoern.gaier@horiba.com</a>, LLVM Developers Mailing List
 <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>></span> <br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5F5F5F">Date:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">17.01.2018 18:29</span>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5F5F5F">Subject:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">Re: [llvm-dev] Dumping debug information from BC files</span>
<o:p></o:p></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="3" width="100%" noshade="" style="color:#A0A0A0" align="center">
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
<br>
The debug information is actually still in a different format in the .bc file, it is LLVM metadata. I think the best reference for it is here: <a href="https://llvm.org/docs/SourceLevelDebugging.html#ccxx-frontend">https://llvm.org/docs/SourceLevelDebugging.html#ccxx-frontend</a>
<br>
<br>
You can dump it just by disassembling the .bc file to textual IR using llvm-dis and examining the !DI* metadata nodes. You will have to run the file through llc to generate an object file to generate actual CodeView or DWARF.
<br>
<br>
On Wed, Jan 17, 2018 at 5:09 AM, <span style="font-family:"MS Gothic"">陳韋任</span> via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">3.) Then I used clang-cl to generate a .bc file - but now I'm not able to use "llvm-readobj" anymore. Is there any tool available which can dump this debug information too?</span> 
<br>
<br>
<span style="font-family:"Arial","sans-serif"">​.bc is LLVM bitcode [1], not the usual object file. `llvm-readobj` should works only on the latter.</span>
<br>
<br>
<span style="font-family:"Arial","sans-serif"">​[1] </span><a href="https://llvm.org/docs/BitCodeFormat.html" target="_blank"><span style="font-family:"Arial","sans-serif"">https://llvm.org/docs/BitCodeFormat.html</span></a>
<br>
<br>
<span style="color:#8F8F8F">-- </span><br>
<span style="color:#8F8F8F">Wei-Ren Chen (</span><span style="font-family:"MS Gothic";color:#8F8F8F">陳韋任</span><span style="color:#8F8F8F">)<br>
Homepage: </span><a href="https://people.cs.nctu.edu.tw/~chenwj" target="_blank">https://people.cs.nctu.edu.tw/~chenwj</a>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<u><span style="color:blue"><br>
</span></u><a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><u><span style="color:blue"><br>
</span></u><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><br>
<br>
<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.</span><o:p></o:p></p>
</div>
</div>
</body>
</html>