[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 12/24] gdbstub: Simplify XML lookup
From: |
Akihiko Odaki |
Subject: |
[RFC PATCH 12/24] gdbstub: Simplify XML lookup |
Date: |
Mon, 31 Jul 2023 17:43:39 +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 | 28 +++++++++-------------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 182efe7e0f..e5bb2c89ba 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,15 +363,12 @@ 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) {
char *buf = process->target_xml;
const size_t buf_sz = sizeof(process->target_xml);
/* Generate the XML description for this CPU. */
if (!buf[0]) {
- GDBRegisterState *r;
-
pstrcat(buf, buf_sz,
"<?xml version=\"1.0\"?>"
"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"
@@ -389,28 +385,22 @@ static const char *get_feature_xml(const char *p, const
char **newp,
pstrcat(buf, buf_sz, "\"/>");
for (r = cpu->gdb_regs; r; r = r->next) {
pstrcat(buf, buf_sz, "<xi:include href=\"");
- pstrcat(buf, buf_sz, r->feature->xml);
+ pstrcat(buf, buf_sz, r->feature->xmlname);
pstrcat(buf, buf_sz, "\"/>");
}
pstrcat(buf, buf_sz, "</target>");
}
return buf;
}
- 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_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_features[i].xml : NULL;
+ return NULL;
}
const GDBFeature *gdb_find_static_feature(const char *xmlname)
--
2.41.0
- [RFC PATCH 02/24] gdbstub: Introduce GDBFeature structure, (continued)
- [RFC PATCH 02/24] gdbstub: Introduce GDBFeature structure, Akihiko Odaki, 2023/07/31
- [RFC PATCH 03/24] gdbstub: Add num_regs member to GDBFeature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 04/24] gdbstub: Introduce gdb_find_static_feature(), Akihiko Odaki, 2023/07/31
- [RFC PATCH 05/24] target/arm: Move the reference to arm-core.xml, Akihiko Odaki, 2023/07/31
- [RFC PATCH 06/24] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 08/24] target/ppc: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/07/31
- [RFC PATCH 07/24] target/arm: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/07/31
- [RFC PATCH 09/24] target/riscv: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/07/31
- [RFC PATCH 10/24] gdbstub: Use GDBFeature for gdb_register_coprocessor, Akihiko Odaki, 2023/07/31
- [RFC PATCH 11/24] gdbstub: Use GDBFeature for GDBRegisterState, Akihiko Odaki, 2023/07/31
- [RFC PATCH 12/24] gdbstub: Simplify XML lookup,
Akihiko Odaki <=
- [RFC PATCH 13/24] hw/core/cpu: Remove gdb_get_dynamic_xml member, Akihiko Odaki, 2023/07/31
- [RFC PATCH 14/24] gdbstub: Add members to identify registers to GDBFeature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 15/24] target/arm: Fill new members of GDBFeature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 16/24] target/ppc: Fill new members of GDBFeature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 17/24] target/riscv: Fill new members of GDBFeature, Akihiko Odaki, 2023/07/31
- [RFC PATCH 18/24] hw/core/cpu: Add a parameter to gdb_read_register/gdb_write_register, Akihiko Odaki, 2023/07/31
- [RFC PATCH 20/24] gdbstub: Expose functions to read registers, Akihiko Odaki, 2023/07/31
- [RFC PATCH 19/24] gdbstub: Hide gdb_has_xml, Akihiko Odaki, 2023/07/31
- [RFC PATCH 21/24] plugins: Allow to read registers, Akihiko Odaki, 2023/07/31
- [RFC PATCH 22/24] contrib/plugins: Allow to log registers, Akihiko Odaki, 2023/07/31