The Linux specific backtrace() and backtrace_symbols() allows you to produce a call trace of the program. However, it only prints function addresse
backtrace()
backtrace_symbols()
Use the addr2line command to map executable addresses to source code filename+line number. Give the -f option to get function names as well.
-f
Alternatively, try libunwind.