1 #include <stdio.h>
2
3 static FILE *fp_trace;
4
5 void
6 __attribute__ ((constructor))
trace_begin(void)7 trace_begin (void)
8 {
9 fp_trace = fopen("function_trace.out", "w");
10 }
11
12 void
13 __attribute__ ((destructor))
trace_end(void)14 trace_end (void)
15 {
16 if(fp_trace != NULL) {
17 fclose(fp_trace);
18 }
19 }
20
21
22 void
__cyg_profile_func_enter(void * func,void * caller)23 __cyg_profile_func_enter (void *func, void *caller)
24 {
25 if(fp_trace != NULL) {
26 fprintf(fp_trace, "e %p %p\n", func, caller);
27 }
28 }
29
30 void
__cyg_profile_func_exit(void * func,void * caller)31 __cyg_profile_func_exit (void *func, void *caller)
32 {
33 if(fp_trace != NULL) {
34 fprintf(fp_trace, "x %p %p\n", func, caller);
35 }
36 }
37