[cfe-dev] How to pretty print the abstract syntax tree for a C source file?
Ronan Keryell
Ronan.Keryell at hpc-project.com
Tue Aug 23 10:58:25 PDT 2011
>>>>> On Tue, 23 Aug 2011 10:16:56 -0700, Simon <simonhf at gmail.com> said:
Simon> I am trying to find a tool that will parse and tell me
Simon> information about a C source file in a verbose manner which I
Simon> can digest and use in a script I am writing. The closest I
Simon> have come so far using gcc to generate debug info and then
Simon> extract the debug info and parse that.
That is not a bad solution if it works for you, because you can use only
some standard tools already available on any systems, such as objdump or
gdb with a script...
Simon> However, what I'd prefer is a tool which lets me get at
Simon> similar debug info (although obviously not memory offsets
Simon> etc) *without* having to compile the C source code into
Simon> object files. I know that clang has been re-written from
Simon> scratch to be a lot more flexible than gcc. Does anybody in
Simon> this list know how I could use clang (or another tool) to
Simon> obtain such debug info without compiling all the way?
In the "other tools" family, gcc-xml can output the AST in an XML way.
http://www.gccxml.org/HTML/Index.html
In our Par4All compiler, we use another tool internally, PIPS, that
allows to output the AST in HTML or in a textual format.
There is a web service you can use to have an idea of what it can output:
http://pips4u.org/doc/ir-navigator
--
Ronan KERYELL |\/
HPC Project |/) Cell: +33 613 143 766
5201 Great America Parkway #3241 K Ronan.Keryell at hpc-project.com
Santa Clara, CA 95054 |\ skype:keryell
USA | \ http://hpc-project.com
More information about the cfe-dev
mailing list