Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright (C) 2011-2020 Free Software Foundation, Inc. |
8e3b41a9 JK |
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 | ||
de5f37e1 | 16 | standard_testfile .s |
6e8b1ab2 | 17 | set opts {nopie} |
8e3b41a9 JK |
18 | |
19 | if [info exists COMPILE] { | |
20 | # make check RUNTESTFLAGS="gdb.arch/amd64-entry-value.exp COMPILE=1" | |
21 | set srcfile ${testfile}.cc | |
22 | lappend opts debug optimize=-O2 | |
23 | } elseif { ![istarget x86_64-*-* ] || ![is_lp64_target] } { | |
24 | verbose "Skipping amd64-entry-value." | |
25 | return | |
26 | } | |
27 | ||
5b362f04 | 28 | if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } { |
8e3b41a9 JK |
29 | return -1 |
30 | } | |
31 | ||
32 | if ![runto_main] { | |
33 | return -1 | |
34 | } | |
35 | ||
36 | gdb_breakpoint "breakhere" | |
e18b2753 JK |
37 | gdb_breakpoint "breakhere_locexpr" |
38 | gdb_breakpoint "stacktest" | |
39 | gdb_breakpoint "breakhere_stacktest" | |
40 | gdb_breakpoint "different" | |
41 | gdb_breakpoint "breakhere_different" | |
42 | gdb_breakpoint "breakhere_validity" | |
43 | gdb_breakpoint "breakhere_invalid" | |
a471c594 JK |
44 | gdb_breakpoint "reference" |
45 | gdb_breakpoint "breakhere_reference" | |
8e3b41a9 JK |
46 | |
47 | ||
48 | # Test @entry values for register passed parameters. | |
49 | ||
50 | gdb_continue_to_breakpoint "entry: breakhere" | |
51 | ||
e18b2753 | 52 | gdb_test "bt" "^bt\r\n#0 +d *\\(i=31, i@entry=30, j=31\\.5, j@entry=30\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ |
8e3b41a9 JK |
53 | "entry: bt" |
54 | gdb_test "p i" " = 31" "entry: p i" | |
36b11add | 55 | gdb_test "p i@entry" " = 30" "entry: p i@entry" |
8e3b41a9 | 56 | gdb_test "p j" { = 31\.5} "entry: p j" |
36b11add | 57 | gdb_test "p j@entry" { = 30\.5} "entry: p j@entry" |
111c6489 JK |
58 | |
59 | ||
e18b2753 JK |
60 | # Test @entry values when parameter in function is locexpr (and not loclist). |
61 | ||
62 | gdb_continue_to_breakpoint "entry_locexpr: breakhere_locexpr" | |
63 | gdb_test "p i" " = 30" "entry_locexpr: p i" | |
64 | gdb_test_no_output "set variable i = 0" "entry_locexpr: set variable i = 0" | |
65 | gdb_test "bt" "^bt\r\n#0 +locexpr *\\(i=0, i@entry=30\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ | |
66 | "entry_locexpr: bt" | |
67 | ||
68 | ||
69 | # Test @entry values for stack passed parameters. | |
70 | ||
71 | gdb_continue_to_breakpoint "entry_stack: stacktest" | |
72 | ||
73 | gdb_test "bt" "^bt\r\n#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=s1@entry=11, s2=s2@entry=12, \[^\r\n\]+, d9=d9@entry=11\\.5, da=da@entry=12\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ | |
74 | "entry_stack: bt at entry" | |
75 | ||
76 | gdb_continue_to_breakpoint "entry_stack: breakhere_stacktest" | |
77 | ||
78 | gdb_test "bt" "^bt\r\n#0 +stacktest *\\(r1=r1@entry=1, r2=r2@entry=2, \[^\r\n\]+, s1=3, s1@entry=11, s2=4, s2@entry=12, \[^\r\n\]+, d9=3\\.5, d9@entry=11\\.5, da=4\\.5, da@entry=12\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main .*" \ | |
79 | "entry_stack: bt" | |
80 | ||
81 | gdb_test "p s1" " = 3" "entry_stack: p s1" | |
36b11add | 82 | gdb_test "p s1@entry" " = 11" "entry_stack: p s1@entry" |
e18b2753 | 83 | gdb_test "p s2" " = 4" "entry_stack: p s2" |
36b11add | 84 | gdb_test "p s2@entry" " = 12" "entry_stack: p s2@entry" |
e18b2753 | 85 | gdb_test "p d9" " = 3\\.5" "entry_stack: p d9" |
36b11add | 86 | gdb_test "p d9@entry" " = 11\\.5" "entry_stack: p d9@entry" |
e18b2753 | 87 | gdb_test "p da" " = 4\\.5" "entry_stack: p da" |
36b11add | 88 | gdb_test "p da@entry" " = 12\\.5" "entry_stack: p da@entry" |
e18b2753 | 89 | |
b1b189e0 AB |
90 | # Test @entry values for a static file scoped variable, and for an |
91 | # unknown symbol. Both of these should give an error. | |
92 | gdb_test "p v@entry" \ | |
93 | "@entry can be used only for function parameters, not for \"v\"" \ | |
94 | "attempt to print global v@entry" | |
95 | gdb_test "p unknown@entry" \ | |
96 | "@entry can be used only for function parameters, not for \"unknown\"" \ | |
97 | "attempt to print unknown@entry" | |
e18b2753 JK |
98 | |
99 | # Test various kinds of `set print entry-values'. | |
100 | ||
101 | gdb_continue_to_breakpoint "entry_equal: breakhere" | |
102 | ||
103 | gdb_test_no_output "set print entry-values no" "entry_equal: set print entry-values no" | |
104 | gdb_test "frame" {\(val=5\).*} "entry_equal: frame: no" | |
105 | gdb_test_no_output "set print entry-values only" "entry_equal: set print entry-values only" | |
106 | gdb_test "frame" {\(val@entry=5\).*} "entry_equal: frame: only" | |
107 | gdb_test_no_output "set print entry-values preferred" "entry_equal: set print entry-values preferred" | |
108 | gdb_test "frame" {\(val@entry=5\).*} "entry_equal: frame: preferred" | |
109 | gdb_test_no_output "set print entry-values if-needed" "entry_equal: set print entry-values if-needed" | |
110 | gdb_test "frame" {\(val=5\).*} "entry_equal: frame: if-needed" | |
111 | gdb_test_no_output "set print entry-values both" "entry_equal: set print entry-values both" | |
112 | gdb_test "frame" {\(val=5, val@entry=5\).*} "entry_equal: frame: both" | |
113 | gdb_test_no_output "set print entry-values compact" "entry_equal: set print entry-values compact" | |
114 | gdb_test "frame" {\(val=val@entry=5\).*} "entry_equal: frame: compact" | |
115 | gdb_test_no_output "set print entry-values default" "entry_equal: set print entry-values default" | |
116 | gdb_test "frame" {\(val=val@entry=5\).*} "entry_equal: frame: default" | |
117 | ||
118 | gdb_continue_to_breakpoint "entry_different: breakhere" | |
119 | ||
120 | gdb_test_no_output "set print entry-values no" "entry_different: set print entry-values no" | |
121 | gdb_test "frame" {\(val=6\).*} "entry_different: frame: no" | |
122 | gdb_test_no_output "set print entry-values only" "entry_different: set print entry-values only" | |
123 | gdb_test "frame" {\(val@entry=5\).*} "entry_different: frame: only" | |
124 | gdb_test_no_output "set print entry-values preferred" "entry_different: set print entry-values preferred" | |
125 | gdb_test "frame" {\(val@entry=5\).*} "entry_different: frame: preferred" | |
126 | gdb_test_no_output "set print entry-values if-needed" "entry_different: set print entry-values if-needed" | |
127 | gdb_test "frame" {\(val=6\).*} "entry_different: frame: if-needed" | |
128 | gdb_test_no_output "set print entry-values both" "entry_different: set print entry-values both" | |
129 | gdb_test "frame" {\(val=6, val@entry=5\).*} "entry_different: frame: both" | |
130 | gdb_test_no_output "set print entry-values compact" "entry_different: set print entry-values compact" | |
131 | gdb_test "frame" {\(val=6, val@entry=5\).*} "entry_different: frame: compact" | |
132 | gdb_test_no_output "set print entry-values default" "entry_different: set print entry-values default" | |
133 | gdb_test "frame" {\(val=6, val@entry=5\).*} "entry_different: frame: default" | |
134 | ||
135 | gdb_continue_to_breakpoint "entry_validity: breakhere" | |
136 | ||
137 | gdb_test_no_output "set print entry-values no" "entry_validity: set print entry-values no" | |
138 | gdb_test "frame" {\(lost=<optimized out>, born=10\).*} "entry_validity: frame: no" | |
139 | gdb_test_no_output "set print entry-values only" "entry_validity: set print entry-values only" | |
140 | gdb_test "frame" {\(lost@entry=5, born@entry=<optimized out>\).*} "entry_validity: frame: only" | |
141 | gdb_test_no_output "set print entry-values preferred" "entry_validity: set print entry-values preferred" | |
142 | gdb_test "frame" {\(lost@entry=5, born=10\).*} "entry_validity: frame: preferred" | |
143 | gdb_test_no_output "set print entry-values if-needed" "entry_validity: set print entry-values if-needed" | |
144 | gdb_test "frame" {\(lost@entry=5, born=10\).*} "entry_validity: frame: if-needed" | |
145 | gdb_test_no_output "set print entry-values both" "entry_validity: set print entry-values both" | |
146 | gdb_test "frame" {\(lost=<optimized out>, lost@entry=5, born=10, born@entry=<optimized out>\).*} "entry_validity: frame: both" | |
147 | gdb_test_no_output "set print entry-values compact" "entry_validity: set print entry-values compact" | |
148 | gdb_test "frame" {\(lost@entry=5, born=10\).*} "entry_validity: frame: compact" | |
149 | gdb_test_no_output "set print entry-values default" "entry_validity: set print entry-values default" | |
150 | gdb_test "frame" {\(lost=<optimized out>, lost@entry=5, born=10\).*} "entry_validity: frame: default" | |
151 | ||
152 | gdb_continue_to_breakpoint "entry_invalid: breakhere" | |
153 | ||
154 | gdb_test_no_output "set print entry-values no" "entry_invalid: set print entry-values no" | |
155 | gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: no" | |
156 | gdb_test_no_output "set print entry-values only" "entry_invalid: set print entry-values only" | |
157 | gdb_test "frame" {\(inv@entry=<optimized out>\).*} "entry_invalid: frame: only" | |
158 | gdb_test_no_output "set print entry-values preferred" "entry_invalid: set print entry-values preferred" | |
159 | gdb_test "frame" {\(inv@entry=<optimized out>\).*} "entry_invalid: frame: preferred" | |
160 | gdb_test_no_output "set print entry-values if-needed" "entry_invalid: set print entry-values if-needed" | |
161 | gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: if-needed" | |
162 | gdb_test_no_output "set print entry-values both" "entry_invalid: set print entry-values both" | |
163 | gdb_test "frame" {\(inv=<optimized out>, inv@entry=<optimized out>\).*} "entry_invalid: frame: both" | |
164 | gdb_test_no_output "set print entry-values compact" "entry_invalid: set print entry-values compact" | |
165 | gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: compact" | |
166 | gdb_test_no_output "set print entry-values default" "entry_invalid: set print entry-values default" | |
167 | gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: default" | |
168 | ||
169 | ||
216f72a1 | 170 | # Test @entry values for DW_AT_call_data_value parameters. |
a471c594 JK |
171 | |
172 | gdb_continue_to_breakpoint "entry_reference: reference" | |
173 | ||
174 | # GCC PR debug/49980: Missing stackparam1@entry and stackparam2@entry. | |
175 | gdb_test "bt" "#0 +reference \\(regparam=regparam@entry=@0x\[0-9a-f\]+: 1, nodataparam=@0x\[0-9a-f\]+: 2, \[^\r\n\]+, stackparam1=@0x\[0-9a-f\]+: 11, stackparam2=@0x\[0-9a-f\]+: 12\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main \\(\\) \[^\r\n\]*" \ | |
176 | "entry_reference: bt at entry" | |
177 | ||
178 | gdb_continue_to_breakpoint "entry_reference: breakhere_reference" | |
179 | ||
180 | # GCC PR debug/49980: Missing stackparam1@entry and stackparam2@entry. | |
181 | gdb_test "bt" "#0 +reference \\(regparam=@0x\[0-9a-f\]+: 21, regparam@entry=@0x\[0-9a-f\]+: 1, nodataparam=@0x\[0-9a-f\]+: 22, \[^\r\n\]+, stackparam1=@0x\[0-9a-f\]+: 31, stackparam2=@0x\[0-9a-f\]+: 32\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in main \\(\\) \[^\r\n\]*" \ | |
182 | "entry_reference: bt" | |
183 | gdb_test "ptype regparam" " = int &" "entry_reference: ptype regparam" | |
184 | ||
185 | set test "entry_reference: p regparam" | |
186 | set addr "" | |
187 | gdb_test_multiple "p regparam" $test { | |
188 | -re " = \\(int &\\) @(0x\[0-9a-f\]+): 21\r\n$gdb_prompt $" { | |
189 | set addr $expect_out(1,string) | |
190 | pass $test | |
191 | } | |
192 | } | |
193 | ||
194 | gdb_test "ptype regparam@entry" " = int &" "entry_reference: ptype regparam@entry" | |
195 | gdb_test "p regparam@entry" " = \\(int &\\) @$addr: 1" "entry_reference: p regparam@entry" | |
196 | gdb_test "p ®param@entry" " = \\(int \\*\\) $addr" "entry_reference: p ®param@entry" | |
197 | gdb_test "p regcopy" " = 1" "entry_reference: p regcopy" | |
198 | gdb_test "p nodataparam" " = \\(int &\\) @0x\[0-9a-f\]+: 22" "entry_reference: p nodataparam" | |
216f72a1 | 199 | gdb_test "p nodataparam@entry" "Cannot resolve DW_AT_call_data_value" "entry_reference: p nodataparam@entry" |
a471c594 JK |
200 | |
201 | ||
111c6489 JK |
202 | # Test virtual tail call frames. |
203 | ||
204 | gdb_continue_to_breakpoint "tailcall: breakhere" | |
205 | ||
e18b2753 | 206 | gdb_test "bt" "^bt\r\n#0 +d *\\(i=71, i@entry=70, j=73\\.5, j@entry=72\\.5\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in c \\(i=i@entry=7, j=j@entry=7\\.25\\) \[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in b \\(i=i@entry=5, j=j@entry=5\\.25\\) \[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in main \[^\r\n\]*" \ |
111c6489 JK |
207 | "tailcall: bt" |
208 | gdb_test "p i" " = 71" "tailcall: p i" | |
36b11add | 209 | gdb_test "p i@entry" " = 70" "tailcall: p i@entry" |
111c6489 | 210 | gdb_test "p j" " = 73\\.5" "tailcall: p j" |
36b11add | 211 | gdb_test "p j@entry" " = 72\\.5" "tailcall: p j@entry" |
111c6489 JK |
212 | |
213 | # Test $sp simulation for tail call frames. | |
214 | #gdb_test {p/x $sp} " = 0x.*" | |
215 | #gdb_test {p/x $pc} " = 0x.*" | |
216 | gdb_test_no_output {set $sp0=$sp} | |
217 | gdb_test "up" "\r\n#1 .*" | |
218 | #gdb_test {p/x $sp} " = 0x.*" | |
219 | gdb_test {p $sp0 == $sp} " = true" | |
220 | gdb_test "frame 3" "\r\n#3 .*" | |
221 | gdb_test {p $sp0 + sizeof (void *) == $sp} " = true" | |
222 | ||
9bf4bce9 JK |
223 | # Test $pc adjustment which is now right after the function end. |
224 | # Also verify the current PC indicator "=> " is not displayed anywhere. | |
225 | gdb_test "down" "\r\n#2 .*" | |
226 | set test "disassemble" | |
227 | gdb_test_multiple $test $test { | |
228 | -re "^$test\r\n" { | |
229 | exp_continue | |
230 | } | |
231 | -re "^Dump of assembler code for function b\\(int, double\\):\r\n" { | |
232 | exp_continue | |
233 | } | |
234 | -re "^ 0x\[^\r\n\]*\r\n" { | |
235 | exp_continue | |
236 | } | |
237 | -re "^End of assembler dump\\.\r\n$gdb_prompt $" { | |
238 | pass $test | |
239 | } | |
240 | } | |
241 | ||
111c6489 JK |
242 | |
243 | # Test partial-ambiguous virtual tail call frames chain. | |
244 | ||
245 | gdb_continue_to_breakpoint "ambiguous: breakhere" | |
246 | ||
e18b2753 | 247 | gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in amb_z \\(i=<optimized out>\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in amb_y \\(i=<optimized out>\\)\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in amb_x \\(i=<optimized out>\\)\[^\r\n\]*\r\n#4 +0x\[0-9a-f\]+ in amb_b \\(i=i@entry=101\\)\[^\r\n\]*\r\n#5 +0x\[0-9a-f\]+ in amb_a \\(i=i@entry=100\\)\[^\r\n\]*\r\n#6 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \ |
111c6489 | 248 | "ambiguous: bt" |
2d6c5dc2 JK |
249 | |
250 | ||
251 | # Test self tail calls verification. | |
252 | # GDB should not print the real value as it is ambiguous. | |
253 | ||
254 | gdb_continue_to_breakpoint "self: breakhere" | |
255 | ||
256 | gdb_test "bt" "^bt\r\n#0 +d \\(i=<optimized out>, j=<optimized out>\\)\[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in self \\(i=<optimized out>\\)\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in main \\(\\)\[^\r\n\]*" \ | |
257 | "self: bt" | |
258 | ||
259 | gdb_test_no_output "set debug entry-values 1" | |
216f72a1 | 260 | gdb_test "bt" "DW_OP_entry_value resolving has found function \"self\\(int\\)\" at 0x\[0-9a-f\]+ can call itself via tail calls\r\n.*" \ |
2d6c5dc2 | 261 | "self: bt debug entry-values" |