Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.reverse / time-reverse.exp
blob35415a0fe1f4fadbd7f0364207aa773ece359134
1 # Copyright 2015-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 # This file is part of the gdb testsuite.
19 # This test tests time syscall for reverse execution.
22 require supports_reverse
24 standard_testfile
26 # MODE is either "syscall" for testing the time syscall explicitly, or
27 # "c" for testing the C time(2) function.
28 proc test {mode} {
29     set options {debug}
31     if {$mode == "syscall"} {
32         lappend options additional_flags=-DUSE_SYSCALL
33     } elseif {$mode != "c"} {
34         error "unrecognized mode: $mode"
35     }
37     if { [prepare_for_testing "failed to prepare" $::testfile-$mode $::srcfile $options] } {
38         return
39     }
41     runto marker1
43     if [supports_process_record] {
44         # Activate process record/replay
45         gdb_test_no_output "record" "turn on process record"
46     }
48     gdb_test "break marker2" \
49         "Breakpoint $::decimal at $::hex: file .*$::srcfile, line $::decimal.*" \
50         "set breakpoint at marker2"
52     gdb_continue_to_breakpoint "marker2" ".*$::srcfile:.*"
54     # Show how many instructions we've recorded.
55     gdb_test "info record" "Active record target: .*"
57     gdb_test "reverse-continue" ".*$::srcfile:$::decimal.*" "reverse to marker1"
59     # If the variable was recorded properly, the old contents (-1)
60     # will be remembered.  If not, new contents (current time) will be
61     # used, and the test will fail.
63     gdb_test "print time_global" ".* = -1" "check time record"
66 # Test both using the syscall explicitly, and using the time(2) C
67 # function.
69 # The C variant ensures that if some platform uses some syscall we are
70 # not aware of yet, we'll still exercise it (and likely fail).
72 # The explicit syscall variant is useful on platforms where the C
73 # function does not call a syscall at all by default, e.g., on some
74 # systems the C time function wraps an implementation provided by the
75 # vDSO.
77 foreach_with_prefix mode {syscall c} {
78     if {$mode == "syscall" && ![have_syscall time]} {
79         continue
80     }
82     test $mode