Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / testsuite / gdb.base / nodebug.c
1 #include <stdlib.h>
2 /* Test that things still (sort of) work when compiled without -g.  */
3
4 int dataglobal = 3;                     /* Should go in global data */
5 static int datalocal = 4;               /* Should go in local data */
6 int bssglobal;                          /* Should go in global bss */
7 static int bsslocal;                    /* Should go in local bss */
8
9 int
10 inner (int x)
11 {
12   return x + dataglobal + datalocal + bssglobal + bsslocal;
13 }
14
15 static short
16 middle (int x)
17 {
18   return 2 * inner (x);
19 }
20
21 short
22 top (int x)
23 {
24   return 2 * middle (x);
25 }
26
27 int
28 main (int argc, char **argv)
29 {
30   return top (argc);
31 }
32
33 int *x;
34
35 int array_index (char *arr, int i)
36 {
37   /* The basic concept is just "return arr[i];".  But call malloc so that gdb
38      will be able to call functions.  */
39   char retval;
40   x = (int *) malloc (sizeof (int));
41   *x = i;
42   retval = arr[*x];
43   free (x);
44   return retval;
45 }