Skip to content

shadow libstdc++ __cxa_throw and __cxa_rethrow with versions that obtain, demangle and print a stack trace, before deferring to the standard ones. Helps in locating the thrower of an exception.

Notifications You must be signed in to change notification settings

marc1uk/cpp_stacktrace_on_exception

Repository files navigation

Code taken from https://web.archive.org/web/20150706050621/http://blog.sjinks.pro/c-cpp/969-track-uncaught-exceptions, credit Опубликовано Vladimir (i believe, please open an issue to correct this if incorrect)
Improved stacktrace print function by Yale Zhang from https://stackoverflow.com/a/63855266.
Other stacktrace print functions based on boost::stacktrace and gdb are also included.
The gdb version also prints local variables and threading information, but is much slower.
Ensure your application is compiled with debug symbols (`-g`) and linker options `-ldl -rdynamic` (or `-Wl,-export-dynamic`).

compilation: `make hack2` (builds the library version)
Then to print stacktraces on exceptions when running your program, preload this library when calling your binary:
LD_PRELOAD=/path/to/libstacktrace_on_exception.so ./main <args>

An alternative, shorter version of a program to override __cxa_throw is included from https://stackoverflow.com/a/11674810.


About

shadow libstdc++ __cxa_throw and __cxa_rethrow with versions that obtain, demangle and print a stack trace, before deferring to the standard ones. Helps in locating the thrower of an exception.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published