1 # Copyright 2008-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. It tests reverse debugging
17 # with breakpoints in a process record logfile.
19 # This test suitable only for process record-replay
20 require supports_process_record
22 standard_testfile break-reverse.c
23 set precsave [standard_output_file break.precsave]
25 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
29 set foo_location [gdb_get_line_number "break in foo" ]
30 set bar_location [gdb_get_line_number "break in bar" ]
31 set main_location [gdb_get_line_number "break in main"]
32 set end_location [gdb_get_line_number "end of main" ]
34 proc precsave_tests {} {
35 global foo_location bar_location main_location end_location
36 global decimal srcfile precsave gdb_prompt
40 # Activate process record/replay
41 gdb_test_no_output "record" "turn on process record"
43 gdb_test "break $end_location" \
44 "Breakpoint $decimal at .*$srcfile, line $end_location\." \
47 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
49 gdb_test "record save $precsave" \
50 "Saved core file $precsave with execution log\." \
51 "save process recfile"
53 gdb_test "kill" "" "kill process, prepare to debug log file" \
54 "Kill the program being debugged\\? \\(y or n\\) " "y"
56 gdb_test "record restore $precsave" \
57 "Restored records from core file .*" \
58 "reload precord save file"
60 gdb_test "break foo" \
61 "Breakpoint $decimal at .* line $foo_location\." \
62 "set breakpoint on foo"
64 gdb_test "break bar" \
65 "Breakpoint $decimal at .* line $bar_location\." \
66 "set breakpoint on bar"
68 gdb_continue_to_breakpoint "foo forward after restore" \
69 ".*$srcfile:$foo_location.*"
70 gdb_continue_to_breakpoint "bar forward after restore" \
71 ".*$srcfile:$bar_location.*"
72 gdb_test_multiple "continue" "go to end of main forward" {
73 -re ".*Breakpoint $decimal,.*$srcfile:$end_location.*$gdb_prompt $" {
74 pass "go to end of main forward"
76 -re -wrap "Reached end of recorded.*Following forward.* end of main .*" {
77 pass "go to end of main forward"
81 gdb_test_no_output "set exec-direction reverse" "set reverse"
83 gdb_continue_to_breakpoint "bar backward" ".*$srcfile:$bar_location.*"
84 gdb_continue_to_breakpoint "foo backward" ".*$srcfile:$foo_location.*"
86 gdb_test_multiple "continue" "main backward" {
87 -re ".*Breakpoint $decimal,.*$srcfile:$main_location.*$gdb_prompt $" {
90 -re -wrap "Reached end of recorded.*Backward execution.* break in main .*" {
95 gdb_test_no_output "set exec-direction forward" "set forward"
97 gdb_continue_to_breakpoint "foo forward again" \
98 ".*$srcfile:$foo_location.*"
99 gdb_continue_to_breakpoint "bar forward again" \
100 ".*$srcfile:$bar_location.*"
102 gdb_test_multiple "continue" "end of record log" {
103 -re ".*Breakpoint $decimal,.*$srcfile:$end_location.*$gdb_prompt $" {
104 pass "end of record log"
106 -re -wrap "Reached end of recorded.*Following forward.* end of main .*" {
107 pass "end of record log"