aboutsummaryrefslogtreecommitdiff
path: root/unittest/function_trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'unittest/function_trace.c')
-rw-r--r--unittest/function_trace.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/unittest/function_trace.c b/unittest/function_trace.c
new file mode 100644
index 0000000..5ed47a9
--- /dev/null
+++ b/unittest/function_trace.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+
+static FILE *fp_trace;
+
+void
+__attribute__ ((constructor))
+trace_begin (void)
+{
+ fp_trace = fopen("function_trace.out", "w");
+}
+
+void
+__attribute__ ((destructor))
+trace_end (void)
+{
+ if(fp_trace != NULL) {
+ fclose(fp_trace);
+ }
+}
+
+
+void
+__cyg_profile_func_enter (void *func, void *caller)
+{
+ if(fp_trace != NULL) {
+ fprintf(fp_trace, "e %p %p\n", func, caller);
+ }
+}
+
+void
+__cyg_profile_func_exit (void *func, void *caller)
+{
+ if(fp_trace != NULL) {
+ fprintf(fp_trace, "x %p %p\n", func, caller);
+ }
+}