This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Fwd: [Fwd: GCC tree access]]
- 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, 6 Dec 2002 19:35:07 +0100
- Subject: Re: [Fwd: [Fwd: GCC tree access]]
- References: <3DF0D3B4.65F9992@link.com>
Hi,
On Fri, Dec 06, 2002 at 11:43:32AM -0500, Jeffrey Richardson wrote:
> > >
> > > I am interested in developing a combination "intelligent editor" and
> > > source browser using the tree structure created internally by GCC, as
> > > described in the article on trees in the GCC Internals manual.
> > >
Have a look at http://gcc.gnu.org/projects/tree-ssa/tree-browser.html
This is (for the moment) just a debugging tool, but it could be extended
into an interactive source browsing/editing tool.
> > > My question is this: if I write my own version of "precess_stmt" which
> > > uses the macros to access various tree information and write it out to a
> > > file, where is the best place to call my function? Can it be called
> > > from a single location (such as finish_function), and still have access
> > > to the full tree structure?
> > >
Yes.
You can use TB for experimenting during a gdb session and see what information
is available at a given point of the compiler.
Ouch... I just realised that there's no link to a page explaining how to
debug GCC using GDB. Is there any page that contains these bits?
Otherwise I'll write one from scratch.
> > > Also, what is the "permanence" of the tree structure.
For the moment in tree-ssa branch you cannot store tree structures into a file.
However this operation was implemented in pch-branch, and thus it could be
included in tree-ssa-branch once pch-branch stabilize.
> > > As a source file
> > > is parsed, and the tree structure is constructed, is there a point at
> > > which branches of the tree are discarded because they are no longer
> > > needed (e.g. when a function has been completed),
yes, once trees were translated into RTL garbage collector is called and
tree structures for function's body are freed.
I think that there's a possiblilty to make GCC keep all functions from a
compilation unit in memory simply by avoiding to go into rest_of_compilation.
For handling projects with multiple files we'll need a load_tree operation
(already implemented in pch-branch I think).
A source editing tool working on top of GCC could improve development style,
productivity, and code understandability (for example class hierarchy, call-
graph,... are for free when you work with ASTs). Moreover the programmer
could focus on a small part of the code and optimize it locally. One could
even imagine more interaction when the compiler could extract information by
questioning directly the programmer.
> > > or is there a point at
> > > which a complete tree exists for the entire source file, which would
> > > therefore be the best time to call a function to output a "snapshot" of
> > > the tree? (I guess this is actually a re-statement of my first
> > > question.)
> > >
just before genrtl_ expanders (expr.c).
> > > If there are any examples or code fragments of similar applications that
> > > you can share with me, I would very much appreciate it.
Yes, two weeks ago I contributed tree-browser.c in tree-ssa branch.
For checking this branch out, have a look at the instructions:
http://gcc.gnu.org/projects/tree-ssa/index.html
Sebastian