From 72094f1208248d1c22978559d113c16fdb96ef63 Mon Sep 17 00:00:00 2001 From: Eduard Karacharov Date: Mon, 3 Mar 2025 18:07:46 +0200 Subject: [PATCH] Fix macos stacktraces for 19.x Use backtrace function instead of unw_backtrace for OS_DARWIN Ref: 2a8967b60cbe5bc2df253712bac343cc5263c5fc --- libcxx/include/__exception/exception.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libcxx/include/__exception/exception.h b/libcxx/include/__exception/exception.h index 181374d8ac0b7..b8523ff534d53 100644 --- a/libcxx/include/__exception/exception.h +++ b/libcxx/include/__exception/exception.h @@ -22,8 +22,12 @@ #endif #ifdef STD_EXCEPTION_HAS_STACK_TRACE +#if defined(OS_DARWIN) +extern "C" int backtrace(void **, int); +#else extern "C" int unw_backtrace(void **, int); #endif +#endif namespace std { // purposefully not using versioning namespace @@ -103,7 +107,11 @@ class _LIBCPP_EXPORTED_FROM_ABI exception { int size = 0; void capture() _NOEXCEPT { +#if defined(OS_DARWIN) + size = backtrace(frames, capacity); +#else size = unw_backtrace(frames, capacity); +#endif } #endif };