[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 09/25] target/ppc: Use GDBFeature for dynamic XML
From: |
Akihiko Odaki |
Subject: |
[PATCH v4 09/25] target/ppc: Use GDBFeature for dynamic XML |
Date: |
Wed, 16 Aug 2023 23:51:30 +0900 |
In preparation for a change to use GDBFeature as a parameter of
gdb_register_coprocessor(), convert the internal representation of
dynamic feature from plain XML to GDBFeature.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
target/ppc/cpu-qom.h | 3 +--
target/ppc/cpu.h | 2 +-
target/ppc/cpu_init.c | 2 +-
target/ppc/gdbstub.c | 45 ++++++++++++++-----------------------------
4 files changed, 17 insertions(+), 35 deletions(-)
diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h
index be33786bd8..633fb402b5 100644
--- a/target/ppc/cpu-qom.h
+++ b/target/ppc/cpu-qom.h
@@ -186,8 +186,7 @@ struct PowerPCCPUClass {
int bfd_mach;
uint32_t l1_dcache_size, l1_icache_size;
#ifndef CONFIG_USER_ONLY
- unsigned int gdb_num_sprs;
- const char *gdb_spr_xml;
+ GDBFeature gdb_spr;
#endif
const PPCHash64Options *hash64_opts;
struct ppc_radix_page_info *radix_page_info;
diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h
index 25fac9577a..5f251bdffe 100644
--- a/target/ppc/cpu.h
+++ b/target/ppc/cpu.h
@@ -1381,7 +1381,7 @@ int ppc_cpu_gdb_write_register(CPUState *cpu, uint8_t
*buf, int reg);
int ppc_cpu_gdb_write_register_apple(CPUState *cpu, uint8_t *buf, int reg);
#ifndef CONFIG_USER_ONLY
hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
-void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu);
+void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu);
const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name);
#endif
int ppc64_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs,
diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c
index eb56226865..938cd2b7e1 100644
--- a/target/ppc/cpu_init.c
+++ b/target/ppc/cpu_init.c
@@ -6673,7 +6673,7 @@ static void init_ppc_proc(PowerPCCPU *cpu)
(*pcc->init_proc)(env);
#if !defined(CONFIG_USER_ONLY)
- ppc_gdb_gen_spr_xml(cpu);
+ ppc_gdb_gen_spr_feature(cpu);
#endif
/* MSR bits & flags consistency checks */
diff --git a/target/ppc/gdbstub.c b/target/ppc/gdbstub.c
index ca39efdc35..0ef484dbee 100644
--- a/target/ppc/gdbstub.c
+++ b/target/ppc/gdbstub.c
@@ -318,15 +318,21 @@ int ppc_cpu_gdb_write_register_apple(CPUState *cs,
uint8_t *mem_buf, int n)
}
#ifndef CONFIG_USER_ONLY
-void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu)
+void ppc_gdb_gen_spr_feature(PowerPCCPU *cpu)
{
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
CPUPPCState *env = &cpu->env;
- GString *xml;
- char *spr_name;
+ GDBFeatureBuilder builder;
unsigned int num_regs = 0;
int i;
+ if (pcc->gdb_spr.xml) {
+ return;
+ }
+
+ gdb_feature_builder_init(&builder, &pcc->gdb_spr,
+ "org.qemu.power.spr", "power-spr.xml");
+
for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
ppc_spr_t *spr = &env->spr_cb[i];
@@ -344,35 +350,12 @@ void ppc_gdb_gen_spr_xml(PowerPCCPU *cpu)
*/
spr->gdb_id = num_regs;
num_regs++;
- }
-
- if (pcc->gdb_spr_xml) {
- return;
- }
-
- xml = g_string_new("<?xml version=\"1.0\"?>");
- g_string_append(xml, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">");
- g_string_append(xml, "<feature name=\"org.qemu.power.spr\">");
- for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) {
- ppc_spr_t *spr = &env->spr_cb[i];
-
- if (!spr->name) {
- continue;
- }
-
- spr_name = g_ascii_strdown(spr->name, -1);
- g_string_append_printf(xml, "<reg name=\"%s\"", spr_name);
- g_free(spr_name);
-
- g_string_append_printf(xml, " bitsize=\"%d\"", TARGET_LONG_BITS);
- g_string_append(xml, " group=\"spr\"/>");
+ gdb_feature_builder_append_reg(&builder, g_ascii_strdown(spr->name,
-1),
+ TARGET_LONG_BITS, "int", "spr");
}
- g_string_append(xml, "</feature>");
-
- pcc->gdb_num_sprs = num_regs;
- pcc->gdb_spr_xml = g_string_free(xml, false);
+ gdb_feature_builder_end(&builder);
}
const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const char *xml_name)
@@ -380,7 +363,7 @@ const char *ppc_gdb_get_dynamic_xml(CPUState *cs, const
char *xml_name)
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
if (strcmp(xml_name, "power-spr.xml") == 0) {
- return pcc->gdb_spr_xml;
+ return pcc->gdb_spr.xml;
}
return NULL;
}
@@ -618,6 +601,6 @@ void ppc_gdb_init(CPUState *cs, PowerPCCPUClass *pcc)
}
#ifndef CONFIG_USER_ONLY
gdb_register_coprocessor(cs, gdb_get_spr_reg, gdb_set_spr_reg,
- pcc->gdb_num_sprs, "power-spr.xml", 0);
+ pcc->gdb_spr.num_regs, "power-spr.xml", 0);
#endif
}
--
2.41.0
- [PATCH v4 00/25] plugins: Allow to read registers, Akihiko Odaki, 2023/08/16
- [PATCH v4 01/25] contrib/plugins: Use GRWLock in execlog, Akihiko Odaki, 2023/08/16
- [PATCH v4 02/25] gdbstub: Introduce GDBFeature structure, Akihiko Odaki, 2023/08/16
- [PATCH v4 03/25] gdbstub: Add num_regs member to GDBFeature, Akihiko Odaki, 2023/08/16
- [PATCH v4 04/25] gdbstub: Introduce gdb_find_static_feature(), Akihiko Odaki, 2023/08/16
- [PATCH v4 05/25] target/arm: Move the reference to arm-core.xml, Akihiko Odaki, 2023/08/16
- [PATCH v4 06/25] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature, Akihiko Odaki, 2023/08/16
- [PATCH v4 07/25] gdbstub: Introduce GDBFeatureBuilder, Akihiko Odaki, 2023/08/16
- [PATCH v4 08/25] target/arm: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/08/16
- [PATCH v4 09/25] target/ppc: Use GDBFeature for dynamic XML,
Akihiko Odaki <=
- [PATCH v4 10/25] target/riscv: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/08/16
- [PATCH v4 11/25] gdbstub: Use GDBFeature for gdb_register_coprocessor, Akihiko Odaki, 2023/08/16
- [PATCH v4 12/25] gdbstub: Use GDBFeature for GDBRegisterState, Akihiko Odaki, 2023/08/16
- [PATCH v4 13/25] hw/core/cpu: Return static value with gdb_arch_name(), Akihiko Odaki, 2023/08/16
- [PATCH v4 14/25] gdbstub: Dynamically allocate target.xml buffer, Akihiko Odaki, 2023/08/16
- [PATCH v4 15/25] gdbstub: Simplify XML lookup, Akihiko Odaki, 2023/08/16
- [PATCH v4 16/25] hw/core/cpu: Remove gdb_get_dynamic_xml member, Akihiko Odaki, 2023/08/16
- [PATCH v4 17/25] gdbstub: Add members to identify registers to GDBFeature, Akihiko Odaki, 2023/08/16
- [PATCH v4 18/25] hw/core/cpu: Add a parameter to gdb_read_register/gdb_write_register, Akihiko Odaki, 2023/08/16
- [PATCH v4 19/25] gdbstub: Hide gdb_has_xml, Akihiko Odaki, 2023/08/16