gdb/
[binutils-gdb.git] / gdb / testsuite / gdb.arch / amd64-entry-value.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2011 Free Software Foundation, Inc.
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
18 static volatile int v;
19
20 static void __attribute__((noinline, noclone))
21 e (int i, double j)
22 {
23 v = 0;
24 }
25
26 static void __attribute__((noinline, noclone))
27 d (int i, double j)
28 {
29 i++;
30 j++;
31 e (i, j);
32 e (v, v);
33 asm ("breakhere:");
34 e (v, v);
35 }
36
37 static void __attribute__((noinline, noclone))
38 locexpr (int i)
39 {
40 i = i;
41 asm ("breakhere_locexpr:");
42 }
43
44 static void __attribute__((noinline, noclone))
45 c (int i, double j)
46 {
47 d (i * 10, j * 10);
48 }
49
50 static void __attribute__((noinline, noclone))
51 a (int i, double j)
52 {
53 c (i + 1, j + 1);
54 }
55
56 static void __attribute__((noinline, noclone))
57 b (int i, double j)
58 {
59 c (i + 2, j + 2);
60 }
61
62 static void __attribute__((noinline, noclone))
63 amb_z (int i)
64 {
65 d (i + 7, i + 7.5);
66 }
67
68 static void __attribute__((noinline, noclone))
69 amb_y (int i)
70 {
71 amb_z (i + 6);
72 }
73
74 static void __attribute__((noinline, noclone))
75 amb_x (int i)
76 {
77 amb_y (i + 5);
78 }
79
80 static void __attribute__((noinline, noclone))
81 amb (int i)
82 {
83 if (i < 0)
84 amb_x (i + 3);
85 else
86 amb_x (i + 4);
87 }
88
89 static void __attribute__((noinline, noclone))
90 amb_b (int i)
91 {
92 amb (i + 2);
93 }
94
95 static void __attribute__((noinline, noclone))
96 amb_a (int i)
97 {
98 amb_b (i + 1);
99 }
100
101 static void __attribute__((noinline, noclone)) self (int i);
102
103 static void __attribute__((noinline, noclone))
104 self2 (int i)
105 {
106 self (i);
107 }
108
109 static void __attribute__((noinline, noclone))
110 self (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
124 static void __attribute__((noinline, noclone))
125 stacktest (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);
134 asm ("breakhere_stacktest:");
135 e (v, v);
136 }
137
138 static int __attribute__((noinline, noclone))
139 data (void)
140 {
141 return 10;
142 }
143
144 static int __attribute__((noinline, noclone))
145 data2 (void)
146 {
147 return 20;
148 }
149
150 static int __attribute__((noinline, noclone))
151 different (int val)
152 {
153 val++;
154 e (val, val);
155 asm ("breakhere_different:");
156 return val;
157 }
158
159 static int __attribute__((noinline, noclone))
160 validity (int lost, int born)
161 {
162 lost = data ();
163 e (0, 0.0);
164 asm ("breakhere_validity:");
165 return born;
166 }
167
168 static void __attribute__((noinline, noclone))
169 invalid (int inv)
170 {
171 e (0, 0.0);
172 asm ("breakhere_invalid:");
173 }
174
175 int
176 main ()
177 {
178 d (30, 30.5);
179 locexpr (30);
180 stacktest (1, 2, 3, 4, 5, 6, 11, 12,
181 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 11.5, 12.5);
182 different (5);
183 validity (5, data ());
184 invalid (data2 ());
185
186 if (v)
187 a (1, 1.25);
188 else
189 b (5, 5.25);
190 amb_a (100);
191 self (200);
192 return 0;
193 }