Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a stack trace in C++ exceptions

Tags:

c++

exception

The fact a stack/function trace is supplied in Java/C# exceptions is really useful. Is there a handy way to do this in C++ or would I have to bake extra data into every method/function?

like image 928
Mr. Boy Avatar asked Dec 05 '25 10:12

Mr. Boy


1 Answers

Most debuggers can be set up to pause your program each time an exception is thrown (either any exception or an exception for which there's no handler) so that you can obserevr a call stack.

Also if your code only throws exceptions of classes you control you can put code for dumping the call stack in those classes constructors.

like image 199
sharptooth Avatar answered Dec 07 '25 14:12

sharptooth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!