]>
Commit | Line | Data |
---|---|---|
0b302171 JB |
1 | /* Copyright 1992-1996, 1999, 2004, 2007-2012 Free Software Foundation, |
2 | Inc. | |
0a8490ad MC |
3 | |
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
a9762ec7 JB |
8 | the Free Software Foundation; either version 3 of the License, or |
9 | (at your option) any later version. | |
0a8490ad | 10 | |
a9762ec7 JB |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
0a8490ad MC |
15 | |
16 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
0a8490ad | 18 | |
d65308ae RM |
19 | /* Simple little program that just generates a core dump from inside some |
20 | nested function calls. Keep this as self contained as possible, I.E. | |
21 | use no environment resources other than possibly abort(). */ | |
22 | ||
23 | #ifndef __STDC__ | |
24 | #define const /**/ | |
25 | #endif | |
26 | ||
27 | #ifndef HAVE_ABORT | |
28 | #define HAVE_ABORT 1 | |
29 | #endif | |
30 | ||
31 | #if HAVE_ABORT | |
c9133d23 | 32 | #include <stdlib.h> |
d65308ae RM |
33 | #define ABORT abort() |
34 | #else | |
35 | #define ABORT {char *invalid = 0; *invalid = 0xFF;} | |
36 | #endif | |
37 | ||
2e98ca53 JK |
38 | #ifdef USE_RLIMIT |
39 | # include <sys/resource.h> | |
40 | # ifndef RLIM_INFINITY | |
41 | # define RLIM_INFINITY -1 | |
42 | # endif | |
43 | #endif /* USE_RLIMIT */ | |
44 | ||
d65308ae RM |
45 | /* Don't make these automatic vars or we will have to walk back up the |
46 | stack to access them. */ | |
47 | ||
48 | char *buf1; | |
49 | char *buf2; | |
50 | ||
51 | int coremaker_data = 1; /* In Data section */ | |
52 | int coremaker_bss; /* In BSS section */ | |
53 | ||
54 | const int coremaker_ro = 201; /* In Read-Only Data section */ | |
55 | ||
56 | void | |
57 | func2 (int x) | |
58 | { | |
59 | int coremaker_local[5]; | |
60 | int i; | |
61 | static int y; | |
62 | ||
2e98ca53 JK |
63 | #ifdef USE_RLIMIT |
64 | { | |
65 | struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY }; | |
66 | ||
67 | setrlimit (RLIMIT_CORE, &rlim); | |
68 | } | |
69 | #endif | |
70 | ||
d65308ae RM |
71 | /* Make sure that coremaker_local doesn't get optimized away. */ |
72 | for (i = 0; i < 5; i++) | |
73 | coremaker_local[i] = i; | |
74 | coremaker_bss = 0; | |
75 | for (i = 0; i < 5; i++) | |
76 | coremaker_bss += coremaker_local[i]; | |
77 | coremaker_data = coremaker_ro + 1; | |
78 | y = 10 * x; | |
79 | ABORT; | |
80 | } | |
81 | ||
82 | void | |
83 | func1 (int x) | |
84 | { | |
85 | func2 (x * 2); | |
86 | } | |
87 | ||
88 | int main () | |
89 | { | |
90 | func1 (10); | |
91 | return 0; | |
92 | } |