[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 10/18] gdbstub: Simplify XML lookup
From: |
Akihiko Odaki |
Subject: |
[PATCH v6 10/18] gdbstub: Simplify XML lookup |
Date: |
Sun, 3 Sep 2023 14:03:18 +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 1c5cbc0472..6c8816e3ad 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -352,8 +352,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);
@@ -362,7 +361,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) {
@@ -396,21 +394,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.42.0
- [PATCH v6 00/18] plugins: Allow to read registers, Akihiko Odaki, 2023/09/03
- [PATCH v6 01/18] gdbstub: Add num_regs member to GDBFeature, Akihiko Odaki, 2023/09/03
- [PATCH v6 02/18] gdbstub: Introduce gdb_find_static_feature(), Akihiko Odaki, 2023/09/03
- [PATCH v6 04/18] gdbstub: Introduce GDBFeatureBuilder, Akihiko Odaki, 2023/09/03
- [PATCH v6 07/18] target/riscv: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/09/03
- [PATCH v6 08/18] gdbstub: Use GDBFeature for gdb_register_coprocessor, Akihiko Odaki, 2023/09/03
- [PATCH v6 10/18] gdbstub: Simplify XML lookup,
Akihiko Odaki <=
- [PATCH v6 11/18] hw/core/cpu: Remove gdb_get_dynamic_xml member, Akihiko Odaki, 2023/09/03
- [PATCH v6 09/18] gdbstub: Use GDBFeature for GDBRegisterState, Akihiko Odaki, 2023/09/03
- [PATCH v6 12/18] gdbstub: Add members to identify registers to GDBFeature, Akihiko Odaki, 2023/09/03
- [PATCH v6 13/18] gdbstub: Expose functions to read registers, Akihiko Odaki, 2023/09/03
- [PATCH v6 18/18] contrib/plugins: Add cc plugin, Akihiko Odaki, 2023/09/03
- [PATCH v6 17/18] plugins: Support C++, Akihiko Odaki, 2023/09/03
- [PATCH v6 03/18] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature, Akihiko Odaki, 2023/09/03
- [PATCH v6 05/18] target/arm: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/09/03
- [PATCH v6 06/18] target/ppc: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/09/03
- [PATCH v6 14/18] cpu: Call plugin hooks only when ready, Akihiko Odaki, 2023/09/03