[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 16/23] target/ppc: Drop exit checks for singlestep_enabled
From: |
Richard Henderson |
Subject: |
[PATCH v2 16/23] target/ppc: Drop exit checks for singlestep_enabled |
Date: |
Tue, 12 Oct 2021 09:21:52 -0700 |
GDB single-stepping is now handled generically.
Reuse gen_debug_exception to handle architectural debug exceptions.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/ppc/translate.c | 38 ++++++++------------------------------
1 file changed, 8 insertions(+), 30 deletions(-)
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index b985e9e55b..80635b0621 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -42,7 +42,6 @@
#define CPU_SINGLE_STEP 0x1
#define CPU_BRANCH_STEP 0x2
-#define GDBSTUB_SINGLE_STEP 0x4
/* Include definitions for instructions classes and implementations flags */
/* #define PPC_DEBUG_DISAS */
@@ -333,7 +332,7 @@ static uint32_t gen_prep_dbgex(DisasContext *ctx)
static void gen_debug_exception(DisasContext *ctx)
{
- gen_helper_raise_exception(cpu_env, tcg_constant_i32(EXCP_DEBUG));
+ gen_helper_raise_exception(cpu_env, tcg_constant_i32(gen_prep_dbgex(ctx)));
ctx->base.is_jmp = DISAS_NORETURN;
}
@@ -4307,15 +4306,8 @@ static inline bool use_goto_tb(DisasContext *ctx,
target_ulong dest)
static void gen_lookup_and_goto_ptr(DisasContext *ctx)
{
- int sse = ctx->singlestep_enabled;
- if (unlikely(sse)) {
- if (sse & GDBSTUB_SINGLE_STEP) {
- gen_debug_exception(ctx);
- } else if (sse & (CPU_SINGLE_STEP | CPU_BRANCH_STEP)) {
- gen_helper_raise_exception(cpu_env,
tcg_constant_i32(gen_prep_dbgex(ctx)));
- } else {
- tcg_gen_exit_tb(NULL, 0);
- }
+ if (unlikely(ctx->singlestep_enabled)) {
+ gen_debug_exception(ctx);
} else {
tcg_gen_lookup_and_goto_ptr();
}
@@ -8561,17 +8553,11 @@ static void ppc_tr_init_disas_context(DisasContextBase
*dcbase, CPUState *cs)
ctx->singlestep_enabled = 0;
if ((hflags >> HFLAGS_SE) & 1) {
ctx->singlestep_enabled |= CPU_SINGLE_STEP;
+ ctx->base.max_insns = 1;
}
if ((hflags >> HFLAGS_BE) & 1) {
ctx->singlestep_enabled |= CPU_BRANCH_STEP;
}
- if (unlikely(ctx->base.singlestep_enabled)) {
- ctx->singlestep_enabled |= GDBSTUB_SINGLE_STEP;
- }
-
- if (ctx->singlestep_enabled & (CPU_SINGLE_STEP | GDBSTUB_SINGLE_STEP)) {
- ctx->base.max_insns = 1;
- }
}
static void ppc_tr_tb_start(DisasContextBase *db, CPUState *cs)
@@ -8640,7 +8626,6 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
DisasContext *ctx = container_of(dcbase, DisasContext, base);
DisasJumpType is_jmp = ctx->base.is_jmp;
target_ulong nip = ctx->base.pc_next;
- int sse;
if (is_jmp == DISAS_NORETURN) {
/* We have already exited the TB. */
@@ -8648,8 +8633,8 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
}
/* Honor single stepping. */
- sse = ctx->singlestep_enabled & (CPU_SINGLE_STEP | GDBSTUB_SINGLE_STEP);
- if (unlikely(sse)) {
+ if (unlikely(ctx->singlestep_enabled & CPU_SINGLE_STEP)
+ && (nip <= 0x100 || nip > 0xf00)) {
switch (is_jmp) {
case DISAS_TOO_MANY:
case DISAS_EXIT_UPDATE:
@@ -8663,15 +8648,8 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
g_assert_not_reached();
}
- if (sse & GDBSTUB_SINGLE_STEP) {
- gen_debug_exception(ctx);
- return;
- }
- /* else CPU_SINGLE_STEP... */
- if (nip <= 0x100 || nip > 0xf00) {
- gen_helper_raise_exception(cpu_env,
tcg_constant_i32(gen_prep_dbgex(ctx)));
- return;
- }
+ gen_debug_exception(ctx);
+ return;
}
switch (is_jmp) {
--
2.25.1
- Re: [PATCH v2 13/23] target/mips: Fix single stepping, (continued)
- [PATCH v2 15/23] target/openrisc: Drop checks for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 10/23] target/m68k: Drop checks for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 12/23] target/microblaze: Drop checks for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 14/23] target/mips: Drop exit checks for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 17/23] target/riscv: Remove dead code after exception, Richard Henderson, 2021/10/12
- [PATCH v2 18/23] target/riscv: Remove exit_tb and lookup_and_goto_ptr, Richard Henderson, 2021/10/12
- [PATCH v2 16/23] target/ppc: Drop exit checks for singlestep_enabled,
Richard Henderson <=
- [PATCH v2 21/23] target/sh4: Drop check for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 22/23] target/tricore: Drop check for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 19/23] target/rx: Drop checks for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 20/23] target/s390x: Drop check for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 23/23] target/xtensa: Drop check for singlestep_enabled, Richard Henderson, 2021/10/12
- [PATCH v2 08/23] target/i386: Check CF_NO_GOTO_TB for dc->jmp_opt, Richard Henderson, 2021/10/12