Is it possible to output the call stack when an assert
fails in Release mode?
I can see the call stack inside Visual Studio when an assert
fails in Debug mode. I have compiled Release mode with NDEBUG
removed so that assertions are compiled. When this assert
fails, the assert parameters are printed onto the console. It would be very helpful if I can somehow get an output of the call stack too.
There are two functions that should help: CaptureStackBackTrace and StackWalk64 (requires Dbghelp.dll, here's an example).
Anyhow, both of them return you only a list of return addresses, so have to resolve them into function names manually. You can set VS to generate a MAP file with addresses of all functions in you executable. Here's how.
Also, don't forget that some functions may (and will) be inlined. So don't be surprised when instead of A -> B -> C
you will see A -> C
calls tack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With