Re: Insert Code Into Every Function
Re: Insert Code Into Every Function
- Subject: Re: Insert Code Into Every Function
- From: Graham J Lee <email@hidden>
- Date: Sat, 15 Mar 2008 08:27:31 +0000
On 15 Mar 2008, at 06:48, Dave Keck wrote:
Hello,
I've got some simple assembly code that I'd like to insert into every
function of a C & Objective-C application at compile time. It's for my
own purposes of helping identify bugs, profiling, flow control, etc.
and it may develop into a larger public project. I've done extensive
research into projects that accomplish similar tasks (Gprof and other
projects) but none of them do what I need to, so I'm prepared to do it
myself.
Hi Dave,
Documented in the GCC manpage:
-finstrument-functions
Generate instrumentation calls for entry and exit to
functions.
Just after function entry and just before function exit, the
following profiling functions will be called with the
address of
the current function and its call site. (On some platforms,
"__builtin_return_address" does not work beyond the current
function, so the call site information may not be
available to the
profiling functions otherwise.)
void __cyg_profile_func_enter (void *this_fn,
void *call_site);
void __cyg_profile_func_exit (void *this_fn,
void *call_site);
The first argument is the address of the start of the
current
function, which may be looked up exactly in the symbol
table.
...and so on.
Don't forget to declare your profiling functions with __atribute__
((no_instrument_function)) ;-)
Thanks,
Graham.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden