There are some situations in which the user may try to do some things
that record-full doesn't quite support. Previously, we'd just chug
along, with either poor results or even corrupting the state of the
inferior.
One of these situations would be stopping recording in the past. In
situations like these, if the inferior was dealing with resources like
sockets, connections or files, the inferior could be confused about
the situation, such as rewriting things in a file or re-sending
information to servers. And now that GDB supports reviving threads,
the user could return to a moment before the thread exited, so the
program believes a thread exists but the kernel has made it exit
already. However, there are also reasonable situations where a user
can do that, such as when none of those resources are changed and the
user wishes to supply a different value and examine the execution. So
we now query the user on whether they are sure they want to do this.
This change required many updates to the testsuite, as it turns out
there are several points at which we delete the recording in the
past. These are trivial changes.
Another unsupported use case is recording the creation of a
thread. There's no mechanism to return to a stage before the thread
existed, for example. And more pressing, when creating a corefile with
the history log, we return to the start of history and dump the
current stage, which means the thread may not be dumped, or regcache
may assert. This commit identifies the syscalls that can create a
thread and error, causing recording to stop.
This caused an issue to the waitpid-reverse.exp test. In my machine,
despite using fork, we were triggering the error in the clone
syscall. To avoid any possible issues, since the point of the test is
only checking the waitpid syscall, not our ability to record a fork,
the testcase was slightly changed to start recording after the fork
call.
Finally, a user could try to use the `set scheduler-locking' command
while replaying the inferior. Until now, it wasn't a big deal, as not
supporting multi-threaded inferiors in the first place was a more
pressing issue. However, now that we do support it, we should be more
careful about what we let the user select. For now, there's no way for
the record subsystem to manage multiple threads executing at once, and
so, we warn at any point when we could be recording or
replaying.
---
gdb/infrun.c | 2 ++
gdb/linux-record.c | 5 ++-
gdb/record.c | 6 ++++
.../gdb.reverse/basic-record-full.exp | 5 +--
.../gdb.reverse/finish-reverse-next.exp | 10 +++---
.../gdb.reverse/i386-avx-reverse.exp | 36 ++++++++++---------
gdb/testsuite/gdb.reverse/insn-reverse.exp | 3 +-
gdb/testsuite/gdb.reverse/waitpid-reverse.c | 3 +-
gdb/testsuite/gdb.reverse/waitpid-reverse.exp | 10 +++---
9 files changed, 49 insertions(+), 31 deletions(-)
@@ -2407,6 +2407,8 @@ set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c)
error (_("Target '%s' cannot support this command."),
target_shortname ());
}
+ else if (record_full_is_replaying () || record_full_is_recording ())
+ error (_("Changing the scheduler will have no effect while replaying."));
}
/* True if execution commands resume all threads of all processes by
@@ -1181,10 +1181,13 @@ Do you want to stop the program?"),
case gdb_sys_fsync:
case gdb_sys_sigreturn:
- case gdb_sys_clone:
case gdb_sys_setdomainname:
break;
+ case gdb_sys_clone:
+ error (_("Recording the creation of a thread is unsupported."));
+ break;
+
case gdb_sys_newuname:
if (record_mem_at_reg (regcache, tdep->arg1,
tdep->size_new_utsname))
@@ -28,6 +28,7 @@
#include "disasm.h"
#include "interps.h"
#include "top.h"
+#include "record-full.h"
/* This is the debug switch for process record. */
@@ -314,6 +315,11 @@ static void
cmd_record_stop (const char *args, int from_tty)
{
struct target_ops *t = require_record_target ();
+ if (record_full_is_replaying ()
+ && !query (_("Removing the history at this point may leave the inferior "
+ "in an irrecoverable state. Are you sure?")))
+ error (_("Not deleting the history"));
+
bool thread_moved = record_stop (t);
record_unpush (t);
@@ -36,6 +36,7 @@ gdb_test_no_output "record" "turn on process record"
gdb_test "show exec-dir" "Forward." "Before any change"
gdb_test_no_output "set exec-direction reverse"
gdb_test "show exec-dir" "Reverse." "Setting direction by hand"
-gdb_test "recor stop" \
- "Process record is stopped and all execution logs are deleted."
+gdb_test "record stop" \
+ "Process record is stopped and all execution logs are deleted." \
+ "stopping record" ".*Are you sure?.*" "y"
gdb_test "show exec-dir" "Forward." "After stopping record"
@@ -85,8 +85,8 @@ gdb_test "reverse-next" ".*b = 5;.*" "reverse next 2, at b = 5, call from LEP"
gdb_test "reverse-continue" ".*" "setup for test 2"
# Turn off record to clear logs and turn on again
-gdb_test "record stop" "Process record is stopped.*" \
- "turn off process record for test1"
+gdb_test "record stop" ".*" \
+ "turn off process record for test1" ".*Are you sure?.*" "y"
gdb_test_no_output "record" "turn on process record for test2"
@@ -115,7 +115,7 @@ gdb_test "reverse-continue" ".*" "setup for test 3"
# Turn off record to clear logs and turn on again
gdb_test "record stop" "Process record is stopped.*" \
- "turn off process record for test2"
+ "turn off process record for test2" ".*Are you sure?.*" "y"
gdb_test_no_output "record" "turn on process record for test3"
@@ -145,7 +145,7 @@ gdb_test "reverse-continue" ".*" "setup for test 4"
# Turn off record to clear logs and turn on again
gdb_test "record stop" "Process record is stopped.*" \
- "turn off process record for test3"
+ "turn off process record for test3" ".*Are you sure?.*" "y"
gdb_test_no_output "record" "turn on process record for test4"
### TEST 4: reverse finish from between the GEP and LEP in
@@ -178,7 +178,7 @@ gdb_test "reverse-continue" ".*" "setup for test 5"
# Turn off record to clear logs and turn on again
gdb_test "record stop" "Process record is stopped.*" \
- "turn off process record for test4"
+ "turn off process record for test4" ".*Are you sure?.*" "y"
gdb_test_no_output "record" "turn on process record for test5"
@@ -132,6 +132,8 @@ proc record_full_function {function} {
}
}
+ # Since there was no backwards execution here, there shouldn't be a
+ # query from GDB.
gdb_test "record stop" "Process record is stopped.*" \
"delete failed record history"
# If we didn't exit early, the temporary breakpoint at the end of
@@ -313,7 +315,7 @@ if {[record_full_function "vmov"] == true} {
# Stop recording to get a clean history.
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vmov_test"
+ "delete history for vmov_test" ".*Are you sure?.*" "y"
} else {
untested "could not record vmov_test"
}
@@ -379,7 +381,7 @@ if {[record_full_function "vpunpck"] == true} {
# Move to the end of vmov_test to set up next.
# Stop recording in case of recording errors.
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vpunpck_test"
+ "delete history for vpunpck_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't test vpunpck tests"
}
@@ -425,7 +427,7 @@ if {[record_full_function "vpbroadcast"] == true} {
test_one_register "vpbroadcastb" "ymm0" "0x0, 0x0"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vpbroadcast_test"
+ "delete history for vpbroadcast_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run vpbroadcast tests"
}
@@ -495,7 +497,7 @@ if {[record_full_function "vpor_xor"] == true} {
test_one_register "vpxor" "ymm0" "0x0, 0x12345" "second: "
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vpor_xor_test"
+ "delete history for vpor_xor_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run vpor_xor tests"
}
@@ -540,7 +542,7 @@ if {[record_full_function "vpcmpeq"] == true} {
test_one_register "vpcmpeqb" "ymm0" "0x12345, 0x12345" "xmm: "
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vpcmpeq_test"
+ "delete history for vpcmpeq_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run vpcmpeq tests"
}
@@ -561,7 +563,7 @@ if {[record_full_function "vpmovmskb"] == true} {
test_one_general_register "vpmovmskb" "rax" "0x0"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vpmovmskb_test"
+ "delete history for vpmovmskb_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run vpmovmskb tests"
}
@@ -700,7 +702,7 @@ if {[record_full_function "arith"] == true} {
test_one_register "vaddps" "ymm15" "0x0, 0x0" "xmm operation: "
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for arith_test"
+ "delete history for arith_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run arith tests"
}
@@ -735,7 +737,7 @@ if {[record_full_function "vaddsubpd"] == true} {
"0xcafeface, 0xcafeface" "ymm0: "
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vaddsubpd_test"
+ "delete history for vaddsubpd_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run vaddsubpd tests"
}
@@ -770,7 +772,7 @@ if {[record_full_function "vaddsubps"] == true} {
"0xcafeface, 0xcafeface" "ymm2: "
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for vaddsubps_test"
+ "delete history for vaddsubps_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run vaddsubps tests"
}
@@ -861,7 +863,7 @@ if {[record_full_function "shift"] == true} {
test_one_register "vpsllw" "ymm0" "0x0, 0x0" "from constant: "
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for shift_test"
+ "delete history for shift_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run shift tests"
}
@@ -915,7 +917,7 @@ if {[record_full_function "shuffle"] == true} {
test_one_register "vpshufb" "ymm0" "0x0, 0x0" "low register: "
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for shuffle_test"
+ "delete history for shuffle_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run shuffle tests"
}
@@ -985,7 +987,7 @@ if {[record_full_function "permute"] == true} {
test_one_register "vperm2f128" "ymm0" "0x0, 0x0"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for permute_test"
+ "delete history for permute_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run permute tests"
}
@@ -1040,7 +1042,7 @@ if {[record_full_function "extract_insert"] == true} {
"0x0, 0x0"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for extract_insert_test"
+ "delete history for extract_insert_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run extract_insert tests"
}
@@ -1080,7 +1082,7 @@ if {[record_full_function "blend"] == true} {
test_one_register "vblendps" "ymm0" "0x0, 0x0"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for blend_test"
+ "delete history for blend_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run blend tests"
}
@@ -1103,7 +1105,7 @@ if {[record_full_function "compare"] == true} {
test_one_general_register "vcomisd" "eflags" "0x202"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for compare_test"
+ "delete history for compare_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run compare tests"
}
@@ -1139,7 +1141,7 @@ if {[record_full_function "pack"] == true} {
test_one_register "vpacksswb" "ymm0" "0x0, 0x0"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for pack_test"
+ "delete history for pack_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run pack tests"
}
@@ -1190,7 +1192,7 @@ if {[record_full_function "convert"] == true} {
test_one_register "vcvtdq2ps" "ymm0" "0x0, 0x0"
gdb_test "record stop" "Process record is stopped.*" \
- "delete history for convert_test"
+ "delete history for convert_test" ".*Are you sure?.*" "y"
} else {
untested "couldn't run convert tests"
}
@@ -124,7 +124,8 @@ proc test { func testcase_nr } {
}
}
}
- gdb_test "record stop"
+ gdb_test "record stop" ".*" "finishing proc" \
+ ".*Are you sure?.*" "y"
}
}
@@ -34,8 +34,9 @@ int status = -1;
int
main (void)
{
+ pid_t pid = fork ();
marker1 ();
- if (!fork ())
+ if (pid == 0)
_exit (123);
else
waitpid (-1, &status, 0);
@@ -31,6 +31,12 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
runto_main
+gdb_test "break marker1" \
+ "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
+ "set breakpoint at marker1"
+
+gdb_continue_to_breakpoint "marker1" ".*$srcfile:.*"
+
if {[supports_process_record]} {
# Activate process record/replay
gdb_test_no_output "record" "turn on process record"
@@ -42,10 +48,6 @@ gdb_test "break marker2" \
gdb_continue_to_breakpoint "marker2" ".*$srcfile:.*"
-gdb_test "break marker1" \
- "Breakpoint $decimal at $hex: file .*$srcfile, line $decimal.*" \
- "set breakpoint at marker1"
-
gdb_test "reverse-continue" ".*$srcfile:$decimal.*" "reverse to marker1"
# If the variable was recorded properly on syscall, the old contents (-1)