We are trying to use -finstrument-functions to do some custom profiling on x86 
and ppc.  

For normal code execution, it works fine, calling our entry and exit methods as 
expected.

Unfortunately, we are running into problems related to exceptions.  If we exit 
a function because of an exception, no exit method is called.  This greatly 
diminishes the usefulness of the instrumentation since we are no longer 
guaranteed to get matching entry and exit calls.

It seems to me that if function instrumentation is enabled, then the compiler 
should guarantee that exit (or perhaps a exit_throw?) is called, even if the 
function is exited because of an exception.

I can see where the current instrumentation is added in gcc/function.c.  Is 
there some easy way to add some cleanup code that guarantees exit will be 
called?  Are there any documents on how RTL works?

Another possible place I see to hook it in is unwind.inc, but that does not 
have access to the current function tree, so we can't tell if instrumentation 
is enabled or not.

Thank you,

- Chris Kirby

Reply via email to