*** empty log message ***
[mono.git] / mono / jit / exception.c
index 1ec6a7779f98e90617f173b688fcc8edc4a8592c..d23a4cfce5213796eb24674ea7899493057aa63f 100644 (file)
@@ -237,7 +237,7 @@ x86_unwind_native_frame (MonoDomain *domain, MonoJitTlsData *jit_tls, struct sig
 
        frame = MONO_CONTEXT_GET_BP (ctx);
 
-       max_stack = lmf ? lmf : jit_tls->end_of_stack;
+       max_stack = lmf && lmf->method ? lmf : jit_tls->end_of_stack;
 
        *new_ctx = *ctx;
 
@@ -652,6 +652,9 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoContex
                
                *new_ctx = *ctx;
 
+               if (!(*lmf)->method)
+                       return (gpointer)-1;
+
                if (trace)
                        *trace = g_strdup_printf ("in (unmanaged) %s", mono_method_full_name ((*lmf)->method, TRUE));
                
@@ -683,6 +686,11 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
        MonoArray *res;
        MonoArray *ta = exc->trace_ips;
        int i, len;
+
+       if (ta == NULL) {
+               /* Exception is not thrown yet */
+               return mono_array_new (domain, mono_defaults.stack_frame_class, 0);
+       }
        
        len = mono_array_length (ta);
 
@@ -694,6 +702,12 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
                gpointer ip = mono_array_get (ta, gpointer, i);
 
                ji = mono_jit_info_table_find (domain, ip);
+               if (ji == NULL) {
+                       /* Unmanaged frame */
+                       mono_array_set (res, gpointer, i, sf);
+                       continue;
+               }
+
                g_assert (ji != NULL);
 
                sf->method = mono_method_get_object (domain, ji->method, NULL);
@@ -735,7 +749,10 @@ mono_jit_walk_stack (MonoStackWalk func, gpointer user_data) {
                
                ji = mono_arch_find_jit_info (domain, jit_tls, &ctx, &new_ctx, NULL, &lmf, &native_offset, &managed);
                g_assert (ji);
-               
+
+               if (ji == (gpointer)-1)
+                       return;
+
                il_offset = mono_debug_il_offset_from_address (ji->method, native_offset);
 
                if (func (ji->method, native_offset, il_offset, managed, user_data))
@@ -766,7 +783,7 @@ ves_icall_get_frame_info (gint32 skip, MonoBoolean need_file_info,
                ji = mono_arch_find_jit_info (domain, jit_tls, &ctx, &new_ctx, NULL, &lmf, native_offset, NULL);
                ctx = new_ctx;
                
-               if (!ji || MONO_CONTEXT_GET_BP (&ctx) >= jit_tls->end_of_stack)
+               if (!ji || ji == (gpointer)-1 || MONO_CONTEXT_GET_BP (&ctx) >= jit_tls->end_of_stack)
                        return FALSE;
 
                if (ji->method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE)
@@ -845,14 +862,14 @@ arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only)
                
                ji = mono_arch_find_jit_info (domain, jit_tls, ctx, &new_ctx, 
                                              test_only ? &trace : NULL, &lmf, NULL, NULL);
+
                if (!ji) {
-                       g_warning ("Exception insinde function without unwind info");
+                       g_warning ("Exception inside function without unwind info");
                        g_assert_not_reached ();
                }
 
-               if (ji->method != mono_start_method) {
-                       
-                       if (test_only) {
+               if (ji != (gpointer)-1) {
+                       if (test_only && ji->method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE) {
                                char *tmp, *strace;
 
                                trace_ips = g_list_append (trace_ips, MONO_CONTEXT_GET_IP (ctx));
@@ -861,7 +878,7 @@ arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only)
                                        strace = g_strdup ("");
                                else
                                        strace = mono_string_to_utf8 (((MonoException*)obj)->stack_trace);
-
+                       
                                tmp = g_strdup_printf ("%s%s\n", strace, trace);
                                g_free (strace);
 
@@ -917,7 +934,7 @@ arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only)
                        
                *ctx = new_ctx;
 
-               if (ji->method == mono_start_method || MONO_CONTEXT_GET_BP (ctx) >= jit_tls->end_of_stack) {
+               if ((ji == (gpointer)-1) || MONO_CONTEXT_GET_BP (ctx) >= jit_tls->end_of_stack) {
                        if (!test_only) {
                                jit_tls->lmf = lmf;
                                jit_tls->abort_func (obj);
@@ -933,3 +950,4 @@ arch_handle_exception (MonoContext *ctx, gpointer obj, gboolean test_only)
        g_assert_not_reached ();
 }
 
+