trace for shared lib calles ?

Harald Koenig (
Sat, 26 Jul 1997 07:53:25 +0200


is there an easy way to trace some/all calls to a shared lib (if possible
without hacking the lib sources and add warppers there) similar to "strace"
for system calls ?

if there is no such tool/method available, I'd like to write wrapper functions
which can be preloaded using LD_PPRELOAD which should call the functions
in he original library then and generaet the "ltrace" output.

but how do I create e.g. a function "malloc" for the preload/wrapper library
which then should call "malloc" from the real shared libc without generating
a recursive call to itself (the wrapper function) ?

thanks for any hints...


PS: for now it would be possible to hack the according lib sources to
add code (if someone has tools for this for libc or similar...)
but I'd prefer a binary-only solution to be able to trace libs
without sources (e.g. libXm.2) too!

All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \                     ^^^^^       ^^^^^