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]

process.library("foo") finds more matches than process.library("*")?


Hi,

six years ago I wrote a tool that traces the execution of a process
using ptrace by single-stepping over every single instruction that gets
executed. From the trace it is then possible to reconstruct the names of
functions that got executed. The original goal back then was to figure
out how some dlopen()'d library is used in a daemon that I can not stop
(ltrace does not support attaching to already running processes and also
does not work with dlopen()).

http://iki.fi/lindi/git/itrace.git/

Anyways, last week I was playing with systemtap uprobes support and
thought that it'd be a nice exercise to try to replicate the
functionality of itrace at least to some degree with systemtap. In one
of the testcases test1.c calls funtions in libtest1.c and libtest1.c is
compiled to a shared library libtest1.so in the current directory.

What I noticed is that "*" in the following does not match
"./libtest1.so". How come?

<lindi-_> # stap -l 'process.library("*").function("*")' -c ./test1 | grep libtest1_entry
<lindi-_> undefined symbol: libtest1_entry        (/root/itrace/testsuite/test1)
<lindi-_> # stap -l 'process.library("./libtest1.so").function("*")' -c ./test1 | grep libtest1_entry
<lindi-_> process("/root/itrace/testsuite/libtest1.so").function("libtest1_entry@/root/itrace/testsuite/libtest1.c:14")
<lindi-_> is this expected behavior? is there a way to avoid having to manually list the libraries? I have tried 1) LD_LIBRARY_PATH=. 2) -d libtest1.so and 3) --ldd
<lindi-_> using 1) omits the "undefined" warning but still does not list the symbol
<lindi-_> and strace shows open("./libtest1.so", O_RDONLY|O_CLOEXEC) = 3
<lindi-_> but somehow "*" does not include the library
<mjw> lindi-_, I would have guessed that process.library("*") should do the equivalent of --ldd, but if that also doesn't work...
-*- mjw hasn't actually looked at the code to verify
<lindi-_> mjw: none of 1), 2) or 3) shows the symbol
<lindi-_> mjw: if you want to play with this you can clone my example testsuite/ directory from http://iki.fi/lindi/itrace.git -- only test1.c and libtest1.c are relevant
<lindi-_> mjw: http://iki.fi/lindi/git/itrace.git   even
<lindi-_> mjw: probe process("*").function("*") if (target_set_pid(pid())) ...  seems to do what I want but it's bit overkill
<lindi-_> mjw: I'm not sure if this is a bug or not since the documentation does not say much about .library yet
<mjw> lindi-_, I am not sure either, but I would expect it to work myself.

-Timo


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