<div class="gmail_quote">On Tue, Aug 23, 2011 at 10:58 AM, Ronan Keryell <span dir="ltr"><<a href="mailto:Ronan.Keryell@hpc-project.com">Ronan.Keryell@hpc-project.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
>>>>> On Tue, 23 Aug 2011 10:16:56 -0700, Simon <<a href="mailto:simonhf@gmail.com">simonhf@gmail.com</a>> said:<br>
<br>
    Simon> I am trying to find a tool that will parse and tell me<br>
    Simon> information about a C source file in a verbose manner which I<br>
    Simon> can digest and use in a script I am writing. The closest I<br>
    Simon> have come so far using gcc to generate debug info and then<br>
    Simon> extract the debug info and parse that.<br>
<br>
That is not a bad solution if it works for you, because you can use only<br>
some standard tools already available on any systems, such as objdump or<br>
gdb with a script...<br></blockquote><div> </div><div>It's the solution that gets closest to want I want to achieve so far. But it's not pretty :-) It also doesn't contain the whitespace and comment data (see below) which would be useful.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">   Simon>  However, what I'd prefer is a tool which lets me get at<br>
    Simon> similar debug info (although obviously not memory offsets<br>
    Simon> etc) *without* having to compile the C source code into<br>
    Simon> object files. I know that clang has been re-written from<br>
    Simon> scratch to be a lot more flexible than gcc. Does anybody in<br>
    Simon> this list know how I could use clang (or another tool) to<br>
    Simon> obtain such debug info without compiling all the way?<br>
<br>
In the "other tools" family, gcc-xml can output the AST in an XML way.<br>
<a href="http://www.gccxml.org/HTML/Index.html" target="_blank">http://www.gccxml.org/HTML/Index.html</a></blockquote><div><br></div><div>I really like the idea of this project. Too bad it's C++ only, unfinished (doesn't process function bodies), and all but dead.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">In our Par4All compiler, we use another tool internally, PIPS, that<br>
allows to output the AST in HTML or in a textual format.<br>
<br>
There is a web service you can use to have an idea of what it can output:<br>
<a href="http://pips4u.org/doc/ir-navigator" target="_blank">http://pips4u.org/doc/ir-navigator</a></blockquote><div><br></div><div>I tried it out. Very nice web interface. Close to what I want except for two things:</div>
<div>1. Is it possible to output file line number and character position so that it is also part of the tree?</div><div>2. Is it possible for the tree to contain info relating to whitespace and comments?</div><div><br></div>
<div>Ideally I'd like to be able to use a tool like PIPS to do so-called round trip parsing where the original source code can be rebuilt exactly from the intermediate representation. Somewhat like what this Perl module achieves:</div>
<div><br></div><div><a href="http://search.cpan.org/~adamk/PPI-1.215/lib/PPI.pm">http://search.cpan.org/~adamk/PPI-1.215/lib/PPI.pm</a></div><div><br></div><div>Thanks,</div><div>Simon</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<font color="#888888">--<br>
  Ronan KERYELL                      |\/<br>
  HPC Project                        |/)  Cell:   <a href="tel:%2B33%20613%20143%20766" value="+33613143766">+33 613 143 766</a><br>
  5201 Great America Parkway #3241   K    <a href="mailto:Ronan.Keryell@hpc-project.com">Ronan.Keryell@hpc-project.com</a><br>
  Santa Clara, CA 95054              |\   skype:keryell<br>
  USA                                | \  <a href="http://hpc-project.com" target="_blank">http://hpc-project.com</a><br>
</font></blockquote></div><br>