diff options
author | Andrew Waterman <waterman@s144.Millennium.Berkeley.EDU> | 2011-04-16 19:44:16 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@s144.Millennium.Berkeley.EDU> | 2011-04-16 19:44:16 -0700 |
commit | 6e2844c1b5d1b2c8bbc6b36a29726c19fd0c0593 (patch) | |
tree | 7f14bb9dd6939d268af4e6c79c9bc89e37dae5d1 /riscv/sim.cc | |
parent | 5c96429584484a6ce88cb5a0432582e57ee9e211 (diff) | |
download | riscv-isa-sim-6e2844c1b5d1b2c8bbc6b36a29726c19fd0c0593.zip riscv-isa-sim-6e2844c1b5d1b2c8bbc6b36a29726c19fd0c0593.tar.gz riscv-isa-sim-6e2844c1b5d1b2c8bbc6b36a29726c19fd0c0593.tar.bz2 |
[sim] added "str" debug command
it prints the c string starting at the specified memory address.
Diffstat (limited to 'riscv/sim.cc')
-rw-r--r-- | riscv/sim.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/riscv/sim.cc b/riscv/sim.cc index 50264ed..7ac60c1 100644 --- a/riscv/sim.cc +++ b/riscv/sim.cc @@ -75,6 +75,7 @@ void sim_t::run(bool debug) funcs["fregs"] = &sim_t::interactive_fregs; funcs["fregd"] = &sim_t::interactive_fregd; funcs["mem"] = &sim_t::interactive_mem; + funcs["str"] = &sim_t::interactive_str; funcs["until"] = &sim_t::interactive_until; funcs["while"] = &sim_t::interactive_until; funcs["q"] = &sim_t::interactive_quit; @@ -254,6 +255,22 @@ void sim_t::interactive_mem(const std::string& cmd, const std::vector<std::strin printf("0x%016llx\n",(unsigned long long)get_mem(args)); } +void sim_t::interactive_str(const std::string& cmd, const std::vector<std::string>& args) +{ + if(args.size() != 1) + throw trap_illegal_instruction; + + reg_t addr = strtol(args[0].c_str(),NULL,16); + + mmu_t mmu(mem,memsz); + char ch; + + while((ch = mmu.load_uint8(addr++))) + putchar(ch); + + putchar('\n'); +} + void sim_t::interactive_until(const std::string& cmd, const std::vector<std::string>& args) { if(args.size() < 3) |