Re: [0/1] RISC-V: Update CSR to priv 1.11.

Andrew Burgess
2020-06-08T21:39:30Z

* Tom Tromey <tom@tromey.com> [2020-06-08 09:37:43 -0600]:

> >>>>> ">" == Nelson Chu <nelson.chu@sifive.com> writes:
>
> >> Since RISCV priv spec 1.11 has been officially released, it would be good if
> >> binutils, gdb, qemu and OpenOCD can support the new CSR. Therfore, I update
> >> the CSR to 1.11 in binutils, and the gdm xml files and gas/testsuite/gas/riscv/csr-dw-regnums
> >> also need to be updated. There are two difference between 1.10 and 1.11,
>
> >> 1. 0x320 is mcountinhibit rather than mucounteren. You can still use the
> >> mucounteren, but objdump will show mcountinhibit for it.
>
> >> 2. 0x7b2 is dscratch0 rather than dscratch, and 0x7b3 is dscratch1. You
> >> can still use the old naming, but objdump will show the new one.
>
> I noticed that this patch broke compatibility between gdb and some
> versions of qemu.
>
> We're using qemu 4.0.0. Our internal test suite has many failures if I
> run an unpatched gdb against this version -- locally I've backed out all
> RISC-V patches since this one, but that's getting cumbersome, and I
> belated realized I should probably just bring this up.
>
> A typical failure looks like:
>
> (gdb) info registers dscratch
> dscratch Could not fetch register "dscratch"; remote failure reply 'E14'
>
> It seems to me that the best thing to do would be to have gdb adapt to
> the registers that are reported by the remote. Is there a reason this
> was not done?

Unless I misunderstand here, you asking why we don't use the xml
target descriptions? We do. Or we _should_ do. Maybe it's not
working? Is your target definitely sending back a description? And
it definitely includes register "dscratch" ?

This patch (the only you replied too) is only changing the default xml
description, the one that gets picked up if the target doesn't supply
a description.

I'll try to get QEMU built and running tomorrow and see if I can give
you a better answer, however, the patch below might help. It adds an
alias from 'dscratch' to 'dscratch0', so your 'info registers
dscratch' should start working again.

Let me know if this helps at all.

Thanks,
Andrew

---

diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 6edf77a0ce0..42ca6440756 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -3380,6 +3380,10 @@ riscv_gdbarch_init (struct gdbarch_info info,
riscv_setup_register_aliases (gdbarch, &riscv_freg_feature);
riscv_setup_register_aliases (gdbarch, &riscv_csr_feature);

+ static int dscratch_regnum = RISCV_CSR_DSCRATCH0_REGNUM;
+ user_reg_add (gdbarch, "dscratch", value_of_riscv_user_reg,
+ &dscratch_regnum);
+
/* Compile command hooks. */
set_gdbarch_gcc_target_options (gdbarch, riscv_gcc_target_options);
set_gdbarch_gnu_triplet_regexp (gdbarch, riscv_gnu_triplet_regexp);