aboutsummaryrefslogtreecommitdiff
path: root/riscv/trap.cc
diff options
context:
space:
mode:
Diffstat (limited to 'riscv/trap.cc')
-rw-r--r--riscv/trap.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/riscv/trap.cc b/riscv/trap.cc
new file mode 100644
index 0000000..d873a19
--- /dev/null
+++ b/riscv/trap.cc
@@ -0,0 +1,10 @@
+#include "trap.h"
+
+const char* trap_name(trap_t t)
+{
+ #define DECLARE_TRAP(x) "trap_"#x
+ static const char* names[] = { TRAP_LIST };
+ #undef DECLARE_TRAP
+
+ return (unsigned)t >= sizeof(names)/sizeof(names[0]) ? "unknown" : names[t];
+}