[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 18/30] target/ppc: Move single-step check to ppc_tr_tb_stop
From: |
Richard Henderson |
Subject: |
[PATCH v3 18/30] target/ppc: Move single-step check to ppc_tr_tb_stop |
Date: |
Thu, 29 Apr 2021 18:15:31 -0700 |
When single-stepping, force max_insns to 1 in init_disas
so that we exit the translation loop immediately.
Combine the single-step checks in tb_stop, and give the
gdb exception priority over the cpu exception, just as
we already do in gen_lookup_and_goto_ptr.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/ppc/translate.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index d78071a4a4..c018960ce9 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -7910,7 +7910,6 @@ static void ppc_tr_init_disas_context(DisasContextBase
*dcbase, CPUState *cs)
{
DisasContext *ctx = container_of(dcbase, DisasContext, base);
CPUPPCState *env = cs->env_ptr;
- int bound;
ctx->spr_cb = env->spr_cb;
ctx->pr = msr_pr;
@@ -7986,13 +7985,13 @@ static void ppc_tr_init_disas_context(DisasContextBase
*dcbase, CPUState *cs)
if (unlikely(ctx->base.singlestep_enabled)) {
ctx->singlestep_enabled |= GDBSTUB_SINGLE_STEP;
}
-#if defined(DO_SINGLE_STEP) && 0
- /* Single step trace mode */
- msr_se = 1;
-#endif
- bound = -(ctx->base.pc_first | TARGET_PAGE_MASK) / 4;
- ctx->base.max_insns = MIN(ctx->base.max_insns, bound);
+ if (ctx->singlestep_enabled & (CPU_SINGLE_STEP | GDBSTUB_SINGLE_STEP)) {
+ ctx->base.max_insns = 1;
+ } else {
+ int bound = -(ctx->base.pc_first | TARGET_PAGE_MASK) / 4;
+ ctx->base.max_insns = MIN(ctx->base.max_insns, bound);
+ }
}
static void ppc_tr_tb_start(DisasContextBase *db, CPUState *cs)
@@ -8046,14 +8045,6 @@ static void ppc_tr_translate_insn(DisasContextBase
*dcbase, CPUState *cs)
handler->count++;
#endif
- /* Check trace mode exceptions */
- if (unlikely(ctx->singlestep_enabled & CPU_SINGLE_STEP &&
- (ctx->base.pc_next <= 0x100 || ctx->base.pc_next > 0xF00) &&
- ctx->base.is_jmp != DISAS_NORETURN)) {
- uint32_t excp = gen_prep_dbgex(ctx);
- gen_exception_nip(ctx, excp, ctx->base.pc_next);
- }
-
if (tcg_check_temp_count()) {
qemu_log("Opcode %02x %02x %02x %02x (%08x) leaked "
"temporaries\n", opc1(ctx->opcode), opc2(ctx->opcode),
@@ -8066,6 +8057,7 @@ 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. */
@@ -8073,7 +8065,8 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
}
/* Honor single stepping. */
- if (unlikely(ctx->base.singlestep_enabled)) {
+ sse = ctx->singlestep_enabled & (CPU_SINGLE_STEP | GDBSTUB_SINGLE_STEP);
+ if (unlikely(sse)) {
switch (is_jmp) {
case DISAS_TOO_MANY:
case DISAS_EXIT_UPDATE:
@@ -8086,8 +8079,16 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
default:
g_assert_not_reached();
}
- gen_debug_exception(ctx);
- return;
+
+ if (sse & GDBSTUB_SINGLE_STEP) {
+ gen_debug_exception(ctx);
+ return;
+ }
+ /* else CPU_SINGLE_STEP... */
+ if (nip <= 0x100 || nip > 0xf00) {
+ gen_exception(ctx, gen_prep_dbgex(ctx));
+ return;
+ }
}
switch (is_jmp) {
--
2.25.1
- [PATCH v3 12/30] target/ppc: Replace POWERPC_EXCP_SYNC with DISAS_EXIT, (continued)
- [PATCH v3 12/30] target/ppc: Replace POWERPC_EXCP_SYNC with DISAS_EXIT, Richard Henderson, 2021/04/29
- [PATCH v3 13/30] target/ppc: Remove unnecessary gen_io_end calls, Richard Henderson, 2021/04/29
- [PATCH v3 14/30] target/ppc: Introduce gen_icount_io_start, Richard Henderson, 2021/04/29
- [PATCH v3 15/30] target/ppc: Replace POWERPC_EXCP_STOP with DISAS_EXIT_UPDATE, Richard Henderson, 2021/04/29
- [PATCH v3 16/30] target/ppc: Replace POWERPC_EXCP_BRANCH with DISAS_NORETURN, Richard Henderson, 2021/04/29
- [PATCH v3 08/30] target/ppc: Remove special case for POWERPC_SYSCALL, Richard Henderson, 2021/04/29
- [PATCH v3 11/30] target/ppc: Introduce DISAS_{EXIT,CHAIN}{,_UPDATE}, Richard Henderson, 2021/04/29
- [PATCH v3 17/30] target/ppc: Remove DisasContext.exception, Richard Henderson, 2021/04/29
- [PATCH v3 22/30] target/ppc: Introduce macros to check isa extensions, Richard Henderson, 2021/04/29
- [PATCH v3 18/30] target/ppc: Move single-step check to ppc_tr_tb_stop,
Richard Henderson <=
- [PATCH v3 20/30] target/ppc: Mark helper_raise_exception* as noreturn, Richard Henderson, 2021/04/29
- [PATCH v3 07/30] target/ppc: Move DISAS_NORETURN setting into gen_exception*, Richard Henderson, 2021/04/29
- [PATCH v3 23/30] target/ppc: Add infrastructure for prefixed insns, Richard Henderson, 2021/04/29
- [PATCH v3 21/30] target/ppc: Use translator_loop_temp_check, Richard Henderson, 2021/04/29
- [PATCH v3 19/30] target/ppc: Tidy exception vs exit_tb, Richard Henderson, 2021/04/29
- [PATCH v3 24/30] target/ppc: Move page crossing check to ppc_tr_translate_insn, Richard Henderson, 2021/04/29
- [PATCH v3 28/30] target/ppc: Implement prefixed integer load instructions, Richard Henderson, 2021/04/29
- [PATCH v3 29/30] target/ppc: Move D/DS/X-form integer stores to decodetree, Richard Henderson, 2021/04/29
- [PATCH v3 27/30] target/ppc: Move D/DS/X-form integer loads to decodetree, Richard Henderson, 2021/04/29