add a help screen to interactive mode
authorMike Frysinger <vapier@gentoo.org>
Thu, 4 Jun 2015 15:59:00 +0000 (23:59 +0800)
committerMike Frysinger <vapier@gentoo.org>
Thu, 4 Jun 2015 15:59:00 +0000 (23:59 +0800)
There's no documentation that covers all the available functionality
(in source or the accompanied docs).  Start a help command so that the
info is always live and up-to-date for people.

riscv/interactive.cc
riscv/sim.h

index abdcc3991b985838bcd29499324a1c34ced11485..b18a6fa9501b131562644b97d0c30ef6d9a58598 100644 (file)
@@ -61,6 +61,7 @@ void sim_t::interactive()
   funcs["until"] = &sim_t::interactive_until;
   funcs["while"] = &sim_t::interactive_until;
   funcs["q"] = &sim_t::interactive_quit;
+  funcs["h"] = &sim_t::interactive_help;
 
   while (!htif->done())
   {
@@ -91,6 +92,29 @@ void sim_t::interactive()
   ctrlc_pressed = false;
 }
 
+void sim_t::interactive_help(const std::string& cmd, const std::vector<std::string>& args)
+{
+  std::cerr <<
+    "Interactive commands:\n"
+    "reg <core> <reg>                # Display <reg> in <core>\n"
+    "fregs <core> <reg>              # Display single precision <reg> in <core>\n"
+    "fregd <core> <reg>              # Display double precision <reg> in <core>\n"
+    "mem <hex addr>                  # Show contents of physical memory\n"
+    "str <hex addr>                  # Show NUL-terminated C string\n"
+    "until reg <core> <reg> <val>    # Stop when <reg> in <core> hits <val>\n"
+    "until pc <core> <val>           # Stop when PC in <core> hits <val>\n"
+    "until mem <addr> <val>          # Stop when memory <addr> becomes <val>\n"
+    "while reg <core> <reg> <val>    # Run while <reg> in <core> is <val>\n"
+    "while pc <core> <val>           # Run while PC in <core> is <val>\n"
+    "while mem <addr> <val>          # Run while memory <addr> is <val>\n"
+    "r [count]                       # Resume noisy execution (until CTRL+C, or [count] insns)\n"
+    "rs [count]                      # Resume silent execution (until CTRL+C, or [count] insns)\n"
+    "q                               # End the simulation\n"
+    "h                               # This screen!\n"
+    "Note: Hitting enter is the same as: run 1\n"
+    << std::flush;
+}
+
 void sim_t::interactive_run_noisy(const std::string& cmd, const std::vector<std::string>& args)
 {
   interactive_run(cmd,args,true);
index 6615ab007b131874c54981bed70ca21729130f9b..9b8f6e0f90582011493e72484564aeb436d06453 100644 (file)
@@ -58,6 +58,7 @@ private:
   void interactive();
 
   // functions that help implement interactive()
+  void interactive_help(const std::string& cmd, const std::vector<std::string>& args);
   void interactive_quit(const std::string& cmd, const std::vector<std::string>& args);
   void interactive_run(const std::string& cmd, const std::vector<std::string>& args, bool noisy);
   void interactive_run_noisy(const std::string& cmd, const std::vector<std::string>& args);