Hi,
The problem is:
I am trying to get the function call tree by using the profiling functions __cyg_profile_f unc_enter and __cyg_profile_f unc_exit. But it is printing the address of these fns (__cyg_profile_ func_enter and __cyg_profile_f unc_exit) instead of the other functions.
Please see the code and suggest a solution.
This is running on zdcc, a gcc derivative on Windows.
The code is
The code gets compiled and when running I got the following output.
I checked the addresses and found out that 29ff corresponds to __cyg_profile_f unc_enter and 2a79 corresponds to __cyg_profile_f unc_exit.
Why is this happening? Why is the proper address not printed?
The problem is:
I am trying to get the function call tree by using the profiling functions __cyg_profile_f unc_enter and __cyg_profile_f unc_exit. But it is printing the address of these fns (__cyg_profile_ func_enter and __cyg_profile_f unc_exit) instead of the other functions.
Please see the code and suggest a solution.
This is running on zdcc, a gcc derivative on Windows.
The code is
Code:
#include <stdio.h> void __cyg_profile_func_enter( void *, void * ) __attribute__ ((no_instrument_function)); void __cyg_profile_func_exit( void *, void * ) __attribute__ ((no_instrument_function)); FILE *fp = NULL; int call_level = 0; void *last_fn; void __cyg_profile_func_enter(void *this_fn, void *call_site) { if (fp == NULL) fp = fopen( "trace.txt", "w" ); if (fp == NULL) exit(-1); if ( this_fn!=last_fn) ++call_level; for (int i=0;i<=call_level;i++) fprintf(fp,"\t"); fprintf(fp, "entering %p\n", (int *)this_fn); (void)call_site; last_fn = this_fn; } void __cyg_profile_func_exit(void *this_fn, void *call_site) { --call_level; for (int i=0;i<=call_level;i++) fprintf(fp,"\t"); fprintf(fp, "exiting %p\n", (int *)this_fn); (void)call_site; }
Code:
entering 29ff entering 29ff entering 29ff exiting 2a79 entering 29ff exiting 2a79 entering 29ff exiting 2a79 entering 29ff exiting 2a79 entering 29ff exiting 2a79 entering 29ff exiting 2a79
Why is this happening? Why is the proper address not printed?
Comment