Commit 33e7c328e0 for qemu.org
commit 33e7c328e0ed776703fd4dc0ff222194e70f601d
Author: Aleksandr Sergeev <sergeev0xef@gmail.com>
Date: Wed Oct 28 10:23:08 2026 +0300
accel/tcg: Fix false awakening of gdb
In qemu there is a mechanism to cancel execution of tb.
If `cpu->neg.icount_decr` is <0, translation block
will exit in prolog.
E.g. such may happen when RCU thread kicks out vCPU.
If tb is not executed, we shall not raise EXCP_DEBUG,
because no step actually happened.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4766
Signed-off-by: Aleksandr Sergeev <sergeev0xef@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20261028072308.839836-1-al.sergeev@syntacore.com>
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 9ead35418d..4497701486 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -478,16 +478,16 @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit)
last_tb->tc.ptr, pc, lookup_symbol(pc));
}
}
- }
-
- /*
- * If gdb single-step, and we haven't raised another exception,
- * raise a debug exception. Single-step with another exception
- * is handled in cpu_handle_exception.
- */
- if (unlikely(cpu_single_stepping(cpu)) && cpu->exception_index == -1) {
- cpu->exception_index = EXCP_DEBUG;
- cpu_loop_exit(cpu);
+ } else {
+ /*
+ * If gdb single-step, and we haven't raised another exception,
+ * raise a debug exception. Single-step with another exception
+ * is handled in cpu_handle_exception.
+ */
+ if (unlikely(cpu_single_stepping(cpu)) && cpu->exception_index == -1) {
+ cpu->exception_index = EXCP_DEBUG;
+ cpu_loop_exit(cpu);
+ }
}
return last_tb;