[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 15/24] gdbstub: introduce gdb_get_max_cpus
From: |
Alex Bennée |
Subject: |
[PATCH v3 15/24] gdbstub: introduce gdb_get_max_cpus |
Date: |
Tue, 21 Feb 2023 22:52:18 +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>
---
v3
- rm out of date comment
---
gdbstub/internals.h | 1 +
gdbstub/gdbstub.c | 11 +----------
gdbstub/softmmu.c | 9 +++++++++
gdbstub/user.c | 17 +++++++++++++++++
4 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/gdbstub/internals.h b/gdbstub/internals.h
index 9de995ce3a..90069a9415 100644
--- a/gdbstub/internals.h
+++ b/gdbstub/internals.h
@@ -127,6 +127,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 91021859a1..f9950200b8 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 d9b9ba0a32..65aa2018a7 100644
--- a/gdbstub/softmmu.c
+++ b/gdbstub/softmmu.c
@@ -433,6 +433,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 b956c0e297..15ff3ab08d 100644
--- a/gdbstub/user.c
+++ b/gdbstub/user.c
@@ -388,6 +388,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.1
- [PATCH v3 05/24] gdbstub: move GDBState to shared internals header, (continued)
- [PATCH v3 05/24] gdbstub: move GDBState to shared internals header, Alex Bennée, 2023/02/21
- [PATCH v3 04/24] gdbstub: define separate user/system structures, Alex Bennée, 2023/02/21
- [PATCH v3 06/24] includes: move tb_flush into its own header, Alex Bennée, 2023/02/21
- [PATCH v3 11/24] gdbstub: rationalise signal mapping in softmmu, Alex Bennée, 2023/02/21
- [PATCH v3 07/24] gdbstub: move fromhex/tohex routines to internals, Alex Bennée, 2023/02/21
- [PATCH v3 08/24] gdbstub: make various helpers visible to the rest of the module, Alex Bennée, 2023/02/21
- [PATCH v3 09/24] gdbstub: move chunk of softmmu functionality to own file, Alex Bennée, 2023/02/21
- [PATCH v3 13/24] gdbstub: specialise handle_query_attached, Alex Bennée, 2023/02/21
- [PATCH v3 10/24] gdbstub: move chunks of user code into own files, Alex Bennée, 2023/02/21
- [PATCH v3 23/24] include: split target_long definition from cpu-defs, Alex Bennée, 2023/02/21
- [PATCH v3 15/24] gdbstub: introduce gdb_get_max_cpus,
Alex Bennée <=
- [PATCH v3 24/24] gdbstub: split out softmmu/user specifics for syscall handling, Alex Bennée, 2023/02/21
- [PATCH v3 20/24] gdbstub: move syscall handling to new file, Alex Bennée, 2023/02/21
- [PATCH v3 22/24] testing: probe gdb for supported architectures ahead of time, Alex Bennée, 2023/02/21
- [PATCH v3 17/24] gdbstub: fix address type of gdb_set_cpu_pc, Alex Bennée, 2023/02/21
- [PATCH v3 14/24] gdbstub: specialise target_memory_rw_debug, Alex Bennée, 2023/02/21
- [PATCH v3 16/24] gdbstub: specialise stub_can_reverse, Alex Bennée, 2023/02/21
- [PATCH v3 12/24] gdbstub: abstract target specific details from gdb_put_packet_binary, Alex Bennée, 2023/02/21
- [PATCH v3 21/24] gdbstub: only compile gdbstub twice for whole build, Alex Bennée, 2023/02/21
- [PATCH v3 18/24] gdbstub: don't use target_ulong while handling registers, Alex Bennée, 2023/02/21
- [PATCH v3 19/24] gdbstub: move register helpers into standalone include, Alex Bennée, 2023/02/21