<font color="#330099"><font><font face="georgia,serif"><br>Thanks a lot james and Hans, It is really helpful. Have great time!.<br></font></font></font><br><div class="gmail_quote">On Mon, Dec 12, 2011 at 11:00 PM, James Molloy <span dir="ltr"><<a href="mailto:james.molloy@arm.com">james.molloy@arm.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Just type “gdb –args” before your command
line.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">You’ll need to unwrap the driver invocation from the actual
cc1 invocation by giving the –### argument to clang. This will
cause it to print out its cc1 command line:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">./bin/clang –ast-print –S test.c –o - -###<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Then take that and run it under gdb:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Gdb –args “./bin/clang” “-cc1” ...<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">And set a breakpoint where you care:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">(gdb) b StmtPrinter.cpp:49<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">(gdb) r<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Breakpoint 1, (anonymous namespace)::StmtPrinter::PrintStmt
(this=0xffffabd0, S=0xad9a438, SubIndent=2)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Done.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Cheers,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">James<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> eyasu getahun [mailto:<a href="mailto:eya.get@gmail.com" target="_blank">eya.get@gmail.com</a>] <br>
<b>Sent:</b> 12 December 2011 14:37<br>
<b>To:</b> Hans Wennborg<br>
<b>Cc:</b> James Molloy; <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a></span></p><div class="im"><br>
<b>Subject:</b> Re: [cfe-dev] main functions of clang<u></u><u></u></div><p></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Georgia","serif";color:#330099"><br></span></p><div><div class="h5">
Hi Hans,<br>
<br>
I can't use debugger. Because am using Linux command line to run clang.
There is no debugging option at Linux. Thanks for the idea.</div></div><u></u><u></u><p></p><div><div class="h5">
<div>
<p class="MsoNormal">On Mon, Dec 12, 2011 at 10:23 PM, Hans Wennborg <<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>> wrote:<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">On Mon, Dec 12, 2011 at 2:03
PM, eyasu getahun <<a href="mailto:eya.get@gmail.com" target="_blank">eya.get@gmail.com</a>>
wrote:<br>
><br>
> Hey James,<br>
><br>
> Thanks for the command line option. But where is the function called? I
mean<br>
> in which main method of clang it is called? We know that every function
must<br>
> be called at least at one main method/function to be executed. Let me make<br>
> it clear like this way:<br>
><br>
> int main ()//main method<br>
> {<br>
> S->Printpretty(context);<br>
> }<br>
><br>
> So, which main method is calling our printpretty() function? Hope now its<br>
> clear for you.<u></u><u></u></p>
</div>
<p class="MsoNormal">Hi Eyasu,<br>
<br>
The best way to find out where a function is called from is to run<br>
Clang in a debugger, set a breakpoint in the function you are asking<br>
about (StmtPrinter::PrintStmt), and look at the stack trace.<br>
<span style="color:#888888"><br>
<span> - Hans</span></span><u></u><u></u></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br clear="all">
<br>
-- <br>
<b>With Best Regards,<br>
<br>
===========================================<br>
Eyasu Getahun</b><br>
<br>
1 Fusionopolis way, #08-10 Connexis North Tower<br>
Singapore 138632, Singapore<br>
Mobile: <a href="tel:%2B393279239907" value="+393279239907" target="_blank">+393279239907</a><br>
<b>===========================================</b><u></u><u></u></p>
</div></div></div>
</div>
</blockquote></div><br><br clear="all"><br>-- <br><b>With Best Regards,<br><br>===========================================<br>Eyasu Getahun</b><br><br>1 Fusionopolis way, #08-10 Connexis North Tower<br>Singapore 138632, Singapore<br>
Mobile: +393279239907<br><b>===========================================<br></b><br>