Skip to content

Commit ddceba5

Browse files
committed
Add informational commands: absolute-time, when-end, info recording
absolute-time gives the absolute monotonic clock time from the current event. This is useful when you want to align events with a perf recording that also uses the monotonic clock (you still have to scale by 1000000000 of course.) when-end gives the event number of the last event in the whole recording. This is useful when running a replay with non-stopping breakpoints and displaying the "progress" of the replay to the user. info recording prints out the path of the recording folder. This is useful for running additional `rr replay` sessions from an existing one, or for calling `rr dump` to get data that is not otherwise surfaced by any gdb commands.
1 parent ed838f5 commit ddceba5

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

‎src/DebuggerExtensionCommand.cc‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#include "DebuggerExtensionCommand.h"
44

55
#include "ReplayTask.h"
6+
#include "TraceFrame.h"
67
#include "log.h"
8+
#include "util.h"
79

810
using namespace std;
911

@@ -25,6 +27,21 @@ static SimpleDebuggerExtensionCommand elapsed_time(
2527
return string("Elapsed Time (s): ") + to_string(elapsed_time);
2628
});
2729

30+
static SimpleDebuggerExtensionCommand absolute_time(
31+
"absolute-time",
32+
"Print absolute time (in seconds) from the monotonic clock in the"
33+
" 'record' timeline.",
34+
[](GdbServer&, Task* t, const vector<string>&) {
35+
if (!t->session().is_replaying()) {
36+
return DebuggerExtensionCommandHandler::cmd_end_diversion();
37+
}
38+
39+
ReplayTask* replay_t = static_cast<ReplayTask*>(t);
40+
double elapsed_time = replay_t->session().get_trace_start_time();
41+
42+
return string("Absolute Time (s): ") + to_string(elapsed_time);
43+
});
44+
2845
static SimpleDebuggerExtensionCommand when(
2946
"when", "Print the number of the last completely replayed rr event.",
3047
[](GdbServer&, Task* t, const vector<string>&) {
@@ -56,6 +73,41 @@ static SimpleDebuggerExtensionCommand when_tid(
5673
return string("Current tid: ") + to_string(t->tid);
5774
});
5875

76+
static SimpleDebuggerExtensionCommand when_end(
77+
"when-end", "Print the number of the last rr event in the recording.",
78+
[](GdbServer&, Task* t, const vector<string>&) {
79+
if (!t->session().is_replaying()) {
80+
return DebuggerExtensionCommandHandler::cmd_end_diversion();
81+
}
82+
83+
ReplayTask* task = static_cast<ReplayTask*>(t);
84+
TraceReader seek_reader(task->session().as_replay()->trace_reader());
85+
FrameTime time;
86+
for (;;) {
87+
auto result = seek_reader.read_task_event(&time);
88+
if (result.type() == TraceTaskEvent::Type::NONE) {
89+
break;
90+
}
91+
}
92+
return string("Event at end of Recording: ") + to_string(time);
93+
});
94+
95+
static SimpleDebuggerExtensionCommand info_recording(
96+
"info recording",
97+
"Print the path of the recording RR is"
98+
" currently replaying.",
99+
[](GdbServer&, Task* t, const vector<string>&) {
100+
if (!t->session().is_replaying()) {
101+
return DebuggerExtensionCommandHandler::cmd_end_diversion();
102+
}
103+
104+
ReplayTask* task = static_cast<ReplayTask*>(t);
105+
auto trace_dir = task->session().as_replay()->trace_reader().dir();
106+
107+
return string("Path of Recording: \"") + json_escape(trace_dir) +
108+
string("\"");
109+
});
110+
59111
static std::vector<ReplayTimeline::Mark> back_stack;
60112
static ReplayTimeline::Mark current_history_cp;
61113
static std::vector<ReplayTimeline::Mark> forward_stack;

0 commit comments

Comments
 (0)