Merge pull request #880 from awinters-fvs/xbuild/make-dist-fix
[mono.git] / mono / mini / mini-exceptions.c
index 8f3b55e684e18560e47aceb48ccfd7f1f5ad55c0..86ac38e31f25bfcc4fce69d77857c388a88b181a 100644 (file)
@@ -50,7 +50,6 @@
 #include <mono/utils/mono-logger-internal.h>
 
 #include "mini.h"
-#include "debug-mini.h"
 #include "trace.h"
 #include "debugger-agent.h"
 
@@ -1510,7 +1509,7 @@ mono_handle_exception_internal (MonoContext *ctx, gpointer obj, gboolean resume,
        MonoContext initial_ctx;
        MonoMethod *method;
        int frame_count = 0;
-       gint32 filter_idx, first_filter_idx;
+       gint32 filter_idx, first_filter_idx = 0;
        int i;
        MonoObject *ex_obj;
        MonoObject *non_exception = NULL;
@@ -1934,7 +1933,7 @@ mono_setup_altstack (MonoJitTlsData *tls)
        if (mono_running_on_valgrind ())
                return;
 
-       mono_thread_get_stack_bounds (&staddr, &stsize);
+       mono_thread_info_get_stack_bounds (&staddr, &stsize);
 
        g_assert (staddr);
 
@@ -2109,6 +2108,7 @@ typedef struct {
        int count;
 } PrintOverflowUserData;
 
+#ifdef MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX
 static gboolean
 print_overflow_stack_frame (StackFrameInfo *frame, MonoContext *ctx, gpointer data)
 {
@@ -2147,12 +2147,15 @@ print_overflow_stack_frame (StackFrameInfo *frame, MonoContext *ctx, gpointer da
 
        return FALSE;
 }
+#endif
 
 void
 mono_handle_hard_stack_ovf (MonoJitTlsData *jit_tls, MonoJitInfo *ji, void *ctx, guint8* fault_addr)
 {
+#ifdef MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX
        PrintOverflowUserData ud;
        MonoContext mctx;
+#endif
 
        /* we don't do much now, but we can warn the user with a useful message */
        mono_runtime_printf_err ("Stack overflow: IP: %p, fault addr: %p", mono_arch_ip_from_context (ctx), fault_addr);
@@ -2234,8 +2237,14 @@ mono_handle_native_sigsegv (int signal, void *ctx)
 
        if (mini_get_debug_options ()->suspend_on_sigsegv) {
                mono_runtime_printf_err ("Received SIGSEGV, suspending...");
+#ifdef HOST_WIN32
                while (1)
                        ;
+#else
+               while (1) {
+                       sleep (0);
+               }
+#endif
        }
 
        /* To prevent infinite loops when the stack walk causes a crash */
@@ -2266,7 +2275,7 @@ mono_handle_native_sigsegv (int signal, void *ctx)
        /* Try to get more meaningful information using gdb */
 
 #if !defined(HOST_WIN32) && defined(HAVE_SYS_SYSCALL_H) && defined(SYS_fork)
-       if (!mini_get_debug_options ()->no_gdb_backtrace && !mono_debug_using_mono_debugger ()) {
+       if (!mini_get_debug_options ()->no_gdb_backtrace) {
                /* From g_spawn_command_line_sync () in eglib */
                pid_t pid;
                int status;
@@ -2700,3 +2709,16 @@ mono_restore_context (MonoContext *ctx)
        g_assert_not_reached ();
 }
 
+/*
+ * mono_jinfo_get_unwind_info:
+ *
+ *   Return the unwind info for JI.
+ */
+guint8*
+mono_jinfo_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len)
+{
+       if (ji->from_aot)
+               return mono_aot_get_unwind_info (ji, unwind_info_len);
+       else
+               return mono_get_cached_unwind_info (ji->used_regs, unwind_info_len);
+}