Getting stack trace in C ++ exceptions

The fact that the stack / function trace comes in Java / C # exceptions is really useful. Is there a convenient way to do this in C ++ or will I have to bake additional data into each method / function?

+3
source share
3 answers

Most debuggers can be configured to pause your program every time an exception is thrown (any exception or exception for which there is no handler) so you can observe the call stack.

Also, if your code only generates class exceptions that you control, you can put code to reset the call stack in these class constructors .

+1
source

, . boost:: exception , .

0

Some OS APIs provide a stack trace; I know that the Windows API has StackWalk64 or something like that that can do a stack trace.

However, if you cannot depend on such a thing, then almost all you can do is either debug the assembly or do it manually.

0
source

Source: https://habr.com/ru/post/1782759/


All Articles