[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 10/18] gdbstub: Simplify XML lookup
From: |
Akihiko Odaki |
Subject: |
[PATCH v7 10/18] gdbstub: Simplify XML lookup |
Date: |
Tue, 12 Sep 2023 16:11:56 +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 | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
index 7554318118..90dc78832b 100644
--- a/gdbstub/gdbstub.c
+++ b/gdbstub/gdbstub.c
@@ -352,6 +352,7 @@ static const char *get_feature_xml(const char *p, const
char **newp,
{
CPUState *cpu = gdb_get_first_cpu_in_process(process);
CPUClass *cc = CPU_GET_CLASS(cpu);
+ GDBRegisterState *r;
size_t len;
/*
@@ -365,7 +366,6 @@ static const char *get_feature_xml(const char *p, const
char **newp,
/* Is it the main target xml? */
if (strncmp(p, "target.xml", len) == 0) {
if (!process->target_xml) {
- GDBRegisterState *r;
g_autoptr(GPtrArray) xml = g_ptr_array_new_with_free_func(g_free);
g_ptr_array_add(
@@ -398,20 +398,15 @@ static const char *get_feature_xml(const char *p, const
char **newp,
}
return process->target_xml;
}
- /* Is it dynamically generated by the target? */
- if (cc->gdb_get_dynamic_xml) {
- g_autofree char *xmlname = g_strndup(p, len);
- const char *xml = cc->gdb_get_dynamic_xml(cpu, xmlname);
- if (xml) {
- return xml;
- }
+ /* Is it the core feature? */
+ if (strncmp(p, cc->gdb_core_feature->xmlname, len) == 0) {
+ return cc->gdb_core_feature->xml;
}
- /* Is it one of the encoded gdb-xml/ files? */
- for (int i = 0; gdb_static_features[i].xmlname; i++) {
- const char *name = gdb_static_features[i].xmlname;
- if ((strncmp(name, p, len) == 0) &&
- strlen(name) == len) {
- return gdb_static_features[i].xml;
+ /* Is it one of the coprocessor features? */
+ for (guint i = 0; i < cpu->gdb_regs->len; i++) {
+ r = &g_array_index(cpu->gdb_regs, GDBRegisterState, i);
+ if (strncmp(p, r->feature->xmlname, len) == 0) {
+ return r->feature->xml;
}
}
--
2.42.0
- [PATCH v7 00/18] plugins: Allow to read registers, Akihiko Odaki, 2023/09/12
- [PATCH v7 01/18] gdbstub: Add num_regs member to GDBFeature, Akihiko Odaki, 2023/09/12
- [PATCH v7 02/18] gdbstub: Introduce gdb_find_static_feature(), Akihiko Odaki, 2023/09/12
- [PATCH v7 04/18] gdbstub: Introduce GDBFeatureBuilder, Akihiko Odaki, 2023/09/12
- [PATCH v7 03/18] hw/core/cpu: Replace gdb_core_xml_file with gdb_core_feature, Akihiko Odaki, 2023/09/12
- [PATCH v7 05/18] target/arm: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/09/12
- [PATCH v7 06/18] target/ppc: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/09/12
- [PATCH v7 07/18] target/riscv: Use GDBFeature for dynamic XML, Akihiko Odaki, 2023/09/12
- [PATCH v7 08/18] gdbstub: Use GDBFeature for gdb_register_coprocessor, Akihiko Odaki, 2023/09/12
- [PATCH v7 09/18] gdbstub: Use GDBFeature for GDBRegisterState, Akihiko Odaki, 2023/09/12
- [PATCH v7 10/18] gdbstub: Simplify XML lookup,
Akihiko Odaki <=
- [PATCH v7 11/18] hw/core/cpu: Remove gdb_get_dynamic_xml member, Akihiko Odaki, 2023/09/12
- [PATCH v7 12/18] gdbstub: Add members to identify registers to GDBFeature, Akihiko Odaki, 2023/09/12
- [PATCH v7 13/18] gdbstub: Expose functions to read registers, Akihiko Odaki, 2023/09/12
- [PATCH v7 14/18] cpu: Call plugin hooks only when ready, Akihiko Odaki, 2023/09/12
- [PATCH v7 15/18] plugins: Allow to read registers, Akihiko Odaki, 2023/09/12
- [PATCH v7 16/18] contrib/plugins: Allow to log registers, Akihiko Odaki, 2023/09/12
- [PATCH v7 17/18] plugins: Support C++, Akihiko Odaki, 2023/09/12
- [PATCH v7 18/18] contrib/plugins: Add cc plugin, Akihiko Odaki, 2023/09/12