-finstrument-functions problems

Nick Burrett nick at dsvr.net
Sat Jan 24 07:29:58 PST 2004

Jeffrey Lee wrote:
> Hi,
> I've spent ages tracking this down, and still have no real idea why the
> code is going wrong. What happens is that if -finstrument-functions is
> used, the call_site parameter given to the instrumentation functions is
> the corrupt. For example, in the following program: (Note that you may
> need my __builtin_return_address patch to get it working at all)

This patch should fix the problem:

Index: builtins.c
RCS file: /usr/local/cvsroot/gccsdk/gcc/gcc/builtins.c,v
retrieving revision 1.6
diff -u -p -r1.6 builtins.c
--- builtins.c  13 Dec 2003 19:25:19 -0000      1.6
+++ builtins.c  24 Jan 2004 15:24:59 -0000
@@ -438,6 +438,7 @@ expand_builtin_return_addr (fndecl_code,
         emit_library_call_value (function_call, tem, LCT_NORMAL,
                                  Pmode, 1,
                                  GEN_INT (count), SImode);
+       return tem;

The trouble is that we were generating a temporary pseudo-reg for the 
library call return value of __builtin_return_address but not telling 
GCC to use it.

This code is wrong, because the result of __builtin_return_address is 
not being passed to __cyg_profile_func_enter.

 > 	bl	|__builtin_return_address|
 > 	mov	__ip, __a1
 > 	ldr	__a1, |L..12|
 > 	ldr	__a2, [__ip, #-4]
 > 	bl	|__cyg_profile_func_enter|

Verify that the above patch does indeed fix your problem, then I'll take 
a took at your __builtin_return_address changes.


More information about the gcc mailing list