2004-10-21 <vargaz@freemail.hu>
[mono.git] / mono / mini / exceptions-s390.c
index 9be9815dea67015cbb5acfef255d9b9aaf339615..96d84bac04f21c71f40968ef4707d7ba766aad72 100644 (file)
@@ -500,6 +500,10 @@ throw_exception (MonoObject *exc, unsigned long ip, unsigned long sp,
        MONO_CONTEXT_SET_BP (&ctx, sp);
        MONO_CONTEXT_SET_IP (&ctx, ip);
        
+       if (mono_object_isinst (exc, mono_defaults.exception_class)) {
+               MonoException *mono_ex = (MonoException*)exc;
+               mono_ex->stack_trace = NULL;
+       }
        mono_arch_handle_exception (&ctx, exc, FALSE);
        setcontext(&ctx);
 
@@ -823,6 +827,10 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
        MonoArray *ta = exc->trace_ips;
        int i, len;
        
+       if (ta == NULL) {
+               return mono_array_new (domain, mono_defaults.stack_frame_class, 0);
+       }
+
        len = mono_array_length (ta);
 
        res = mono_array_new (domain, mono_defaults.stack_frame_class, 
@@ -834,7 +842,10 @@ 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);
-               g_assert (ji != NULL);
+               if (ji == NULL) {
+                       mono_array_set (res, gpointer, i, sf);
+                       continue;
+               }
 
                sf->method = mono_method_get_object (domain, ji->method, NULL);
                sf->native_offset = (char *)ip - (char *)ji->code_start;
@@ -869,7 +880,7 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
 /*------------------------------------------------------------------*/
 
 void
-mono_jit_walk_stack (MonoStackWalk func, gpointer user_data) {
+mono_jit_walk_stack (MonoStackWalk func, gboolean do_il_offset, gpointer user_data) {
        MonoDomain *domain = mono_domain_get ();
        MonoJitTlsData *jit_tls = TlsGetValue (mono_jit_tls_id);
        MonoLMF *lmf = jit_tls->lmf;
@@ -891,7 +902,7 @@ mono_jit_walk_stack (MonoStackWalk func, gpointer user_data) {
                if (ji == (gpointer)-1)
                        return;
 
-               il_offset = mono_debug_il_offset_from_address (ji->method, native_offset, domain);
+               il_offset = do_il_offset ? mono_debug_il_offset_from_address (ji->method, native_offset, domain): -1;
 
                if (func (ji->method, native_offset, il_offset, managed, user_data))
                        return;
@@ -1041,7 +1052,7 @@ mono_arch_handle_exception (void *uc, gpointer obj, gboolean test_only)
                        if (test_only && ji->method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE && mono_ex) {
                                char *tmp, *strace;
 
-                               trace_ips = g_list_append (trace_ips, MONO_CONTEXT_GET_IP (ctx));
+                               trace_ips = g_list_prepend (trace_ips, MONO_CONTEXT_GET_IP (ctx));
 
                                if (!mono_ex->stack_trace)
                                        strace = g_strdup ("");
@@ -1072,8 +1083,10 @@ mono_arch_handle_exception (void *uc, gpointer obj, gboolean test_only)
                                                    ((ei->flags == MONO_EXCEPTION_CLAUSE_FILTER &&
                                                      call_filter (ctx, ei->data.filter, obj)))) {
                                                        if (test_only) {
-                                                               if (mono_ex)
+                                                               if (mono_ex) {
+                                                                       trace_ips = g_list_reverse (trace_ips);
                                                                        mono_ex->trace_ips = glist_to_array (trace_ips);
+                                                               }
                                                                g_list_free (trace_ips);
                                                                g_free (trace);
                                                                return TRUE;
@@ -1116,8 +1129,10 @@ mono_arch_handle_exception (void *uc, gpointer obj, gboolean test_only)
                                jit_tls->abort_func (obj);
                                g_assert_not_reached ();
                        } else {
-                               if (mono_ex)
+                               if (mono_ex) {
+                                       trace_ips = g_list_reverse (trace_ips);
                                        mono_ex->trace_ips = glist_to_array (trace_ips);
+                               }
                                g_list_free (trace_ips);
                                return FALSE;
                        }