1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2011-2020 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 /* Based on the gcc testcase `gcc/testsuite/gcc.dg/split-1.c'. This test
19 needs to use setrlimit to set the stack size, so it can only run on Unix.
23 #include <sys/types.h>
24 #include <sys/resource.h>
28 /* Use a noinline function to ensure that the buffer is not removed
30 static void use_buffer (char *buf
) __attribute__ ((noinline
));
32 use_buffer (char *buf
)
37 static volatile int marker_var
;
52 #define RESERVED_SIZE 0x1000000
54 /* Each recursive call uses 10,000 bytes. We call it 1000 times,
55 using a total of 10,000,000 bytes. If -fsplit-stack is not
56 working, that will overflow our stack limit. */
64 if (last
&& last
< (void *) buf
)
66 printf ("%d: %p < %p\n", i
, last
, buf
);
73 if (munmap (reserved
, RESERVED_SIZE
) != 0)
92 reserved
= mmap (NULL
, RESERVED_SIZE
, PROT_READ
| PROT_WRITE
,
93 MAP_ANONYMOUS
| MAP_PRIVATE
, -1, 0);
94 if (reserved
== MAP_FAILED
)
97 /* We set a stack limit because we are usually invoked via make, and
98 make sets the stack limit to be as large as possible. */
99 r
.rlim_cur
= 8192 * 1024;
100 r
.rlim_max
= 8192 * 1024;
101 if (setrlimit (RLIMIT_STACK
, &r
) != 0)
This page took 0.030718 seconds and 4 git commands to generate.