Besides the usual debugger and aspect-oriented programming techniques, you can also inject your own instrumentation functions using gcc’s -finstrument-functions
command line options. You’ll have to implement your own __cyg_profile_func_enter()
and __cyg_profile_func_exit()
functions (declare these as extern "C"
in C++).
They provide a means to track what function was called from where. However, the interface is a bit difficult to use since the address of the function being called and its call site are passed instead of a function name, for example. You could log the addresses, and then pull the corresponding names from the symbol table using something like objdump --syms
or nm
, assuming of course the symbols haven’t been stripped from the binaries in question.
It may just be easier to use gdb
. YMMV. 🙂