These members will be used to help plugins to identify registers. Signed-off-by: Akihiko Odaki <akihiko.od...@daynix.com> --- target/riscv/gdbstub.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c index 224c69ea99..b3d4d4de3e 100644 --- a/target/riscv/gdbstub.c +++ b/target/riscv/gdbstub.c @@ -217,6 +217,7 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) RISCVCPU *cpu = RISCV_CPU(cs); CPURISCVState *env = &cpu->env; GString *s = g_string_new(NULL); + const char **regs = g_new(const char *, CSR_TABLE_SIZE); riscv_csr_predicate_fn predicate; int bitsize = 16 << env->misa_mxl_max; int i; @@ -240,11 +241,10 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) } predicate = csr_ops[i].predicate; if (predicate && (predicate(env, i) == RISCV_EXCP_NONE)) { - if (csr_ops[i].name) { - g_string_append_printf(s, "<reg name=\"%s\"", csr_ops[i].name); - } else { - g_string_append_printf(s, "<reg name=\"csr%03x\"", i); - } + regs[i] = + csr_ops[i].name ? + csr_ops[i].name : g_strdup_printf("csr%03x", i); + g_string_append_printf(s, "<reg name=\"%s\"", regs[i]); g_string_append_printf(s, " bitsize=\"%d\"", bitsize); g_string_append_printf(s, " regnum=\"%d\"/>", base_reg + i); } @@ -252,6 +252,8 @@ static GDBFeature *riscv_gen_dynamic_csr_feature(CPUState *cs, int base_reg) g_string_append_printf(s, "</feature>"); + cpu->dyn_csr_feature.name = "org.gnu.gdb.riscv.csr"; + cpu->dyn_csr_feature.regs = regs; cpu->dyn_csr_feature.num_regs = CSR_TABLE_SIZE; cpu->dyn_csr_feature.xmlname = "riscv-csr.xml"; cpu->dyn_csr_feature.xml = g_string_free(s, false); @@ -268,10 +270,12 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg) RISCVCPU *cpu = RISCV_CPU(cs); GString *s = g_string_new(NULL); g_autoptr(GString) ts = g_string_new(""); + const char **regs; int reg_width = cpu->cfg.vlen; int i; cpu->dyn_vreg_feature.num_regs = 32; + regs = g_new(const char *, cpu->dyn_vreg_feature.num_regs); g_string_printf(s, "<?xml version=\"1.0\"?>"); g_string_append_printf(s, "<!DOCTYPE target SYSTEM \"gdb-target.dtd\">"); @@ -297,15 +301,18 @@ static GDBFeature *ricsv_gen_dynamic_vector_feature(CPUState *cs, int base_reg) /* Define vector registers */ for (i = 0; i < cpu->dyn_vreg_feature.num_regs; i++) { + regs[i] = g_strdup_printf("v%d", i); g_string_append_printf(s, - "<reg name=\"v%d\" bitsize=\"%d\"" + "<reg name=\"%s\" bitsize=\"%d\"" " regnum=\"%d\" group=\"vector\"" " type=\"riscv_vector\"/>", - i, reg_width, base_reg++); + regs[i], reg_width, base_reg++); } g_string_append_printf(s, "</feature>"); + cpu->dyn_vreg_feature.name = "org.gnu.gdb.riscv.vector"; + cpu->dyn_vreg_feature.regs = regs; cpu->dyn_vreg_feature.xmlname = "riscv-vector.xml"; cpu->dyn_vreg_feature.xml = g_string_free(s, false); return &cpu->dyn_vreg_feature; -- 2.41.0