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