2004-10-20 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Thu, 21 Oct 2004 22:24:20 +0000 (22:24 -0000)
committerMartin Baulig <martin@novell.com>
Thu, 21 Oct 2004 22:24:20 +0000 (22:24 -0000)
* mini-exceptions.c (mono_handle_exception): Call
mono_debugger_handle_exception() to tell the debugger about
catch/finally clauses.

svn path=/trunk/mono/; revision=35226

mono/mini/ChangeLog
mono/mini/exceptions-x86.c
mono/mini/mini-exceptions.c

index 81dc6dcceee1f90dfe794d53efe9d707c0c62bdd..8decf84e846f70fa8779ae73bc9dd373b533cc14 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-21  Martin Baulig  <martin@ximian.com>
+
+       * exceptions-x86.c (throw_exception): Call mono_debugger_throw_exception();
+       if it returns true, unwind the stack to the call instruction.
+
 2004-10-21    <vargaz@freemail.hu>
 
        * aot.c: Reorganize the AOT file format to avoid relocations. Fix warnings.
index 95df078100c828832bd548d70ed25fd0c002f5bc..070dac0d49b944210cd0715e5e05ca39a3dd2eaa 100644 (file)
@@ -234,9 +234,6 @@ throw_exception (unsigned long eax, unsigned long ecx, unsigned long edx, unsign
        if (!restore_context)
                restore_context = mono_arch_get_restore_context ();
 
-       /* adjust eip so that it point into the call instruction */
-       eip -= 1;
-
        /* Pop argument and return address */
        ctx.SC_ESP = esp + (2 * sizeof (gpointer));
        ctx.SC_EIP = eip;
@@ -247,12 +244,27 @@ throw_exception (unsigned long eax, unsigned long ecx, unsigned long edx, unsign
        ctx.SC_EDX = edx;
        ctx.SC_ECX = ecx;
        ctx.SC_EAX = eax;
-       
+
+       if (mono_debugger_throw_exception (eip - 5, esp, exc)) {
+               /*
+                * The debugger wants us to stop on the `throw' instruction.
+                * By the time we get here, it already inserted a breakpoint on
+                * eip - 5 (which is the address of the call).
+                */
+               ctx.SC_EIP = eip - 5;
+               ctx.SC_ESP = esp + sizeof (gpointer);
+               restore_context (&ctx);
+               g_assert_not_reached ();
+       }
+
+       /* adjust eip so that it point into the call instruction */
+       ctx.SC_EIP -= 1;
+
        if (mono_object_isinst (exc, mono_defaults.exception_class)) {
                MonoException *mono_ex = (MonoException*)exc;
                mono_ex->stack_trace = NULL;
        }
-       mono_handle_exception (&ctx, exc, eip + 1, FALSE);
+       mono_handle_exception (&ctx, exc, eip, FALSE);
        restore_context (&ctx);
 
        g_assert_not_reached ();
index e6fa1e1aa04eee543ff34833ee89a0e12909c1e0..9dacf48b291bafd5c393b3d150e6c2fc5509e448 100644 (file)
@@ -437,7 +437,7 @@ mono_handle_exception (MonoContext *ctx, gpointer obj, gpointer original_ip, gbo
                                                if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER) {
                                                        mono_debugger_handle_exception (ei->data.filter, MONO_CONTEXT_GET_SP (ctx), obj);
                                                        filtered = call_filter (ctx, ei->data.filter);
-                                       }
+                                               }
 
                                                if ((ei->flags == MONO_EXCEPTION_CLAUSE_NONE && 
                                                     mono_object_isinst (obj, mono_class_get (ji->method->klass->image, ei->data.token))) || filtered) {