[PATCH 7/57][Arm][GAS] Add support for MVE instructions: vstr/vldr
[binutils-gdb.git] / gdb / testsuite / gdb.base / longjmp.c
blob1bba72d8034943e6da745e9d55a7e52798ba696e
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2008-2019 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/>. */
18 #include <setjmp.h>
20 jmp_buf env;
22 volatile int longjmps = 0;
23 volatile int resumes = 0;
25 int
26 call_longjmp (jmp_buf *buf)
28 longjmps++;
29 longjmp (*buf, 1);
32 void
33 hidden_longjmp (void)
35 if (setjmp (env) == 0)
37 call_longjmp (&env);
39 else
40 resumes++;
43 int
44 main ()
46 volatile int i = 0;
48 /* Pattern 1 - simple longjmp. */
49 if (setjmp (env) == 0) /* patt1 */
51 longjmps++;
52 longjmp (env, 1);
54 else
56 resumes++;
59 i = 1; /* miss_step_1 */
62 /* Pattern 2 - longjmp from an inner function. */
63 if (setjmp (env) == 0) /* patt2 */
65 call_longjmp (&env);
67 else
69 resumes++;
72 i = 2; /* miss_step_2 */
74 /* Pattern 3 - setjmp/longjmp inside stepped-over function. */
75 hidden_longjmp (); /* patt3 */
77 i = 77; /* longjmp caught */
79 i = 3; /* patt_end3. */
81 return 0;