Author: zoltan
Date: 2007-09-07 11:56:20 -0400 (Fri, 07 Sep 2007)
New Revision: 85483

Modified:
   trunk/mono/mono/mini/ChangeLog
   trunk/mono/mono/mini/driver.c
   trunk/mono/mono/mini/mini-amd64.c
   trunk/mono/mono/mini/mini-amd64.h
   trunk/mono/mono/mini/mini.c
   trunk/mono/mono/mini/mini.h
Log:
2007-09-07  Zoltan Varga  <[EMAIL PROTECTED]>

        * driver.c mini.h mini.c: Add a new devel command line option for 
injecting
        async exceptions into a method.

        * mini-amd64.h mini-amd64.c: Implement injecting of async exceptions 
for the
        purpose of testing whenever the unwinder works at every instruction.


Modified: trunk/mono/mono/mini/ChangeLog
===================================================================
--- trunk/mono/mono/mini/ChangeLog      2007-09-07 15:04:05 UTC (rev 85482)
+++ trunk/mono/mono/mini/ChangeLog      2007-09-07 15:56:20 UTC (rev 85483)
@@ -1,4 +1,11 @@
+2007-09-07  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * driver.c mini.h mini.c: Add a new devel command line option for 
injecting
+       async exceptions into a method.
+
+       * mini-amd64.h mini-amd64.c: Implement injecting of async exceptions 
for the
+       purpose of testing whenever the unwinder works at every instruction.
+
 Thu Sep 6 12:42:14 CEST 2007 Paolo Molaro <[EMAIL PROTECTED]>
 
        * mini.c: check accessibility of method used in ldftn (fixes

Modified: trunk/mono/mono/mini/driver.c
===================================================================
--- trunk/mono/mono/mini/driver.c       2007-09-07 15:04:05 UTC (rev 85482)
+++ trunk/mono/mono/mini/driver.c       2007-09-07 15:56:20 UTC (rev 85483)
@@ -906,6 +906,7 @@
                 "    --statfile FILE        Sets the stat file to FILE\n"
                 "    --stats                Print statistics about the JIT 
operations\n"
                 "    --wapi=hps|semdel      IO-layer maintenance\n"
+                "    --inject-async-exc METHOD OFFSET Inject an asynchronous 
exception at METHOD\n"
                 "\n"
                 "Other options:\n" 
                 "    --graph[=TYPE] METHOD  Draws a graph of the specified 
method:\n");
@@ -1126,6 +1127,17 @@
                        
                        if (!mono_debugger_insert_breakpoint (argv [++i], 
FALSE))
                                fprintf (stderr, "Error: invalid method name 
'%s'\n", argv [i]);
+               } else if (strcmp (argv [i], "--inject-async-exc") == 0) {
+                       if (i + 2 >= argc) {
+                               fprintf (stderr, "Missing method name or 
position in --inject-async-exc command line option\n");
+                               return 1;
+                       }
+                       mono_inject_async_exc_method = mono_method_desc_new 
(argv [++i], TRUE);
+                       if (mono_inject_async_exc_method == NULL) {
+                               fprintf (stderr, "Method name is in a bad 
format in --inject-async-exc command line option\n");
+                               return 1;
+                       }
+                       mono_inject_async_exc_pos = atoi (argv [++i]);
                } else if (strcmp (argv [i], "--print-vtable") == 0) {
                        mono_print_vtable = TRUE;
                } else if (strcmp (argv [i], "--stats") == 0) {

Modified: trunk/mono/mono/mini/mini-amd64.c
===================================================================
--- trunk/mono/mono/mini/mini-amd64.c   2007-09-07 15:04:05 UTC (rev 85482)
+++ trunk/mono/mono/mini/mini-amd64.c   2007-09-07 15:56:20 UTC (rev 85483)
@@ -4277,6 +4277,19 @@
        }
 }
 
+/*
+ * This macro is used for testing whenever the unwinder works correctly at 
every point
+ * where an async exception can happen.
+ */
+/* This will generate a SIGSEGV at the given point in the code */
+#define async_exc_point(code) do { \
+    if (mono_inject_async_exc_method && mono_method_desc_full_match 
(mono_inject_async_exc_method, cfg->method)) { \
+         if (cfg->arch.async_point_count == mono_inject_async_exc_pos) \
+             amd64_mov_reg_mem (code, AMD64_RAX, 0, 4); \
+         cfg->arch.async_point_count ++; \
+    } \
+} while (0)
+
 guint8 *
 mono_arch_emit_prolog (MonoCompile *cfg)
 {
@@ -4312,9 +4325,13 @@
         * - save callee saved regs using moves
         */
 
+       async_exc_point (code);
+
        if (!cfg->arch.omit_fp) {
                amd64_push_reg (code, AMD64_RBP);
+               async_exc_point (code);
                amd64_mov_reg_reg (code, AMD64_RBP, AMD64_RSP, sizeof 
(gpointer));
+               async_exc_point (code);
        }
 
        /* Save callee saved registers */
@@ -4323,6 +4340,7 @@
                        if (AMD64_IS_CALLEE_SAVED_REG (i) && 
(cfg->used_int_regs & (1 << i))) {
                                amd64_push_reg (code, i);
                                pos += sizeof (gpointer);
+                               async_exc_point (code);
                        }
        }
 
@@ -4347,13 +4365,17 @@
                guint32 remaining_size = alloc_size;
                while (remaining_size >= 0x1000) {
                        amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 0x1000);
+                       async_exc_point (code);
                        amd64_test_membase_reg (code, AMD64_RSP, 0, AMD64_RSP);
                        remaining_size -= 0x1000;
                }
