diff mbox

[PUSHED] gdb/riscv: Give user-friendly names for CSRs

Message ID 20181023123223.701-1-andrew.burgess@embecosm.com
State New
Headers show

Commit Message

Andrew Burgess Oct. 23, 2018, 12:32 p.m. UTC
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    |  5 +++++
 gdb/riscv-tdep.c | 19 +++++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 48ca2accb4a..f02420dfe52 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -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)