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