Minor usability improvements (#48)
[riscv-isa-sim.git] / riscv / interactive.cc
index 6ae1892f001ea2c2ff9878a468eeb0c666727b88..d24ec50714e9d707fbb1be793f09b6dc50500c5c 100644 (file)
@@ -3,6 +3,7 @@
 #include "decode.h"
 #include "disasm.h"
 #include "sim.h"
+#include "mmu.h"
 #include "htif.h"
 #include <sys/mman.h>
 #include <termios.h>
@@ -99,6 +100,8 @@ void sim_t::interactive()
     {
       if(funcs.count(cmd))
         (this->*funcs[cmd])(cmd, args);
+      else
+        fprintf(stderr, "Unknown command %s\n", cmd.c_str());
     }
     catch(trap_t t) {}
   }
@@ -183,9 +186,8 @@ reg_t sim_t::get_reg(const std::vector<std::string>& args)
     r = strtoul(args[1].c_str(), &ptr, 10);
     if (*ptr) {
       #define DECLARE_CSR(name, number) if (args[1] == #name) return p->get_csr(number);
-      if (0) ;
-      #include "encoding.h"
-      else r = NXPR;
+      #include "encoding.h"              // generates if's for all csrs
+      r = NXPR;                          // else case (csr name not found)
       #undef DECLARE_CSR
     }
   }
@@ -217,7 +219,7 @@ void sim_t::interactive_reg(const std::string& cmd, const std::vector<std::strin
     // Show all the regs!
     processor_t *p = get_core(args[0]);
 
-    for (int r = 0; r < NFPR; ++r) {
+    for (int r = 0; r < NXPR; ++r) {
       fprintf(stderr, "%-4s: 0x%016" PRIx64 "  ", xpr_name[r], p->state.XPR[r]);
       if ((r + 1) % 4 == 0)
         fprintf(stderr, "\n");