Any hints on this problem? Thanks!

Jim Wilson
Fri Feb 9 20:12:00 GMT 2007

?? wrote:
>     Now, my question becomes clear. How to make my inserted function call
> not affect the orginal state of program?

Try looking at a similar feature.  One such similar feature is the 
mcount calls emitted for profiling.  The various solutions for mcount 
1) saving lots of registers before the call, and restoring lots of 
registers after the call.  This has a high cost which may not work in 
your case.
2) Writing mcount in assembly language, so that you can avoid clobbering 
any registers.

Another possible solution is to use special compiler options when 
compiling the function.  For instance -fcall-saved-r14 will tell gcc 
that r14 must be saved/restored in the prologue/epilogue when used.  If 
you split your instrumentation function into a separate file, and 
compile with special options, this might work.  You will need to use 
such an option for every normal call clobbered register.  There are 
quite a few of them.

Another solution is to add the instrumentation earlier, and use expand_call.
Jim Wilson, GNU Tools Support,

More information about the Gcc mailing list