gdb/riscv: Give user-friendly names for CSRs
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 23 Oct 2018 12:23:34 +0000 (13:23 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 23 Oct 2018 12:27:56 +0000 (13:27 +0100)
The recent commit:

    commit 0dbfcfffe9abbc5198bce95eb8c66b6bc9b364be
    Date:   Tue Oct 16 22:40:09 2018 +0100

        gdb/riscv: Fix register access for register aliases

broke the CSR names for RISC-V, now all of the CSRs have names like,
csr0, csr1, csr2, etc.  This commit restores the previous
user-friendly names.

gdb/ChangeLog:

* riscv-tdep.c (riscv_register_name): Use the user-friendly names
for CSRs.

gdb/ChangeLog
gdb/riscv-tdep.c

index 88d76db13a18ac2b2591929910c94dd6fac7ccba..db4c6b1a3228b9f589a4400c15384c58be06446b 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-23  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * riscv-tdep.c (riscv_register_name): Use the user-friendly names
+       for CSRs.
+
 2018-10-23  Joel Brobecker  <brobecker@adacore.com>
 
        * riscv-tdep.c (riscv_gdbarch_init): Set the gdbarch's
index 48ca2accb4abf61d8fe372bf63945bc84bb7db31..f02420dfe52162121978d5a8e5d5d066d4bb5f2c 100644 (file)
@@ -482,11 +482,22 @@ riscv_register_name (struct gdbarch *gdbarch, int regnum)
 
   if (regnum >= RISCV_FIRST_CSR_REGNUM && regnum <= RISCV_LAST_CSR_REGNUM)
     {
-      static char buf[20];
+#define DECLARE_CSR(NAME,VALUE) \
+      case RISCV_ ## VALUE ## _REGNUM: return # NAME;
 
-      xsnprintf (buf, sizeof (buf), "csr%d",
-                regnum - RISCV_FIRST_CSR_REGNUM);
-      return buf;
+      switch (regnum)
+       {
+         #include "opcode/riscv-opc.h"
+       default:
+          {
+            static char buf[20];
+
+            xsnprintf (buf, sizeof (buf), "csr%d",
+                       regnum - RISCV_FIRST_CSR_REGNUM);
+            return buf;
+          }
+       }
+#undef DECLARE_CSR
     }
 
   if (regnum == RISCV_PRIV_REGNUM)
This page took 0.032866 seconds and 4 git commands to generate.