[Ltrace-devel] ltrace not working on some shared objects

Petr Machata pmachata at redhat.com
Fri Jul 25 20:29:53 UTC 2014


Patric Schmitz <bzk0711 at aol.com> writes:

> On Fri, 25 Jul 2014 11:03:36 +0200
> Petr Machata <pmachata at redhat.com> wrote:
>> Patric Schmitz <bzk0711 at aol.com> writes:
>> > that easily, so I'm kinda stuck here. What might be reasons for ltrace
>> > not being able to trace calls in-between linked shared objects?
>> 
>> ... 
>> In your case, if you want to trace calls _to_ libGL, the more useful
>> ltrace flag might be -l libGL\*.
>
> I already tried that, but it works only if I link the libraries which
> call into libGL statically. With other applications, e.g. glxgears, I
> can see the calls *from* the shared libGL *to* libnvidia-glcore by
> doing "ltrace -l libnv\* glxgears" as expected. I need to see the calls
> from my shared objects (which were built as shown in the last mail) to
> libGL.

OK, that's suspicious.  I don't know the exact scenario, but it should
work:

$ cat lib3.c
int lib3() { return 7; }
$ cat lib2.cc
extern "C" int lib3();
int lib2 () { return lib3 () + 1; }
$ cat main.cc
int lib2 ();
int main(int argc, char *argv[]) { return lib2 () + 1; }
$ gcc -fpic -shared lib3.c -o lib3.so
$ c++ -Wall -Wno-reorder -g -DDEBUG -fPIC -c lib2.cc
$ c++ -fPIC -Wall -Wno-reorder -g -DDEBUG -shared -Wl,-soname,lib2.so  -o lib2.so lib2.o -lrt
$ c++ main.cc lib2.so lib3.so 
$ LD_LIBRARY_PATH=. ltrace -l lib3\* ./a.out
lib2.so->lib3(1, 0x7fffc92814b8, 0x7fffc92814c8, 64) = 7
+++ exited (status 9) +++

I'll need a bit more context here.  Can you create a self-contained
example that exhibits this problem?  Something that I can use to debug
whatever is happening?

Thanks,
PM



More information about the Ltrace-devel mailing list