Add new public API function mono_set_crash_chaining.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 3 Apr 2014 16:02:57 +0000 (12:02 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 3 Apr 2014 16:04:59 +0000 (12:04 -0400)
mono_set_crash_chaining tells mono to chain crash signals instead of just
running the next one.

This allows us to get the crash info from both mono and the native system.

mono/mini/driver.c
mono/mini/jit.h
mono/mini/mini-exceptions.c
mono/mini/mini.c
mono/mini/mini.h

index d71c077a39a94199b5e2c03a1bdca163f5a0f3e0..34177bd9b8389abe75d702fb830e45296852fd4e 100644 (file)
@@ -2253,3 +2253,16 @@ mono_set_signal_chaining (gboolean chain_signals)
 {
        mono_do_signal_chaining = chain_signals;
 }
+
+/**
+ * mono_set_crash_chaining:
+ *
+ * Enable/disable crash chaining due to signals. When a fatal signal is delivered and
+ * Mono doesn't know how to handle it, it will invoke the crash handler. If chrash chaining
+ * is enabled, it will first print its crash information and then try to chain with the native handler.
+ */
+void
+mono_set_crash_chaining (gboolean chain_crashes)
+{
+       mono_do_crash_chaining = chain_crashes;
+}
index 95e690159ee2cfaa87e4032ea8f9e8aeb2164678..5200da4dd91d8167ec790c67fc2bbd2a2d8d5b88 100644 (file)
@@ -30,6 +30,9 @@ mono_jit_set_trace_options (const char* options);
 MONO_API void
 mono_set_signal_chaining   (mono_bool chain_signals);
 
+MONO_API void
+mono_set_crash_chaining   (mono_bool chain_signals);
+
 MONO_API void
 mono_jit_set_aot_only      (mono_bool aot_only);
 
index 1b38f65ce9db5322c8f3c01a4dbfb62381fcc5f7..221082759f7bcbe51b0ef034a0b922aa3e06654b 100644 (file)
@@ -2334,12 +2334,14 @@ mono_handle_native_sigsegv (int signal, void *ctx)
 
 #endif
 
-       /*Android abort is a fluke, it doesn't abort, it triggers another segv. */
+       if (!mono_do_crash_chaining) {
+               /*Android abort is a fluke, it doesn't abort, it triggers another segv. */
 #if defined (PLATFORM_ANDROID)
-       exit (-1);
+               exit (-1);
 #else
-       abort ();
+               abort ();
 #endif
+       }
 }
 
 static void
index 81ae90d53e0212a0ba541d7e9d676bd6421c7cd2..fe8209d7c7542100676b85a425d9188e4a330ad7 100644 (file)
@@ -101,6 +101,7 @@ int mono_break_at_bb_bb_num;
 gboolean mono_do_x86_stack_align = TRUE;
 const char *mono_build_date;
 gboolean mono_do_signal_chaining;
+gboolean mono_do_crash_chaining;
 static gboolean        mono_using_xdebug;
 static int mini_verbose = 0;
 
@@ -6753,10 +6754,12 @@ SIG_HANDLER_FUNC (, mono_sigfpe_signal_handler)
 #endif
 
        if (!ji) {
-               if (mono_chain_signal (SIG_HANDLER_PARAMS))
+               if (!mono_do_crash_chaining && mono_chain_signal (SIG_HANDLER_PARAMS))
                        return;
 
                mono_handle_native_sigsegv (SIGSEGV, ctx);
+               if (mono_do_crash_chaining)
+                       mono_chain_signal (SIG_HANDLER_PARAMS);
        }
        
        mono_arch_handle_exception (ctx, exc);
@@ -6804,9 +6807,11 @@ SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
 
        /* The thread might no be registered with the runtime */
        if (!mono_domain_get () || !jit_tls) {
-               if (mono_chain_signal (SIG_HANDLER_PARAMS))
+               if (!mono_do_crash_chaining && mono_chain_signal (SIG_HANDLER_PARAMS))
                        return;
                mono_handle_native_sigsegv (SIGSEGV, ctx);
+               if (mono_do_crash_chaining)
+                       mono_chain_signal (SIG_HANDLER_PARAMS);
        }
 
        ji = mono_jit_info_table_find (mono_domain_get (), mono_arch_ip_from_context (ctx));
@@ -6845,10 +6850,13 @@ SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
 #else
 
        if (!ji) {
-               if (mono_chain_signal (SIG_HANDLER_PARAMS))
+               if (!mono_do_crash_chaining && mono_chain_signal (SIG_HANDLER_PARAMS))
                        return;
 
                mono_handle_native_sigsegv (SIGSEGV, ctx);
+
+               if (mono_do_crash_chaining)
+                       mono_chain_signal (SIG_HANDLER_PARAMS);
        }
                        
        mono_arch_handle_exception (ctx, NULL);
index 8b820726f05565f62c826c5406b2d2527deb1cef..894fef53c2c084cf4c09d4be7428817c76c00159 100644 (file)
@@ -526,6 +526,7 @@ extern gboolean mono_dont_free_global_codeman;
 extern gboolean mono_do_x86_stack_align;
 extern const char *mono_build_date;
 extern gboolean mono_do_signal_chaining;
+extern gboolean mono_do_crash_chaining;
 extern gboolean mono_use_llvm;
 extern gboolean mono_do_single_method_regression;
 extern guint32 mono_single_method_regression_opt;