This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CentOS cannot trace /lib64/ld-2.5.so library


On 11/12/2010 05:42 AM, Mandar Gurav wrote:
> I can trace/probe all user defined functions in my C program. But now
> I wanted to trace/probe the any external library calls for my C
> program.

BTW, there is also a tool called 'ltrace' for exactly this purpose.

> I googled for some information. And got reference of "Dynamic loader"
> for linux - "/lib64/ld-2.5.so" this library is responsible for loading
> of external symbols/functions.

ld.so is responsible for runtime linking, yes.  So you might be able to
use probes there to figure out how the symbol resolution is done.  But
it won't help you find out when those functions are actually called -
for that you need probes on the functions themselves.

> So I want to probe "dlopen" function and "dlsym" function from above library.

dlopen and dlsym are for manually loading symbols, as opposed to the
automatic linking done by ld.so.  So again, this won't show you the
calls, just how they're initially loaded.

> probe process("/lib64/ld-linux-x86-64.so.2").function("dlopen")

dlopen is actually from libdl.so.  Of course it's not that simple,
because at least on my system, dlopen is versioned:

$ nm /usr/lib64/libdl.so | grep dlopen
0000003448600f90 t __dlopen
0000003448600f90 t __dlopen_check
0000003448600f90 T dlopen@@GLIBC_2.2.5
0000003448600eb0 t dlopen_doit

So your options are either to probe by the internal name "__dlopen", or
match the versioned name.  We can't use '@' in our function pattern,
since we treat that as a srcfile separator, but a wildcard should work:

  probe process("/lib64/libdl.so.2").function("dlopen??GLIBC_2.2.5") {}

Developer side note - do people think it would make sense for us to
automatically strip @@VERSION from symbol table names for matching?  Or
should I just refine our pattern parsing to not treat "@@" like a
@srcfile.  Or do both, so either "name" or "name@@VERSION" will work.

> Missing separate debuginfos, use: debuginfo-install glibc-2.5-49.el5_5.7.x86_64
> 
> But i have already installed "glibc-2.5-49.el5_5.7.x86_64 ".

The debuginfo-install command is to install the -debuginfo packages
corresponding to the given arguments.  So of course you have glibc
installed already, but for stap you'll need glibc-debuginfo as well.

Please check with "rpm -q glibc glibc-debuginfo" that both are installed
and have the same version.


Josh


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