Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix seek-ticks when already at the target event #3522

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix seek-ticks when already at the target event
  • Loading branch information
dzaima committed May 15, 2023
commit 9d75cec193d51c9dea9069d2da98b1088a90668f
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()