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> | |
22 | ||
23 | enum tests { | |
24 | code_entry_point, code_descriptor, data_pointer | |
25 | }; | |
26 | ||
27 | static volatile enum tests test; | |
28 | ||
29 | /* Some basic types and zero buffers. */ | |
30 | ||
31 | typedef long data_t; | |
32 | typedef long code_t (void); | |
33 | static volatile data_t *data[10]; | |
34 | static volatile code_t *code[10]; | |
35 | ||
36 | jmp_buf env; | |
37 | ||
38 | extern void | |
39 | keeper (int sig) | |
40 | { | |
41 | longjmp (env, 0); | |
42 | } | |
43 | ||
44 | extern long | |
45 | bowler (void) | |
46 | { | |
47 | switch (test) | |
48 | { | |
49 | case data_pointer: | |
50 | return *data[0]; | |
51 | case code_entry_point: | |
52 | return code[0] (); | |
53 | case code_descriptor: | |
54 | return ((code_t *) &code) (); | |
55 | } | |
56 | } | |
57 | ||
58 | int | |
59 | main () | |
60 | { | |
61 | static volatile int i; | |
62 | signal (SIGSEGV, keeper); | |
63 | for (i = 0; i < 10; i++) | |
64 | { | |
65 | setjmp (env); | |
66 | bowler (); | |
67 | } | |
68 | } |