This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How can I get the line number and file name from GCC tree.
- From: Jim Wilson <wilson at specifixinc dot com>
- To: Matthieu Moy <Matthieu dot Moy at imag dot fr>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 05 Jan 2004 16:54:30 -0800
- Subject: Re: How can I get the line number and file name from GCC tree.
- References: <vpq1xqxchei.fsf@ecrins.imag.fr>
Matthieu Moy wrote:
I have a GCC tree that I can print from GDB with debug_tree(t). What I
would like is to be able to get back-to-source information, ie which
file and at which line number is the source code which has been parsed
to produce this tree.
Historically, gcc made no attempt to track source/line info for
expression trees. We only keep track of this for declarations for use
in debug info. The front ends generated expressions trees one at a
time, and then reduced them to RTL, so we had no need for source/line
info for them.
Relatively recently, some front ends were modified to produce trees for
an entire function before generating RTL, at which point source/line
info had to be added in after the fact. Different front ends do this
different ways.
The STMT_LINENO macro is only used by the C family (C, Obj-C, C++). It
should work in those front ends. Filenames are stored in separate
FILE_STMT trees, and are emitted only if the filename changes. It is
probably better to do without this info if you can, since it may be hard
to extract in a useful form.
Things in this area are probably a lot nicer on the tree-ssa branch,
which has tried to design a better interface and unify the different
language front ends to use a common interface.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com