MCPcopy Create free account
hub / github.com/boostorg/stacktrace / from_current_exception

Function from_current_exception

include/boost/stacktrace/stacktrace.hpp:394–415  ·  view source on GitHub ↗

Returns a basic_stacktrace object containing a stacktrace captured at the point where the currently handled exception was thrown by its initial throw-expression (i.e. not a rethrow), or an empty basic_stacktrace object if: - the `boost_stacktrace_from_exception` library is not linked to the current binary, or - the initialization of stacktrace failed, or - stacktrace captures are not enabled for

Source from the content-addressed store, hash-verified

392 ///
393 /// Implements https://wg21.link/p2370r1
394 static basic_stacktrace<Allocator> from_current_exception(const allocator_type& alloc = allocator_type()) noexcept {
395 // Matches the constant from implementation
396 constexpr std::size_t kStacktraceDumpSize = 4096;
397
398 const char* trace = nullptr;
399#if defined(__GNUC__) && defined(__ELF__)
400 if (impl::current_exception_stacktrace) {
401 trace = impl::current_exception_stacktrace();
402 }
403#elif defined(BOOST_MSVC)
404 trace = boost_stacktrace_impl_current_exception_stacktrace();
405#endif
406
407 if (trace) {
408 try {
409 return basic_stacktrace<Allocator>::from_dump(trace, kStacktraceDumpSize, alloc);
410 } catch (const std::exception&) {
411 // ignore
412 }
413 }
414 return basic_stacktrace<Allocator>{0, 0, alloc};
415 }
416};
417
418/// @brief Compares stacktraces for less, order is platform dependent.

Callers 10

test_no_exceptionFunction · 0.85
test_rethrowFunction · 0.85
test_nestedFunction · 0.85
test_rethrow_nestedFunction · 0.85
test_from_other_threadFunction · 0.85
mainFunction · 0.85

Tested by 9

test_no_exceptionFunction · 0.68
test_rethrowFunction · 0.68
test_nestedFunction · 0.68
test_rethrow_nestedFunction · 0.68
test_from_other_threadFunction · 0.68