shared objects profiling

Hi!

how can i do profiling of shared objects?
eg:

// module main.c
#include <stdio.h>
#include <dlfcn.h>

void dl_func0(){
printf(“main dl func0 called\n”);
}
static void dl_func1(){
printf(“main dl func1 called\n”);
}

typedef int (*func_t)(int);

int main(){
void *so1;
func_t f1;
so1 = dlopen(“so.so”, RTLD_NOW);
printf(“dlopen:%p\n”,so1);
if (!so1){
xit(dlerror());
}
printf(“dlsym:%p\n”,f1);
f1 = (func_t)dlsym(so1,“func”);
if (!f1)
xit(dlerror());
printf(“so:%p f1:%p\n”,so1,f1);
f1((int)dl_func0);
f1((int)dl_func1);
return 0;
}

// module so.c
#include <stdio.h>

typedef void (*xdl_func_t)();

int func(int x){
xdl_func_t f;
printf (“Func(%d) called\n”,x);
f = (xdl_func_t)x;
f();
return 0;
}

if i run main then it output:
Func(xxxxxx) called
main dl func0 called
Func(xxxxxx) called
main dl func1 called

and gmon.out (gprof main) contains:

time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1 0.00 0.00 main

index % time self children called name
0.00 0.00 1/1 _start [28]
[1] 0.0 0.00 0.00 1 main [1]

Q: why call of the following functions does not appeared:
in main.c:
void dl_func0();
static void dl_func1();
in so.c:
int func(int x);

can i get it?

Thanks

Profiling of shared objects isn’t currently supported
by gprof. It has no idea what shared objects where
loaded nor where they were loaded.

vasilii <vv40in@rambler.ru> wrote:

Hi!

how can i do profiling of shared objects?
eg:

// module main.c
#include <stdio.h
#include <dlfcn.h

void dl_func0(){
printf(“main dl func0 called\n”);
}
static void dl_func1(){
printf(“main dl func1 called\n”);
}

typedef int (*func_t)(int);

int main(){
void *so1;
func_t f1;
so1 = dlopen(“so.so”, RTLD_NOW);
printf(“dlopen:%p\n”,so1);
if (!so1){
xit(dlerror());
}
printf(“dlsym:%p\n”,f1);
f1 = (func_t)dlsym(so1,“func”);
if (!f1)
xit(dlerror());
printf(“so:%p f1:%p\n”,so1,f1);
f1((int)dl_func0);
f1((int)dl_func1);
return 0;
}

// module so.c
#include <stdio.h

typedef void (*xdl_func_t)();

int func(int x){
xdl_func_t f;
printf (“Func(%d) called\n”,x);
f = (xdl_func_t)x;
f();
return 0;
}

if i run main then it output:
Func(xxxxxx) called
main dl func0 called
Func(xxxxxx) called
main dl func1 called

and gmon.out (gprof main) contains:

time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1 0.00 0.00 main

index % time self children called name
0.00 0.00 1/1 _start [28]
[1] 0.0 0.00 0.00 1 main [1]

Q: why call of the following functions does not appeared:
in main.c:
void dl_func0();
static void dl_func1();
in so.c:
int func(int x);

can i get it?

Thanks



cburgess@qnx.com