]>
Commit | Line | Data |
---|---|---|
d5f96005 PA |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
4a94e368 | 3 | Copyright 1993-2022 Free Software Foundation, Inc. |
d5f96005 PA |
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 | #if defined __x86_64__ | |
19 | # define ASM_REG "rax" | |
20 | #elif defined __i386__ | |
21 | # define ASM_REG "eax" | |
485caa08 CL |
22 | #elif defined __powerpc64__ |
23 | # define ASM_REG "r9" | |
d5f96005 PA |
24 | #else |
25 | # error "port me" | |
26 | #endif | |
27 | ||
28 | /* A class small enough that it fits in a register. */ | |
29 | struct small | |
30 | { | |
31 | int x; | |
32 | int method (); | |
33 | }; | |
34 | ||
35 | int | |
36 | small::method () | |
37 | { | |
38 | return x + 5; | |
39 | } | |
40 | ||
41 | int | |
42 | register_class () | |
43 | { | |
44 | /* Given the use of the GNU register-asm local variables extension, | |
45 | the compiler puts this variable in a register. This means that | |
46 | GDB can't call any methods for this variable, which is what we | |
47 | want to test. */ | |
48 | register small v asm (ASM_REG); | |
49 | ||
50 | int i; | |
51 | ||
52 | /* Perform a computation sufficiently complicated that optimizing | |
53 | compilers won't optimize out the variable. If some compiler | |
54 | constant-folds this whole loop, maybe using a parameter to this | |
55 | function here would help. */ | |
56 | v.x = 0; | |
57 | for (i = 0; i < 13; ++i) | |
58 | v.x += i; | |
59 | --v.x; /* v.x is now 77 */ | |
60 | return v.x + 5; /* set breakpoint here */ | |
61 | } | |
62 | ||
63 | int | |
64 | main () | |
65 | { | |
66 | register_class (); | |
67 | return 0; | |
68 | } |