-               if (remaining_size)
+               if (remaining_size) {
                        amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, 
remaining_size);
+                       async_exc_point (code);
+               }
 #else
                amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, alloc_size);
+               async_exc_point (code);
 #endif
        }
 
@@ -4397,6 +4419,7 @@
                        if (AMD64_IS_CALLEE_SAVED_REG (i) && 
(cfg->used_int_regs & (1 << i))) {
                                amd64_mov_membase_reg (code, AMD64_RSP, 
save_area_offset, i, 8);
                                save_area_offset += 8;
+                               async_exc_point (code);
                        }
        }
 
@@ -4735,6 +4758,7 @@
        } else {
                amd64_leave (code);
        }
+       async_exc_point (code);
        amd64_ret (code);
 
        cfg->code_len = code - cfg->native_code;

Modified: trunk/mono/mono/mini/mini-amd64.h
===================================================================
--- trunk/mono/mono/mini/mini-amd64.h   2007-09-07 15:04:05 UTC (rev 85482)
+++ trunk/mono/mono/mini/mini-amd64.h   2007-09-07 15:56:20 UTC (rev 85483)
@@ -143,6 +143,7 @@
        gint32 stack_alloc_size;
        gboolean omit_fp, omit_fp_computed;
        gpointer cinfo;
+       gint32 async_point_count;
 } MonoCompileArch;
 
 typedef struct {

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2007-09-07 15:04:05 UTC (rev 85482)
+++ trunk/mono/mono/mini/mini.c 2007-09-07 15:56:20 UTC (rev 85483)
@@ -149,6 +149,8 @@
 #ifndef DISABLE_AOT
 gboolean mono_compile_aot = FALSE;
 #endif
+MonoMethodDesc *mono_inject_async_exc_method = NULL;
+int mono_inject_async_exc_pos;
 
 static int mini_verbose = 0;
 
@@ -12230,6 +12232,9 @@
 
        mono_counters_dump (-1, stdout);
 
+       if (mono_inject_async_exc_method)
+               mono_method_desc_free (mono_inject_async_exc_method);
+
        TlsFree(mono_jit_tls_id);
 
        DeleteCriticalSection (&jit_mutex);

Modified: trunk/mono/mono/mini/mini.h
===================================================================
--- trunk/mono/mono/mini/mini.h 2007-09-07 15:04:05 UTC (rev 85482)
+++ trunk/mono/mono/mini/mini.h 2007-09-07 15:56:20 UTC (rev 85483)
@@ -15,6 +15,7 @@
 #include "mono/metadata/class-internals.h"
 #include "mono/metadata/object-internals.h"
 #include <mono/metadata/profiler-private.h>
+#include <mono/metadata/debug-helpers.h>
 #include <mono/utils/mono-compiler.h>
 
 #include "mini-arch.h"
@@ -130,6 +131,8 @@
 #else
 extern gboolean mono_compile_aot;
 #endif
+extern MonoMethodDesc *mono_inject_async_exc_method;
+extern int mono_inject_async_exc_pos;
 
 struct MonoEdge {
        MonoEdge *next;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to