target-arm: Fix arm_debug_excp_handler() for singlestep enabled
PATCH 1/1 target-arm: Fix arm_debug_excp_handler() for singlestep enabled
CPU singlestep is done by generating a debug internal exception. Do not raise a real CPU exception in case of singlestepping.
--- target-arm/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/op_helper.c +1 -1
@@ -909,7 +909,7 @@ void arm_debug_excp_handler(CPUState *cs)uint64_t pc =is_a64 (env) ? env->pc : env->regs[15 ];bool same_el = (arm_debug_target_el (env) ==arm_current_el (env)); -if (cpu_breakpoint_test (cs, pc,BP_GDB )) { +if (cs->singlestep_enabled ||cpu_breakpoint_test (cs, pc,BP_GDB )) {return ; }
Signature · 1 line
1.9.1
Quoted 13 lines · Sergey Fedorov
CPU singlestep is done by generating a debug internal exception. Do not raise a real CPU exception in case of singlestepping.
Signed-off-by Sergey Fedorov <[email protected]>--- target-arm/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/op_helper.c +0
-0
target-arm/op_helper.c void arm_debug_excp_handler(CPUState *cs) · line 914
Quoted 7 lines
target-arm/op_helper.c +1
-1@@ -909,7 +909,7 @@ void arm_debug_excp_handler(CPUState *cs)uint64_t pc =is_a64 (env) ? env->pc : env->regs[15 ];bool same_el = (arm_debug_target_el (env) ==arm_current_el (env)); -if (cpu_breakpoint_test (cs, pc,BP_GDB )) { +if (cs->singlestep_enabled ||cpu_breakpoint_test (cs, pc,BP_GDB )) {return ; }
So I think this will mean that if we're gdbstub-single-stepping then an architectural breakpoint on the insn we're stepping won't fire.
Does using a test
if (!cpu_breakpoint_test(cs, pc, BP_CPU)) {
return;
}fix the singlestep bug too? If so I think it would probably be preferable.
thanks
-- PMM
Quoted 24 lines · Peter Maydell
Quoted 13 lines · Sergey Fedorov
CPU singlestep is done by generating a debug internal exception. Do not raise a real CPU exception in case of singlestepping.
Signed-off-by Sergey Fedorov <[email protected]>--- target-arm/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/op_helper.c +0
-0target-arm/op_helper.c void arm_debug_excp_handler(CPUState *cs) · line 914
Quoted 7 lines
target-arm/op_helper.c +1
-1@@ -909,7 +909,7 @@ void arm_debug_excp_handler(CPUState *cs)uint64_t pc =is_a64 (env) ? env->pc : env->regs[15 ];bool same_el = (arm_debug_target_el (env) ==arm_current_el (env)); -if (cpu_breakpoint_test (cs, pc,BP_GDB )) { +if (cs->singlestep_enabled ||cpu_breakpoint_test (cs, pc,BP_GDB )) {return ; }So I think this will mean that if we're gdbstub-single-stepping then an architectural breakpoint on the insn we're stepping won't fire.
Quoted 8 lines
Does using a test
if (!cpu_breakpoint_test(cs, pc, BP_CPU)) { return; }fix the singlestep bug too? If so I think it would probably be preferable.
Actually, it is supposed that gdbstub breakpoints should be handled before CPU breakpoints. So I think we should rather do this way:
if (cpu_breakpoint_test(cs, pc, BP_GDB) || !cpu_breakpoint_test(cs, pc, BP_CPU)) {
return;
}Thanks,
Sergey
Quoted 34 lines · Sergey Fedorov
Quoted 24 lines · Peter Maydell
Quoted 13 lines · Sergey Fedorov
CPU singlestep is done by generating a debug internal exception. Do not raise a real CPU exception in case of singlestepping.
Signed-off-by Sergey Fedorov <[email protected]>--- target-arm/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/op_helper.c +0
-0target-arm/op_helper.c void arm_debug_excp_handler(CPUState *cs) · line 914
Quoted 7 lines
target-arm/op_helper.c +1
-1@@ -909,7 +909,7 @@ void arm_debug_excp_handler(CPUState *cs)uint64_t pc =is_a64 (env) ? env->pc : env->regs[15 ];bool same_el = (arm_debug_target_el (env) ==arm_current_el (env)); -if (cpu_breakpoint_test (cs, pc,BP_GDB )) { +if (cs->singlestep_enabled ||cpu_breakpoint_test (cs, pc,BP_GDB )) {return ; }So I think this will mean that if we're gdbstub-single-stepping then an architectural breakpoint on the insn we're stepping won't fire.
Quoted 8 lines
Does using a test
if (!cpu_breakpoint_test(cs, pc, BP_CPU)) { return; }fix the singlestep bug too? If so I think it would probably be preferable.
Quoted 6 lines
Actually, it is supposed that gdbstub breakpoints should be handled before CPU breakpoints. So I think we should rather do this way:
if (cpu_breakpoint_test(cs, pc, BP_GDB) || !cpu_breakpoint_test(cs, pc, BP_CPU)) { return; }
Yes, that sounds like the right logic. I think a comment will be helpful to explain what's going on for future readers :-)
thanks
-- PMM