This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC tree access & Pretty-print
- From: Pop Sébastian <pop at gauvain dot u-strasbg dot fr>
- To: Jeffrey Richardson <jlrichardson at link dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 14 Mar 2003 14:30:24 +0100
- Subject: Re: GCC tree access & Pretty-print
- References: <3DF0D3B4.65F9992@link.com> <20021206183507.GB25799@gauvain.u-strasbg.fr> <3E70CFDA.C73B9467@link.com>
Hi,
On Thu, Mar 13, 2003 at 01:37:15PM -0500, Jeffrey Richardson wrote:
> I was wondering if you (or anyone else at gcc.gnu.org) could tell me how the
> pretty-print capability works? I see alot of code starting with
> pp_c_pretty_printer_init, but I cannot decern how it is used. Is this a debugging
> capability that has to be turned on in the code? If so, how do you do so?
>
These functions are used in mainline for printing diagnostic messages (such as
errors or warnings). In the tree-ssa branch we have a set of functions
debug_generic_*, debug_c_* that we use for dumping the trees in a c-like syntax.
The dumped format is not compilable.
> As before, any examples that anyone can provide for either the pretty-print stuff,
> or accessing trees in general would be greatly appreciated.
>
For accessing trees you could follow the instructions given in:
- http://gcc.gnu.org/bugs/reghunt.html for getting and installing the sources,
- http://gcc.gnu.org/bugs/segfault.html gives some instructions for debugging GCC.
You can for example insert a "browse_tree (fndecl);" in
"tree-optimize.c: optimize_function_tree (fndecl)"
rebuild the compiler and compile with -O2 foo.c.
You can insert this kind of code where you want in the compiler. You can also call
the tree browser from gdb "call browse_tree (some_tree_node)". There are also
the "debug_*" functions that dump on stderr useful information about structures.
> Also, If anyone has instructions on the best way quickly test changes to the gcc
> code, I would like to see them. I downloaded the CVS tree, did a "configure" to
> /usr/local, did a "make bootstrap", and then a "make install". I find that to test
> changes I need to do a "make" in objdir, and then do another "make install" (as
> root), to get the changes. The "make install" takes quite a bit of time. Is there
> a faster way to test changes that I make to the code?
>
You can use the cc1* compilers from objdir/gcc/ once you have built GCC:
for example "objdir/gcc/cc1 -O2 foo.c", or
"gdb objdir/gcc/cc1" and then "(gdb) run -O2 foo.c"
Sebastian