diff options
author | Andrew Waterman <andrew@sifive.com> | 2023-02-27 14:22:51 -0800 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2023-02-27 14:22:51 -0800 |
commit | 620e67ebf28ae81fad55e0381a7816d87bf69f99 (patch) | |
tree | 77aaa5b2d338ca598906693ba98767c017d3c90d | |
parent | 3165f365f1ea76ae375e0df252f0c12afcef294c (diff) | |
download | riscv-isa-sim-620e67ebf28ae81fad55e0381a7816d87bf69f99.zip riscv-isa-sim-620e67ebf28ae81fad55e0381a7816d87bf69f99.tar.gz riscv-isa-sim-620e67ebf28ae81fad55e0381a7816d87bf69f99.tar.bz2 |
Return periodically from interactive_run and interactive_until
This avoids stalling the HTIF.
-rw-r--r-- | riscv/interactive.cc | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/riscv/interactive.cc b/riscv/interactive.cc index d7ef42a..e0db1c9 100644 --- a/riscv/interactive.cc +++ b/riscv/interactive.cc @@ -402,9 +402,16 @@ void sim_t::interactive_run(const std::string& cmd, const std::vector<std::strin size_t steps = args.size() ? atoll(args[0].c_str()) : -1; ctrlc_pressed = false; set_procs_debug(noisy); - for (size_t i = 0; i < steps && !ctrlc_pressed && !done(); i++) + + const size_t actual_steps = std::min(INTERLEAVE, steps); + for (size_t i = 0; i < actual_steps && !ctrlc_pressed && !done(); i++) step(1); + if (actual_steps < steps) { + next_interactive_action = [=](){ interactive_run(cmd, {std::to_string(steps - actual_steps)}, noisy); }; + return; + } + std::ostream out(sout_.rdbuf()); if (!noisy) out << ":" << std::endl; } @@ -736,7 +743,7 @@ void sim_t::interactive_until(const std::string& cmd, const std::vector<std::str ctrlc_pressed = false; - while (1) + for (size_t i = 0; i < INTERLEAVE; i++) { try { @@ -746,15 +753,17 @@ void sim_t::interactive_until(const std::string& cmd, const std::vector<std::str if (max_xlen == 32) current &= 0xFFFFFFFF; if (cmd_until == (current == val)) - break; + return; if (ctrlc_pressed) - break; + return; } catch (trap_t& t) {} set_procs_debug(noisy); step(1); } + + next_interactive_action = [=](){ interactive_until(cmd, args, noisy); }; } void sim_t::interactive_dumpmems(const std::string& cmd, const std::vector<std::string>& args) |