1 # Copyright 2008-2019 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 'until' and
17 # 'advance' in reverse debugging.
19 if ![supports_reverse] {
23 standard_testfile .c ur1.c
25 if { [prepare_for_testing "failed to prepare" $testfile \
26 [list $srcfile $srcfile2]] } {
30 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
31 set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
32 set bp_location8 [gdb_get_line_number "set breakpoint 8 here" "$srcfile2"]
33 set bp_location19 [gdb_get_line_number "set breakpoint 19 here"]
34 set bp_location20 [gdb_get_line_number "set breakpoint 20 here"]
35 set bp_location21 [gdb_get_line_number "set breakpoint 21 here"]
39 if [supports_process_record] {
40 # Activate process record/replay
41 gdb_test_no_output "record" "turn on process record"
44 # Verify that plain vanilla "until <location>" works.
46 gdb_test "until $bp_location1" \
47 "main .* at .*:$bp_location1.*" \
50 # Advance up to factorial, outer invocation
52 set test "advance to factorial"
53 set pass_pattern "factorial .value=6..*$srcfile:$bp_location7.*"
54 set kfail_pattern "Process record does not support instruction 0xfae64 at.*"
55 gdb_test_multiple "advance factorial" $test {
56 -re "\[\r\n\]*(?:$pass_pattern)\[\r\n\]+$gdb_prompt $" {
59 -re "\[\r\n\]*(?:$kfail_pattern)\[\r\n\]+$gdb_prompt $" {
60 kfail "gdb/25038" $test
65 # At this point, 'until' should continue the inferior up to when all the
66 # inner invocations of factorial() are completed and we are back at this
69 gdb_test "until $bp_location19" \
70 "factorial .value=720.*${srcfile}:$bp_location19.*" \
71 "until factorial, recursive function"
73 # Finish out to main scope
76 "main .*$srcfile:.*" \
79 # Advance to a function called by main (marker2)
81 gdb_test "advance marker2" \
82 "marker2 .a=43.*$srcfile2:$bp_location8.*" \
85 # Now issue an until with another function, not called by the current
86 # frame, as argument. This should not work, i.e. the program should
87 # stop at main, the caller, where we put the 'guard' breakpoint.
89 set test_msg "until func, not called by current frame"
90 gdb_test_multiple "until marker3" "$test_msg" {
91 -re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" {
94 -re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" {
103 # Set reverse execution direction
105 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
108 # We should now be at main, after the return from marker2.
109 # "Advance" backward into marker2.
112 gdb_test "advance marker2" \
113 "marker2 .a=43.*$srcfile2:$bp_location8.*" \
114 "reverse-advance to marker2"
116 # Finish out to main scope (backward)
119 " in main .*$srcfile:$bp_location20.*" \
120 "reverse-finish from marker2"
122 # Advance backward to last line of factorial (outer invocation)
124 gdb_test "advance $bp_location19" \
125 "factorial .value=720.*${srcfile}:$bp_location19.*" \
126 "reverse-advance to final return of factorial"
128 # Now do "until" across the recursive calls,
129 # ending up in the same frame where we are now.
131 gdb_test "until $bp_location7" \
132 "factorial .value=6..*$srcfile:$bp_location7.*" \
133 "reverse-until to entry of factorial"