> Presumably this particular implementation won't work if libcxxabi is
statically linked

Yes, that's right. But as the paper says - `libsfe` is just a prototype to show that we can add `std::stacktrace::from_current_exception` without breaking ABI. Library does not pretend to be a release implementation.

пн, 26 апр. 2021 г. в 19:57, Edward Catmur <ecatmur@googlemail.com>:
Presumably this particular implementation won't work if libcxxabi is statically linked?

We hook exception throwing by subclassing std::type_info, overriding __do_catch, and using a small bit of asm to create a polymorphic type whose vtable points to that std::type_info subclass. This does admittedly mean that you can only access the stack trace if you have a catch specification with this custom type, but we find that usually where you want the stack trace you'd be doing `catch (...)` anyway so changing that to `catch (AnyException&)` isn't too onerous.

Quick demo: https://gist.githubusercontent.com/ecatmur/8321439b4c8bb5f6851aa55ec2aeecc2/raw/9cdf7113d0056ae0975ecca80c43dc3c90ec7e62/prog3.c++
And godbolt (slightly nerfed, but you get the idea): https://godbolt.org/z/caK3r8jbr

I've occasionally thought that it'd be nice to be able to run arbitrary code at the throw point, but while we've had the technical ability to do so for a couple of years there hasn't been any demand, so probably just being able to access the current exception stack trace is sufficient.

On Mon, 26 Apr 2021 at 17:32, Андрей Некрашевич via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
Hello everybody!

The feature of getting stacktraces from exceptions was requested in https://lists.isocpp.org/std-proposals/2020/11/2086.php and in the "2021 Annual C++ Developer Survey".

I've created a prototype for getting stacktraces from exceptions https://github.com/axolm/libsfe.

More details can be found in the paper D2370R0 "Stacktrace from exception" here  - https://htmlpreview.github.io/?https://github.com/axolm/libsfe/blob/master/paper/stacktrace_from_exception.html

Any comments are welcome!

Regards, Andrei
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals