Previous: Statement, Up: Tracing


7.2 Library tracing

On most UNIX machines there exists a tool for tracing the system calls executed by a program. If you haven't used one of these tools (e.g. ktrace) then now is a good time to learn. Being able to trace the User/Kernel interface is an excellent way to understand complex applications.

The ‘nana-libtrace’ facility generalises this idea to provide a GDB based function call tracer for all functions in which are defined in a particular library. For example the ‘make ex-libtrace’ command in the ‘gdb’ directory produces a trace of all calls to ‘libc’.


Footnotes

[1] If possible we should replace the call to ‘nm’ with a call to something which can print all the symbols for a dynamically linked library. Unfortunately GDB gets upset if you try to set a breakpoint for a function that does not exist. I suppose we could use gdb to print the symbol list out.