Don't elide all inlined frames
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.opt / inline-break.c
CommitLineData
481860b3
GB
1/* This testcase is part of GDB, the GNU debugger.
2
e2882c85 3 Copyright (C) 2012-2018 Free Software Foundation, Inc.
481860b3
GB
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/* The file ../gdb.dwarf2/inline-break.S was generated manually from
19 this file, and should be regenerated if this file is modified. */
20
21#ifdef __GNUC__
522c09bf 22# define ATTR __attribute__((gnu_inline)) __attribute__((always_inline))
481860b3
GB
23#else
24# define ATTR
25#endif
26
27/* A static inlined function that is called once. */
28
29static inline ATTR int
30func1 (int x)
31{
32 return x * 23;
33}
34
35/* A non-static inlined function that is called once. */
36
37inline ATTR int
38func2 (int x)
39{
40 return x * 17;
41}
42
43/* A static inlined function that calls another static inlined
44 function. */
45
46static inline ATTR int
47func3b (int x)
48{
49 return x < 14 ? 1 : 2;
50}
51
52static inline ATTR int
53func3a (int x)
54{
55 return func3b (x * 23);
56}
57
58/* A non-static inlined function that calls a static inlined
59 function. */
60
61static inline ATTR int
62func4b (int x)
63{
64 return x < 13 ? 1 : 2;
65}
66
67inline ATTR int
68func4a (int x)
69{
70 return func4b (x * 17);
71}
72
73/* A static inlined function that calls a non-static inlined
74 function. */
75
76inline ATTR int
77func5b (int x)
78{
79 return x < 12 ? 1 : 2;
80}
81
82static inline ATTR int
83func5a (int x)
84{
85 return func5b (x * 23);
86}
87
88/* A non-static inlined function that calls another non-static inlined
89 function. */
90
91inline ATTR int
92func6b (int x)
93{
94 return x < 14 ? 3 : 2;
95}
96
97inline ATTR int
98func6a (int x)
99{
100 return func6b (x * 17);
101}
102
103/* A static inlined function that is called more than once. */
104
105static inline ATTR int
106func7b (int x)
107{
108 return x < 23 ? 1 : 4;
109}
110
111static inline ATTR int
112func7a (int x)
113{
114 return func7b (x * 29);
115}
116
117/* A non-static inlined function that is called more than once. */
118
119inline ATTR int
120func8b (int x)
121{
122 return x < 7 ? 11 : 9;
123}
124
125static inline ATTR int
126func8a (int x)
127{
128 return func8b (x * 31);
129}
130
ddfe970e
KS
131static inline ATTR int
132inline_func1 (int x)
133{
134 int y = 1; /* inline_func1 */
135
136 return y + x;
137}
138
139static int
140not_inline_func1 (int x)
141{
142 int y = 2; /* not_inline_func1 */
143
144 return y + inline_func1 (x);
145}
146
147inline ATTR int
148inline_func2 (int x)
149{
150 int y = 3; /* inline_func2 */
151
152 return y + not_inline_func1 (x);
153}
154
155int
156not_inline_func2 (int x)
157{
158 int y = 4; /* not_inline_func2 */
159
160 return y + inline_func2 (x);
161}
162
163static inline ATTR int
164inline_func3 (int x)
165{
166 int y = 5; /* inline_func3 */
167
168 return y + not_inline_func2 (x);
169}
170
171static int
172not_inline_func3 (int x)
173{
174 int y = 6; /* not_inline_func3 */
175
176 return y + inline_func3 (x);
177}
178
481860b3
GB
179/* Entry point. */
180
181int
182main (int argc, char *argv[])
183{
184 /* Declaring x as volatile here prevents GCC from combining calls.
185 If GCC is allowed to combine calls then some of them end up with
186 no instructions at all, so there is no specific address for GDB
187 to set a breakpoint at. */
188 volatile int x = argc;
189
190 x = func1 (x);
191
192 x = func2 (x);
193
194 x = func3a (x);
195
196 x = func4a (x);
197
198 x = func5a (x);
199
200 x = func6a (x);
201
202 x = func7a (x) + func7b (x);
203
204 x = func8a (x) + func8b (x);
205
ddfe970e
KS
206 x = not_inline_func3 (-21);
207
481860b3
GB
208 return x;
209}
This page took 0.764378 seconds and 4 git commands to generate.