Fix s390x soft debug
authorNeale Ferguson <neale@sinenomine.net>
Wed, 4 Jun 2014 14:47:37 +0000 (10:47 -0400)
committerNeale Ferguson <neale@sinenomine.net>
Wed, 4 Jun 2014 14:48:43 +0000 (10:48 -0400)
mono/mini/mini-s390x.c
mono/mini/support-s390x.h

index 5d88174bac187c506c946cae96bdcc4604cd040d..fbc6278a34239e379a26c97c0751bcfa055b63ed 100644 (file)
@@ -232,7 +232,7 @@ if (ins->inst_target_bb->native_offset) {                                   \
 #define S390_TRACE_STACK_SIZE (5*sizeof(gpointer)+4*sizeof(gdouble))
 
 #define BREAKPOINT_SIZE                sizeof(breakpoint_t)
-#define S390X_NOP_SIZE         sizeof(I_Format)
+#define S390X_NOP_SIZE         sizeof(RR_Format)
 
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 
@@ -409,6 +409,8 @@ static gpointer bp_trigger_page;
 
 breakpoint_t breakpointCode;
 
+static CRITICAL_SECTION mini_arch_mutex;
+
 /*====================== End of Global Variables ===================*/
 
 /*------------------------------------------------------------------*/
@@ -1257,6 +1259,8 @@ mono_arch_init (void)
 {
        guint8 *code;
 
+       InitializeCriticalSection (&mini_arch_mutex);
+
        ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
        bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
        mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
@@ -1282,6 +1286,11 @@ mono_arch_init (void)
 void
 mono_arch_cleanup (void)
 {
+       if (ss_trigger_page)
+               mono_vfree (ss_trigger_page, mono_pagesize ());
+       if (bp_trigger_page)
+               mono_vfree (bp_trigger_page, mono_pagesize ());
+       DeleteCriticalSection (&mini_arch_mutex);
 }
 
 /*========================= End of Function ========================*/
@@ -4076,6 +4085,13 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
                         */
                        for (i = 0; i < (BREAKPOINT_SIZE / S390X_NOP_SIZE); ++i)
                                s390_nop (code);
+
+                       /*
+                        * Add an additional nop so skipping the bp doesn't cause the ip to point
+                        * to another IL offset.
+                        */
+                       s390_nop (code);
+
                        break;
                }
        
@@ -5980,7 +5996,10 @@ gboolean
 mono_arch_is_breakpoint_event (void *info, void *sigctx)
 {
        siginfo_t* sinfo = (siginfo_t*) info;
-       /* Sometimes the address is off by 4 */
+
+       /* 
+        * Sometimes the address is off by 4 
+        */
        if (sinfo->si_addr >= bp_trigger_page && (guint8*)sinfo->si_addr <= (guint8*)bp_trigger_page + 128)
                return TRUE;
        else
@@ -6002,7 +6021,7 @@ mono_arch_is_breakpoint_event (void *info, void *sigctx)
 void
 mono_arch_skip_breakpoint (MonoContext *ctx, MonoJitInfo *ji)
 {
-       MONO_CONTEXT_SET_IP (ctx, (guint8*)MONO_CONTEXT_GET_IP (ctx) + BREAKPOINT_SIZE);
+       MONO_CONTEXT_SET_IP (ctx, ((guint8*)MONO_CONTEXT_GET_IP (ctx) + sizeof(RXY_Format)));
 }
 
 /*========================= End of Function ========================*/
@@ -6053,7 +6072,9 @@ mono_arch_is_single_step_event (void *info, void *sigctx)
 {
        siginfo_t* sinfo = (siginfo_t*) info;
 
-       /* Sometimes the address is off by 4 */
+       /* 
+        * Sometimes the address is off by 4 
+        */
        if (sinfo->si_addr >= ss_trigger_page && (guint8*)sinfo->si_addr <= (guint8*)ss_trigger_page + 128)
                return TRUE;
        else
index 3ae4c48572a4c47c1d001de7d4c09191c1167ac0..62edcc4e7e9279bb91bdb4079c45b25be997a27f 100644 (file)
                s390_##opy (loc, r, ix, br, off);                       \
        } else {                                                        \
                if (ix == 0) {                                          \
-fprintf(stderr,"\nS390_LONG - no index - r: %d br: %d off: %d\n",r,br,off); \
                        S390_SET(loc, s390_r13, off);                   \
                        s390_la (loc, s390_r13, s390_r13, br, 0);       \
                } else {                                                \
-fprintf(stderr,"\nS390_LONG - index - r: %d br: %d ix: %d off: %d\n",r,br,ix,off); \
                        s390_la   (loc, s390_r13, ix, br, 0);           \
                        S390_SET  (loc, s390_r0, off);                  \
                        s390_agr  (loc, s390_r13, s390_r0);             \