Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-entry-value.cc
CommitLineData
8e3b41a9
JK
1/* This testcase is part of GDB, the GNU debugger.
2
88b9d363 3 Copyright 2011-2022 Free Software Foundation, Inc.
8e3b41a9
JK
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18static volatile int v;
19
20static void __attribute__((noinline, noclone))
21e (int i, double j)
22{
23 v = 0;
24}
25
26static void __attribute__((noinline, noclone))
27d (int i, double j)
28{
29 i++;
30 j++;
31 e (i, j);
32 e (v, v);
33asm ("breakhere:");
34 e (v, v);
35}
36
e18b2753
JK
37static void __attribute__((noinline, noclone))
38locexpr (int i)
39{
40 i = i;
41asm ("breakhere_locexpr:");
42}
43
111c6489
JK
44static void __attribute__((noinline, noclone))
45c (int i, double j)
46{
47 d (i * 10, j * 10);
48}
49
50static void __attribute__((noinline, noclone))
51a (int i, double j)
52{
53 c (i + 1, j + 1);
54}
55
56static void __attribute__((noinline, noclone))
57b (int i, double j)
58{
59 c (i + 2, j + 2);
60}
61
62static void __attribute__((noinline, noclone))
63amb_z (int i)
64{
65 d (i + 7, i + 7.5);
66}
67
68static void __attribute__((noinline, noclone))
69amb_y (int i)
70{
71 amb_z (i + 6);
72}
73
74static void __attribute__((noinline, noclone))
75amb_x (int i)
76{
77 amb_y (i + 5);
78}
79
80static void __attribute__((noinline, noclone))
81amb (int i)
82{
83 if (i < 0)
84 amb_x (i + 3);
85 else
86 amb_x (i + 4);
87}
88
89static void __attribute__((noinline, noclone))
90amb_b (int i)
91{
92 amb (i + 2);
93}
94
95static void __attribute__((noinline, noclone))
96amb_a (int i)
97{
98 amb_b (i + 1);
99}
100
2d6c5dc2
JK
101static void __attribute__((noinline, noclone)) self (int i);
102
103static void __attribute__((noinline, noclone))
104self2 (int i)
105{
106 self (i);
107}
108
109static void __attribute__((noinline, noclone))
110self (int i)
111{
112 if (i == 200)
113 {
114 /* GCC would inline `self' as `cmovne' without the `self2' indirect. */
115 self2 (i + 1);
116 }
117 else
118 {
119 e (v, v);
120 d (i + 2, i + 2.5);
121 }
122}
123
e18b2753
JK
124static void __attribute__((noinline, noclone))
125stacktest (int r1, int r2, int r3, int r4, int r5, int r6, int s1, int s2,
126 double d1, double d2, double d3, double d4, double d5, double d6,
127 double d7, double d8, double d9, double da)
128{
129 s1 = 3;
130 s2 = 4;
131 d9 = 3.5;
132 da = 4.5;
133 e (v, v);
134asm ("breakhere_stacktest:");
135 e (v, v);
136}
137
a471c594
JK
138/* nodataparam has DW_AT_GNU_call_site_value but it does not have
139 DW_AT_GNU_call_site_data_value. GDB should not display dereferenced @entry
140 value for it. */
141
142static void __attribute__((noinline, noclone))
143reference (int &regparam, int &nodataparam, int r3, int r4, int r5, int r6,
144 int &stackparam1, int &stackparam2)
145{
146 int regcopy = regparam, nodatacopy = nodataparam;
147 int stackcopy1 = stackparam1, stackcopy2 = stackparam2;
148
149 regparam = 21;
150 nodataparam = 22;
151 stackparam1 = 31;
152 stackparam2 = 32;
153 e (v, v);
154asm ("breakhere_reference:");
155 e (v, v);
156}
157
158static int *__attribute__((noinline, noclone))
159datap ()
160{
161 static int two = 2;
162
163 return &two;
164}
165
166static void __attribute__((noinline, noclone))
167datap_input (int *datap)
168{
169 (*datap)++;
170}
171
e18b2753
JK
172static int __attribute__((noinline, noclone))
173data (void)
174{
175 return 10;
176}
177
178static int __attribute__((noinline, noclone))
179data2 (void)
180{
181 return 20;
182}
183
184static int __attribute__((noinline, noclone))
185different (int val)
186{
187 val++;
188 e (val, val);
189asm ("breakhere_different:");
190 return val;
191}
192
193static int __attribute__((noinline, noclone))
194validity (int lost, int born)
195{
196 lost = data ();
197 e (0, 0.0);
198asm ("breakhere_validity:");
199 return born;
200}
201
202static void __attribute__((noinline, noclone))
203invalid (int inv)
204{
205 e (0, 0.0);
206asm ("breakhere_invalid:");
207}
208
8e3b41a9
JK
209int
210main ()
211{
212 d (30, 30.5);
e18b2753
JK
213 locexpr (30);
214 stacktest (1, 2, 3, 4, 5, 6, 11, 12,
215 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 11.5, 12.5);
216 different (5);
217 validity (5, data ());
218 invalid (data2 ());
219
a471c594
JK
220 {
221 int regvar = 1, *nodatavarp = datap (), stackvar1 = 11, stackvar2 = 12;
222 reference (regvar, *nodatavarp, 3, 4, 5, 6, stackvar1, stackvar2);
223 datap_input (nodatavarp);
224 }
225
111c6489
JK
226 if (v)
227 a (1, 1.25);
228 else
229 b (5, 5.25);
230 amb_a (100);
2d6c5dc2 231 self (200);
8e3b41a9
JK
232 return 0;
233}
This page took 1.837832 seconds and 4 git commands to generate.