@samitouri / QOSamiQemu / commits / 7e28b7c897

cpu: Rename CPUState @singlestep_enabled -> @singlestep_flags

CPUState::singlestep_enabled contains multiple flags since commit 60897d369f1 ("Debugger single step without interrupts"). Use an unsigned type and rename the field to avoid mistakes. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260705215729.62196-32-philmd@oss.qualcomm.com>

Philippe Mathieu-Daudé committed Jun 26, 2026 at 14:25 UTC 7e28b7c8970ce2740a665156927f3c3cda82fc2e
7 files changed +21 -21
accel/kvm/kvm-all.c
+1 -1
@@ -3815,7 +3815,7 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
3815 if (cpu_single_stepping(cpu)) {
3816 data.dbg.control |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP;
3817
3818 - if (cpu->singlestep_enabled & SSTEP_NOIRQ) {
3818 + if (cpu->singlestep_flags & SSTEP_NOIRQ) {
3819 data.dbg.control |= KVM_GUESTDBG_BLOCKIRQ;
3820 }
3821 }
accel/tcg/cpu-exec.c
+1 -1
@@ -828,7 +828,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
828 return true;
829 }
830
831 - if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
831 + if (unlikely(cpu->singlestep_flags & SSTEP_NOIRQ)) {
832 /* Mask out external interrupts for this step. */
833 interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK;
834 }
accel/tcg/tcg-accel-ops-rr.c
+1 -1
@@ -274,7 +274,7 @@ static void *rr_cpu_thread_fn(void *arg)
274 current_cpu = cpu;
275
276 qemu_clock_enable(QEMU_CLOCK_VIRTUAL,
277 - (cpu->singlestep_enabled & SSTEP_NOTIMER) == 0);
277 + (cpu->singlestep_flags & SSTEP_NOTIMER) == 0);
278
279 if (cpu_can_run(cpu)) {
280 int r;
cpu-target.c
+4 -4
@@ -28,12 +28,12 @@
28
29 /* enable or disable single step mode. EXCP_DEBUG is returned by the
30 CPU loop after each instruction */
31 -void cpu_single_step(CPUState *cpu, int enabled)
31 +void cpu_single_step(CPUState *cpu, unsigned flags)
32 {
33 - if (cpu->singlestep_enabled != enabled) {
33 + if (cpu->singlestep_flags != flags) {
34 trace_cpu_change_singlestep_flags(cpu->cpu_index,
35 - cpu->singlestep_enabled, enabled);
36 - cpu->singlestep_enabled = enabled;
35 + cpu->singlestep_flags, flags);
36 + cpu->singlestep_flags = flags;
37
38 #if !defined(CONFIG_USER_ONLY)
39 const AccelOpsClass *ops = cpus_get_accel();
include/hw/core/cpu.h
+5 -5
@@ -440,7 +440,7 @@ struct qemu_work_item;
440 * @stopped: Indicates the CPU has been artificially stopped.
441 * @unplug: Indicates a pending CPU unplug request.
442 * @crash_occurred: Indicates the OS reported a crash (panic) for this CPU
443 - * @singlestep_enabled: Flags for single-stepping.
443 + * @singlestep_flags: Flags for single-stepping.
444 * @icount_extra: Instructions until next timer event.
445 * @cpu_ases: Pointer to array of CPUAddressSpaces (which define the
446 * AddressSpaces this CPU has)
@@ -505,7 +505,7 @@ struct CPUState {
505 int exclusive_context_count;
506 uint32_t cflags_next_tb;
507 uint32_t interrupt_request;
508 - int singlestep_enabled;
508 + unsigned singlestep_flags;
509 int64_t icount_budget;
510 int64_t icount_extra;
511 uint64_t random_seed;
@@ -1132,11 +1132,11 @@ void qemu_init_vcpu(CPUState *cpu);
1132 /**
1133 * cpu_single_step:
1134 * @cpu: CPU to the flags for.
1135 - * @enabled: Flags to enable.
1135 + * @flags: Flags to enable.
1136 *
1137 * Enables or disables single-stepping for @cpu.
1138 */
1139 -void cpu_single_step(CPUState *cpu, int enabled);
1139 +void cpu_single_step(CPUState *cpu, unsigned flags);
1140
1141 /**
1142 * cpu_single_stepping:
@@ -1146,7 +1146,7 @@ void cpu_single_step(CPUState *cpu, int enabled);
1146 */
1147 static inline bool cpu_single_stepping(const CPUState *cpu)
1148 {
1149 - return cpu->singlestep_enabled;
1149 + return cpu->singlestep_flags;
1150 }
1151
1152 int cpu_breakpoint_insert(CPUState *cpu, vaddr pc, int flags,
target/arm/hvf/hvf.c
+1 -1
@@ -2603,7 +2603,7 @@ int hvf_arch_vcpu_exec(CPUState *cpu)
2603 flush_cpu_state(cpu);
2604
2605 do {
2606 - if (!(cpu->singlestep_enabled & SSTEP_NOIRQ) &&
2606 + if (!(cpu->singlestep_flags & SSTEP_NOIRQ) &&
2607 hvf_inject_interrupts(cpu)) {
2608 return EXCP_INTERRUPT;
2609 }
target/ppc/translate.c
+8 -8
@@ -198,7 +198,7 @@ struct DisasContext {
198 bool pmu_insn_cnt;
199 bool bhrb_enable;
200 ppc_spr_t *spr_cb; /* Needed to check rights for mfspr/mtspr */
201 - int singlestep_enabled;
201 + int singlestep_flags;
202 uint32_t flags;
203 uint64_t insns_flags;
204 uint64_t insns_flags2;
@@ -367,7 +367,7 @@ static void gen_debug_exception(DisasContext *ctx, bool rfi_type)
367 #if !defined(CONFIG_USER_ONLY)
368 if (ctx->flags & POWERPC_FLAG_DE) {
369 target_ulong dbsr = 0;
370 - if (ctx->singlestep_enabled & CPU_SINGLE_STEP) {
370 + if (ctx->singlestep_flags & CPU_SINGLE_STEP) {
371 dbsr = DBCR0_ICMP;
372 } else {
373 /* Must have been branch */
@@ -3645,7 +3645,7 @@ static void pmu_count_insns(DisasContext *ctx)
3645
3646 static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest)
3647 {
3648 - if (unlikely(ctx->singlestep_enabled)) {
3648 + if (unlikely(ctx->singlestep_flags)) {
3649 return false;
3650 }
3651 return translator_use_goto_tb(&ctx->base, dest);
@@ -3653,7 +3653,7 @@ static inline bool use_goto_tb(DisasContext *ctx, target_ulong dest)
3653
3654 static void gen_lookup_and_goto_ptr(DisasContext *ctx)
3655 {
3656 - if (unlikely(ctx->singlestep_enabled)) {
3656 + if (unlikely(ctx->singlestep_flags)) {
3657 gen_debug_exception(ctx, false);
3658 } else {
3659 /*
@@ -6559,13 +6559,13 @@ static void ppc_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
6559 ctx->pmu_insn_cnt = (hflags >> HFLAGS_INSN_CNT) & 1;
6560 ctx->bhrb_enable = (hflags >> HFLAGS_BHRB_ENABLE) & 1;
6561
6562 - ctx->singlestep_enabled = 0;
6562 + ctx->singlestep_flags = 0;
6563 if ((hflags >> HFLAGS_SE) & 1) {
6564 - ctx->singlestep_enabled |= CPU_SINGLE_STEP;
6564 + ctx->singlestep_flags |= CPU_SINGLE_STEP;
6565 ctx->base.max_insns = 1;
6566 }
6567 if ((hflags >> HFLAGS_BE) & 1) {
6568 - ctx->singlestep_enabled |= CPU_BRANCH_STEP;
6568 + ctx->singlestep_flags |= CPU_BRANCH_STEP;
6569 }
6570 }
6571
@@ -6641,7 +6641,7 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
6641 }
6642
6643 /* Honor single stepping. */
6644 - if (unlikely(ctx->singlestep_enabled & CPU_SINGLE_STEP)) {
6644 + if (unlikely(ctx->singlestep_flags & CPU_SINGLE_STEP)) {
6645 bool rfi_type = false;
6646
6647 switch (is_jmp) {