Ethan Tira-Thompson
 

This bit of code provides an interface for generating stack traces from within a program. Inspired by Java's ability to do a backtrace whenever an error occurs, this provides similar capability in C/C++. Very lightweight, and optionally links against libbfd for symbolic output.


I originally wrote this to handle an issue in Tekkotsu on the Aibo where virtual function calls made on an object in shared memory would switch the global context to that of the process which created the object instead of the process which was currently executing.  This would cause issues with acquiring mutual exclusion locks since it would appear that a different process was executing.  However, by performing a stack trace, the root stack frame uniquely identifies each process, and thus allows proper mutual exclusion to be obtained.


The generalized result of this work is that this also allows you to generate a live stack trace of your C/C++ code for debugging purposes.  This can be very handy, such as on an embedded platform where tools such as GDB may not be available, or when producing error messages for end users to report back to you.


Go to stacktrace websitehttps://sourceforge.net/projects/stacktrace

Hosted by SourceForge