]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.reverse/time-reverse.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / time-reverse.exp
1 # Copyright 2015-2024 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
15
16 # This file is part of the gdb testsuite.
17
18 #
19 # This test tests time syscall for reverse execution.
20 #
21
22 require supports_reverse
23
24 standard_testfile
25
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}
30
31 if {$mode == "syscall"} {
32 lappend options additional_flags=-DUSE_SYSCALL
33 } elseif {$mode != "c"} {
34 error "unrecognized mode: $mode"
35 }
36
37 if { [prepare_for_testing "failed to prepare" $::testfile-$mode $::srcfile $options] } {
38 return
39 }
40
41 runto_main
42
43 if [supports_process_record] {
44 # Activate process record/replay
45 gdb_test_no_output "record" "turn on process record"
46 }
47
48 gdb_test "break marker2" \
49 "Breakpoint $::decimal at $::hex: file .*$::srcfile, line $::decimal.*" \
50 "set breakpoint at marker2"
51
52 gdb_continue_to_breakpoint "marker2" ".*$::srcfile:.*"
53
54 gdb_test "break marker1" \
55 "Breakpoint $::decimal at $::hex: file .*$::srcfile, line $::decimal.*" \
56 "set breakpoint at marker1"
57
58 gdb_test "reverse-continue" ".*$::srcfile:$::decimal.*" "reverse to marker1"
59
60 # If the variable was recorded properly, the old contents (-1)
61 # will be remembered. If not, new contents (current time) will be
62 # used, and the test will fail.
63
64 gdb_test "print time_global" ".* = -1" "check time record"
65 }
66
67 # Test both using the syscall explicitly, and using the time(2) C
68 # function.
69 #
70 # The C variant ensures that if some platform uses some syscall we are
71 # not aware of yet, we'll still exercise it (and likely fail).
72 #
73 # The explicit syscall variant is useful on platforms where the C
74 # function does not call a syscall at all by default, e.g., on some
75 # systems the C time function wraps an implementation provided by the
76 # vDSO.
77
78 foreach_with_prefix mode {syscall c} {
79 if {$mode == "syscall" && ![have_syscall time]} {
80 continue
81 }
82
83 test $mode
84 }