From: Mike Frysinger Date: Fri, 5 Jun 2015 13:13:04 +0000 (+0800) Subject: add an interactive "pc" command X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=74225c6f45ae5e79c03a73012fdfb64791d24748;p=riscv-isa-sim.git add an interactive "pc" command This lets you show the current pc quickly. Sometimes when displaying different state you can lose track of what the pc was. Add a simple command that plumbs in the existing functions to the user interface. --- diff --git a/riscv/interactive.cc b/riscv/interactive.cc index c4eb869..689b53a 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -66,6 +66,7 @@ void sim_t::interactive() funcs["reg"] = &sim_t::interactive_reg; funcs["fregs"] = &sim_t::interactive_fregs; funcs["fregd"] = &sim_t::interactive_fregd; + funcs["pc"] = &sim_t::interactive_pc; funcs["mem"] = &sim_t::interactive_mem; funcs["str"] = &sim_t::interactive_str; funcs["until"] = &sim_t::interactive_until; @@ -111,6 +112,7 @@ void sim_t::interactive_help(const std::string& cmd, const std::vector # Display in \n" "fregs # Display single precision in \n" "fregd # Display double precision in \n" + "pc # Show current PC in \n" "mem # Show contents of physical memory\n" "str # Show NUL-terminated C string\n" "until reg # Stop when in hits \n" @@ -163,6 +165,11 @@ reg_t sim_t::get_pc(const std::vector& args) return p->state.pc; } +void sim_t::interactive_pc(const std::string& cmd, const std::vector& args) +{ + fprintf(stderr, "0x%016" PRIx64 "\n", get_pc(args)); +} + reg_t sim_t::get_reg(const std::vector& args) { if(args.size() != 2) diff --git a/riscv/sim.h b/riscv/sim.h index 8f7718a..0c7b0df 100644 --- a/riscv/sim.h +++ b/riscv/sim.h @@ -67,6 +67,7 @@ private: void interactive_reg(const std::string& cmd, const std::vector& args); void interactive_fregs(const std::string& cmd, const std::vector& args); void interactive_fregd(const std::string& cmd, const std::vector& args); + void interactive_pc(const std::string& cmd, const std::vector& args); void interactive_mem(const std::string& cmd, const std::vector& args); void interactive_str(const std::string& cmd, const std::vector& args); void interactive_until(const std::string& cmd, const std::vector& args);