3 days ago · Tech · 0 comments

import NotePanel from ‘packages/mdx-blog-components/src/NotePanel’; Compared to languages like Python or Java, C++ does not provide built-in support for stack traces in exceptions. This can make debugging somewhat difficult when all you end up having is a crash log stating what(): bad optional access. With some linker ticks and a bit of code, it is possible though to add cleaner stack traces to C++ exceptions, including standard library ones. This post focuses specifically on GCC and Clang using the Itanium C++ ABI. It will work on Linux and macOS out of the box and also on Windows when using MinGW with `libstdc++`. For MSVC, a similar approach can be taken by hooking different functions that are used for exception handling in the MSVC runtime, but the details will be different and are not covered in this post. The simplest way to get stack traces working for exceptions is to just create a custom exception type that captures the stack trace in the constructor and then we can print…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.