OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.base/] [whatis.c] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 *      Test file with lots of different types, for testing the
3
 *      "whatis" command.
4
 */
5
 
6
/*
7
 *      First the basic C types.
8
 */
9
 
10
#if !(defined (__STDC__) || defined (_AIX))
11
#define signed  /**/
12
#endif
13
 
14
char            v_char;
15
signed char     v_signed_char;
16
unsigned char   v_unsigned_char;
17
 
18
short           v_short;
19
signed short    v_signed_short;
20
unsigned short  v_unsigned_short;
21
 
22
int             v_int;
23
signed int      v_signed_int;
24
unsigned int    v_unsigned_int;
25
 
26
long            v_long;
27
signed long     v_signed_long;
28
unsigned long   v_unsigned_long;
29
 
30
float           v_float;
31
double          v_double;
32
 
33
/*
34
 *      Now some derived types, which are arrays, functions-returning,
35
 *      pointers, structures, unions, and enumerations.
36
 */
37
 
38
/**** arrays *******/
39
 
40
char            v_char_array[2];
41
signed char     v_signed_char_array[2];
42
unsigned char   v_unsigned_char_array[2];
43
 
44
short           v_short_array[2];
45
signed short    v_signed_short_array[2];
46
unsigned short  v_unsigned_short_array[2];
47
 
48
int             v_int_array[2];
49
signed int      v_signed_int_array[2];
50
unsigned int    v_unsigned_int_array[2];
51
 
52
long            v_long_array[2];
53
signed long     v_signed_long_array[2];
54
unsigned long   v_unsigned_long_array[2];
55
 
56
float           v_float_array[2];
57
double          v_double_array[2];
58
 
59
/**** pointers *******/
60
 
61
/* Make sure they still print as pointer to foo even there is a typedef
62
   for that type.  Test this not just for char *, which might be
63
   a special case kludge in GDB (Unix system include files like to define
64
   caddr_t), but for a variety of types.  */
65
typedef char *char_addr;
66
typedef unsigned short *ushort_addr;
67
typedef signed long *slong_addr;
68
 
69
char            *v_char_pointer;
70
signed char     *v_signed_char_pointer;
71
unsigned char   *v_unsigned_char_pointer;
72
 
73
short           *v_short_pointer;
74
signed short    *v_signed_short_pointer;
75
unsigned short  *v_unsigned_short_pointer;
76
 
77
int             *v_int_pointer;
78
signed int      *v_signed_int_pointer;
79
unsigned int    *v_unsigned_int_pointer;
80
 
81
long            *v_long_pointer;
82
signed long     *v_signed_long_pointer;
83
unsigned long   *v_unsigned_long_pointer;
84
 
85
float           *v_float_pointer;
86
double          *v_double_pointer;
87
 
88
/**** structs *******/
89
 
90
struct t_struct {
91
    char        v_char_member;
92
    short       v_short_member;
93
    int         v_int_member;
94
    long        v_long_member;
95
    float       v_float_member;
96
    double      v_double_member;
97
} v_struct1;
98
 
99
struct {
100
    char        v_char_member;
101
    short       v_short_member;
102
    int         v_int_member;
103
    long        v_long_member;
104
    float       v_float_member;
105
    double      v_double_member;
106
} v_struct2;
107
 
108
/**** unions *******/
109
 
110
union t_union {
111
    char        v_char_member;
112
    short       v_short_member;
113
    int         v_int_member;
114
    long        v_long_member;
115
    float       v_float_member;
116
    double      v_double_member;
117
} v_union;
118
 
119
union {
120
    char        v_char_member;
121
    short       v_short_member;
122
    int         v_int_member;
123
    long        v_long_member;
124
    float       v_float_member;
125
    double      v_double_member;
126
} v_union2;
127
 
128
/*** Functions returning type ********/
129
 
130
char            v_char_func () { return(0); }
131
signed char     v_signed_char_func () { return (0); }
132
unsigned char   v_unsigned_char_func () { return (0); }
133
 
134
short           v_short_func () { return (0); }
135
signed short    v_signed_short_func () { return (0); }
136
unsigned short  v_unsigned_short_func () { return (0); }
137
 
138
int             v_int_func () { return (0); }
139
signed int      v_signed_int_func () { return (0); }
140
unsigned int    v_unsigned_int_func () { return (0); }
141
 
