Hi All,

I am coding an extension for GCC and am having some difficulty with
pre-compiled headers. I dont know if my understanding of how they work
is completely correct and so my code is getting a segfault.

I have a hook into gimplify_function_tree() and I process functions as
they pass through that function.

When compiling a PCH file, the functions being compiled will come
through gimplify_function_tree() i will process them for callgraph and
exception information (which is what my program does), and then store
references to the tree nodes I use into a GTY rooted node as a tree
chain list. This should prevent the nodes from being garbage collected
which is something I want at the moment because i re-visit all the nodes
after the compilation process has been completed (This is not the best
solution but the easiest for my situation at the moment).

In addition to preventing garbage collection of nodes i am interested in
from what i understand of the PCH mechanism, when compiling a file that
uses a PCH GCC should magically re-construct the chain of tree nodes
rooted at the GTY base. What i need to do is then look over those nodes
again after they have been reconstructed and re-process them for
callgraph and exception information (Yes i know this is not good as it
means there is duplicate processing of nodes which is what PCH files are
trying to avoid, but please ignore this fact for the moment).

So i also hook into c_common_no_more_pch() and when it is called i will
look at the tree chain and "re-calculate" the data from the nodes that
should have been recreated from the PCH engine. There seem to be tree
nodes re-created in the tree chain list, however upon trying to process
these nodes I get a segfault almost as though the pointers have been
restored by the PCH engine, but the memory they point to has not.

I am using gcc 4.0.1 on a i386 NetBSD 3.0 system.

Questions:

1) Is there a better place to hook into to know when the PCH engine has
completed reconstructing the tree nodes?

2) Is there something wrong in the way i understand the reconstruction
of data by the PCH engine? I assumed it would re-construct a full tree
hierarchy if i rooted a tree node.

Thanks,
Brendon.

Reply via email to