aboutsummaryrefslogtreecommitdiff
path: root/gdbstub
diff options
context:
space:
mode:
authorAlex Bennée <alex.bennee@linaro.org>2023-03-02 18:57:52 -0800
committerAlex Bennée <alex.bennee@linaro.org>2023-03-07 20:44:08 +0000
commit7ea0c33deffbbfc6b378f51503139aaa036322d6 (patch)
tree26a9d3f54ddc31d706147b59932459b4aed8f60a /gdbstub
parent589a58672e044c0415e70f018393c8406cdd5c49 (diff)
downloadqemu-7ea0c33deffbbfc6b378f51503139aaa036322d6.zip
qemu-7ea0c33deffbbfc6b378f51503139aaa036322d6.tar.gz
qemu-7ea0c33deffbbfc6b378f51503139aaa036322d6.tar.bz2
gdbstub: introduce gdb_get_max_cpus
This is needed for handling vcont packets as the way of calculating max cpus vhanges between user and softmmu mode. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20230302190846.2593720-17-alex.bennee@linaro.org> Message-Id: <20230303025805.625589-17-richard.henderson@linaro.org>
Diffstat (limited to 'gdbstub')
-rw-r--r--gdbstub/gdbstub.c11
-rw-r--r--gdbstub/internals.h1
-rw-r--r--gdbstub/softmmu.c9
-rw-r--r--gdbstub/user.c17
4 files changed, 28 insertions, 10 deletions
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index ed38ab0..1b78310 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -624,16 +624,7 @@ static int gdb_handle_vcont(const char *p)
GDBProcess *process;
CPUState *cpu;
GDBThreadIdKind kind;
-#ifdef CONFIG_USER_ONLY
- int max_cpus = 1; /* global variable max_cpus exists only in system mode */
-
- CPU_FOREACH(cpu) {
- max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus;
- }
-#else
- MachineState *ms = MACHINE(qdev_get_machine());
- unsigned int max_cpus = ms->smp.max_cpus;
-#endif
+ unsigned int max_cpus = gdb_get_max_cpus();
/* uninitialised CPUs stay 0 */
newstates = g_new0(char, max_cpus);
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index d8c0292..26a6468 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -129,6 +129,7 @@ bool gdb_got_immediate_ack(void);
CPUState *gdb_first_attached_cpu(void);
void gdb_append_thread_id(CPUState *cpu, GString *buf);
int gdb_get_cpu_index(CPUState *cpu);
+unsigned int gdb_get_max_cpus(void); /* both */
void gdb_create_default_process(GDBState *s);
diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c
index ab2d182..3a5587d 100644
--- a/gdbstub/softmmu.c
+++ b/gdbstub/softmmu.c
@@ -440,6 +440,15 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr,
return cpu_memory_rw_debug(cpu, addr, buf, len, is_write);
}
+/*
+ * cpu helpers
+ */
+
+unsigned int gdb_get_max_cpus(void)
+{
+ MachineState *ms = MACHINE(qdev_get_machine());
+ return ms->smp.max_cpus;
+}
/*
* Softmmu specific command helpers
diff --git a/gdbstub/user.c b/gdbstub/user.c
index 92663d9..e10988a 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -394,6 +394,23 @@ int gdb_target_memory_rw_debug(CPUState *cpu, hwaddr addr,
}
/*
+ * cpu helpers
+ */
+
+unsigned int gdb_get_max_cpus(void)
+{
+ CPUState *cpu;
+ unsigned int max_cpus = 1;
+
+ CPU_FOREACH(cpu) {
+ max_cpus = max_cpus <= cpu->cpu_index ? cpu->cpu_index + 1 : max_cpus;
+ }
+
+ return max_cpus;
+}
+
+
+/*
* Break/Watch point helpers
*/