Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Sylvain Pelissier <sylvain.pelissier@gmail.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20210106204141.14027-1-sylvain.pelissier@gmail.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
sylvainpelissier authored and alistair23 committed Jan 16, 2021
1 parent 465ef47 commit edf6478
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions target/riscv/cpu.c
Expand Up @@ -557,6 +557,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);
Expand Down Expand Up @@ -592,6 +604,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;
Expand Down

1 comment on commit edf6478

@kallisti5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL. I've been trying to get qemu riscv64 debugging working for a while in gdb / gef. Thanks for fixing this one.
gdb_arch_name being undefined results in gdb choosing "auto" which in the context of qemu gdbstub (potentially without symbols loaded) doesn't mean much.

Please sign in to comment.