diff --git a/src/mono/mono/mini/mini-arm64.h b/src/mono/mono/mini/mini-arm64.h index 7dfe8eed08c06..2943c6c5ae127 100644 --- a/src/mono/mono/mini/mini-arm64.h +++ b/src/mono/mono/mini/mini-arm64.h @@ -198,7 +198,7 @@ typedef struct { #endif -#if defined(TARGET_IOS) || defined(TARGET_WATCHOS) +#if defined(TARGET_IOS) || defined(TARGET_WATCHOS) || defined(__linux__) #define MONO_ARCH_HAVE_UNWIND_BACKTRACE 1 #endif diff --git a/src/mono/mono/mini/mini-exceptions.c b/src/mono/mono/mini/mini-exceptions.c index 56935279a18bd..97e503dc2cf43 100644 --- a/src/mono/mono/mini/mini-exceptions.c +++ b/src/mono/mono/mini/mini-exceptions.c @@ -369,7 +369,7 @@ is_address_protected (MonoJitInfo *ji, MonoJitExceptionInfo *ei, gpointer ip) #ifdef MONO_ARCH_HAVE_UNWIND_BACKTRACE -#if 0 +#if 1 static gboolean show_native_addresses = TRUE; #else static gboolean show_native_addresses = FALSE; diff --git a/src/mono/mono/mini/mini-posix.c b/src/mono/mono/mini/mini-posix.c index be8f83d396872..d5ce694e0bf70 100644 --- a/src/mono/mono/mini/mini-posix.c +++ b/src/mono/mono/mini/mini-posix.c @@ -80,6 +80,10 @@ #include "jit-icalls.h" #include +#ifdef HAVE_UNWIND_H +#include +#endif + #ifdef HOST_DARWIN #include #include @@ -774,6 +778,21 @@ fork_crash_safe (void) } #endif +#ifdef MONO_ARCH_HAVE_UNWIND_BACKTRACE +static _Unwind_Reason_Code +dump_unwind_backtrace (struct _Unwind_Context *frame_ctx, G_GNUC_UNUSED void *state) +{ + uintptr_t ip = _Unwind_GetIP (frame_ctx); + + g_async_safe_printf ("\t Frame: %p\n\t\t"); + mono_print_method_from_ip ((void*)ip); + g_async_safe_printf ("\n"); + + return _URC_NO_REASON; +} + +#endif + static void dump_native_stacktrace (const char *signal, MonoContext *mctx) { @@ -789,6 +808,13 @@ dump_native_stacktrace (const char *signal, MonoContext *mctx) } +#ifdef MONO_ARCH_HAVE_UNWIND_BACKTRACE + g_async_safe_printf ("\n=================================================================\n"); + g_async_safe_printf (" _Unwind_Backtrace stacktrace:\n"); + g_async_safe_printf ("=================================================================\n"); + _Unwind_Backtrace (dump_unwind_backtrace, NULL); +#endif + #ifdef HAVE_BACKTRACE_SYMBOLS void *array [256];