Hi,
is there any method to find who called a particular function at runtime?(may be some kind of printing address.then mapping from system.map file!!)
Thanks
Hi,
is there any method to find who called a particular function at runtime?(may be some kind of printing address.then mapping from system.map file!!)
Thanks
The way I do it is to use a wrapper function call with a macro.
#define doit(a) wrapper( (a), __FILE__, __LINE__ )
doit( int arg ) { // do something }
wrapper_doit( int arg, char *where1, int where2 ) { printf( "%s %d\n", where1, where2 ); doit( arg ); }
All calls to doit will be rerouted to wrapper_doit and will printout the file and line number where the call is.
Bill
You can use the gcc function "void * __builtin_return_address (unsigned int level)" function. The with level 0 it returns the address where the function that used __builtin_return_address returns to. For e.g., f1() called f2() and f3() and f3() called __builtin_return_address then with level 0 it returns the address of the next instruction in f2() after f3() call.
KIRAN
Have something to add? Share your thoughts — no account required.
Ask the community — no account required