xref: /openbsd-src/gnu/usr.bin/binutils/gdb/testsuite/gdb.base/nodebug.c (revision a4afd6dad3fba28f80e70208181c06c482259988)
1 /* Test that things still (sort of) work when compiled without -g.  */
2 
3 int dataglobal = 3;			/* Should go in global data */
4 static int datalocal = 4;		/* Should go in local data */
5 int bssglobal;				/* Should go in global bss */
6 static int bsslocal;			/* Should go in local bss */
7 
8 int
9 inner (x)
10      int x;
11 {
12   return x + dataglobal + datalocal + bssglobal + bsslocal;
13 }
14 
15 static short
16 middle (x)
17      int x;
18 {
19   return 2 * inner (x);
20 }
21 
22 short
23 top (x)
24      int x;
25 {
26   return 2 * middle (x);
27 }
28 
29 int
30 main (argc, argv)
31      int argc;
32      char **argv;
33 {
34   return top (argc);
35 }
36 
37 char *malloc ();
38 
39 int *x;
40 
41 int
42 array_index (arr, i)
43      char *arr;
44      int i;
45 {
46   /* The basic concept is just "return arr[i];".  But call malloc so that gdb
47      will be able to call functions.  */
48   char retval;
49   x = (int *) malloc (sizeof (int));
50   *x = i;
51   retval = arr[*x];
52   free (x);
53   return retval;
54 }
55