Profiling a preloaded shared library with LD_PROFILE

I'm currently trying to profile a preloaded shared library using the LD_PROFILE environment variable.

I compile the library with the -g flag and export LD_PROFILE_OUTPUT as well as LD_PROFILE before running the application (ncat in my case) with the library preloaded. So more precisely what I am doing:

  • Compile the libexample.so shared library with the -g flag.
  • export LD_PROFILE_OUTPUT=`pwd`
  • export LD_PROFILE=libexample.so
  • run LD_PRELOAD=`pwd`/libexample.so ncat ...

The preload itself works, and my library is used, but the libexample.so.profile file is not created. If I use export LD_PROFILE=libc.so.6instead, there is a libc.so.6.profile file as expected.

Is this a problem combining LD_PRELOAD and LD_PROFILE or something I could have done wrong?

I am using glibc v2.12 on CentOS 6.4 if that makes any difference.

Thanks a lot!

+4
source share
1 answer

Sorry, I don’t know the answer why LD_PROFILE does not work with LD_PRELOAD.

However, for profiling binary files compiled with -g, I really like the valgrind tool along with the kcachegrind graphics tool.

valgrind --tool = callgrind / path / to / some / binary with parameters

will create a file called as callgrind.out.1234, where 1234 was the pid of the program at startup. This file can be analyzed with:

kcachegrind callgrind.out.1234

kcachegrind , , . , . , , .

, valgrind , LD_PROFILE. valgrind , , valgrind .

0

All Articles