This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc 2.95.2 -finstrument-functions problem


Bruce Momjian wrote:

> [ Charset ISO-8859-1 unsupported, converting... ]
> > Greetings,
> >
> > The -finstrument-functions option appears to be broken in gcc 2.95.2 on BSDI
> > 4.2 and FreeBSd
> > 4.0-4.3.
> >
> > E.g:
> > Compiling a trivial c program such as
> >
>
> Seeing as they are profiling symbols, I would try compiling with -p.
> Not sure what -finstrument-functions is supposed to do.

The '-p' will not change this.

The -finstrument-functions add a call to __cyg_profile_func_enter at begin
of each of your functions, and a call to __cyg_profile_func_exit at exit(s)
of each of your functions.

GCC don't provides these functions, and you have to link your own module,
with these functions exported.
The exact prototype for these functions is:
void __cyg_profile_func_{enter|exit}(void *this_fn, void *call_site)

with this_fn the address of the current function (the one in which you
enter/exit),
and the call site, which is the address the function will returns when
terminated.
These address can be converted in function names using BFD lib.


Here is a short example:


file toto.c

void f1()
{
  printf("f1\n");
}
int main()
{
  f1();
  return(0);
}


file cyg.c

void __cyg_profile_func_enter(void *this_fn, void *call_site)
{
  printf("entering %p from %p\n", this_fn, call_site);
}

void __cyg_profile_func_exit(void *this_fn, void *call_site)
{
  printf("exiting %p from %p\n", this_fn, call_site);
}


Compile:

gcc -c toto.c -finstrument-functions
gcc -c cyg.c
gcc -o toto toto.o cyg.o


NOTE: don't compile 'cyg' with the -finstrument-functions flag.
I don't know if GCC protect this, but if not, you will obtain in
__cyg_profile_func_enter a call to itself!



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]