4 /* See: http://balau82.wordpress.com/2010/10/06/trace-and-profile-function-calls-with-gcc/ */
10 static FILE *fp_trace
;
12 void __attribute__ ((constructor
)) trace_begin (void) __attribute__ ((no_instrument_function
));
13 void __attribute__ ((destructor
)) trace_end (void) __attribute__ ((no_instrument_function
));
14 void __cyg_profile_func_enter( void *, void * ) __attribute__ ((no_instrument_function
));
15 void __cyg_profile_func_exit( void *, void * ) __attribute__ ((no_instrument_function
));
18 void __attribute__ ((constructor
)) trace_begin (void)
20 fp_trace
= fopen("trace.out", "w");
23 void __attribute__ ((destructor
)) trace_end (void)
25 if(fp_trace
!= NULL
) {
30 void __cyg_profile_func_enter (void *func
, void *caller
)
32 if(fp_trace
!= NULL
) {
33 fprintf(fp_trace
, "e %p %p %lu\n", func
, caller
, time(NULL
) );
37 void __cyg_profile_func_exit (void *func
, void *caller
)
39 if(fp_trace
!= NULL
) {
40 fprintf(fp_trace
, "x %p %p %lu\n", func
, caller
, time(NULL
));