Skip to content

Commit

Permalink
Fix seek-ticks when already at the target event
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaima committed May 15, 2023
1 parent 7edebae commit 9d75cec
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/GdbServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,7 @@ void GdbServer::restart_session(const GdbRequest& req) {
}
}
// Forward the frame reader to the current event
last_time = ticks_start_time;
last_time = ticks_start_time + 1;
while (true) {
TraceFrame frame = tmp_reader.read_frame();
if (frame.time() >= ticks_start_time) {
Expand All @@ -1598,17 +1598,17 @@ void GdbServer::restart_session(const GdbRequest& req) {
}
while (true) {
if (tmp_reader.at_end()) {
cout << "No event found matching specified ticks target.";
cout << "No event found matching specified ticks target.\n";
dbg->notify_restart_failed();
return;
}
TraceFrame frame = tmp_reader.read_frame();
if (frame.tid() == task->tuid().tid() && frame.ticks() >= target) {
break;
}
last_time = frame.time();
last_time = frame.time() + 1;
}
timeline.seek_to_ticks(last_time + 1, target);
timeline.seek_to_ticks(last_time, target);
}

interrupt_pending = true;
Expand Down
15 changes: 15 additions & 0 deletions src/test/seekticks.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,19 @@
if ticks6 != ticks2:
failed('ERROR: Failed to seek forwards to ticks2')

if ticks2 < 4:
failed('ERROR: ticks2 too small to test nearby ticks')

tests = [ticks2, ticks2, ticks2-2, 1, 1, 0, 0, 2, 0, 2, ticks2-2, ticks2-1, ticks2-2, ticks2]

for i in range(len(tests)):
ticks7 = tests[i]
send_gdb("seek-ticks %d" % ticks7)
expect_gdb("Program stopped.")
send_gdb('when-ticks')
expect_gdb(re.compile(r'Current tick: (\d+)'))
ticks8 = eval(last_match().group(1));
if ticks8 != ticks7:
failed("ERROR: seek-ticks didn't go to correct tick on test %d" % i)

ok()

0 comments on commit 9d75cec

Please sign in to comment.