Report SIGBUS and halt simulation when ld/st detect a misaligned address.
[deliverable/binutils-gdb.git] / sim / d10v / interp.c
index 33b5dca30a5cc7c8a0102c5b5161d8bf23618206..80898ab44efd3cabc06fa951d5ecb6b3b4f03f68 100644 (file)
@@ -965,6 +965,25 @@ sim_resume (sd, step, siggnal)
   if (step)
     sim_stop (sd);
 
+  switch (siggnal)
+    {
+    case 0:
+      break;
+#ifdef SIGBUS
+    case SIGBUS:
+#endif
+    case SIGSEGV:
+      SET_BPC (PC);
+      SET_BPSW (PSW);
+      SET_HW_PSW ((PSW & (PSW_F0_BIT | PSW_F1_BIT | PSW_C_BIT)));
+      JMP (AE_VECTOR_START);
+      SLOT_FLUSH ();
+      break;
+    default:
+      /* just ignore it */
+      break;
+    }
+
   do
     {
       iaddr = imem_addr ((uint32)PC << 2);
@@ -1057,11 +1076,16 @@ int
 sim_trace (sd)
      SIM_DESC sd;
 {
+  enum sim_stop reason;
+  static int sigrc = 0;
 #ifdef DEBUG
   d10v_debug = DEBUG;
 #endif
-  sim_resume (sd, 0, 0);
-  return 1;
+  /* NOTE: SIGRC starts with zero and is then, always the value
+     returned by the last sim_stop_reason() call. */
+  sim_resume (sd, 0, sigrc);
+  sim_stop_reason (sd, &reason, &sigrc);
+  return (reason != sim_stopped || sigrc != SIGINT);
 }
 
 void
@@ -1267,6 +1291,15 @@ sim_stop_reason (sd, reason, sigrc)
       *sigrc = GPR (0);
       break;
 
+    case SIG_D10V_BUS:
+      *reason = sim_stopped;
+#ifdef SIGBUS
+      *sigrc = SIGBUS;
+#else
+      *sigrc = SIGSEGV;
+#endif
+      break;
+
     default:                           /* some signal */
       *reason = sim_stopped;
       if (stop_simulator && !State.exception)
This page took 0.0241 seconds and 4 git commands to generate.