]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/until-reverse.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / until-reverse.exp
CommitLineData
42a4f53d 1# Copyright 2008-2019 Free Software Foundation, Inc.
28d41a99
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 'until' and
17# 'advance' in reverse debugging.
18
d3895d7d 19if ![supports_reverse] {
28d41a99
MS
20 return
21}
22
7686c074 23standard_testfile .c ur1.c
28d41a99 24
5b362f04 25if { [prepare_for_testing "failed to prepare" $testfile \
7686c074 26 [list $srcfile $srcfile2]] } {
28d41a99
MS
27 return -1
28}
29
30set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
31set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
dc7e1a77 32set bp_location8 [gdb_get_line_number "set breakpoint 8 here" "$srcfile2"]
28d41a99
MS
33set bp_location19 [gdb_get_line_number "set breakpoint 19 here"]
34set bp_location20 [gdb_get_line_number "set breakpoint 20 here"]
35set bp_location21 [gdb_get_line_number "set breakpoint 21 here"]
36
37runto main
38
d3895d7d 39if [supports_process_record] {
28d41a99 40 # Activate process record/replay
9f058c10 41 gdb_test_no_output "record" "turn on process record"
28d41a99
MS
42}
43
44# Verify that plain vanilla "until <location>" works.
45#
46gdb_test "until $bp_location1" \
47 "main .* at .*:$bp_location1.*" \
48 "until line number"
49
50# Advance up to factorial, outer invocation
51#
52gdb_test "advance factorial" \
53 "factorial .value=6..*$srcfile:$bp_location7.*" \
54 "advance to factorial"
55
56# At this point, 'until' should continue the inferior up to when all the
57# inner invocations of factorial() are completed and we are back at this
58# frame.
59#
60gdb_test "until $bp_location19" \
61 "factorial .value=720.*${srcfile}:$bp_location19.*" \
62 "until factorial, recursive function"
63
64# Finish out to main scope
65#
66gdb_test "finish" \
e6359af3 67 "main .*$srcfile:.*" \
28d41a99
MS
68 "finish to main"
69
70# Advance to a function called by main (marker2)
71#
72gdb_test "advance marker2" \
dc7e1a77 73 "marker2 .a=43.*$srcfile2:$bp_location8.*" \
28d41a99
MS
74 "advance to marker2"
75
76# Now issue an until with another function, not called by the current
77# frame, as argument. This should not work, i.e. the program should
78# stop at main, the caller, where we put the 'guard' breakpoint.
79#
80set test_msg "until func, not called by current frame"
81gdb_test_multiple "until marker3" "$test_msg" {
82 -re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" {
83 pass "$test_msg"
84 }
85 -re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" {
86 pass "$test_msg"
87 }
88}
89
90###
91###
92###
93
94# Set reverse execution direction
28d41a99 95
bcd2dc50 96gdb_test_no_output "set exec-dir reverse" "set reverse execution"
28d41a99
MS
97
98#
99# We should now be at main, after the return from marker2.
100# "Advance" backward into marker2.
101#
102
103gdb_test "advance marker2" \
dc7e1a77 104 "marker2 .a=43.*$srcfile2:$bp_location8.*" \
28d41a99
MS
105 "reverse-advance to marker2"
106
107# Finish out to main scope (backward)
108
109gdb_test "finish" \
110 " in main .*$srcfile:$bp_location20.*" \
111 "reverse-finish from marker2"
112
113# Advance backward to last line of factorial (outer invocation)
114
115gdb_test "advance $bp_location19" \
116 "factorial .value=720.*${srcfile}:$bp_location19.*" \
117 "reverse-advance to final return of factorial"
118
119# Now do "until" across the recursive calls,
120# ending up in the same frame where we are now.
121
122gdb_test "until $bp_location7" \
123 "factorial .value=6..*$srcfile:$bp_location7.*" \
124 "reverse-until to entry of factorial"