[Ltrace-devel] Work on bug #135985 - ltrace could catch library-to-library calls

Petr Machata pmachata at redhat.com
Fri Jan 31 00:27:34 UTC 2014


Jevin Sweval <jevinsweval at gmail.com> writes:

> This is a feature that I would really like to see! I'm not sure where
> to start working though.

This should generally work in ltrace 0.7.0 or later.  Use ltrace -e@ to
tell ltrace that you want to trace calls from all libraries (the empty
string before the @ means "all symbols", the empty string after @ means
"all libraries".  Check out man for more elaborate syntax).  -n sets
indentation so that it's clearer what's happening:

$ ltrace -e@ -n1 echo
echo->__libc_start_main([ "echo" ] <unfinished ...>
 echo->getenv("POSIXLY_CORRECT")                                                                 = nil
 echo->strrchr("echo", '/')                                                                      = nil
 echo->setlocale(LC_ALL, "" <unfinished ...>
  libc.so.6->malloc(5)                                                                           = 0x187a010
  libc.so.6->free(0x187a010)                                                                     = <void>
  [... etc ...]

Note that the method of tracing that ltrace uses has a very high
overhead.  Using e.g. python in this regime is an interesting
contemplative exercise--it takes minutes before you see the prompt and
then every character you write produces a sputter of log messages.

> I don't understand Juan's comment [0] about how libc6 libraries don't
> use the executable's PLT (do they use their own?). I would greatly
> appreciate any pointers!

Each library has its own set of PLT slots through which it calls to
other libraries.  Formerly ltrace only cared about the PLT slots in the
main executable.  The missing functionality was added in 0.7.0.

Thanks,
PM



More information about the Ltrace-devel mailing list