[gdb/testsuite] Factor out lib/valgrind.exp
[external/binutils.git] / gdb / testsuite / gdb.base / gdb1250.c
1 /* Test program for stack trace through noreturn function.
2
3    Copyright 2003-2018 Free Software Foundation, Inc.
4
5    This file is part of the gdb testsuite.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  
20    This file was written by Michael Elizabeth Chastain (mec@shout.net).  */
21
22 #include <stdlib.h>
23
24 int global = 0;
25
26 /* Foo, gcc thinks 'gamma' is a reserved identifier.
27    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12213
28    I am not interested in testing that point so just avoid the word.
29    -- chastain 2003-09-08. */
30 void my_gamma (int *parray)
31 {
32   return;
33 }
34
35 void beta ()
36 {
37   int array [4];
38   array [0] = global++;
39   array [1] = global++;
40   array [2] = global++;
41   array [3] = global++;
42   my_gamma (array);
43   abort ();
44 }
45
46 int alpha ()
47 {
48   global++;
49   beta ();
50   return 0;
51 }
52
53 int main ()
54 {
55   int i;
56   global++;
57   i = alpha ();
58   return i;
59 }