2009-02-07 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Sat, 7 Feb 2009 18:56:37 +0000 (18:56 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 7 Feb 2009 18:56:37 +0000 (18:56 -0000)
* exceptions-arm.c (mono_arch_find_jit_info): Transition this to use the
dwarf unwinder.

* mini-arm.c: Enable the dwarf unwinder.

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

mono/mini/ChangeLog
mono/mini/exceptions-arm.c
mono/mini/mini-arm.h

index 4f8d1fc47088ba117c56dc75dbf9db9a4c7d1c51..e3a4137d277baf9ea342174f99bd980f85c7d009 100644 (file)
@@ -1,5 +1,10 @@
 2009-02-07  Zoltan Varga  <vargaz@gmail.com>
 
+       * exceptions-arm.c (mono_arch_find_jit_info): Transition this to use the
+       dwarf unwinder.
+
+       * mini-arm.c: Enable the dwarf unwinder.
+
        * mini-trampolines.c (mono_magic_trampoline): Use mono_class_get_vtable_entry ()
        instead of mono_class_setup_vtable ().
 
index e3a57184213b83b1e7ac39439b226e3a3faf327f..2d018b0b92598b4a90b76645084dfed87723d2c2 100644 (file)
@@ -377,7 +377,11 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf
                *managed = FALSE;
 
        if (ji != NULL) {
-               int offset;
+               int i;
+               gssize regs [MONO_MAX_IREGS + 1];
+               guint8 *cfa;
+               guint32 unwind_info_len;
+               guint8 *unwind_info;
 
                *new_ctx = *ctx;
 
@@ -385,51 +389,30 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInf
                        if (!ji->method->wrapper_type)
                                *managed = TRUE;
 
-               /*
-                * Some managed methods like pinvoke wrappers might have save_lmf set.
-                * In this case, register save/restore code is not generated by the 
-                * JIT, so we have to restore callee saved registers from the lmf.
-                */
-               if (ji->method->save_lmf) {
-                       /* 
-                        * We only need to do this if the exception was raised in managed
-                        * code, since otherwise the lmf was already popped of the stack.
-                        */
-                       if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) {
-                               memcpy (&new_ctx->regs [0], &(*lmf)->iregs [4], sizeof (gulong) * MONO_SAVED_GREGS);
-                       }
-                       /* This is the sp for the parent frame */
-                       new_ctx->esp = (*lmf)->iregs [12];
-                       new_ctx->eip = (*lmf)->iregs [13];
-                       new_ctx->ebp = new_ctx->esp;
-               } else {
-                       int i;
-                       char* sp;
-                       offset = ji->used_regs >> 16;
-                       offset <<= 2;
-                       /* the saved regs are at sp + offset */
-                       /* restore caller saved registers */
-                       sp = (char*)ctx->ebp;
-                       sp += offset;
-                       for (i = 4; i < 16; ++i) {
-                               if (ji->used_regs & (1 << i)) {
-                                       new_ctx->regs [i - 4] = *(gulong*)sp;
-                                       sp += sizeof (gulong);
-                               }
-                       }
-                       /* IP and LR */
-                       new_ctx->esp = *(gulong*)sp;
-                       sp += sizeof (gulong);
-                       new_ctx->eip = *(gulong*)sp;
-                       sp += sizeof (gulong);
-                       new_ctx->ebp = new_ctx->regs [ARMREG_R11 - 4];
-                       /*
-                        * FIXME this doesn't really do what is supposed to. MonoContext::regs map r4-r11, r12(ip), r14(lr)
-                        * This code is storing in MonoContext::fregs [0]. 
-                        */
-                       /* Needed by get_exception_catch_class () */
-                       new_ctx->regs [ARMREG_R11] = new_ctx->ebp;
-               }
+               unwind_info = mono_get_cached_unwind_info (ji->used_regs, &unwind_info_len);
+
+               /* Beautiful numbers */
+               for (i = 4; i < 12; ++i)
+                       regs [i] = new_ctx->regs [i - 4];
+               regs [ARMREG_IP] = new_ctx->regs [8];
+               regs [ARMREG_LR] = new_ctx->regs [9];
+               regs [ARMREG_SP] = new_ctx->esp;
+
+               mono_unwind_frame (unwind_info, unwind_info_len, -4, ji->code_start, 
+                                                  (guint8*)ji->code_start + ji->code_size,
+                                                  ip, regs, MONO_MAX_IREGS, &cfa);
+
+               for (i = 4; i < 12; ++i)
+                       new_ctx->regs [i - 4] = regs [i];
+               new_ctx->regs [8] = regs [ARMREG_IP];
+               new_ctx->regs [9] = regs [ARMREG_LR];
+               new_ctx->eip = regs [ARMREG_LR];
+               new_ctx->esp = (gsize)cfa;
+               new_ctx->ebp = new_ctx->esp;
+
+               /* Needed by get_exception_catch_class () */
+               // FIXME: Is this neded ?
+               new_ctx->regs [ARMREG_R11] = new_ctx->esp;
 
                if (*lmf && (MONO_CONTEXT_GET_BP (ctx) >= (gpointer)(*lmf)->ebp)) {
                        /* remove any unused lmf */
index f4f8818d55dd61e9316a1cf0e442403c8109f3bb..821aa83014037e93fd015153f00166477d981508 100644 (file)
@@ -139,6 +139,7 @@ typedef struct MonoCompileArch {
 #define MONO_ARCH_HAVE_CREATE_TRAMPOLINE_FROM_TOKEN
 #define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE
 #define MONO_ARCH_COMMON_VTABLE_TRAMPOLINE 1
+#define MONO_ARCH_HAVE_XP_UNWIND 1
 
 #define ARM_NUM_REG_ARGS (ARM_LAST_ARG_REG-ARM_FIRST_ARG_REG+1)
 #define ARM_NUM_REG_FPARGS 0