Skip to content
Snippets Groups Projects
Commit 7ea0c33d authored by Alex Bennée's avatar Alex Bennée
Browse files

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: default avatarRichard Henderson <richard.henderson@linaro.org>
Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>

Message-Id: <20230302190846.2593720-17-alex.bennee@linaro.org>
Message-Id: <20230303025805.625589-17-richard.henderson@linaro.org>
parent 589a5867
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment