Help in using the gcc -finstrument-functions option for tracing programs execution
Help in using the gcc -finstrument-functions option for tracing programs execution
- Subject: Help in using the gcc -finstrument-functions option for tracing programs execution
- From: Antonio Ferraioli <email@hidden>
- Date: Thu, 3 Mar 2005 00:28:00 +0100
Hello,
I hope my english will be clear enough:
- I develop a program that I cannot always test directly
- remote final users help me with testing
- those user are not developers and does not have developer tools installed
on their machines
- actually they can activate a logging mode and produce
a log file containing a trace of the program execution
- this log is generated introducing a couple of NSLog calls
in many important methods ( i use some macros to do this)
the result of the macro explosion is very similar to the following
- (void) foo
{
if (gDebugging) NSLog(@"foo - Enter");
--
-- ......
-- ......
-- the method code
-- ......
-- ......
if (gDebugging) NSLog(@"foo - Exit");
}
- recently I discovered a very interesting feature of the gcc compiler
the "-finstrument-functions" compile option
activating this option force the compiler to automatically introduce
a couple of calls before entering and after exiting of all my methods
those calls are directed to the following functions:
/** According to gcc documentation: called upon function entry */
static UInt32 callDeep = 0;
void __attribute__((__no_instrument_function__))
__cyg_profile_func_enter(void *this_fn, void *call_site)
{
callDeep++;
NSLog(@"enter %p", this_fn);
}
/** According to gcc documentation: called upon function exit */
void __attribute__((__no_instrument_function__))
__cyg_profile_func_exit(void *this_fn, void *call_site)
{
NSLog(@"exit %p", this_fn);
callDeep--;
}
- this is a very interesting feature and could permit me to creare
a trace solution for my program very powerful
1) I could enable and disable tracing in a single point
without adding macros to all the methods of my program
2) I could generate a log that graphically shows nested calls
------------ enter Method One
------------------- enter Method Two
------------------- exit Method Two
------------ exit Method One
- and finally, if you are not too tired for this long description,
my question
I need some explanation on how I could use the input parameters
of the two called functions
__cyg_profile_func_enter(void *this_fn, void *call_site)
__cyg_profile_func_exit(void *this_fn, void *call_site)
the "this_fn" should (I'm not sure) be a ponter to the function/method
called between the enter and the exit __cyg... functions
I arrived to convert this address to the called function name
using the "atos" terminal command,
I'd like to know if it possible (and how) to make this conversion
directly from my tracing routines without the need to use the atos command
(my remote users does not have atos installed on their "non developer" machines)
I gave a look to the dyld(3) manual but with no success
also some information about the meaning of the call_site parameter
could be very interesting for me
thank you all fo reading all this
and eventually to help me finding a solution
sincerely
antonio
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden