gcc -D_GNU_SOURCE -g -Wall -o stacktraceDemo stacktraceDemo.c -lbfdNote: make sure the compiler is called with the -g-option. Otherwise the file and line number information is not available.
Stack trace: [0x401c98] f1 (/home/torsten/projects/c/stacktrace/stacktraceDemo.c:685) [0x401cb5] f2 (/home/torsten/projects/c/stacktrace/stacktraceDemo.c:691) [0x401cc5] f3 (/home/torsten/projects/c/stacktrace/stacktraceDemo.c:696) [0x401d3b] main (/home/torsten/projects/c/stacktrace/stacktraceDemo.c:712) [0x2176d] __libc_start_main (/build/buildd/eglibc-2.15/csu/libc-start.c:258)The trace show the call stack for the test functions f1, f2, f3 of the demo including the source file name and the line numbers.
The code is based on the original source from
OpenLieroX: Debug_extended_backtrace.cpp
Download
stacktracedemo.tar.bz2
ChangeLog
2015-09-05 0.01 * initial public release
Back to top