mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 12:23:53 -06:00
gdbstub: Allow gdb_core_xml_file to be set at runtime
Currently the CPUClass:gdb_core_xml_file setting is a simple 'const char *' which the CPU class must set to a fixed string. Allow the CPU class to instead set a new method gdb_get_core_xml_file() which returns this string. This will allow Arm CPUs to use different XML files for AArch32 vs AArch64 without having to have an extra AArch64-specific class type purely to give somewhere to set cc->gdb_core_xml_file differently. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Acked-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20250317142819.900029-3-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
56a9f0d4c4
commit
a1f728ecc9
2 changed files with 24 additions and 4 deletions
|
@ -565,15 +565,30 @@ static void gdb_register_feature(CPUState *cpu, int base_reg,
|
||||||
g_array_append_val(cpu->gdb_regs, s);
|
g_array_append_val(cpu->gdb_regs, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *gdb_get_core_xml_file(CPUState *cpu)
|
||||||
|
{
|
||||||
|
CPUClass *cc = cpu->cc;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The CPU class can provide the XML filename via a method,
|
||||||
|
* or as a simple fixed string field.
|
||||||
|
*/
|
||||||
|
if (cc->gdb_get_core_xml_file) {
|
||||||
|
return cc->gdb_get_core_xml_file(cpu);
|
||||||
|
}
|
||||||
|
return cc->gdb_core_xml_file;
|
||||||
|
}
|
||||||
|
|
||||||
void gdb_init_cpu(CPUState *cpu)
|
void gdb_init_cpu(CPUState *cpu)
|
||||||
{
|
{
|
||||||
CPUClass *cc = cpu->cc;
|
CPUClass *cc = cpu->cc;
|
||||||
const GDBFeature *feature;
|
const GDBFeature *feature;
|
||||||
|
const char *xmlfile = gdb_get_core_xml_file(cpu);
|
||||||
|
|
||||||
cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState));
|
cpu->gdb_regs = g_array_new(false, false, sizeof(GDBRegisterState));
|
||||||
|
|
||||||
if (cc->gdb_core_xml_file) {
|
if (xmlfile) {
|
||||||
feature = gdb_find_static_feature(cc->gdb_core_xml_file);
|
feature = gdb_find_static_feature(xmlfile);
|
||||||
gdb_register_feature(cpu, 0,
|
gdb_register_feature(cpu, 0,
|
||||||
cc->gdb_read_register, cc->gdb_write_register,
|
cc->gdb_read_register, cc->gdb_write_register,
|
||||||
feature);
|
feature);
|
||||||
|
@ -1644,7 +1659,7 @@ void gdb_extend_qsupported_features(char *qflags)
|
||||||
static void handle_query_supported(GArray *params, void *user_ctx)
|
static void handle_query_supported(GArray *params, void *user_ctx)
|
||||||
{
|
{
|
||||||
g_string_printf(gdbserver_state.str_buf, "PacketSize=%x", MAX_PACKET_LENGTH);
|
g_string_printf(gdbserver_state.str_buf, "PacketSize=%x", MAX_PACKET_LENGTH);
|
||||||
if (first_cpu->cc->gdb_core_xml_file) {
|
if (gdb_get_core_xml_file(first_cpu)) {
|
||||||
g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
|
g_string_append(gdbserver_state.str_buf, ";qXfer:features:read+");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1701,7 +1716,7 @@ static void handle_query_xfer_features(GArray *params, void *user_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
process = gdb_get_cpu_process(gdbserver_state.g_cpu);
|
process = gdb_get_cpu_process(gdbserver_state.g_cpu);
|
||||||
if (!gdbserver_state.g_cpu->cc->gdb_core_xml_file) {
|
if (!gdb_get_core_xml_file(gdbserver_state.g_cpu)) {
|
||||||
gdb_put_packet("");
|
gdb_put_packet("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,6 +131,10 @@ struct SysemuCPUOps;
|
||||||
* @gdb_num_core_regs: Number of core registers accessible to GDB or 0 to infer
|
* @gdb_num_core_regs: Number of core registers accessible to GDB or 0 to infer
|
||||||
* from @gdb_core_xml_file.
|
* from @gdb_core_xml_file.
|
||||||
* @gdb_core_xml_file: File name for core registers GDB XML description.
|
* @gdb_core_xml_file: File name for core registers GDB XML description.
|
||||||
|
* @gdb_get_core_xml_file: Optional callback that returns the file name for
|
||||||
|
* the core registers GDB XML description. The returned value is expected to
|
||||||
|
* be a simple constant string: the caller will not g_free() it. If this
|
||||||
|
* is NULL then @gdb_core_xml_file will be used instead.
|
||||||
* @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop
|
* @gdb_stop_before_watchpoint: Indicates whether GDB expects the CPU to stop
|
||||||
* before the insn which triggers a watchpoint rather than after it.
|
* before the insn which triggers a watchpoint rather than after it.
|
||||||
* @gdb_arch_name: Optional callback that returns the architecture name known
|
* @gdb_arch_name: Optional callback that returns the architecture name known
|
||||||
|
@ -166,6 +170,7 @@ struct CPUClass {
|
||||||
|
|
||||||
const char *gdb_core_xml_file;
|
const char *gdb_core_xml_file;
|
||||||
const gchar * (*gdb_arch_name)(CPUState *cpu);
|
const gchar * (*gdb_arch_name)(CPUState *cpu);
|
||||||
|
const char * (*gdb_get_core_xml_file)(CPUState *cpu);
|
||||||
|
|
||||||
void (*disas_set_info)(CPUState *cpu, disassemble_info *info);
|
void (*disas_set_info)(CPUState *cpu, disassemble_info *info);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue