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
19 require supports_reverse
23 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
27 set foo_location [gdb_get_line_number "break in foo" ]
28 set bar_location [gdb_get_line_number "break in bar" ]
29 set main_location [gdb_get_line_number "break in main"]
30 set end_location [gdb_get_line_number "end of main" ]
34 if [supports_process_record] {
35 # Activate process record/replay
36 gdb_test_no_output "record" "turn on process record"
39 gdb_test "break foo" \
40 "Breakpoint $decimal at .* line $foo_location\." \
41 "set breakpoint on foo"
43 gdb_test "break bar" \
44 "Breakpoint $decimal at .* line $bar_location\." \
45 "set breakpoint on bar"
47 gdb_test "break $end_location" \
48 "Breakpoint $decimal at .* line $end_location\." \
49 "set breakpoint at end of main"
51 gdb_continue_to_breakpoint "foo forward, the first time" \
52 ".*$srcfile:$foo_location.*"
53 gdb_continue_to_breakpoint "bar forward, the first time" \
54 ".*$srcfile:$bar_location.*"
55 gdb_continue_to_breakpoint "end forward, the first time" \
56 ".*$srcfile:$end_location.*"
58 gdb_test_no_output "set exec-direction reverse" "set reverse"
60 gdb_continue_to_breakpoint "bar backward" ".*$srcfile:$bar_location.*"
61 gdb_continue_to_breakpoint "foo backward" ".*$srcfile:$foo_location.*"
63 gdb_test_multiple "continue" "main backward" {
64 -re ".*Breakpoint $decimal,.*$srcfile:$main_location.*$gdb_prompt $" {
67 -re "No more reverse-execution history.* break in main .*$gdb_prompt $" {
72 gdb_test_no_output "set exec-direction forward" "set forward"
74 gdb_continue_to_breakpoint "foo forward again" \
75 ".*$srcfile:$foo_location.*"
76 gdb_continue_to_breakpoint "bar forward again" \
77 ".*$srcfile:$bar_location.*"
79 gdb_test_multiple "continue" "end of record log" {
80 -re ".*Breakpoint $decimal,.*$srcfile:$end_location.*$gdb_prompt $" {
81 pass "end of record log"
83 -re "No more reverse-execution history.* end of main .*$gdb_prompt $" {
84 pass "end of record log"