Skip to content

Commit 21173d6

Browse files
committed
"info recording" command that gives the path to the recording
1 parent fb97ee8 commit 21173d6

5 files changed

Lines changed: 50 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,7 @@ set(TESTS_WITH_PROGRAM
16051605
ignored_sigsegv
16061606
ignore_nested
16071607
immediate_restart
1608+
info_recording
16081609
x86/int3_ok
16091610
interrupt
16101611
intr_ptrace_decline

src/DebuggerExtensionCommand.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "ReplayTask.h"
66
#include "log.h"
7+
#include "util.h"
78

89
using namespace std;
910

@@ -56,6 +57,21 @@ static SimpleDebuggerExtensionCommand when_tid(
5657
return string("Current tid: ") + to_string(t->tid);
5758
});
5859

60+
static SimpleDebuggerExtensionCommand info_recording(
61+
"info recording",
62+
"Print the path of the recording RR is"
63+
" currently replaying.",
64+
[](GdbServer&, Task* t, const vector<string>&) {
65+
if (!t->session().is_replaying()) {
66+
return DebuggerExtensionCommandHandler::cmd_end_diversion();
67+
}
68+
69+
auto task = static_cast<ReplayTask*>(t);
70+
auto trace_dir = task->session().as_replay()->trace_reader().dir();
71+
72+
return string("Path of recording: \"") + json_escape(trace_dir) + string("\"");
73+
});
74+
5975
static std::vector<ReplayTimeline::Mark> back_stack;
6076
static ReplayTimeline::Mark current_history_cp;
6177
static std::vector<ReplayTimeline::Mark> forward_stack;

src/test/info_recording.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* -*- Mode: C; tab-width: 8; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
2+
3+
#include "util.h"
4+
5+
int main(int argc, char *argv[]) {
6+
if (argc <= 1) {
7+
atomic_puts("Hi");
8+
} else {
9+
atomic_puts(argv[1]);
10+
}
11+
return 0;
12+
}

src/test/info_recording.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from util import *
2+
3+
import re
4+
import json
5+
6+
send_gdb('info recording')
7+
expect_gdb(re.compile(r'(?<=Path of recording: ).*'))
8+
path_jsonstr = last_match().group(0)
9+
path_pystr = json.loads(path_jsonstr)
10+
11+
if len(path_pystr) < 6:
12+
failed("ERROR ... Unreasonably short path for recording file found in output")
13+
14+
# Inferior command also has the name of the binary at the end,
15+
# so the pattern matches opening but not closing paren.
16+
send_gdb("inferior")
17+
expect_gdb(f"\\({path_pystr}")
18+
19+
ok()

src/test/info_recording.run

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source `dirname $0`/util.sh
2+
debug_test_gdb_only

0 commit comments

Comments
 (0)