Skip to contentSkip to conversation

gdb: riscv: Add target description

PATCH Superseded Sylvain Pelissier 2 participants 2 messages Jan 6, 2021 RISC-V

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 gdb: riscv: Add target description

Target description is not currently implemented in RISC-V architecture. Thus GDB won't set it properly when attached. The patch implements the target description response.

---
 target/riscv/cpu.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
target/riscv/cpu.c +13 -0
index 254cd83f8b..ed4971978b 100644
@@ -556,6 +556,18 @@ static Property riscv_cpu_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static gchar *riscv_gdb_arch_name(CPUState *cs)
+{
+    RISCVCPU *cpu = RISCV_CPU(cs);
+    CPURISCVState *env = &cpu->env;
+
+    if (riscv_cpu_is_32bit(env)) {
+        return g_strdup("riscv:rv32");
+    } else {
+        return g_strdup("riscv:rv64");
+    }
+}
+
 static void riscv_cpu_class_init(ObjectClass *c, void *data)
 {
     RISCVCPUClass *mcc = RISCV_CPU_CLASS(c);
@@ -591,6 +603,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *data)
     /* For now, mark unmigratable: */
     cc->vmsd = &vmstate_riscv_cpu;
 #endif
+    cc->gdb_arch_name = riscv_gdb_arch_name;
 #ifdef CONFIG_TCG
     cc->tcg_initialize = riscv_translate_init;
     cc->tlb_fill = riscv_cpu_tlb_fill;
Signature · 1 line
2.25.1
#1 lore raw

Hi Sylvain,

Quoted 2 lines · Sylvain Pelissier

Target description is not currently implemented in RISC-V architecture. Thus GDB won't set it properly when attached. The patch implements the target description response.

Please limit the commit message in less than 70 characters per line.

Quoted 16 lines
---
 target/riscv/cpu.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
target/riscv/cpu.c +2 -0
index 254cd83f8b..ed4971978b 100644
@@ -556,6 +556,18 @@ static Property riscv_cpu_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static gchar *riscv_gdb_arch_name(CPUState *cs)
+{

target/riscv/cpu.c static Property riscv_cpu_properties[] = { · line 570

Quoted 10 lines
target/riscv/cpu.c +10 -0
+    RISCVCPU *cpu = RISCV_CPU(cs);
+    CPURISCVState *env = &cpu->env;
+
+    if (riscv_cpu_is_32bit(env)) {
+        return g_strdup("riscv:rv32");
+    } else {
+        return g_strdup("riscv:rv64");
+    }
+}
+

Regards,
Bin