A simple cross-platform C++11 library for generating stack traces.
This library is currently supported on Windows, OSX, and Linux, and requires a compiler that is fairly compliant with C++11 - the library has been compiled under gcc 4.8, clang 3.4, and MSVC 2013 (older versions of those compilers may work, but have not yet been tested).
- Linux:
libbfd
- For Ubuntu and similar distributions, this can be installed through
apt-get install binutils-dev libiberty-dev
.
- For Ubuntu and similar distributions, this can be installed through
- Windows:
DbgHelp.dll
(included with Windows)
#include <withershins.hpp>
void foo()
{
std::vector<withershins::frame> frames = withershins::trace();
assert(frames[0].function_name() == "foo");
assert(frames[1].function_name() == "main");
}
int main(int argc, char *argv[])
{
foo();
return 0;
}