@samitouri / QOSamiQemu / commits / 7ddd3aca5f

gdbstub: Always infer gdb_num_core_regs when using XML file

Rather correct inferred count over invalid manual one. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260219191955.83815-10-philmd@linaro.org>

Philippe Mathieu-Daudé committed Feb 17, 2026 at 12:51 UTC 7ddd3aca5f2efcf6aae10f836011e445ee77a6e1
5 files changed +3 -6
gdbstub/gdbstub.c
+1
@@ -593,6 +593,7 @@ void gdb_init_cpu(CPUState *cpu)
593 gdb_register_feature(cpu, 0,
594 cc->gdb_read_register, cc->gdb_write_register,
595 feature);
596 + assert(!cc->gdb_num_core_regs);
597 cpu->gdb_num_regs = cpu->gdb_num_g_regs = feature->num_regs;
598 }
599
include/hw/core/cpu.h
+2 -2
@@ -128,9 +128,9 @@ struct SysemuCPUOps;
128 * @gdb_adjust_breakpoint: Callback for adjusting the address of a
129 * breakpoint. Used by AVR to handle a gdb mis-feature with
130 * its Harvard architecture split code and data.
131 - * @gdb_num_core_regs: Number of core registers accessible to GDB or 0 to infer
132 - * from @gdb_core_xml_file.
131 * @gdb_core_xml_file: File name for core registers GDB XML description.
132 + * @gdb_num_core_regs: Number of core registers accessible to GDB if no
133 + * @gdb_core_xml_file available (otherwise inferred).
134 * @gdb_get_core_xml_file: Optional callback that returns the file name for
135 * the core registers GDB XML description. The returned value is expected to
136 * be a simple constant string: the caller will not g_free() it. If this
target/alpha/cpu.c
-1
@@ -295,7 +295,6 @@ static void alpha_cpu_class_init(ObjectClass *oc, const void *data)
295 cc->disas_set_info = alpha_cpu_disas_set_info;
296
297 cc->tcg_ops = &alpha_tcg_ops;
298 - cc->gdb_num_core_regs = 67;
298 }
299
300 #define DEFINE_ALPHA_CPU_TYPE(base_type, cpu_model, initfn) \
target/ppc/cpu_init.c
-2
@@ -7551,8 +7551,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, const void *data)
7551 MMU_INST_FETCH == 2 && PAGE_READ == 1 &&
7552 PAGE_WRITE == 2 && PAGE_EXEC == 4);
7553 #endif
7554 -
7555 - cc->gdb_num_core_regs = 70;
7554 cc->gdb_arch_name = ppc_gdb_arch_name;
7555 #if defined(TARGET_PPC64)
7556 cc->gdb_core_xml_file = "power64-core.xml";
target/sparc/cpu.c
-1
@@ -1092,7 +1092,6 @@ static void sparc_cpu_class_init(ObjectClass *oc, const void *data)
1092
1093 #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32)
1094 cc->gdb_core_xml_file = "sparc64-core.xml";
1095 - cc->gdb_num_core_regs = 86;
1095 #else
1096 cc->gdb_num_core_regs = 72;
1097 #endif