[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 15/25] gdbstub: Simplify XML lookup
From: |
Akihiko Odaki |
Subject: |
[PATCH v4 15/25] gdbstub: Simplify XML lookup |
Date: |
Wed, 16 Aug 2023 23:51:36 +0900 |
Now we know all instances of GDBFeature that is used in CPU so we can
traverse them to find XML. This removes the need for a CPU-specific
lookup function for dynamic XMLs.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
gdbstub/gdbstub.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 452b5bf0ef..ccb4ed9d4b 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -354,8 +354,7 @@ static const char *get_feature_xml(const char *p, const
char **newp,
GDBProcess *process)
{
size_t len;
- int i;
- const char *name;
+ GDBRegisterState *r;
CPUState *cpu = gdb_get_first_cpu_in_process(process);
CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -364,7 +363,6 @@ static const char *get_feature_xml(const char *p, const
char **newp,
len++;
*newp = p + len;
- name = NULL;
if (strncmp(p, "target.xml", len) == 0) {
/* Generate the XML description for this CPU. */
if (!process->target_xml) {
@@ -398,21 +396,15 @@ static const char *get_feature_xml(const char *p, const
char **newp,
}
return process->target_xml;
}
- if (cc->gdb_get_dynamic_xml) {
- char *xmlname = g_strndup(p, len);
- const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname);
-
- g_free(xmlname);
- if (xml) {
- return xml;
- }
+ if (strncmp(p, cc->gdb_core_feature->xmlname, len) == 0) {
+ return cc->gdb_core_feature->xml;
}
- for (i = 0; ; i++) {
- name = gdb_static_features[i].xmlname;
- if (!name || (strncmp(name, p, len) == 0 && strlen(name) == len))
- break;
+ for (r = cpu->gdb_regs; r; r = r->next) {
+ if (strncmp(p, r->feature->xmlname, len) == 0) {
+ return r->feature->xml;
+ }
}
- return name ? gdb_static_features[i].xml : NULL;
+ return NULL;
}
void gdb_feature_builder_init(GDBFeatureBuilder *builder, GDBFeature *feature,
--
2.41.0
- [PATCH v4 05/25] target/arm: Move the reference to arm-core.xml, (continued)
- [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, 2023/08/16
- [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 <=
- [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
- [PATCH v4 20/25] gdbstub: Expose functions to read registers, Akihiko Odaki, 2023/08/16
- [PATCH v4 21/25] cpu: Call plugin hooks only when ready, Akihiko Odaki, 2023/08/16
- [PATCH v4 22/25] plugins: Allow to read registers, Akihiko Odaki, 2023/08/16
- [PATCH v4 23/25] contrib/plugins: Allow to log registers, Akihiko Odaki, 2023/08/16
- [PATCH v4 24/25] plugins: Support C++, Akihiko Odaki, 2023/08/16
- [PATCH v4 25/25] contrib/plugins: Add cc plugin, Akihiko Odaki, 2023/08/16