[exception] rename mono_handle_native_sigsegv -> mono_handle_native_crash
[mono.git] / mono / mini / mini-exceptions.c
index 857bbefef3690bbb093ce76f4aace5cc6f4f0678..3d769c6460fa1e905c723121fe9b83665fa4b220 100644 (file)
@@ -108,7 +108,13 @@ first_managed (MonoStackFrameInfo *frame, MonoContext *ctx, gpointer addr)
        if (!frame->managed)
                return FALSE;
 
-       *data = MONO_CONTEXT_GET_SP(ctx);
+       if (!ctx) {
+               // FIXME: Happens with llvm_only
+               *data = NULL;
+               return TRUE;
+       }
+
+       *data = MONO_CONTEXT_GET_SP (ctx);
        g_assert (*data);
        return TRUE;
 }
@@ -163,6 +169,9 @@ mini_above_abort_threshold (void)
        gpointer sp = mono_thread_get_managed_sp ();
        MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
 
+       if (!sp)
+               return TRUE;
+
        gboolean above_threshold = mini_abort_threshold_offset (jit_tls->abort_exc_stack_threshold, sp) >= 0;
 
        if (above_threshold)
@@ -2416,25 +2425,24 @@ print_stack_frame_to_string (StackFrameInfo *frame, MonoContext *ctx, gpointer d
 static gboolean handling_sigsegv = FALSE;
 
 /*
- * mono_handle_native_sigsegv:
+ * mono_handle_native_crash:
  *
- *   Handle a SIGSEGV received while in native code by printing diagnostic 
- * information and aborting.
+ *   Handle a native crash (e.g. SIGSEGV) while in native code by
+ *   printing diagnostic information and aborting.
  */
 void
-mono_handle_native_sigsegv (int signal, void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info)
+mono_handle_native_crash (const char *signal, void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info)
 {
 #ifdef MONO_ARCH_USE_SIGACTION
        struct sigaction sa;
 #endif
        MonoJitTlsData *jit_tls = (MonoJitTlsData *)mono_native_tls_get_value (mono_jit_tls_id);
-       const char *signal_str = (signal == SIGSEGV) ? "SIGSEGV" : "SIGABRT";
 
        if (handling_sigsegv)
                return;
 
        if (mini_get_debug_options ()->suspend_on_sigsegv) {
-               mono_runtime_printf_err ("Received SIGSEGV, suspending...");
+               mono_runtime_printf_err ("Received %s, suspending...", signal);
 #ifdef HOST_WIN32
                while (1)
                        ;
@@ -2523,7 +2531,7 @@ mono_handle_native_sigsegv (int signal, void *ctx, MONO_SIG_HANDLER_INFO_TYPE *i
                         "a fatal error in the mono runtime or one of the native libraries \n"
                         "used by your application.\n"
                         "=================================================================\n",
-                       signal_str);
+                       signal);
 
 
 #ifdef MONO_ARCH_USE_SIGACTION
@@ -2550,7 +2558,7 @@ mono_handle_native_sigsegv (int signal, void *ctx, MONO_SIG_HANDLER_INFO_TYPE *i
 #else
 
 void
-mono_handle_native_sigsegv (int signal, void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info)
+mono_handle_native_crash (const char *signal, void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info)
 {
        g_assert_not_reached ();
 }