xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/nodebug.c (revision 47c37bc27558091724f1a0d4eef4c8f80c94c00a)
1 #include <stdlib.h>
2 #include <stdint.h>
3 
4 /* Test that things still (sort of) work when compiled without -g.  */
5 
6 int dataglobal = 3;			/* Should go in global data */
7 static int datalocal = 4;		/* Should go in local data */
8 int bssglobal;				/* Should go in global bss */
9 static int bsslocal;			/* Should go in local bss */
10 
11 /* Non-int-sized global data variables.  */
12 uint8_t dataglobal8 = 0xff;
13 uint32_t dataglobal32_1 = 0x7fffffff;
14 uint32_t dataglobal32_2 = 0x000000ff;
15 uint64_t dataglobal64_1 = 0x7fffffffffffffff;
16 uint64_t dataglobal64_2 = 0x00000000000000ff;
17 
18 int
inner(int x)19 inner (int x)
20 {
21   return x + dataglobal + datalocal + bssglobal + bsslocal;
22 }
23 
24 static short
middle(int x)25 middle (int x)
26 {
27   return 2 * inner (x);
28 }
29 
30 short
top(int x)31 top (int x)
32 {
33   return 2 * middle (x);
34 }
35 
36 int
main(int argc,char ** argv)37 main (int argc, char **argv)
38 {
39   return top (argc);
40 }
41 
42 int *x;
43 
array_index(char * arr,int i)44 int array_index (char *arr, 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 
56 float
multf(float v1,float v2)57 multf (float v1, float v2)
58 {
59   return v1 * v2;
60 }
61 
62 float
multf_noproto(v1,v2)63 multf_noproto (v1, v2)
64   float v1, v2;
65 {
66   return v1 * v2;
67 }
68 
69 double
mult(double v1,double v2)70 mult (double v1, double v2)
71 {
72   return v1 * v2;
73 }
74 
75 double
mult_noproto(v1,v2)76 mult_noproto (v1, v2)
77   double v1, v2;
78 {
79   return v1 * v2;
80 }
81 
82 uint8_t
add8(uint8_t v1,uint8_t v2)83 add8 (uint8_t v1, uint8_t v2)
84 {
85   return v1 + v2;
86 }
87 
88 uint8_t
add8_noproto(v1,v2)89 add8_noproto (v1, v2)
90   uint8_t v1, v2;
91 {
92   return v1 + v2;
93 }
94