This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How can I get the line number and file name from GCC tree.

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,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]