Skip to content
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
15 changes: 15 additions & 0 deletions src/DebuggerExtensionCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@ static SimpleDebuggerExtensionCommand info_recording(
return string("Path of recording: \"") + json_escape(trace_dir) + string("\"");
});

static SimpleDebuggerExtensionCommand when_end(
"when-end", "Print the number of the last rr event in the recording.",
[](GdbServer&, Task* t, const vector<string>&) {
auto task = static_cast<ReplayTask*>(t);
auto seek_reader(task->session().as_replay()->trace_reader());
FrameTime time;
for (;;) {
auto result = seek_reader.read_task_event(&time);
if (result.type() == TraceTaskEvent::Type::NONE) {
break;
}
}
return string("Event at end of recording: ") + to_string(time);
});

static std::vector<ReplayTimeline::Mark> back_stack;
static ReplayTimeline::Mark current_history_cp;
static std::vector<ReplayTimeline::Mark> forward_stack;
Expand Down
27 changes: 27 additions & 0 deletions src/test/when.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from util import *
import re

send_custom_command('when-end')
expect_debugger(re.compile(r'Event at end of recording: (\d+)'))
first_when_end_result = int(last_match().group(1))
# Check this value after running the program for a bit.

send_custom_command('when')
expect_debugger(re.compile(r'Completed event: (\d+)'))
t = int(last_match().group(1))
Expand Down Expand Up @@ -43,6 +48,10 @@
if tid2 != tid:
failed('ERROR ... tid changed')

send_custom_command('when-end')
expect_debugger(re.compile(r'Event at end of recording: (\d+)'))
second_when_end_result = int(last_match().group(1))

# Ensure 'when' terminates a diversion
expect_expression('(int)strlen("abcd")', 4)
send_custom_command('when')
Expand All @@ -65,4 +74,22 @@
if tid3 != tid2:
failed('ERROR ... diversion changed tid')

stepi()

send_custom_command('when-end')
expect_debugger(re.compile(r'Event at end of recording: (\d+)'))
final_when_end_result = int(last_match().group(1))

if first_when_end_result != second_when_end_result:
failed("ERROR ... first when-end result differs from second when-end result")
if second_when_end_result != final_when_end_result:
failed("ERROR ... second when-end result differs from final when-end result")

if t >= first_when_end_result:
failed("ERROR ... First when result was after when-end")
if t3 >= first_when_end_result:
failed("ERROR ... Second when result was after when-end")
if t3 >= first_when_end_result:
failed("ERROR ... Third when result was after when-end")

ok()
Loading