09-16-2005
3,
0
Join Date: Aug 2005
Last Activity: 25 June 2006, 4:30 AM EDT
Posts: 3
Thanks Given: 0
Thanked 0 Times in 0 Posts
Profiling..entry for a function in pthread_create
Hi jim,
Thanks a lot for ur reply....
I have tried using gprof, FncCheck, SunWorkShop Pro, gprof does not give results thread wise, SunWorkShop is an excellent profiling tool, but since it is avaiable for Solaris platform i am try to find tool that can be used on other m/s also.
i had downloaded the code for profiling pv_trace (Author:= M. Tim Jones), and added modifications for multithreading and shared libraries.
i have made few modifications to the instrument.c code,
eg: As shown below.....
what i wanted is to profile for speicific functions, so what did is specify those functions as an environment variable and had them exported, in the instrument.c i read for that environment variable and populated list of functon entries in a hash table.
Now the problem is for functions calls from shared libraries. The ( *this ) parameter of "__cyg_profile_func_enter" points to some different addr.
eg:
my shared lbrary libMyThread.so on doing an "nm" gives
Addr mangled name demangled name
0x000010cc T EntryPoint__8MyThreadPv MyThread::EntryPoint(void *)
but on call to "MyThread::EntryPoint" the addr is "0xff3510cc"
This is because the linker is resolves entries to such functions at run time, i tried to use dlopen, dlsym functions but how to i get information of mangled functions corresponding to such address (in this case 0xff3510cc),
Also, when casting (*this) as int is gives a negative value(in this case 0xff3510cc). plz help...
Desc.:
checkProfileFlag() := This function tell whether to profile for all functions or
user specified functions.
DEBUG:= Macro for outputting debuggng info.
hx_search():= This is a function form "hash.c" which looks whether the
function needs to be proifiled or not.(Only useful when
functions are exported as env. variables.)
void __cyg_profile_func_enter( void *this, void *callsite )
{
if(DEBUG)
printf("E%p, %d,\n",(int*)this,abs((int*)this));
if(!checkProfileFlag()) {
if(hx_search((int *)this)){
if(DEBUG) {
printf("Profiling for %d, %p,\n",(int *)this,(int *)this);
printf("E%d,J%d\n",pthread_self(),pM[pthread_self()].size);
}
pM[pthread_self()].pth=getpid();
pM[pthread_self()].th=pthread_self();
pM[pthread_self()].fnc[pM[pthread_self()].size].addr=(int*)this;
pM[pthread_self()].fnc[pM[pthread_self()].size].Ch='E';
gettimeofday(&pM[pthread_self()].fnc[pM[pthread_self()].size].tp,NULL);
pM[pthread_self()].size++;
}
} else {
pM[pthread_self()].pth=getpid();
pM[pthread_self()].th=pthread_self();
pM[pthread_self()].fnc[pM[pthread_self()].size].addr=(int*)this;
pM[pthread_self()].fnc[pM[pthread_self()].size].Ch='E';
gettimeofday(&pM[pthread_self()].fnc[pM[pthread_self()].size].tp,NULL);
pM[pthread_self()].size++;
}
}
Last edited by Vikky Panchal; 09-16-2005 at 01:47 AM..