Commit | Line | Data |
---|---|---|
8bfabb04 AC |
1 | /* This testcase is part of GDB, the GNU debugger. |
2 | ||
3 | Copyright 1996, 1999, 2003 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 2 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, write to the Free Software | |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
18 | 02111-1307, USA. */ | |
19 | ||
20 | #include <signal.h> | |
21 | #include <setjmp.h> | |
725603e1 | 22 | #include <stdlib.h> |
8bfabb04 AC |
23 | |
24 | enum tests { | |
25 | code_entry_point, code_descriptor, data_pointer | |
26 | }; | |
27 | ||
28 | static volatile enum tests test; | |
29 | ||
30 | /* Some basic types and zero buffers. */ | |
31 | ||
32 | typedef long data_t; | |
33 | typedef long code_t (void); | |
34 | static volatile data_t *data[10]; | |
35 | static volatile code_t *code[10]; | |
36 | ||
8f5a3103 | 37 | sigjmp_buf env; |
8bfabb04 AC |
38 | |
39 | extern void | |
40 | keeper (int sig) | |
41 | { | |
725603e1 | 42 | siglongjmp (env, 0); |
8bfabb04 AC |
43 | } |
44 | ||
45 | extern long | |
46 | bowler (void) | |
47 | { | |
48 | switch (test) | |
49 | { | |
50 | case data_pointer: | |
51 | return *data[0]; | |
52 | case code_entry_point: | |
53 | return code[0] (); | |
54 | case code_descriptor: | |
55 | return ((code_t *) &code) (); | |
56 | } | |
57 | } | |
58 | ||
59 | int | |
60 | main () | |
61 | { | |
62 | static volatile int i; | |
725603e1 UW |
63 | |
64 | struct sigaction act; | |
65 | memset (&act, 0, sizeof act); | |
66 | act.sa_handler = keeper; | |
67 | sigaction (SIGSEGV, &act, NULL); | |
68 | ||
8bfabb04 AC |
69 | for (i = 0; i < 10; i++) |
70 | { | |
725603e1 | 71 | sigsetjmp (env, 1); |
8bfabb04 AC |
72 | bowler (); |
73 | } | |
74 | } |