Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2008-2016 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 'until' and | |
17 | # 'advance' in precord logfile. | |
18 | ||
19 | # This test suitable only for process record-replay | |
d3895d7d | 20 | if ![supports_process_record] { |
02506ff1 MS |
21 | return |
22 | } | |
23 | ||
7686c074 | 24 | standard_testfile until-reverse.c ur1.c |
55baab26 | 25 | set precsave [standard_output_file until.precsave] |
02506ff1 | 26 | |
7686c074 TT |
27 | if { [prepare_for_testing $testfile.exp $testfile \ |
28 | [list $srcfile $srcfile2]] } { | |
02506ff1 MS |
29 | return -1 |
30 | } | |
31 | ||
32 | set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] | |
33 | set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] | |
dc7e1a77 | 34 | set bp_location8 [gdb_get_line_number "set breakpoint 8 here" "$srcfile2"] |
02506ff1 MS |
35 | set bp_location19 [gdb_get_line_number "set breakpoint 19 here"] |
36 | set bp_location20 [gdb_get_line_number "set breakpoint 20 here"] | |
37 | set bp_location21 [gdb_get_line_number "set breakpoint 21 here"] | |
38 | ||
39 | runto main | |
40 | ||
d3895d7d | 41 | if [supports_process_record] { |
02506ff1 | 42 | # Activate process record/replay |
bcd2dc50 | 43 | gdb_test_no_output "record" "Turn on process record" |
02506ff1 MS |
44 | } |
45 | ||
46 | set end_of_main [gdb_get_line_number "set breakpoint 10a here" ] | |
47 | gdb_test "break $end_of_main" \ | |
a80db015 | 48 | "Breakpoint $decimal at .*$srcfile, line $end_of_main\." \ |
02506ff1 MS |
49 | "BP at end of main" |
50 | ||
27949e73 | 51 | # This can take awhile. |
de1c2c52 | 52 | with_timeout_factor 20 { |
45fd756c | 53 | gdb_test "continue" "Breakpoint .* set breakpoint 10a here .*" "run to end of main" |
7b415901 | 54 | } |
02506ff1 | 55 | |
4c9ed63c | 56 | # So can this, against gdbserver, for example. |
45fd756c | 57 | |
de1c2c52 | 58 | with_timeout_factor 10 { |
45fd756c YQ |
59 | gdb_test "record save $precsave" \ |
60 | "Saved core file $precsave with execution log\." \ | |
61 | "save process recfile" | |
62 | } | |
02506ff1 MS |
63 | |
64 | gdb_test "kill" "" "Kill process, prepare to debug log file" \ | |
65 | "Kill the program being debugged\\? \\(y or n\\) " "y" | |
66 | ||
55baab26 | 67 | gdb_test "record restore $precsave" \ |
470e2f4e | 68 | "Restored records from core file .*" \ |
02506ff1 MS |
69 | "reload core file" |
70 | ||
71 | # Verify that plain vanilla "until <location>" works. | |
72 | # | |
73 | gdb_test "until $bp_location1" \ | |
74 | "main .* at .*:$bp_location1.*" \ | |
75 | "until line number" | |
76 | ||
77 | # Advance up to factorial, outer invocation | |
78 | # | |
79 | gdb_test "advance factorial" \ | |
80 | "factorial .value=6..*$srcfile:$bp_location7.*" \ | |
81 | "advance to factorial" | |
82 | ||
83 | # At this point, 'until' should continue the inferior up to when all the | |
84 | # inner invocations of factorial() are completed and we are back at this | |
85 | # frame. | |
86 | # | |
87 | gdb_test "until $bp_location19" \ | |
88 | "factorial .value=720.*${srcfile}:$bp_location19.*" \ | |
89 | "until factorial, recursive function" | |
90 | ||
91 | # Finish out to main scope | |
92 | # | |
93 | gdb_test "finish" \ | |
e6359af3 | 94 | "main .*$srcfile:.*" \ |
02506ff1 MS |
95 | "finish to main" |
96 | ||
97 | # Advance to a function called by main (marker2) | |
98 | # | |
99 | gdb_test "advance marker2" \ | |
dc7e1a77 | 100 | "marker2 .a=43.*$srcfile2:$bp_location8.*" \ |
02506ff1 MS |
101 | "advance to marker2" |
102 | ||
103 | # Now issue an until with another function, not called by the current | |
104 | # frame, as argument. This should not work, i.e. the program should | |
105 | # stop at main, the caller, where we put the 'guard' breakpoint. | |
106 | # | |
107 | set test_msg "until func, not called by current frame" | |
108 | gdb_test_multiple "until marker3" "$test_msg" { | |
109 | -re "main .*at .*${srcfile}:$bp_location20.*$gdb_prompt $" { | |
110 | pass "$test_msg" | |
111 | } | |
112 | -re "main .*at .*${srcfile}:$bp_location21.*$gdb_prompt $" { | |
113 | pass "$test_msg" | |
114 | } | |
115 | } | |
116 | ||
117 | ### | |
118 | ### | |
119 | ### | |
120 | ||
121 | # Set reverse execution direction | |
02506ff1 | 122 | |
bcd2dc50 | 123 | gdb_test_no_output "set exec-dir reverse" "set reverse execution" |
02506ff1 MS |
124 | |
125 | # | |
126 | # We should now be at main, after the return from marker2. | |
127 | # "Advance" backward into marker2. | |
128 | # | |
129 | ||
130 | gdb_test "advance marker2" \ | |
dc7e1a77 | 131 | "marker2 .a=43.*$srcfile2:$bp_location8.*" \ |
02506ff1 MS |
132 | "reverse-advance to marker2" |
133 | ||
134 | # Finish out to main scope (backward) | |
135 | ||
136 | gdb_test "finish" \ | |
137 | " in main .*$srcfile:$bp_location20.*" \ | |
138 | "reverse-finish from marker2" | |
139 | ||
140 | # Advance backward to last line of factorial (outer invocation) | |
141 | ||
142 | gdb_test "advance $bp_location19" \ | |
143 | "factorial .value=720.*${srcfile}:$bp_location19.*" \ | |
144 | "reverse-advance to final return of factorial" | |
145 | ||
146 | # Now do "until" across the recursive calls, | |
147 | # ending up in the same frame where we are now. | |
148 | ||
149 | gdb_test "until $bp_location7" \ | |
150 | "factorial .value=6..*$srcfile:$bp_location7.*" \ | |
151 | "reverse-until to entry of factorial" |