142
long            v_long_func () { return (0); }
143
signed long     v_signed_long_func () { return (0); }
144
unsigned long   v_unsigned_long_func () { return (0); }
145
 
146
float           v_float_func () { return (0.0); }
147
double          v_double_func () { return (0.0); }
148
 
149
/**** Some misc more complicated things *******/
150
 
151
struct link {
152
        struct link *next;
153
#ifdef __STDC__
154
        struct link *(*linkfunc) (struct link *this, int flags);
155
#else
156
        struct link *(*linkfunc) ();
157
#endif
158
        struct t_struct stuff[1][2][3];
159
} *s_link;
160
 
161
union tu_link {
162
        struct link *next;
163
#ifdef __STDC__
164
        struct link *(*linkfunc) (struct link *this, int flags);
165
#else
166
        struct link *(*linkfunc) ();
167
#endif
168
        struct t_struct stuff[1][2][3];
169
} u_link;
170
 
171
struct outer_struct {
172
        int outer_int;
173
        struct inner_struct {
174
                int inner_int;
175
                long inner_long;
176
        }inner_struct_instance;
177
        union inner_union {
178
                int inner_union_int;
179
                long inner_union_long;
180
        }inner_union_instance;
181
        long outer_long;
182
} nested_su;
183
 
184
/**** Enumerations *******/
185
 
186
enum colors {red, green, blue} color;
187
enum cars {chevy, ford, porsche} clunker;
188
 
189
/***********/
190
 
191
int main ()
192
{
193
#ifdef usestubs
194
  set_debug_traps();
195
  breakpoint();
196
#endif
197
  /* Some linkers (e.g. on AIX) remove unreferenced variables,
198
     so make sure to reference them. */
199
  v_char = 0;
200
  v_signed_char = 1;
201
  v_unsigned_char = 2;
202
 
203
  v_short = 3;
204
  v_signed_short = 4;
205
  v_unsigned_short = 5;
206
 
207
  v_int = 6;
208
  v_signed_int = 7;
209
  v_unsigned_int = 8;
210
 
211
  v_long = 9;
212
  v_signed_long = 10;
213
  v_unsigned_long = 11;
214
 
215
  v_float = 100.0;
216
  v_double = 200.0;
217
 
218
 
219
  v_char_array[0] = v_char;
220
  v_signed_char_array[0] = v_signed_char;
221
  v_unsigned_char_array[0] = v_unsigned_char;
222
 
223
  v_short_array[0] = v_short;
224
  v_signed_short_array[0] = v_signed_short;
225
  v_unsigned_short_array[0] = v_unsigned_short;
226
 
227
  v_int_array[0] = v_int;
228
  v_signed_int_array[0] = v_signed_int;
229
  v_unsigned_int_array[0] = v_unsigned_int;
230
 
231
  v_long_array[0] = v_long;
232
  v_signed_long_array[0] = v_signed_long;
233
  v_unsigned_long_array[0] = v_unsigned_long;
234
 
235
  v_float_array[0] = v_float;
236
  v_double_array[0] = v_double;
237
 
238
  v_char_pointer = &v_char;
239
  v_signed_char_pointer = &v_signed_char;
240
  v_unsigned_char_pointer = &v_unsigned_char;
241
 
242
  v_short_pointer = &v_short;
243
  v_signed_short_pointer = &v_signed_short;
244
  v_unsigned_short_pointer = &v_unsigned_short;
245
 
246
  v_int_pointer = &v_int;
247
  v_signed_int_pointer = &v_signed_int;
248
  v_unsigned_int_pointer = &v_unsigned_int;
249
 
250
  v_long_pointer = &v_long;
251
  v_signed_long_pointer = &v_signed_long;
252
  v_unsigned_long_pointer = &v_unsigned_long;
253
 
254
  v_float_pointer = &v_float;
255
  v_double_pointer = &v_double;
256
 
257
  color = red;
258
  clunker = porsche;
259
 
260
  u_link.next = s_link;
261
 
262
  v_union2.v_short_member = v_union.v_short_member;
263
 
264
  v_struct1.v_char_member = 0;
265
  v_struct2.v_char_member = 0;
266
 
267
  nested_su.outer_int = 0;
268
  return 0;
269
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.