Question

I would like to monitor(debug) a linux dynamic library written in C.
I want to see when and what parameters are passed to it.

The library to monitor 'X', is invoked by another dynamic library 'Y'.
Both 'X and 'Y' appear in /proc/pid/maps of the executable 'A'.

Using ltrace, on the executable did not show lib X or Y.
The executable is using multiple threads.

Also, when using ldd command on the exec it doesn't mention anything about libs X or Y.
ldd Y, shows that Y needs X.

Using ldd on all the libs, execs in the project doesn't mention anyone who would need Y.
Yet Y appears to be loaded in the /proc/pid/maps of the exec.

I'm not sure what steps I could take in order to debug the X lib, any advice is appreciated.

Was it helpful?

Solution

If user756235 can run it under gdb then this is an approach using this and this. The only question is to make a full list of functions in a shared library X: nm ./libX.so | grep "T "

And then create .gdbinit (in my case I control args of print_in_lib):

host: srv2-x64rh5-01, OS: Linux 2.6.18-238.el5>more .gdbinit
file main
set pagination off
set logging file gdb.txt
set breakpoint pending on
set logging on
b print_in_lib
commands
info args
continue
end
r
set logging off
quit

And when I run gdb:

host: srv2-x64rh5-01, OS: Linux 2.6.18-238.el5>gdb -q Function "print_in_lib" not defined. Breakpoint 1 (print_in_lib) pending. warning: no loadable sections found in added symbol-file system-supplied DSO at 0x2aaaaaaab000 thousands: 1 print_debug: 0

Breakpoint 1, print_in_lib (print_debug=0, index=0) at my_lib.cpp:7 7 if (print_debug) { print_debug = 0 index = 0

Breakpoint 1, print_in_lib (print_debug=0, index=1) at my_lib.cpp:7 7 if (print_debug) { print_debug = 0 index = 1

Breakpoint 1, print_in_lib (print_debug=0, index=2) at my_lib.cpp:7 7 if (print_debug) { print_debug = 0 index = 2

Breakpoint 1, print_in_lib (print_debug=0, index=3) at my_lib.cpp:7 7 if (print_debug) { print_debug = 0 index = 3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top