Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.reverse / break-precsave.exp
CommitLineData
88b9d363 1# Copyright 2008-2022 Free Software Foundation, Inc.
02506ff1
MS
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. It tests reverse debugging
17# with breakpoints in a process record logfile.
18
19# This test suitable only for process record-replay
d3895d7d 20if ![supports_process_record] {
02506ff1
MS
21 return
22}
23
7686c074 24standard_testfile break-reverse.c
55baab26 25set precsave [standard_output_file break.precsave]
02506ff1 26
5b362f04 27if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
02506ff1
MS
28 return -1
29}
30
31set foo_location [gdb_get_line_number "break in foo" ]
32set bar_location [gdb_get_line_number "break in bar" ]
33set main_location [gdb_get_line_number "break in main"]
34set end_location [gdb_get_line_number "end of main" ]
35
b3ccfe11
TT
36proc precsave_tests {} {
37 global foo_location bar_location main_location end_location
38 global decimal srcfile precsave gdb_prompt
02506ff1 39
50441f0f 40 runto_main
02506ff1 41
b3ccfe11
TT
42 if [supports_process_record] {
43 # Activate process record/replay
9f058c10 44 gdb_test_no_output "record" "turn on process record"
b3ccfe11 45 }
02506ff1 46
b3ccfe11 47 gdb_test "break $end_location" \
a80db015 48 "Breakpoint $decimal at .*$srcfile, line $end_location\." \
b3ccfe11 49 "BP at end of main"
02506ff1 50
b3ccfe11 51 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
02506ff1 52
b3ccfe11
TT
53 gdb_test "record save $precsave" \
54 "Saved core file $precsave with execution log\." \
55 "save process recfile"
02506ff1 56
cdc7edd7 57 gdb_test "kill" "" "kill process, prepare to debug log file" \
b3ccfe11 58 "Kill the program being debugged\\? \\(y or n\\) " "y"
02506ff1 59
b3ccfe11 60 gdb_test "record restore $precsave" \
470e2f4e 61 "Restored records from core file .*" \
b3ccfe11 62 "reload precord save file"
02506ff1 63
b3ccfe11
TT
64 gdb_test "break foo" \
65 "Breakpoint $decimal at .* line $foo_location\." \
66 "set breakpoint on foo"
02506ff1 67
b3ccfe11
TT
68 gdb_test "break bar" \
69 "Breakpoint $decimal at .* line $bar_location\." \
70 "set breakpoint on bar"
71
4d421147
AB
72 gdb_continue_to_breakpoint "foo forward after restore" \
73 ".*$srcfile:$foo_location.*"
74 gdb_continue_to_breakpoint "bar forward after restore" \
75 ".*$srcfile:$bar_location.*"
b3ccfe11 76 gdb_test_multiple "continue" "go to end of main forward" {
a80db015 77 -re ".*Breakpoint $decimal,.*$srcfile:$end_location.*$gdb_prompt $" {
b3ccfe11
TT
78 pass "go to end of main forward"
79 }
80 -re "No more reverse-execution history.* end of main .*$gdb_prompt $" {
81 pass "go to end of main forward"
82 }
02506ff1 83 }
02506ff1 84
b3ccfe11 85 gdb_test_no_output "set exec-direction reverse" "set reverse"
02506ff1 86
a80db015
LM
87 gdb_continue_to_breakpoint "bar backward" ".*$srcfile:$bar_location.*"
88 gdb_continue_to_breakpoint "foo backward" ".*$srcfile:$foo_location.*"
02506ff1 89
b3ccfe11 90 gdb_test_multiple "continue" "main backward" {
a80db015 91 -re ".*Breakpoint $decimal,.*$srcfile:$main_location.*$gdb_prompt $" {
b3ccfe11
TT
92 pass "main backward"
93 }
94 -re "No more reverse-execution history.* break in main .*$gdb_prompt $" {
95 pass "main backward"
96 }
02506ff1 97 }
02506ff1 98
b3ccfe11 99 gdb_test_no_output "set exec-direction forward" "set forward"
02506ff1 100
4d421147
AB
101 gdb_continue_to_breakpoint "foo forward again" \
102 ".*$srcfile:$foo_location.*"
103 gdb_continue_to_breakpoint "bar forward again" \
104 ".*$srcfile:$bar_location.*"
02506ff1 105
b3ccfe11 106 gdb_test_multiple "continue" "end of record log" {
a80db015 107 -re ".*Breakpoint $decimal,.*$srcfile:$end_location.*$gdb_prompt $" {
b3ccfe11
TT
108 pass "end of record log"
109 }
110 -re "No more reverse-execution history.* end of main .*$gdb_prompt $" {
111 pass "end of record log"
112 }
02506ff1
MS
113 }
114}
b3ccfe11
TT
115
116precsave_tests
This page took 1.608325 seconds and 4 git commands to generate.