Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.reverse / machinestate.c
blob663576938c2fae1cce747713d535bf78a801c07b
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2008-2024 Free Software Foundation, Inc.
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.
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.
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/>. */
19 * Test restoration of machine state
22 extern void hide (int);
24 /* Test register variable
25 Requires -- compiler honors 'register'. */
27 void
28 register_state (void)
30 register int a = 0;
32 hide (a); /* External function to defeat optimization. */
33 a++; /* register_state: set breakpoint here */
34 hide (a); /* register post-change */
37 /* Test auto variable (whatever that means). */
39 void
40 auto_state (void)
42 auto int a = 0;
44 hide (a); /* External function to defeat optimization. */
45 a++; /* auto_state: set breakpoint here */
46 hide (a); /* auto post-change */
49 /* Test function-static variable. */
51 void
52 function_static_state (void)
54 static int a = 0;
56 hide (a); /* External function to defeat optimization. */
57 a++; /* function_static_state: set breakpoint here */
58 hide (a); /* function static post-change */
61 /* Test module-static variable. */
63 static int astatic;
65 void
66 module_static_state (void)
68 astatic = 0;
70 hide (astatic); /* External function to defeat optimization. */
71 astatic++; /* module_static_state: set breakpoint here */
72 hide (astatic); /* module static post-change */
75 /* Test module-global variable. */
77 int aglobal;
79 void
80 module_global_state (void)
82 aglobal = 0;
84 hide (aglobal); /* External function to defeat optimization. */
85 aglobal++; /* module_global_state: set breakpoint here */
86 hide (aglobal); /* module global post-change */
89 /* main test driver */
91 int
92 main (int argc, char **argv)
94 register_state (); /* begin main */
95 auto_state ();
96 function_static_state ();
97 module_static_state ();
98 module_global_state ();
100 return 0; /* end main */