diff mbox series

[v2,3/5] target/sh4: Do not singlestep after exceptions

Message ID 20170907185057.23421-4-richard.henderson@linaro.org
State New
Headers show
Series target/sh4 updates | expand

Commit Message

Richard Henderson Sept. 7, 2017, 6:50 p.m. UTC
From: Richard Henderson <rth@twiddle.net>


If we've already raised an exception (and set NORETURN),
do not emit unreachable code to raise a debug exception.
Note that gen_goto_tb takes single-stepping into account.

Signed-off-by: Richard Henderson <rth@twiddle.net>

---
 target/sh4/translate.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

-- 
2.13.5
diff mbox series

Patch

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 6e03370871..5cda27cc0a 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -281,6 +281,7 @@  static void gen_jump(DisasContext * ctx)
         } else {
             tcg_gen_lookup_and_goto_ptr(cpu_pc);
         }
+        ctx->bstate = DISAS_NORETURN;
     } else {
 	gen_goto_tb(ctx, 0, ctx->delayed_pc);
     }
@@ -2349,24 +2350,23 @@  void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb)
         ctx.envflags &= ~GUSA_MASK;
     }
 
-    if (cs->singlestep_enabled) {
+    switch (ctx.bstate) {
+    case DISAS_STOP:
         gen_save_cpu_state(&ctx, true);
-        gen_helper_debug(cpu_env);
-    } else {
-	switch (ctx.bstate) {
-        case DISAS_STOP:
-            gen_save_cpu_state(&ctx, true);
+        if (cs->singlestep_enabled) {
+            gen_helper_debug(cpu_env);
+        } else {
             tcg_gen_exit_tb(0);
-            break;
-        case DISAS_NEXT:
-            gen_save_cpu_state(&ctx, false);
-            gen_goto_tb(&ctx, 0, ctx.pc);
-            break;
-        case DISAS_NORETURN:
-            break;
-        default:
-            g_assert_not_reached();
-	}
+        }
+        break;
+    case DISAS_NEXT:
+        gen_save_cpu_state(&ctx, false);
+        gen_goto_tb(&ctx, 0, ctx.pc);
+        break;
+    case DISAS_NORETURN:
+        break;
+    default:
+        g_assert_not_reached();
     }
 
     gen_tb_end(tb, num_insns);