aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2023-03-23 19:13:16 -0400
committerGitHub <noreply@github.com>2023-03-23 19:13:16 -0400
commit4b0e34e0135b94171c1a81cdfc292d70e237a7b1 (patch)
treeef4345183677185803050ccbd79b438f0115a8c7
parent8983efd14694e57121d6855283432f7a5b775b50 (diff)
parent99a98013a497bf9cc97defcba3311e31ea7a44bb (diff)
downloadriscv-isa-sim-4b0e34e0135b94171c1a81cdfc292d70e237a7b1.zip
riscv-isa-sim-4b0e34e0135b94171c1a81cdfc292d70e237a7b1.tar.gz
riscv-isa-sim-4b0e34e0135b94171c1a81cdfc292d70e237a7b1.tar.bz2
Merge pull request #1279 from riscv-software-src/jerryz123-patch-1
Improve ctrlc responsiveness in interactive mode
-rw-r--r--riscv/interactive.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/riscv/interactive.cc b/riscv/interactive.cc
index 8ad7592..d9fb39b 100644
--- a/riscv/interactive.cc
+++ b/riscv/interactive.cc
@@ -252,7 +252,13 @@ static std::string readline(int fd)
void sim_t::interactive()
{
+ if (ctrlc_pressed) {
+ next_interactive_action = std::nullopt;
+ ctrlc_pressed = false;
+ }
+
if (next_interactive_action.has_value()) {
+ ctrlc_pressed = false;
auto f = next_interactive_action.value();
next_interactive_action = std::nullopt;
return f();
@@ -400,14 +406,13 @@ void sim_t::interactive_run_silent(const std::string& cmd, const std::vector<std
void sim_t::interactive_run(const std::string& cmd, const std::vector<std::string>& args, bool noisy)
{
size_t steps = args.size() ? atoll(args[0].c_str()) : -1;
- ctrlc_pressed = false;
set_procs_debug(noisy);
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 && !ctrlc_pressed) {
+ if (actual_steps < steps) {
next_interactive_action = [=](){ interactive_run(cmd, {std::to_string(steps - actual_steps)}, noisy); };
return;
}
@@ -741,8 +746,6 @@ void sim_t::interactive_until(const std::string& cmd, const std::vector<std::str
if (func == NULL)
throw trap_interactive();
- ctrlc_pressed = false;
-
for (size_t i = 0; i < INTERLEAVE; i++)
{
try