I would like to trace the function calls to a particular library, call it libfoo. Unfortunately the documentation I have found on it is sparse, so I have a lot of questions.
In the documentation of libfoo, it lists the calls foo_a, foo_b, foo_c .. as api calls. In a Windows DLL, generating such a call list is easy, each external call must be declared so (dllexport(DLL) or something like that), a simple script would extract all the exported symbols. How would I go about generating such a list for linux shared objects.
Once I generate such a list, how do I go about using it with ltrace to generate a trace of the calls using a particular program. Also how do I expand out the ( C ) string arguments in those calls?
Best Answer
There are some tools you can use to do this; the one that will be immediately available is
perf
.Lets say I want to see in real time what's going on with firefox process; I could do
perf top -p <pidof firefox>
; you will see output such as:You could then use
?
to see what you can do in the interface; you could zoom in to a symbol usingd
. You can browse details of a map of a symbol to see exact calls of a process.You probably want to aggregate data; you can use
perf record
to do that instead ofperf top
.There are other tools you can use such as
SystemTap
or an actual debugger.