From 66e1078e9dc6aa4139d91a8f00b7e4fe572129f4 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 4 Jun 2015 23:59:00 +0800 Subject: [PATCH] add a help screen to interactive mode 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 | 24 ++++++++++++++++++++++++ riscv/sim.h | 1 + 2 files changed, 25 insertions(+) diff --git a/riscv/interactive.cc b/riscv/interactive.cc index abdcc39..b18a6fa 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -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& args) +{ + std::cerr << + "Interactive commands:\n" + "reg # Display in \n" + "fregs # Display single precision in \n" + "fregd # Display double precision in \n" + "mem # Show contents of physical memory\n" + "str # Show NUL-terminated C string\n" + "until reg # Stop when in hits \n" + "until pc # Stop when PC in hits \n" + "until mem # Stop when memory becomes \n" + "while reg # Run while in is \n" + "while pc # Run while PC in is \n" + "while mem # Run while memory is \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& args) { interactive_run(cmd,args,true); diff --git a/riscv/sim.h b/riscv/sim.h index 6615ab0..9b8f6e0 100644 --- a/riscv/sim.h +++ b/riscv/sim.h @@ -58,6 +58,7 @@ private: void interactive(); // functions that help implement interactive() + void interactive_help(const std::string& cmd, const std::vector& args); void interactive_quit(const std::string& cmd, const std::vector& args); void interactive_run(const std::string& cmd, const std::vector& args, bool noisy); void interactive_run_noisy(const std::string& cmd, const std::vector& args); -- 2.30.2