]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 2008-2024 Free Software Foundation, Inc. |
2a8339b7 CL |
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 reverse stepping. | |
17 | # Lots of code borrowed from "step-test.exp". | |
18 | ||
19 | # The reverse finish command should return from a function and stop on | |
20 | # the first instruction of the source line where the function call is made. | |
21 | # Specifically, the behavior should match doing a reverse next from the | |
22 | # first instruction in the function. GDB should only take one reverse step | |
23 | # or next statement to reach the previous source code line. | |
24 | ||
25 | # This testcase verifies the reverse-finish command stops at the first | |
26 | # instruction in the source code line where the function was called. There | |
27 | # are two scenarios that must be checked: | |
28 | # 1) gdb is at the entry point instruction for the function | |
29 | # 2) gdb is in the body of the function. | |
30 | ||
31 | # This test verifies the fix for gdb bugzilla: | |
32 | # https://sourceware.org/bugzilla/show_bug.cgi?id=29927 | |
33 | ||
34 | # PowerPC supports two entry points to a function. The normal entry point | |
35 | # is called the local entry point (LEP). The alternate entry point is called | |
36 | # the global entry point (GEP). A function call via a function pointer | |
37 | # will entry via the GEP. A normal function call will enter via the LEP. | |
38 | # | |
39 | # This test has been expanded to include tests to verify the reverse-finish | |
40 | # command works properly if the function is called via the GEP. The original | |
41 | # test only verified the reverse-finish command for a normal call that used | |
42 | # the LEP. | |
43 | ||
44 | if ![supports_reverse] { | |
45 | return | |
46 | } | |
47 | ||
48 | standard_testfile | |
49 | ||
50 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { | |
51 | return -1 | |
52 | } | |
53 | ||
54 | runto_main | |
55 | set target_remote [gdb_is_target_remote] | |
56 | ||
57 | if [supports_process_record] { | |
58 | # Activate process record/replay. | |
59 | gdb_test_no_output "record" "turn on process record for test1" | |
60 | } | |
61 | ||
62 | ||
63 | ### TEST 1: reverse finish from the entry point instruction (LEP) in | |
64 | ### function1 when called using the normal entry point (LEP). | |
65 | ||
66 | # Set breakpoint at call to function1 in main. | |
67 | set bp_LEP_test [gdb_get_line_number "CALL VIA LEP" $srcfile] | |
68 | gdb_breakpoint $srcfile:$bp_LEP_test temporary | |
69 | ||
70 | # Continue to break point at function1 call in main. | |
71 | gdb_continue_to_breakpoint \ | |
72 | "stopped at function1 entry point instruction to stepi into function" \ | |
73 | ".*$srcfile:$bp_LEP_test\r\n.*" | |
74 | ||
75 | # stepi until we see "{" indicating we entered function1 | |
76 | repeat_cmd_until "stepi" "CALL VIA LEP" "{" "stepi into function1 call" "100" | |
77 | ||
78 | # The reverse-finish command should stop on the function call instruction | |
d04ead74 CL |
79 | # which is the last instruction in the source code line. Another reverse-next |
80 | # instruction stops at the previous source code line. | |
2a8339b7 CL |
81 | gdb_test "reverse-finish" ".*function1 \\(a, b\\); // CALL VIA LEP.*" \ |
82 | "reverse-finish function1 LEP call from LEP " | |
2a8339b7 CL |
83 | gdb_test "reverse-next" ".*b = 5;.*" "reverse next 2, at b = 5, call from LEP" |
84 | ||
85 | ||
86 | gdb_test "reverse-continue" ".*" "setup for test 2" | |
87 | ||
88 | # Turn off record to clear logs and turn on again | |
89 | gdb_test "record stop" "Process record is stopped.*" \ | |
90 | "turn off process record for test1" | |
91 | gdb_test_no_output "record" "turn on process record for test2" | |
92 | ||
93 | ||
94 | ### TEST 2: reverse finish from the body of function1. | |
95 | ||
96 | # Set breakpoint at call to function1 in main. | |
97 | gdb_breakpoint $srcfile:$bp_LEP_test temporary | |
98 | ||
99 | # Continue to break point at function1 call in main. | |
100 | gdb_continue_to_breakpoint \ | |
101 | "at function1 entry point instruction to step to body of function" \ | |
102 | ".*$srcfile:$bp_LEP_test\r\n.*" | |
103 | ||
104 | # do a step instruction to get to the body of the function | |
105 | gdb_test "step" ".*int ret = 0;.*" "step test 1" | |
106 | ||
107 | # The reverse-finish command should stop on the function call instruction | |
d04ead74 CL |
108 | # which is the last instruction in the source code line. Another reverse-next |
109 | # instruction stops at the previous source code line. | |
2a8339b7 CL |
110 | gdb_test "reverse-finish" ".*function1 \\(a, b\\); // CALL VIA LEP.*" \ |
111 | "reverse-finish function1 LEP call from function body" | |
2a8339b7 CL |
112 | gdb_test "reverse-next" ".*b = 5;.*" \ |
113 | "reverse next 2 at b = 5, from function body" | |
114 | ||
115 | gdb_test "reverse-continue" ".*" "setup for test 3" | |
116 | ||
117 | # Turn off record to clear logs and turn on again | |
118 | gdb_test "record stop" "Process record is stopped.*" \ | |
119 | "turn off process record for test2" | |
120 | gdb_test_no_output "record" "turn on process record for test3" | |
121 | ||
122 | ||
123 | ### TEST 3: reverse finish from the alternate entry point instruction (GEP) in | |
124 | ### function1 when called using the alternate entry point (GEP). | |
125 | ||
126 | # Set breakpoint at call to funp in main. | |
127 | set bp_GEP_test [gdb_get_line_number "CALL VIA GEP" $srcfile] | |
128 | gdb_breakpoint $srcfile:$bp_GEP_test temporary | |
129 | ||
130 | # Continue to break point at funp call in main. | |
131 | gdb_continue_to_breakpoint \ | |
132 | "stopped at function1 entry point instruction to stepi into funp" \ | |
133 | ".*$srcfile:$bp_GEP_test\r\n.*" | |
134 | ||
135 | # stepi until we see "{" indicating we entered function. | |
136 | repeat_cmd_until "stepi" "CALL VIA GEP" "{" "stepi into funp call" | |
137 | ||
138 | # The reverse-finish command should stop on the function call instruction | |
d04ead74 CL |
139 | # which is the last instruction in the source code line. Another reverse-next |
140 | # instruction stops at the previous source code line. | |
2a8339b7 CL |
141 | gdb_test "reverse-finish" ".*funp \\(a, b\\);.*" \ |
142 | "function1 GEP call call from GEP" | |
2a8339b7 CL |
143 | gdb_test "reverse-next" ".*b = 50;.*" "reverse next 2 at b = 50, call from GEP" |
144 | ||
145 | gdb_test "reverse-continue" ".*" "setup for test 4" | |
146 | ||
147 | # Turn off record to clear logs and turn on again | |
148 | gdb_test "record stop" "Process record is stopped.*" \ | |
149 | "turn off process record for test3" | |
150 | gdb_test_no_output "record" "turn on process record for test4" | |
151 | ||
152 | ### TEST 4: reverse finish from between the GEP and LEP in | |
153 | ### function1 when called using the alternate entry point (GEP). | |
154 | ||
155 | # Set breakpoint at call to funp in main. | |
156 | set bp_GEP_test [gdb_get_line_number "CALL VIA GEP" $srcfile] | |
157 | gdb_breakpoint $srcfile:$bp_GEP_test temporary | |
158 | ||
159 | # Continue to break point at funp call in main. | |
160 | gdb_continue_to_breakpoint \ | |
161 | "stopped at function1 entry point instruction to stepi into funp again" \ | |
162 | ".*$srcfile:$bp_GEP_test\r\n.*" | |
163 | ||
164 | # stepi until we see "{" indicating we entered function. | |
165 | repeat_cmd_until "stepi" "CALL VIA GEP" "{" "stepi into funp call again" | |
166 | ||
167 | # do one more stepi so we are between the GEP and LEP. | |
168 | gdb_test "stepi" "{" "stepi to between GEP and LEP" | |
169 | ||
170 | # The reverse-finish command should stop on the function call instruction | |
d04ead74 CL |
171 | # which is the last instruction in the source code line. Another reverse-next |
172 | # instruction stops at the previous source code line. | |
2a8339b7 CL |
173 | gdb_test "reverse-finish" ".*funp \\(a, b\\);.*" \ |
174 | "function1 GEP call call from GEP again" | |
2a8339b7 CL |
175 | gdb_test "reverse-next" ".*b = 50;.*" \ |
176 | "reverse next 2 at b = 50, call from GEP again" | |
177 | ||
178 | gdb_test "reverse-continue" ".*" "setup for test 5" | |
179 | ||
180 | # Turn off record to clear logs and turn on again | |
181 | gdb_test "record stop" "Process record is stopped.*" \ | |
182 | "turn off process record for test4" | |
183 | gdb_test_no_output "record" "turn on process record for test5" | |
184 | ||
185 | ||
186 | ### TEST 5: reverse finish from the body of function 1 when calling using the | |
187 | ### alternate entrypoint (GEP). | |
188 | gdb_breakpoint $srcfile:$bp_GEP_test temporary | |
189 | ||
190 | # Continue to break point at funp call. | |
191 | gdb_continue_to_breakpoint \ | |
192 | "at function1 entry point instruction to step to body of funp call" \ | |
193 | ".*$srcfile:$bp_GEP_test\r\n.*" | |
194 | ||
195 | # Step into body of funp, called via GEP. | |
196 | gdb_test "step" ".*int ret = 0;.*" "step test 2" | |
197 | ||
198 | # The reverse-finish command should stop on the function call instruction | |
d04ead74 CL |
199 | # which is the last instruction in the source code line. Another reverse-next |
200 | # instruction stops at the previous source code line. | |
2a8339b7 CL |
201 | gdb_test "reverse-finish" ".*funp \\(a, b\\);.*" \ |
202 | "reverse-finish function1 GEP call, from function body " | |
2a8339b7 CL |
203 | gdb_test "reverse-next" ".*b = 50;.*" \ |
204 | "reverse next 2 at b = 50 from function body" |