[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/30] gdbstub: introduce gdb_get_max_cpus
From: |
Alex Bennée |
Subject: |
[PULL 16/30] gdbstub: introduce gdb_get_max_cpus |
Date: |
Tue, 7 Mar 2023 21:21:25 +0000 |
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>
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index d8c0292d99..26a6468a69 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/gdbstub.c b/gdbstub/gdbstub.c
index ed38ab0aaa..1b783100c2 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/softmmu.c b/gdbstub/softmmu.c
index ab2d182654..3a5587d387 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 92663d971c..e10988a62b 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -393,6 +393,23 @@ 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)
+{
+ 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
*/
--
2.39.2
- [PULL 12/30] gdbstub: rationalise signal mapping in softmmu, (continued)
- [PULL 12/30] gdbstub: rationalise signal mapping in softmmu, Alex Bennée, 2023/03/07
- [PULL 09/30] gdbstub: make various helpers visible to the rest of the module, Alex Bennée, 2023/03/07
- [PULL 11/30] gdbstub: move chunks of user code into own files, Alex Bennée, 2023/03/07
- [PULL 02/30] gdbstub: fix-up copyright and license files, Alex Bennée, 2023/03/07
- [PULL 06/30] gdbstub: move GDBState to shared internals header, Alex Bennée, 2023/03/07
- [PULL 13/30] gdbstub: abstract target specific details from gdb_put_packet_binary, Alex Bennée, 2023/03/07
- [PULL 17/30] gdbstub: specialise stub_can_reverse, Alex Bennée, 2023/03/07
- [PULL 26/30] gdbstub: Remove gdb_do_syscallv, Alex Bennée, 2023/03/07
- [PULL 29/30] gdbstub: Build syscall.c once, Alex Bennée, 2023/03/07
- [PULL 28/30] stubs: split semihosting_get_target from system only stubs, Alex Bennée, 2023/03/07
- [PULL 16/30] gdbstub: introduce gdb_get_max_cpus,
Alex Bennée <=
- [PULL 25/30] gdbstub: split out softmmu/user specifics for syscall handling, Alex Bennée, 2023/03/07
- [PULL 30/30] gdbstub: move update guest debug to accel ops, Alex Bennée, 2023/03/07
- [PULL 27/30] gdbstub: Adjust gdb_do_syscall to only use uint32_t and uint64_t, Alex Bennée, 2023/03/07
- [PULL 19/30] gdbstub: don't use target_ulong while handling registers, Alex Bennée, 2023/03/07
- [PULL 15/30] gdbstub: specialise target_memory_rw_debug, Alex Bennée, 2023/03/07
- [PULL 20/30] gdbstub: move register helpers into standalone include, Alex Bennée, 2023/03/07
- [PULL 24/30] include: split target_long definition from cpu-defs, Alex Bennée, 2023/03/07
- [PULL 18/30] gdbstub: fix address type of gdb_set_cpu_pc, Alex Bennée, 2023/03/07
- [PULL 23/30] testing: probe gdb for supported architectures ahead of time, Alex Bennée, 2023/03/07
- [PULL 21/30] gdbstub: move syscall handling to new file, Alex Bennée, 2023/03/07