How to display a stack trace when an exception is thrown
c++, exception, stack-trace
Solution
It depends which platform.
On GCC it's pretty trivial, see this post for more details.
On MSVC then you can use the StackWalker library that handles all of the underlying API calls needed for Windows.
You'll have to figure out the best way to integrate this functionality into your app, but the amount of code you need to write should be minimal.
Problem
I want to have a way to report the stack trace to the user if an exception is thrown. What is the best way to do this? I'd like it to be portable if possible. I want information to pop up, so the user can copy the stack trace and email it to me if an error comes up.
Related problems
- How to get a stack trace for C++ using gcc with line number information?
- How can I print stack trace for caught exceptions in C++ & code injection in C++
- How to automatically generate a stacktrace when my program crashes
- Is it possible to attach gdb to a crashed process (a.k.a "just-in-time" debugging)
- Why doesn't C++ use std::nested_exception to allow throwing from destructor?
- How to know the exact line of code where an exception has been caused?
- Why is my UnhandledExceptionFilter not being called on a simple divide by zero?