gdb: Allow GDB to _not_ load a previous command history
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-entry-value.exp
CommitLineData
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 16standard_testfile .s
6e8b1ab2 17set opts {nopie}
8e3b41a9
JK
18
19if [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 28if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
8e3b41a9
JK
29 return -1
30}
31
32if ![runto_main] {
33 return -1
34}
35
36gdb_breakpoint "breakhere"
e18b2753
JK
37gdb_breakpoint "breakhere_locexpr"
38gdb_breakpoint "stacktest"
39gdb_breakpoint "breakhere_stacktest"
40gdb_breakpoint "different"
41gdb_breakpoint "breakhere_different"
42gdb_breakpoint "breakhere_validity"
43gdb_breakpoint "breakhere_invalid"
a471c594
JK
44gdb_breakpoint "reference"
45gdb_breakpoint "breakhere_reference"
8e3b41a9
JK
46
47
48# Test @entry values for register passed parameters.
49
50gdb_continue_to_breakpoint "entry: breakhere"
51
e18b2753 52gdb_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"
54gdb_test "p i" " = 31" "entry: p i"
36b11add 55gdb_test "p i@entry" " = 30" "entry: p i@entry"
8e3b41a9 56gdb_test "p j" { = 31\.5} "entry: p j"
36b11add 57gdb_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
62gdb_continue_to_breakpoint "entry_locexpr: breakhere_locexpr"
63gdb_test "p i" " = 30" "entry_locexpr: p i"
64gdb_test_no_output "set variable i = 0" "entry_locexpr: set variable i = 0"
65gdb_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
71gdb_continue_to_breakpoint "entry_stack: stacktest"
72
73gdb_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
76gdb_continue_to_breakpoint "entry_stack: breakhere_stacktest"
77
78gdb_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
81gdb_test "p s1" " = 3" "entry_stack: p s1"
36b11add 82gdb_test "p s1@entry" " = 11" "entry_stack: p s1@entry"
e18b2753 83gdb_test "p s2" " = 4" "entry_stack: p s2"
36b11add 84gdb_test "p s2@entry" " = 12" "entry_stack: p s2@entry"
e18b2753 85gdb_test "p d9" " = 3\\.5" "entry_stack: p d9"
36b11add 86gdb_test "p d9@entry" " = 11\\.5" "entry_stack: p d9@entry"
e18b2753 87gdb_test "p da" " = 4\\.5" "entry_stack: p da"
36b11add 88gdb_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.
92gdb_test "p v@entry" \
93 "@entry can be used only for function parameters, not for \"v\"" \
94 "attempt to print global v@entry"
95gdb_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
101gdb_continue_to_breakpoint "entry_equal: breakhere"
102
103gdb_test_no_output "set print entry-values no" "entry_equal: set print entry-values no"
104gdb_test "frame" {\(val=5\).*} "entry_equal: frame: no"
105gdb_test_no_output "set print entry-values only" "entry_equal: set print entry-values only"
106gdb_test "frame" {\(val@entry=5\).*} "entry_equal: frame: only"
107gdb_test_no_output "set print entry-values preferred" "entry_equal: set print entry-values preferred"
108gdb_test "frame" {\(val@entry=5\).*} "entry_equal: frame: preferred"
109gdb_test_no_output "set print entry-values if-needed" "entry_equal: set print entry-values if-needed"
110gdb_test "frame" {\(val=5\).*} "entry_equal: frame: if-needed"
111gdb_test_no_output "set print entry-values both" "entry_equal: set print entry-values both"
112gdb_test "frame" {\(val=5, val@entry=5\).*} "entry_equal: frame: both"
113gdb_test_no_output "set print entry-values compact" "entry_equal: set print entry-values compact"
114gdb_test "frame" {\(val=val@entry=5\).*} "entry_equal: frame: compact"
115gdb_test_no_output "set print entry-values default" "entry_equal: set print entry-values default"
116gdb_test "frame" {\(val=val@entry=5\).*} "entry_equal: frame: default"
117
118gdb_continue_to_breakpoint "entry_different: breakhere"
119
120gdb_test_no_output "set print entry-values no" "entry_different: set print entry-values no"
121gdb_test "frame" {\(val=6\).*} "entry_different: frame: no"
122gdb_test_no_output "set print entry-values only" "entry_different: set print entry-values only"
123gdb_test "frame" {\(val@entry=5\).*} "entry_different: frame: only"
124gdb_test_no_output "set print entry-values preferred" "entry_different: set print entry-values preferred"
125gdb_test "frame" {\(val@entry=5\).*} "entry_different: frame: preferred"
126gdb_test_no_output "set print entry-values if-needed" "entry_different: set print entry-values if-needed"
127gdb_test "frame" {\(val=6\).*} "entry_different: frame: if-needed"
128gdb_test_no_output "set print entry-values both" "entry_different: set print entry-values both"
129gdb_test "frame" {\(val=6, val@entry=5\).*} "entry_different: frame: both"
130gdb_test_no_output "set print entry-values compact" "entry_different: set print entry-values compact"
131gdb_test "frame" {\(val=6, val@entry=5\).*} "entry_different: frame: compact"
132gdb_test_no_output "set print entry-values default" "entry_different: set print entry-values default"
133gdb_test "frame" {\(val=6, val@entry=5\).*} "entry_different: frame: default"
134
135gdb_continue_to_breakpoint "entry_validity: breakhere"
136
137gdb_test_no_output "set print entry-values no" "entry_validity: set print entry-values no"
138gdb_test "frame" {\(lost=<optimized out>, born=10\).*} "entry_validity: frame: no"
139gdb_test_no_output "set print entry-values only" "entry_validity: set print entry-values only"
140gdb_test "frame" {\(lost@entry=5, born@entry=<optimized out>\).*} "entry_validity: frame: only"
141gdb_test_no_output "set print entry-values preferred" "entry_validity: set print entry-values preferred"
142gdb_test "frame" {\(lost@entry=5, born=10\).*} "entry_validity: frame: preferred"
143gdb_test_no_output "set print entry-values if-needed" "entry_validity: set print entry-values if-needed"
144gdb_test "frame" {\(lost@entry=5, born=10\).*} "entry_validity: frame: if-needed"
145gdb_test_no_output "set print entry-values both" "entry_validity: set print entry-values both"
146gdb_test "frame" {\(lost=<optimized out>, lost@entry=5, born=10, born@entry=<optimized out>\).*} "entry_validity: frame: both"
147gdb_test_no_output "set print entry-values compact" "entry_validity: set print entry-values compact"
148gdb_test "frame" {\(lost@entry=5, born=10\).*} "entry_validity: frame: compact"
149gdb_test_no_output "set print entry-values default" "entry_validity: set print entry-values default"
150gdb_test "frame" {\(lost=<optimized out>, lost@entry=5, born=10\).*} "entry_validity: frame: default"
151
152gdb_continue_to_breakpoint "entry_invalid: breakhere"
153
154gdb_test_no_output "set print entry-values no" "entry_invalid: set print entry-values no"
155gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: no"
156gdb_test_no_output "set print entry-values only" "entry_invalid: set print entry-values only"
157gdb_test "frame" {\(inv@entry=<optimized out>\).*} "entry_invalid: frame: only"
158gdb_test_no_output "set print entry-values preferred" "entry_invalid: set print entry-values preferred"
159gdb_test "frame" {\(inv@entry=<optimized out>\).*} "entry_invalid: frame: preferred"
160gdb_test_no_output "set print entry-values if-needed" "entry_invalid: set print entry-values if-needed"
161gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: if-needed"
162gdb_test_no_output "set print entry-values both" "entry_invalid: set print entry-values both"
163gdb_test "frame" {\(inv=<optimized out>, inv@entry=<optimized out>\).*} "entry_invalid: frame: both"
164gdb_test_no_output "set print entry-values compact" "entry_invalid: set print entry-values compact"
165gdb_test "frame" {\(inv=<optimized out>\).*} "entry_invalid: frame: compact"
166gdb_test_no_output "set print entry-values default" "entry_invalid: set print entry-values default"
167gdb_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
172gdb_continue_to_breakpoint "entry_reference: reference"
173
174# GCC PR debug/49980: Missing stackparam1@entry and stackparam2@entry.
175gdb_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
178gdb_continue_to_breakpoint "entry_reference: breakhere_reference"
179
180# GCC PR debug/49980: Missing stackparam1@entry and stackparam2@entry.
181gdb_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"
183gdb_test "ptype regparam" " = int &" "entry_reference: ptype regparam"
184
185set test "entry_reference: p regparam"
186set addr ""
187gdb_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
194gdb_test "ptype regparam@entry" " = int &" "entry_reference: ptype regparam@entry"
195gdb_test "p regparam@entry" " = \\(int &\\) @$addr: 1" "entry_reference: p regparam@entry"
196gdb_test "p &regparam@entry" " = \\(int \\*\\) $addr" "entry_reference: p &regparam@entry"
197gdb_test "p regcopy" " = 1" "entry_reference: p regcopy"
198gdb_test "p nodataparam" " = \\(int &\\) @0x\[0-9a-f\]+: 22" "entry_reference: p nodataparam"
216f72a1 199gdb_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
204gdb_continue_to_breakpoint "tailcall: breakhere"
205
e18b2753 206gdb_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"
208gdb_test "p i" " = 71" "tailcall: p i"
36b11add 209gdb_test "p i@entry" " = 70" "tailcall: p i@entry"
111c6489 210gdb_test "p j" " = 73\\.5" "tailcall: p j"
36b11add 211gdb_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.*"
216gdb_test_no_output {set $sp0=$sp}
217gdb_test "up" "\r\n#1 .*"
218#gdb_test {p/x $sp} " = 0x.*"
219gdb_test {p $sp0 == $sp} " = true"
220gdb_test "frame 3" "\r\n#3 .*"
221gdb_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.
225gdb_test "down" "\r\n#2 .*"
226set test "disassemble"
227gdb_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
245gdb_continue_to_breakpoint "ambiguous: breakhere"
246
e18b2753 247gdb_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
254gdb_continue_to_breakpoint "self: breakhere"
255
256gdb_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
259gdb_test_no_output "set debug entry-values 1"
216f72a1 260gdb_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"
This page took 1.068865 seconds and 4 git commands to generate.