Commit | Line | Data |
---|---|---|
1ab3bf1b | 1 | /* Support routines for manipulating internal types for GDB. |
24418cfb | 2 | Copyright (C) 1992, 93, 94, 95, 96, 1998 Free Software Foundation, Inc. |
1ab3bf1b JG |
3 | Contributed by Cygnus Support, using pieces from other GDB modules. |
4 | ||
5 | This file is part of GDB. | |
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 2 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, write to the Free Software | |
6c9638b4 | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
1ab3bf1b | 20 | |
1ab3bf1b | 21 | #include "defs.h" |
2b576293 | 22 | #include "gdb_string.h" |
1ab3bf1b JG |
23 | #include "bfd.h" |
24 | #include "symtab.h" | |
25 | #include "symfile.h" | |
5e2e79f8 | 26 | #include "objfiles.h" |
1ab3bf1b JG |
27 | #include "gdbtypes.h" |
28 | #include "expression.h" | |
29 | #include "language.h" | |
30 | #include "target.h" | |
31 | #include "value.h" | |
8f793aa5 | 32 | #include "demangle.h" |
51b80b00 | 33 | #include "complaints.h" |
1ab3bf1b | 34 | |
c4413e2c FF |
35 | /* These variables point to the objects |
36 | representing the predefined C data types. */ | |
37 | ||
38 | struct type *builtin_type_void; | |
39 | struct type *builtin_type_char; | |
40 | struct type *builtin_type_short; | |
41 | struct type *builtin_type_int; | |
42 | struct type *builtin_type_long; | |
43 | struct type *builtin_type_long_long; | |
44 | struct type *builtin_type_signed_char; | |
45 | struct type *builtin_type_unsigned_char; | |
46 | struct type *builtin_type_unsigned_short; | |
47 | struct type *builtin_type_unsigned_int; | |
48 | struct type *builtin_type_unsigned_long; | |
49 | struct type *builtin_type_unsigned_long_long; | |
50 | struct type *builtin_type_float; | |
51 | struct type *builtin_type_double; | |
52 | struct type *builtin_type_long_double; | |
53 | struct type *builtin_type_complex; | |
54 | struct type *builtin_type_double_complex; | |
55 | struct type *builtin_type_string; | |
980714f9 AC |
56 | struct type *builtin_type_int8; |
57 | struct type *builtin_type_uint8; | |
58 | struct type *builtin_type_int16; | |
59 | struct type *builtin_type_uint16; | |
60 | struct type *builtin_type_int32; | |
61 | struct type *builtin_type_uint32; | |
62 | struct type *builtin_type_int64; | |
63 | struct type *builtin_type_uint64; | |
64 | /* start-sanitize-r5900 */ | |
65 | struct type *builtin_type_int128; | |
66 | struct type *builtin_type_uint128; | |
67 | /* end-sanitize-r5900 */ | |
c4413e2c | 68 | |
b607efe7 FF |
69 | struct extra { char str[128]; int len; }; /* maximum extention is 128! FIXME */ |
70 | ||
71 | static void add_name PARAMS ((struct extra *, char *)); | |
72 | static void add_mangled_type PARAMS ((struct extra *, struct type *)); | |
73 | #if 0 | |
74 | static void cfront_mangle_name PARAMS ((struct type *, int, int)); | |
75 | #endif | |
76 | static void print_bit_vector PARAMS ((B_TYPE *, int)); | |
77 | static void print_arg_types PARAMS ((struct type **, int)); | |
78 | static void dump_fn_fieldlists PARAMS ((struct type *, int)); | |
79 | static void print_cplus_stuff PARAMS ((struct type *, int)); | |
80 | ||
24418cfb JM |
81 | void _initialize_gdbtypes PARAMS ((void)); |
82 | ||
1ab3bf1b JG |
83 | /* Alloc a new type structure and fill it with some defaults. If |
84 | OBJFILE is non-NULL, then allocate the space for the type structure | |
85 | in that objfile's type_obstack. */ | |
86 | ||
87 | struct type * | |
88 | alloc_type (objfile) | |
89 | struct objfile *objfile; | |
90 | { | |
91 | register struct type *type; | |
92 | ||
93 | /* Alloc the structure and start off with all fields zeroed. */ | |
94 | ||
95 | if (objfile == NULL) | |
96 | { | |
97 | type = (struct type *) xmalloc (sizeof (struct type)); | |
98 | } | |
99 | else | |
100 | { | |
101 | type = (struct type *) obstack_alloc (&objfile -> type_obstack, | |
102 | sizeof (struct type)); | |
2dd30c72 | 103 | OBJSTAT (objfile, n_types++); |
1ab3bf1b | 104 | } |
dac9734e | 105 | memset ((char *) type, 0, sizeof (struct type)); |
1ab3bf1b JG |
106 | |
107 | /* Initialize the fields that might not be zero. */ | |
108 | ||
109 | TYPE_CODE (type) = TYPE_CODE_UNDEF; | |
110 | TYPE_OBJFILE (type) = objfile; | |
111 | TYPE_VPTR_FIELDNO (type) = -1; | |
112 | ||
113 | return (type); | |
114 | } | |
115 | ||
ea1549b3 JG |
116 | /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points |
117 | to a pointer to memory where the pointer type should be stored. | |
118 | If *TYPEPTR is zero, update it to point to the pointer type we return. | |
119 | We allocate new memory if needed. */ | |
120 | ||
121 | struct type * | |
122 | make_pointer_type (type, typeptr) | |
123 | struct type *type; | |
124 | struct type **typeptr; | |
125 | { | |
126 | register struct type *ntype; /* New type */ | |
127 | struct objfile *objfile; | |
128 | ||
129 | ntype = TYPE_POINTER_TYPE (type); | |
130 | ||
131 | if (ntype) | |
24418cfb JM |
132 | { |
133 | if (typeptr == 0) | |
134 | return ntype; /* Don't care about alloc, and have new type. */ | |
135 | else if (*typeptr == 0) | |
136 | { | |
137 | *typeptr = ntype; /* Tracking alloc, and we have new type. */ | |
138 | return ntype; | |
139 | } | |
140 | } | |
ea1549b3 JG |
141 | |
142 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |
143 | { | |
144 | ntype = alloc_type (TYPE_OBJFILE (type)); | |
145 | if (typeptr) | |
146 | *typeptr = ntype; | |
147 | } | |
148 | else /* We have storage, but need to reset it. */ | |
149 | { | |
150 | ntype = *typeptr; | |
151 | objfile = TYPE_OBJFILE (ntype); | |
dac9734e | 152 | memset ((char *) ntype, 0, sizeof (struct type)); |
ea1549b3 JG |
153 | TYPE_OBJFILE (ntype) = objfile; |
154 | } | |
155 | ||
156 | TYPE_TARGET_TYPE (ntype) = type; | |
157 | TYPE_POINTER_TYPE (type) = ntype; | |
158 | ||
159 | /* FIXME! Assume the machine has only one representation for pointers! */ | |
160 | ||
161 | TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT; | |
162 | TYPE_CODE (ntype) = TYPE_CODE_PTR; | |
163 | ||
164 | /* pointers are unsigned */ | |
165 | TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED; | |
166 | ||
167 | if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */ | |
168 | TYPE_POINTER_TYPE (type) = ntype; | |
169 | ||
170 | return ntype; | |
171 | } | |
172 | ||
1ab3bf1b JG |
173 | /* Given a type TYPE, return a type of pointers to that type. |
174 | May need to construct such a type if this is the first use. */ | |
175 | ||
176 | struct type * | |
177 | lookup_pointer_type (type) | |
178 | struct type *type; | |
179 | { | |
ea1549b3 JG |
180 | return make_pointer_type (type, (struct type **)0); |
181 | } | |
182 | ||
183 | /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points | |
184 | to a pointer to memory where the reference type should be stored. | |
185 | If *TYPEPTR is zero, update it to point to the reference type we return. | |
186 | We allocate new memory if needed. */ | |
187 | ||
188 | struct type * | |
189 | make_reference_type (type, typeptr) | |
190 | struct type *type; | |
191 | struct type **typeptr; | |
192 | { | |
193 | register struct type *ntype; /* New type */ | |
194 | struct objfile *objfile; | |
195 | ||
196 | ntype = TYPE_REFERENCE_TYPE (type); | |
1ab3bf1b | 197 | |
ea1549b3 | 198 | if (ntype) |
24418cfb JM |
199 | { |
200 | if (typeptr == 0) | |
201 | return ntype; /* Don't care about alloc, and have new type. */ | |
202 | else if (*typeptr == 0) | |
203 | { | |
204 | *typeptr = ntype; /* Tracking alloc, and we have new type. */ | |
205 | return ntype; | |
206 | } | |
207 | } | |
ea1549b3 JG |
208 | |
209 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |
210 | { | |
211 | ntype = alloc_type (TYPE_OBJFILE (type)); | |
212 | if (typeptr) | |
213 | *typeptr = ntype; | |
214 | } | |
215 | else /* We have storage, but need to reset it. */ | |
1ab3bf1b | 216 | { |
ea1549b3 JG |
217 | ntype = *typeptr; |
218 | objfile = TYPE_OBJFILE (ntype); | |
dac9734e | 219 | memset ((char *) ntype, 0, sizeof (struct type)); |
ea1549b3 | 220 | TYPE_OBJFILE (ntype) = objfile; |
1ab3bf1b | 221 | } |
ea1549b3 JG |
222 | |
223 | TYPE_TARGET_TYPE (ntype) = type; | |
224 | TYPE_REFERENCE_TYPE (type) = ntype; | |
225 | ||
226 | /* FIXME! Assume the machine has only one representation for references, | |
227 | and that it matches the (only) representation for pointers! */ | |
228 | ||
229 | TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT; | |
230 | TYPE_CODE (ntype) = TYPE_CODE_REF; | |
231 | ||
232 | if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */ | |
233 | TYPE_REFERENCE_TYPE (type) = ntype; | |
234 | ||
235 | return ntype; | |
1ab3bf1b JG |
236 | } |
237 | ||
ea1549b3 JG |
238 | /* Same as above, but caller doesn't care about memory allocation details. */ |
239 | ||
1ab3bf1b JG |
240 | struct type * |
241 | lookup_reference_type (type) | |
242 | struct type *type; | |
243 | { | |
ea1549b3 JG |
244 | return make_reference_type (type, (struct type **)0); |
245 | } | |
246 | ||
247 | /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points | |
248 | to a pointer to memory where the function type should be stored. | |
249 | If *TYPEPTR is zero, update it to point to the function type we return. | |
250 | We allocate new memory if needed. */ | |
1ab3bf1b | 251 | |
ea1549b3 JG |
252 | struct type * |
253 | make_function_type (type, typeptr) | |
254 | struct type *type; | |
255 | struct type **typeptr; | |
256 | { | |
257 | register struct type *ntype; /* New type */ | |
258 | struct objfile *objfile; | |
259 | ||
ea1549b3 | 260 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ |
1ab3bf1b | 261 | { |
ea1549b3 JG |
262 | ntype = alloc_type (TYPE_OBJFILE (type)); |
263 | if (typeptr) | |
264 | *typeptr = ntype; | |
1ab3bf1b | 265 | } |
ea1549b3 JG |
266 | else /* We have storage, but need to reset it. */ |
267 | { | |
268 | ntype = *typeptr; | |
269 | objfile = TYPE_OBJFILE (ntype); | |
dac9734e | 270 | memset ((char *) ntype, 0, sizeof (struct type)); |
ea1549b3 JG |
271 | TYPE_OBJFILE (ntype) = objfile; |
272 | } | |
273 | ||
274 | TYPE_TARGET_TYPE (ntype) = type; | |
ea1549b3 JG |
275 | |
276 | TYPE_LENGTH (ntype) = 1; | |
277 | TYPE_CODE (ntype) = TYPE_CODE_FUNC; | |
278 | ||
ea1549b3 | 279 | return ntype; |
1ab3bf1b JG |
280 | } |
281 | ||
ea1549b3 | 282 | |
1ab3bf1b JG |
283 | /* Given a type TYPE, return a type of functions that return that type. |
284 | May need to construct such a type if this is the first use. */ | |
285 | ||
286 | struct type * | |
287 | lookup_function_type (type) | |
288 | struct type *type; | |
289 | { | |
ea1549b3 | 290 | return make_function_type (type, (struct type **)0); |
1ab3bf1b JG |
291 | } |
292 | ||
293 | /* Implement direct support for MEMBER_TYPE in GNU C++. | |
294 | May need to construct such a type if this is the first use. | |
295 | The TYPE is the type of the member. The DOMAIN is the type | |
296 | of the aggregate that the member belongs to. */ | |
297 | ||
298 | struct type * | |
299 | lookup_member_type (type, domain) | |
300 | struct type *type; | |
301 | struct type *domain; | |
302 | { | |
303 | register struct type *mtype; | |
304 | ||
305 | mtype = alloc_type (TYPE_OBJFILE (type)); | |
306 | smash_to_member_type (mtype, domain, type); | |
307 | return (mtype); | |
308 | } | |
309 | ||
310 | /* Allocate a stub method whose return type is TYPE. | |
311 | This apparently happens for speed of symbol reading, since parsing | |
312 | out the arguments to the method is cpu-intensive, the way we are doing | |
313 | it. So, we will fill in arguments later. | |
314 | This always returns a fresh type. */ | |
315 | ||
316 | struct type * | |
317 | allocate_stub_method (type) | |
318 | struct type *type; | |
319 | { | |
320 | struct type *mtype; | |
321 | ||
322 | mtype = alloc_type (TYPE_OBJFILE (type)); | |
323 | TYPE_TARGET_TYPE (mtype) = type; | |
324 | /* _DOMAIN_TYPE (mtype) = unknown yet */ | |
325 | /* _ARG_TYPES (mtype) = unknown yet */ | |
326 | TYPE_FLAGS (mtype) = TYPE_FLAG_STUB; | |
327 | TYPE_CODE (mtype) = TYPE_CODE_METHOD; | |
328 | TYPE_LENGTH (mtype) = 1; | |
329 | return (mtype); | |
330 | } | |
331 | ||
a8a69e63 | 332 | /* Create a range type using either a blank type supplied in RESULT_TYPE, |
ec16f701 FF |
333 | or creating a new type, inheriting the objfile from INDEX_TYPE. |
334 | ||
335 | Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to | |
336 | HIGH_BOUND, inclusive. | |
a8a69e63 FF |
337 | |
338 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |
339 | sure it is TYPE_CODE_UNDEF before we bash it into a range type? */ | |
340 | ||
341 | struct type * | |
342 | create_range_type (result_type, index_type, low_bound, high_bound) | |
343 | struct type *result_type; | |
344 | struct type *index_type; | |
345 | int low_bound; | |
346 | int high_bound; | |
347 | { | |
348 | if (result_type == NULL) | |
349 | { | |
350 | result_type = alloc_type (TYPE_OBJFILE (index_type)); | |
351 | } | |
352 | TYPE_CODE (result_type) = TYPE_CODE_RANGE; | |
353 | TYPE_TARGET_TYPE (result_type) = index_type; | |
e55a5796 PB |
354 | if (TYPE_FLAGS (index_type) & TYPE_FLAG_STUB) |
355 | TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB; | |
356 | else | |
d1f4065e | 357 | TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type)); |
a8a69e63 FF |
358 | TYPE_NFIELDS (result_type) = 2; |
359 | TYPE_FIELDS (result_type) = (struct field *) | |
360 | TYPE_ALLOC (result_type, 2 * sizeof (struct field)); | |
361 | memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field)); | |
362 | TYPE_FIELD_BITPOS (result_type, 0) = low_bound; | |
363 | TYPE_FIELD_BITPOS (result_type, 1) = high_bound; | |
364 | TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */ | |
365 | TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */ | |
366 | ||
ce225290 FCE |
367 | if(low_bound >= 0) |
368 | TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED; | |
369 | ||
a8a69e63 FF |
370 | return (result_type); |
371 | } | |
372 | ||
706bfe5a PB |
373 | /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE. |
374 | Return 1 of type is a range type, 0 if it is discrete (and bounds | |
375 | will fit in LONGEST), or -1 otherwise. */ | |
376 | ||
377 | int | |
378 | get_discrete_bounds (type, lowp, highp) | |
379 | struct type *type; | |
380 | LONGEST *lowp, *highp; | |
381 | { | |
d1f4065e | 382 | CHECK_TYPEDEF (type); |
706bfe5a PB |
383 | switch (TYPE_CODE (type)) |
384 | { | |
4dda8ef3 | 385 | case TYPE_CODE_RANGE: |
706bfe5a PB |
386 | *lowp = TYPE_LOW_BOUND (type); |
387 | *highp = TYPE_HIGH_BOUND (type); | |
388 | return 1; | |
389 | case TYPE_CODE_ENUM: | |
d1f4065e PB |
390 | if (TYPE_NFIELDS (type) > 0) |
391 | { | |
d221b17e WM |
392 | /* The enums may not be sorted by value, so search all |
393 | entries */ | |
394 | int i; | |
395 | ||
396 | *lowp = *highp = TYPE_FIELD_BITPOS (type, 0); | |
397 | for (i = 0; i < TYPE_NFIELDS (type); i++) | |
398 | { | |
399 | if (TYPE_FIELD_BITPOS (type, i) < *lowp) | |
400 | *lowp = TYPE_FIELD_BITPOS (type, i); | |
401 | if (TYPE_FIELD_BITPOS (type, i) > *highp) | |
402 | *highp = TYPE_FIELD_BITPOS (type, i); | |
403 | } | |
7924771e FCE |
404 | |
405 | /* Set unsigned indicator if warranted. */ | |
406 | if(*lowp >= 0) | |
407 | { | |
408 | TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED; | |
409 | } | |
d1f4065e PB |
410 | } |
411 | else | |
412 | { | |
413 | *lowp = 0; | |
414 | *highp = -1; | |
415 | } | |
706bfe5a PB |
416 | return 0; |
417 | case TYPE_CODE_BOOL: | |
418 | *lowp = 0; | |
419 | *highp = 1; | |
420 | return 0; | |
421 | case TYPE_CODE_INT: | |
f6d16585 | 422 | if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */ |
706bfe5a PB |
423 | return -1; |
424 | if (!TYPE_UNSIGNED (type)) | |
425 | { | |
426 | *lowp = - (1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1)); | |
427 | *highp = -*lowp - 1; | |
428 | return 0; | |
429 | } | |
430 | /* ... fall through for unsigned ints ... */ | |
431 | case TYPE_CODE_CHAR: | |
432 | *lowp = 0; | |
f6d16585 PB |
433 | /* This round-about calculation is to avoid shifting by |
434 | TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work | |
435 | if TYPE_LENGTH (type) == sizeof (LONGEST). */ | |
436 | *highp = 1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1); | |
437 | *highp = (*highp - 1) | *highp; | |
706bfe5a PB |
438 | return 0; |
439 | default: | |
440 | return -1; | |
441 | } | |
442 | } | |
443 | ||
85f0a848 | 444 | /* Create an array type using either a blank type supplied in RESULT_TYPE, |
ec16f701 FF |
445 | or creating a new type, inheriting the objfile from RANGE_TYPE. |
446 | ||
447 | Elements will be of type ELEMENT_TYPE, the indices will be of type | |
448 | RANGE_TYPE. | |
1ab3bf1b | 449 | |
85f0a848 FF |
450 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make |
451 | sure it is TYPE_CODE_UNDEF before we bash it into an array type? */ | |
1ab3bf1b JG |
452 | |
453 | struct type * | |
a8a69e63 | 454 | create_array_type (result_type, element_type, range_type) |
85f0a848 | 455 | struct type *result_type; |
1ab3bf1b | 456 | struct type *element_type; |
a8a69e63 | 457 | struct type *range_type; |
1ab3bf1b | 458 | { |
d1f4065e | 459 | LONGEST low_bound, high_bound; |
1ab3bf1b | 460 | |
85f0a848 FF |
461 | if (result_type == NULL) |
462 | { | |
ec16f701 | 463 | result_type = alloc_type (TYPE_OBJFILE (range_type)); |
85f0a848 | 464 | } |
1ab3bf1b JG |
465 | TYPE_CODE (result_type) = TYPE_CODE_ARRAY; |
466 | TYPE_TARGET_TYPE (result_type) = element_type; | |
d1f4065e PB |
467 | if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) |
468 | low_bound = high_bound = 0; | |
469 | CHECK_TYPEDEF (element_type); | |
85f0a848 FF |
470 | TYPE_LENGTH (result_type) = |
471 | TYPE_LENGTH (element_type) * (high_bound - low_bound + 1); | |
1ab3bf1b | 472 | TYPE_NFIELDS (result_type) = 1; |
a8a69e63 FF |
473 | TYPE_FIELDS (result_type) = |
474 | (struct field *) TYPE_ALLOC (result_type, sizeof (struct field)); | |
85f0a848 | 475 | memset (TYPE_FIELDS (result_type), 0, sizeof (struct field)); |
8050a57b | 476 | TYPE_FIELD_TYPE (result_type, 0) = range_type; |
1ab3bf1b JG |
477 | TYPE_VPTR_FIELDNO (result_type) = -1; |
478 | ||
81508b27 WM |
479 | /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */ |
480 | if (TYPE_LENGTH (result_type) == 0) | |
481 | TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB; | |
482 | ||
1ab3bf1b JG |
483 | return (result_type); |
484 | } | |
485 | ||
c4413e2c FF |
486 | /* Create a string type using either a blank type supplied in RESULT_TYPE, |
487 | or creating a new type. String types are similar enough to array of | |
488 | char types that we can use create_array_type to build the basic type | |
489 | and then bash it into a string type. | |
490 | ||
491 | For fixed length strings, the range type contains 0 as the lower | |
492 | bound and the length of the string minus one as the upper bound. | |
493 | ||
494 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |
495 | sure it is TYPE_CODE_UNDEF before we bash it into a string type? */ | |
496 | ||
497 | struct type * | |
498 | create_string_type (result_type, range_type) | |
499 | struct type *result_type; | |
500 | struct type *range_type; | |
501 | { | |
ead95f8a PB |
502 | result_type = create_array_type (result_type, |
503 | *current_language->string_char_type, | |
504 | range_type); | |
c4413e2c FF |
505 | TYPE_CODE (result_type) = TYPE_CODE_STRING; |
506 | return (result_type); | |
507 | } | |
1ab3bf1b | 508 | |
e909f287 PB |
509 | struct type * |
510 | create_set_type (result_type, domain_type) | |
511 | struct type *result_type; | |
512 | struct type *domain_type; | |
513 | { | |
d1f4065e | 514 | LONGEST low_bound, high_bound, bit_length; |
e909f287 PB |
515 | if (result_type == NULL) |
516 | { | |
517 | result_type = alloc_type (TYPE_OBJFILE (domain_type)); | |
518 | } | |
519 | TYPE_CODE (result_type) = TYPE_CODE_SET; | |
520 | TYPE_NFIELDS (result_type) = 1; | |
521 | TYPE_FIELDS (result_type) = (struct field *) | |
522 | TYPE_ALLOC (result_type, 1 * sizeof (struct field)); | |
523 | memset (TYPE_FIELDS (result_type), 0, sizeof (struct field)); | |
576f9770 PB |
524 | |
525 | if (! (TYPE_FLAGS (domain_type) & TYPE_FLAG_STUB)) | |
526 | { | |
d1f4065e PB |
527 | if (get_discrete_bounds (domain_type, &low_bound, &high_bound) < 0) |
528 | low_bound = high_bound = 0; | |
576f9770 PB |
529 | bit_length = high_bound - low_bound + 1; |
530 | TYPE_LENGTH (result_type) | |
b4680522 | 531 | = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT; |
576f9770 | 532 | } |
e909f287 | 533 | TYPE_FIELD_TYPE (result_type, 0) = domain_type; |
7924771e FCE |
534 | |
535 | if(low_bound >= 0) | |
536 | TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED; | |
537 | ||
e909f287 PB |
538 | return (result_type); |
539 | } | |
540 | ||
1ab3bf1b JG |
541 | /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. |
542 | A MEMBER is a wierd thing -- it amounts to a typed offset into | |
543 | a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't | |
544 | include the offset (that's the value of the MEMBER itself), but does | |
545 | include the structure type into which it points (for some reason). | |
546 | ||
c2e4669f | 547 | When "smashing" the type, we preserve the objfile that the |
1ab3bf1b | 548 | old type pointed to, since we aren't changing where the type is actually |
c2e4669f | 549 | allocated. */ |
1ab3bf1b JG |
550 | |
551 | void | |
552 | smash_to_member_type (type, domain, to_type) | |
553 | struct type *type; | |
554 | struct type *domain; | |
555 | struct type *to_type; | |
556 | { | |
557 | struct objfile *objfile; | |
558 | ||
559 | objfile = TYPE_OBJFILE (type); | |
560 | ||
dac9734e | 561 | memset ((char *) type, 0, sizeof (struct type)); |
1ab3bf1b JG |
562 | TYPE_OBJFILE (type) = objfile; |
563 | TYPE_TARGET_TYPE (type) = to_type; | |
564 | TYPE_DOMAIN_TYPE (type) = domain; | |
565 | TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ | |
566 | TYPE_CODE (type) = TYPE_CODE_MEMBER; | |
567 | } | |
568 | ||
569 | /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE. | |
570 | METHOD just means `function that gets an extra "this" argument'. | |
571 | ||
c2e4669f | 572 | When "smashing" the type, we preserve the objfile that the |
1ab3bf1b | 573 | old type pointed to, since we aren't changing where the type is actually |
c2e4669f | 574 | allocated. */ |
1ab3bf1b JG |
575 | |
576 | void | |
577 | smash_to_method_type (type, domain, to_type, args) | |
578 | struct type *type; | |
579 | struct type *domain; | |
580 | struct type *to_type; | |
581 | struct type **args; | |
582 | { | |
583 | struct objfile *objfile; | |
584 | ||
585 | objfile = TYPE_OBJFILE (type); | |
586 | ||
dac9734e | 587 | memset ((char *) type, 0, sizeof (struct type)); |
1ab3bf1b JG |
588 | TYPE_OBJFILE (type) = objfile; |
589 | TYPE_TARGET_TYPE (type) = to_type; | |
590 | TYPE_DOMAIN_TYPE (type) = domain; | |
591 | TYPE_ARG_TYPES (type) = args; | |
592 | TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ | |
593 | TYPE_CODE (type) = TYPE_CODE_METHOD; | |
594 | } | |
595 | ||
b2bebdb0 JK |
596 | /* Return a typename for a struct/union/enum type without "struct ", |
597 | "union ", or "enum ". If the type has a NULL name, return NULL. */ | |
1ab3bf1b JG |
598 | |
599 | char * | |
600 | type_name_no_tag (type) | |
601 | register const struct type *type; | |
602 | { | |
b2bebdb0 JK |
603 | if (TYPE_TAG_NAME (type) != NULL) |
604 | return TYPE_TAG_NAME (type); | |
1ab3bf1b | 605 | |
b2bebdb0 JK |
606 | /* Is there code which expects this to return the name if there is no |
607 | tag name? My guess is that this is mainly used for C++ in cases where | |
608 | the two will always be the same. */ | |
609 | return TYPE_NAME (type); | |
1ab3bf1b JG |
610 | } |
611 | ||
612 | /* Lookup a primitive type named NAME. | |
613 | Return zero if NAME is not a primitive type.*/ | |
614 | ||
615 | struct type * | |
616 | lookup_primitive_typename (name) | |
617 | char *name; | |
618 | { | |
619 | struct type ** const *p; | |
620 | ||
621 | for (p = current_language -> la_builtin_type_vector; *p != NULL; p++) | |
622 | { | |
2e4964ad | 623 | if (STREQ ((**p) -> name, name)) |
1ab3bf1b JG |
624 | { |
625 | return (**p); | |
626 | } | |
627 | } | |
628 | return (NULL); | |
629 | } | |
630 | ||
631 | /* Lookup a typedef or primitive type named NAME, | |
632 | visible in lexical block BLOCK. | |
633 | If NOERR is nonzero, return zero if NAME is not suitably defined. */ | |
634 | ||
635 | struct type * | |
636 | lookup_typename (name, block, noerr) | |
637 | char *name; | |
638 | struct block *block; | |
639 | int noerr; | |
640 | { | |
641 | register struct symbol *sym; | |
642 | register struct type *tmp; | |
643 | ||
644 | sym = lookup_symbol (name, block, VAR_NAMESPACE, 0, (struct symtab **) NULL); | |
645 | if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF) | |
646 | { | |
647 | tmp = lookup_primitive_typename (name); | |
648 | if (tmp) | |
649 | { | |
650 | return (tmp); | |
651 | } | |
652 | else if (!tmp && noerr) | |
653 | { | |
654 | return (NULL); | |
655 | } | |
656 | else | |
657 | { | |
658 | error ("No type named %s.", name); | |
659 | } | |
660 | } | |
661 | return (SYMBOL_TYPE (sym)); | |
662 | } | |
663 | ||
664 | struct type * | |
665 | lookup_unsigned_typename (name) | |
666 | char *name; | |
667 | { | |
668 | char *uns = alloca (strlen (name) + 10); | |
669 | ||
670 | strcpy (uns, "unsigned "); | |
671 | strcpy (uns + 9, name); | |
672 | return (lookup_typename (uns, (struct block *) NULL, 0)); | |
673 | } | |
674 | ||
a252e715 PB |
675 | struct type * |
676 | lookup_signed_typename (name) | |
677 | char *name; | |
678 | { | |
679 | struct type *t; | |
680 | char *uns = alloca (strlen (name) + 8); | |
681 | ||
682 | strcpy (uns, "signed "); | |
683 | strcpy (uns + 7, name); | |
684 | t = lookup_typename (uns, (struct block *) NULL, 1); | |
685 | /* If we don't find "signed FOO" just try again with plain "FOO". */ | |
686 | if (t != NULL) | |
687 | return t; | |
688 | return lookup_typename (name, (struct block *) NULL, 0); | |
689 | } | |
690 | ||
1ab3bf1b JG |
691 | /* Lookup a structure type named "struct NAME", |
692 | visible in lexical block BLOCK. */ | |
693 | ||
694 | struct type * | |
695 | lookup_struct (name, block) | |
696 | char *name; | |
697 | struct block *block; | |
698 | { | |
699 | register struct symbol *sym; | |
700 | ||
701 | sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0, | |
702 | (struct symtab **) NULL); | |
703 | ||
704 | if (sym == NULL) | |
705 | { | |
706 | error ("No struct type named %s.", name); | |
707 | } | |
2640f7e1 JG |
708 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT) |
709 | { | |
710 | error ("This context has class, union or enum %s, not a struct.", name); | |
711 | } | |
712 | return (SYMBOL_TYPE (sym)); | |
1ab3bf1b JG |
713 | } |
714 | ||
715 | /* Lookup a union type named "union NAME", | |
716 | visible in lexical block BLOCK. */ | |
717 | ||
718 | struct type * | |
719 | lookup_union (name, block) | |
720 | char *name; | |
721 | struct block *block; | |
722 | { | |
723 | register struct symbol *sym; | |
724 | ||
725 | sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0, | |
726 | (struct symtab **) NULL); | |
727 | ||
728 | if (sym == NULL) | |
729 | { | |
730 | error ("No union type named %s.", name); | |
731 | } | |
2640f7e1 JG |
732 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_UNION) |
733 | { | |
734 | error ("This context has class, struct or enum %s, not a union.", name); | |
735 | } | |
736 | return (SYMBOL_TYPE (sym)); | |
1ab3bf1b JG |
737 | } |
738 | ||
739 | /* Lookup an enum type named "enum NAME", | |
740 | visible in lexical block BLOCK. */ | |
741 | ||
742 | struct type * | |
743 | lookup_enum (name, block) | |
744 | char *name; | |
745 | struct block *block; | |
746 | { | |
747 | register struct symbol *sym; | |
748 | ||
749 | sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0, | |
750 | (struct symtab **) NULL); | |
751 | if (sym == NULL) | |
752 | { | |
753 | error ("No enum type named %s.", name); | |
754 | } | |
2640f7e1 JG |
755 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM) |
756 | { | |
757 | error ("This context has class, struct or union %s, not an enum.", name); | |
758 | } | |
759 | return (SYMBOL_TYPE (sym)); | |
1ab3bf1b JG |
760 | } |
761 | ||
762 | /* Lookup a template type named "template NAME<TYPE>", | |
763 | visible in lexical block BLOCK. */ | |
764 | ||
765 | struct type * | |
766 | lookup_template_type (name, type, block) | |
767 | char *name; | |
768 | struct type *type; | |
769 | struct block *block; | |
770 | { | |
771 | struct symbol *sym; | |
772 | char *nam = (char*) alloca(strlen(name) + strlen(type->name) + 4); | |
773 | strcpy (nam, name); | |
774 | strcat (nam, "<"); | |
775 | strcat (nam, type->name); | |
776 | strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */ | |
777 | ||
778 | sym = lookup_symbol (nam, block, VAR_NAMESPACE, 0, (struct symtab **)NULL); | |
779 | ||
780 | if (sym == NULL) | |
781 | { | |
782 | error ("No template type named %s.", name); | |
783 | } | |
784 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT) | |
785 | { | |
786 | error ("This context has class, union or enum %s, not a struct.", name); | |
787 | } | |
788 | return (SYMBOL_TYPE (sym)); | |
789 | } | |
790 | ||
edf67bd1 | 791 | /* Given a type TYPE, lookup the type of the component of type named NAME. |
45364c8a FF |
792 | |
793 | TYPE can be either a struct or union, or a pointer or reference to a struct or | |
794 | union. If it is a pointer or reference, its target type is automatically used. | |
795 | Thus '.' and '->' are interchangable, as specified for the definitions of the | |
796 | expression element types STRUCTOP_STRUCT and STRUCTOP_PTR. | |
797 | ||
edf67bd1 MT |
798 | If NOERR is nonzero, return zero if NAME is not suitably defined. |
799 | If NAME is the name of a baseclass type, return that type. */ | |
1ab3bf1b JG |
800 | |
801 | struct type * | |
802 | lookup_struct_elt_type (type, name, noerr) | |
803 | struct type *type; | |
804 | char *name; | |
805 | int noerr; | |
806 | { | |
807 | int i; | |
808 | ||
d1f4065e PB |
809 | for (;;) |
810 | { | |
811 | CHECK_TYPEDEF (type); | |
812 | if (TYPE_CODE (type) != TYPE_CODE_PTR | |
813 | && TYPE_CODE (type) != TYPE_CODE_REF) | |
814 | break; | |
5c5b5d4b | 815 | type = TYPE_TARGET_TYPE (type); |
d1f4065e | 816 | } |
5c5b5d4b | 817 | |
1ab3bf1b JG |
818 | if (TYPE_CODE (type) != TYPE_CODE_STRUCT && |
819 | TYPE_CODE (type) != TYPE_CODE_UNION) | |
820 | { | |
821 | target_terminal_ours (); | |
199b2450 TL |
822 | gdb_flush (gdb_stdout); |
823 | fprintf_unfiltered (gdb_stderr, "Type "); | |
824 | type_print (type, "", gdb_stderr, -1); | |
1ab3bf1b JG |
825 | error (" is not a structure or union type."); |
826 | } | |
827 | ||
45364c8a FF |
828 | #if 0 |
829 | /* FIXME: This change put in by Michael seems incorrect for the case where | |
830 | the structure tag name is the same as the member name. I.E. when doing | |
831 | "ptype bell->bar" for "struct foo { int bar; int foo; } bell;" | |
832 | Disabled by fnf. */ | |
e7bf1152 RP |
833 | { |
834 | char *typename; | |
835 | ||
836 | typename = type_name_no_tag (type); | |
837 | if (typename != NULL && STREQ (typename, name)) | |
838 | return type; | |
839 | } | |
45364c8a | 840 | #endif |
edf67bd1 | 841 | |
1ab3bf1b JG |
842 | for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) |
843 | { | |
844 | char *t_field_name = TYPE_FIELD_NAME (type, i); | |
845 | ||
2e4964ad | 846 | if (t_field_name && STREQ (t_field_name, name)) |
1ab3bf1b JG |
847 | { |
848 | return TYPE_FIELD_TYPE (type, i); | |
849 | } | |
850 | } | |
851 | ||
852 | /* OK, it's not in this class. Recursively check the baseclasses. */ | |
853 | for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) | |
854 | { | |
855 | struct type *t; | |
856 | ||
d112a0c6 | 857 | t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, noerr); |
1ab3bf1b JG |
858 | if (t != NULL) |
859 | { | |
860 | return t; | |
861 | } | |
862 | } | |
863 | ||
864 | if (noerr) | |
865 | { | |
866 | return NULL; | |
867 | } | |
868 | ||
869 | target_terminal_ours (); | |
199b2450 TL |
870 | gdb_flush (gdb_stdout); |
871 | fprintf_unfiltered (gdb_stderr, "Type "); | |
872 | type_print (type, "", gdb_stderr, -1); | |
873 | fprintf_unfiltered (gdb_stderr, " has no component named "); | |
874 | fputs_filtered (name, gdb_stderr); | |
1ab3bf1b JG |
875 | error ("."); |
876 | return (struct type *)-1; /* For lint */ | |
877 | } | |
878 | ||
ac88287f JK |
879 | /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE |
880 | valid. Callers should be aware that in some cases (for example, | |
881 | the type or one of its baseclasses is a stub type and we are | |
882 | debugging a .o file), this function will not be able to find the virtual | |
883 | function table pointer, and vptr_fieldno will remain -1 and vptr_basetype | |
884 | will remain NULL. */ | |
1ab3bf1b JG |
885 | |
886 | void | |
887 | fill_in_vptr_fieldno (type) | |
888 | struct type *type; | |
889 | { | |
d1f4065e | 890 | CHECK_TYPEDEF (type); |
ac88287f | 891 | |
1ab3bf1b JG |
892 | if (TYPE_VPTR_FIELDNO (type) < 0) |
893 | { | |
894 | int i; | |
edf67bd1 MT |
895 | |
896 | /* We must start at zero in case the first (and only) baseclass is | |
897 | virtual (and hence we cannot share the table pointer). */ | |
898 | for (i = 0; i < TYPE_N_BASECLASSES (type); i++) | |
1ab3bf1b JG |
899 | { |
900 | fill_in_vptr_fieldno (TYPE_BASECLASS (type, i)); | |
901 | if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)) >= 0) | |
902 | { | |
903 | TYPE_VPTR_FIELDNO (type) | |
904 | = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)); | |
905 | TYPE_VPTR_BASETYPE (type) | |
906 | = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type, i)); | |
907 | break; | |
908 | } | |
909 | } | |
910 | } | |
911 | } | |
912 | ||
a46d92a7 PS |
913 | /* Find the method and field indices for the destructor in class type T. |
914 | Return 1 if the destructor was found, otherwise, return 0. */ | |
915 | ||
916 | int | |
917 | get_destructor_fn_field (t, method_indexp, field_indexp) | |
918 | struct type *t; | |
919 | int *method_indexp; | |
920 | int *field_indexp; | |
921 | { | |
922 | int i; | |
923 | ||
924 | for (i = 0; i < TYPE_NFN_FIELDS (t); i++) | |
925 | { | |
926 | int j; | |
927 | struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); | |
928 | ||
929 | for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (t, i); j++) | |
930 | { | |
931 | if (DESTRUCTOR_PREFIX_P (TYPE_FN_FIELD_PHYSNAME (f, j))) | |
932 | { | |
933 | *method_indexp = i; | |
934 | *field_indexp = j; | |
935 | return 1; | |
936 | } | |
937 | } | |
938 | } | |
939 | return 0; | |
940 | } | |
941 | ||
1ab3bf1b JG |
942 | /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989. |
943 | ||
944 | If this is a stubbed struct (i.e. declared as struct foo *), see if | |
945 | we can find a full definition in some other file. If so, copy this | |
dda398c3 JK |
946 | definition, so we can use it in future. There used to be a comment (but |
947 | not any code) that if we don't find a full definition, we'd set a flag | |
948 | so we don't spend time in the future checking the same type. That would | |
949 | be a mistake, though--we might load in more symbols which contain a | |
950 | full definition for the type. | |
1ab3bf1b JG |
951 | |
952 | This used to be coded as a macro, but I don't think it is called | |
dda398c3 | 953 | often enough to merit such treatment. */ |
1ab3bf1b JG |
954 | |
955 | struct complaint stub_noname_complaint = | |
956 | {"stub type has NULL name", 0, 0}; | |
957 | ||
d1f4065e PB |
958 | struct type * |
959 | check_typedef (type) | |
960 | register struct type *type; | |
961 | { | |
962 | struct type *orig_type = type; | |
963 | while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) | |
964 | { | |
965 | if (!TYPE_TARGET_TYPE (type)) | |
966 | { | |
7ef89313 PB |
967 | char* name; |
968 | struct symbol *sym; | |
969 | ||
970 | /* It is dangerous to call lookup_symbol if we are currently | |
971 | reading a symtab. Infinite recursion is one danger. */ | |
972 | if (currently_reading_symtab) | |
973 | return type; | |
974 | ||
975 | name = type_name_no_tag (type); | |
d1f4065e PB |
976 | /* FIXME: shouldn't we separately check the TYPE_NAME and the |
977 | TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE | |
978 | as appropriate? (this code was written before TYPE_NAME and | |
979 | TYPE_TAG_NAME were separate). */ | |
d1f4065e PB |
980 | if (name == NULL) |
981 | { | |
982 | complain (&stub_noname_complaint); | |
983 | return type; | |
984 | } | |
985 | sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0, | |
986 | (struct symtab **) NULL); | |
987 | if (sym) | |
988 | TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym); | |
989 | else | |
990 | TYPE_TARGET_TYPE (type) = alloc_type (NULL); /* TYPE_CODE_UNDEF */ | |
991 | } | |
992 | type = TYPE_TARGET_TYPE (type); | |
993 | } | |
994 | ||
7ef89313 | 995 | if ((TYPE_FLAGS(type) & TYPE_FLAG_STUB) && ! currently_reading_symtab) |
1ab3bf1b JG |
996 | { |
997 | char* name = type_name_no_tag (type); | |
065525e3 JK |
998 | /* FIXME: shouldn't we separately check the TYPE_NAME and the |
999 | TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE | |
1000 | as appropriate? (this code was written before TYPE_NAME and | |
1001 | TYPE_TAG_NAME were separate). */ | |
1ab3bf1b JG |
1002 | struct symbol *sym; |
1003 | if (name == NULL) | |
1004 | { | |
51b80b00 | 1005 | complain (&stub_noname_complaint); |
d1f4065e | 1006 | return type; |
1ab3bf1b JG |
1007 | } |
1008 | sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0, | |
1009 | (struct symtab **) NULL); | |
1010 | if (sym) | |
1011 | { | |
dda398c3 JK |
1012 | memcpy ((char *)type, |
1013 | (char *)SYMBOL_TYPE(sym), | |
1014 | sizeof (struct type)); | |
1015 | } | |
1016 | } | |
1017 | ||
1018 | if (TYPE_FLAGS (type) & TYPE_FLAG_TARGET_STUB) | |
1019 | { | |
1020 | struct type *range_type; | |
d1f4065e | 1021 | struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type)); |
dda398c3 | 1022 | |
dd600735 | 1023 | if (TYPE_FLAGS (target_type) & (TYPE_FLAG_STUB | TYPE_FLAG_TARGET_STUB)) |
e55a5796 PB |
1024 | { } |
1025 | else if (TYPE_CODE (type) == TYPE_CODE_ARRAY | |
1026 | && TYPE_NFIELDS (type) == 1 | |
1027 | && (TYPE_CODE (range_type = TYPE_FIELD_TYPE (type, 0)) | |
1028 | == TYPE_CODE_RANGE)) | |
dda398c3 JK |
1029 | { |
1030 | /* Now recompute the length of the array type, based on its | |
1031 | number of elements and the target type's length. */ | |
1032 | TYPE_LENGTH (type) = | |
1033 | ((TYPE_FIELD_BITPOS (range_type, 1) | |
1034 | - TYPE_FIELD_BITPOS (range_type, 0) | |
1035 | + 1) | |
d1f4065e | 1036 | * TYPE_LENGTH (target_type)); |
dda398c3 | 1037 | TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB; |
1ab3bf1b | 1038 | } |
e55a5796 PB |
1039 | else if (TYPE_CODE (type) == TYPE_CODE_RANGE) |
1040 | { | |
d1f4065e | 1041 | TYPE_LENGTH (type) = TYPE_LENGTH (target_type); |
e55a5796 PB |
1042 | TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB; |
1043 | } | |
1ab3bf1b | 1044 | } |
d1f4065e PB |
1045 | /* Cache TYPE_LENGTH for future use. */ |
1046 | TYPE_LENGTH (orig_type) = TYPE_LENGTH (type); | |
1047 | return type; | |
1ab3bf1b JG |
1048 | } |
1049 | ||
94f5a25f DP |
1050 | /* New code added to support parsing of Cfront stabs strings */ |
1051 | #include <ctype.h> | |
1052 | #define INIT_EXTRA { pextras->len=0; pextras->str[0]='\0'; } | |
1053 | #define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; } | |
b607efe7 FF |
1054 | |
1055 | static void | |
94f5a25f DP |
1056 | add_name(pextras,n) |
1057 | struct extra * pextras; | |
1058 | char * n; | |
1059 | { | |
b607efe7 FF |
1060 | int nlen; |
1061 | ||
94f5a25f DP |
1062 | if ((nlen = (n ? strlen(n) : 0))==0) |
1063 | return; | |
1064 | sprintf(pextras->str+pextras->len,"%d%s",nlen,n); | |
1065 | pextras->len=strlen(pextras->str); | |
1066 | } | |
1067 | ||
b607efe7 | 1068 | static void |
94f5a25f DP |
1069 | add_mangled_type(pextras,t) |
1070 | struct extra * pextras; | |
1071 | struct type * t; | |
1072 | { | |
1073 | enum type_code tcode; | |
1074 | int tlen, tflags; | |
1075 | char * tname; | |
1076 | ||
1077 | tcode = TYPE_CODE(t); | |
1078 | tlen = TYPE_LENGTH(t); | |
1079 | tflags = TYPE_FLAGS(t); | |
1080 | tname = TYPE_NAME(t); | |
1081 | /* args of "..." seem to get mangled as "e" */ | |
1082 | ||
1083 | switch (tcode) | |
1084 | { | |
1085 | case TYPE_CODE_INT: | |
1086 | if (tflags==1) | |
1087 | ADD_EXTRA('U'); | |
1088 | switch (tlen) | |
1089 | { | |
1090 | case 1: | |
1091 | ADD_EXTRA('c'); | |
1092 | break; | |
1093 | case 2: | |
1094 | ADD_EXTRA('s'); | |
1095 | break; | |
1096 | case 4: | |
1097 | { | |
1098 | char* pname; | |
1099 | if ((pname=strrchr(tname,'l'),pname) && !strcmp(pname,"long")) | |
1100 | ADD_EXTRA('l') | |
1101 | else | |
1102 | ADD_EXTRA('i') | |
1103 | } | |
1104 | break; | |
1105 | default: | |
1106 | { | |
1107 | ||
1108 | static struct complaint msg = {"Bad int type code length x%x\n",0,0}; | |
1109 | ||
1110 | complain (&msg, tlen); | |
1111 | ||
1112 | } | |
1113 | } | |
1114 | break; | |
1115 | case TYPE_CODE_FLT: | |
1116 | switch (tlen) | |
1117 | { | |
1118 | case 4: | |
1119 | ADD_EXTRA('f'); | |
1120 | break; | |
1121 | case 8: | |
1122 | ADD_EXTRA('d'); | |
1123 | break; | |
1124 | case 16: | |
1125 | ADD_EXTRA('r'); | |
1126 | break; | |
1127 | default: | |
1128 | { | |
1129 | static struct complaint msg = {"Bad float type code length x%x\n",0,0}; | |
1130 | complain (&msg, tlen); | |
1131 | } | |
1132 | } | |
1133 | break; | |
1134 | case TYPE_CODE_REF: | |
1135 | ADD_EXTRA('R'); | |
1136 | /* followed by what it's a ref to */ | |
1137 | break; | |
1138 | case TYPE_CODE_PTR: | |
1139 | ADD_EXTRA('P'); | |
1140 | /* followed by what it's a ptr to */ | |
1141 | break; | |
1142 | case TYPE_CODE_TYPEDEF: | |
1143 | { | |
1144 | static struct complaint msg = {"Typedefs in overloaded functions not yet supported\n",0,0}; | |
1145 | complain (&msg); | |
1146 | } | |
1147 | /* followed by type bytes & name */ | |
1148 | break; | |
1149 | case TYPE_CODE_FUNC: | |
1150 | ADD_EXTRA('F'); | |
1151 | /* followed by func's arg '_' & ret types */ | |
1152 | break; | |
1153 | case TYPE_CODE_VOID: | |
1154 | ADD_EXTRA('v'); | |
1155 | break; | |
1156 | case TYPE_CODE_METHOD: | |
1157 | ADD_EXTRA('M'); | |
1158 | /* followed by name of class and func's arg '_' & ret types */ | |
1159 | add_name(pextras,tname); | |
1160 | ADD_EXTRA('F'); /* then mangle function */ | |
1161 | break; | |
1162 | case TYPE_CODE_STRUCT: /* C struct */ | |
1163 | case TYPE_CODE_UNION: /* C union */ | |
1164 | case TYPE_CODE_ENUM: /* Enumeration type */ | |
1165 | /* followed by name of type */ | |
1166 | add_name(pextras,tname); | |
1167 | break; | |
1168 | ||
1169 | /* errors possible types/not supported */ | |
1170 | case TYPE_CODE_CHAR: | |
1171 | case TYPE_CODE_ARRAY: /* Array type */ | |
1172 | case TYPE_CODE_MEMBER: /* Member type */ | |
1173 | case TYPE_CODE_BOOL: | |
1174 | case TYPE_CODE_COMPLEX: /* Complex float */ | |
1175 | case TYPE_CODE_UNDEF: | |
1176 | case TYPE_CODE_SET: /* Pascal sets */ | |
1177 | case TYPE_CODE_RANGE: | |
1178 | case TYPE_CODE_STRING: | |
1179 | case TYPE_CODE_BITSTRING: | |
1180 | case TYPE_CODE_ERROR: | |
1181 | default: | |
1182 | { | |
1183 | static struct complaint msg = {"Unknown type code x%x\n",0,0}; | |
1184 | complain (&msg, tcode); | |
1185 | } | |
1186 | } | |
1187 | if (t->target_type) | |
1188 | add_mangled_type(pextras,t->target_type); | |
1189 | } | |
1190 | ||
b607efe7 FF |
1191 | #if 0 |
1192 | void | |
94f5a25f DP |
1193 | cfront_mangle_name(type, i, j) |
1194 | struct type *type; | |
1195 | int i; | |
1196 | int j; | |
1197 | { | |
1198 | struct fn_field *f; | |
1199 | char *mangled_name = gdb_mangle_name (type, i, j); | |
1200 | ||
1201 | f = TYPE_FN_FIELDLIST1 (type, i); /* moved from below */ | |
1202 | ||
1203 | /* kludge to support cfront methods - gdb expects to find "F" for | |
1204 | ARM_mangled names, so when we mangle, we have to add it here */ | |
1205 | if (ARM_DEMANGLING) | |
1206 | { | |
1207 | int k; | |
1208 | char * arm_mangled_name; | |
1209 | struct fn_field *method = &f[j]; | |
1210 | char *field_name = TYPE_FN_FIELDLIST_NAME (type, i); | |
1211 | char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); | |
1212 | char *newname = type_name_no_tag (type); | |
1213 | ||
1214 | struct type *ftype = TYPE_FN_FIELD_TYPE (f, j); | |
1215 | int nargs = TYPE_NFIELDS(ftype); /* number of args */ | |
1216 | struct extra extras, * pextras = &extras; | |
1217 | INIT_EXTRA | |
1218 | ||
1219 | if (TYPE_FN_FIELD_STATIC_P (f, j)) /* j for sublist within this list */ | |
1220 | ADD_EXTRA('S') | |
1221 | ADD_EXTRA('F') | |
1222 | /* add args here! */ | |
1223 | if (nargs <= 1) /* no args besides this */ | |
1224 | ADD_EXTRA('v') | |
1225 | else { | |
1226 | for (k=1; k<nargs; k++) | |
1227 | { | |
1228 | struct type * t; | |
1229 | t = TYPE_FIELD_TYPE(ftype,k); | |
1230 | add_mangled_type(pextras,t); | |
1231 | } | |
1232 | } | |
1233 | ADD_EXTRA('\0') | |
1234 | printf("add_mangled_type: %s\n",extras.str); /* FIXME */ | |
1235 | arm_mangled_name = malloc(strlen(mangled_name)+extras.len); | |
1236 | sprintf(arm_mangled_name,"%s%s",mangled_name,extras.str); | |
1237 | free(mangled_name); | |
1238 | mangled_name = arm_mangled_name; | |
1239 | } | |
1240 | } | |
b607efe7 FF |
1241 | #endif /* 0 */ |
1242 | ||
94f5a25f DP |
1243 | #undef ADD_EXTRA |
1244 | /* End of new code added to support parsing of Cfront stabs strings */ | |
1245 | ||
1ab3bf1b JG |
1246 | /* Ugly hack to convert method stubs into method types. |
1247 | ||
1248 | He ain't kiddin'. This demangles the name of the method into a string | |
1249 | including argument types, parses out each argument type, generates | |
1250 | a string casting a zero to that type, evaluates the string, and stuffs | |
1251 | the resulting type into an argtype vector!!! Then it knows the type | |
1252 | of the whole function (including argument types for overloading), | |
1253 | which info used to be in the stab's but was removed to hack back | |
1254 | the space required for them. */ | |
1255 | ||
1256 | void | |
f6d23b6f | 1257 | check_stub_method (type, method_id, signature_id) |
1ab3bf1b | 1258 | struct type *type; |
f6d23b6f SG |
1259 | int method_id; |
1260 | int signature_id; | |
1ab3bf1b JG |
1261 | { |
1262 | struct fn_field *f; | |
f6d23b6f | 1263 | char *mangled_name = gdb_mangle_name (type, method_id, signature_id); |
8050a57b FF |
1264 | char *demangled_name = cplus_demangle (mangled_name, |
1265 | DMGL_PARAMS | DMGL_ANSI); | |
1ab3bf1b JG |
1266 | char *argtypetext, *p; |
1267 | int depth = 0, argcount = 1; | |
1268 | struct type **argtypes; | |
1269 | struct type *mtype; | |
1270 | ||
e045712f BK |
1271 | /* Make sure we got back a function string that we can use. */ |
1272 | if (demangled_name) | |
1273 | p = strchr (demangled_name, '('); | |
1274 | ||
1275 | if (demangled_name == NULL || p == NULL) | |
1276 | error ("Internal: Cannot demangle mangled name `%s'.", mangled_name); | |
1ab3bf1b JG |
1277 | |
1278 | /* Now, read in the parameters that define this type. */ | |
e045712f BK |
1279 | p += 1; |
1280 | argtypetext = p; | |
1ab3bf1b JG |
1281 | while (*p) |
1282 | { | |
1283 | if (*p == '(') | |
1284 | { | |
1285 | depth += 1; | |
1286 | } | |
1287 | else if (*p == ')') | |
1288 | { | |
1289 | depth -= 1; | |
1290 | } | |
1291 | else if (*p == ',' && depth == 0) | |
1292 | { | |
1293 | argcount += 1; | |
1294 | } | |
1295 | ||
1296 | p += 1; | |
1297 | } | |
1298 | ||
1299 | /* We need two more slots: one for the THIS pointer, and one for the | |
1300 | NULL [...] or void [end of arglist]. */ | |
1301 | ||
1302 | argtypes = (struct type **) | |
dac9734e | 1303 | TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *)); |
1ab3bf1b | 1304 | p = argtypetext; |
e552788b | 1305 | /* FIXME: This is wrong for static member functions. */ |
1ab3bf1b JG |
1306 | argtypes[0] = lookup_pointer_type (type); |
1307 | argcount = 1; | |
1308 | ||
1309 | if (*p != ')') /* () means no args, skip while */ | |
1310 | { | |
1311 | depth = 0; | |
1312 | while (*p) | |
1313 | { | |
1314 | if (depth <= 0 && (*p == ',' || *p == ')')) | |
1315 | { | |
393e55ba JK |
1316 | /* Avoid parsing of ellipsis, they will be handled below. */ |
1317 | if (strncmp (argtypetext, "...", p - argtypetext) != 0) | |
1318 | { | |
1319 | argtypes[argcount] = | |
1320 | parse_and_eval_type (argtypetext, p - argtypetext); | |
1321 | argcount += 1; | |
1322 | } | |
1ab3bf1b JG |
1323 | argtypetext = p + 1; |
1324 | } | |
1325 | ||
1326 | if (*p == '(') | |
1327 | { | |
1328 | depth += 1; | |
1329 | } | |
1330 | else if (*p == ')') | |
1331 | { | |
1332 | depth -= 1; | |
1333 | } | |
1334 | ||
1335 | p += 1; | |
1336 | } | |
1337 | } | |
1338 | ||
c0f1085b | 1339 | if (p[-2] != '.') /* Not '...' */ |
1ab3bf1b | 1340 | { |
c0f1085b | 1341 | argtypes[argcount] = builtin_type_void; /* List terminator */ |
1ab3bf1b JG |
1342 | } |
1343 | else | |
1344 | { | |
c0f1085b | 1345 | argtypes[argcount] = NULL; /* Ellist terminator */ |
1ab3bf1b JG |
1346 | } |
1347 | ||
1348 | free (demangled_name); | |
1349 | ||
f6d23b6f | 1350 | f = TYPE_FN_FIELDLIST1 (type, method_id); |
94f5a25f | 1351 | |
f6d23b6f | 1352 | TYPE_FN_FIELD_PHYSNAME (f, signature_id) = mangled_name; |
1ab3bf1b JG |
1353 | |
1354 | /* Now update the old "stub" type into a real type. */ | |
f6d23b6f | 1355 | mtype = TYPE_FN_FIELD_TYPE (f, signature_id); |
1ab3bf1b JG |
1356 | TYPE_DOMAIN_TYPE (mtype) = type; |
1357 | TYPE_ARG_TYPES (mtype) = argtypes; | |
1358 | TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB; | |
f6d23b6f | 1359 | TYPE_FN_FIELD_STUB (f, signature_id) = 0; |
1ab3bf1b JG |
1360 | } |
1361 | ||
0213d96f | 1362 | const struct cplus_struct_type cplus_struct_default; |
1ab3bf1b JG |
1363 | |
1364 | void | |
1365 | allocate_cplus_struct_type (type) | |
1366 | struct type *type; | |
1367 | { | |
1368 | if (!HAVE_CPLUS_STRUCT (type)) | |
1369 | { | |
1370 | TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *) | |
dac9734e | 1371 | TYPE_ALLOC (type, sizeof (struct cplus_struct_type)); |
1ab3bf1b JG |
1372 | *(TYPE_CPLUS_SPECIFIC(type)) = cplus_struct_default; |
1373 | } | |
1374 | } | |
1375 | ||
50e0dc41 FF |
1376 | /* Helper function to initialize the standard scalar types. |
1377 | ||
1378 | If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy | |
1379 | of the string pointed to by name in the type_obstack for that objfile, | |
1380 | and initialize the type name to that copy. There are places (mipsread.c | |
1381 | in particular, where init_type is called with a NULL value for NAME). */ | |
1ab3bf1b JG |
1382 | |
1383 | struct type * | |
1384 | init_type (code, length, flags, name, objfile) | |
1385 | enum type_code code; | |
1386 | int length; | |
1387 | int flags; | |
1388 | char *name; | |
1389 | struct objfile *objfile; | |
1390 | { | |
1391 | register struct type *type; | |
1392 | ||
1393 | type = alloc_type (objfile); | |
1394 | TYPE_CODE (type) = code; | |
1395 | TYPE_LENGTH (type) = length; | |
1396 | TYPE_FLAGS (type) |= flags; | |
50e0dc41 FF |
1397 | if ((name != NULL) && (objfile != NULL)) |
1398 | { | |
1399 | TYPE_NAME (type) = | |
1400 | obsavestring (name, strlen (name), &objfile -> type_obstack); | |
1401 | } | |
1402 | else | |
1403 | { | |
1404 | TYPE_NAME (type) = name; | |
1405 | } | |
1ab3bf1b JG |
1406 | |
1407 | /* C++ fancies. */ | |
1408 | ||
1409 | if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION) | |
1410 | { | |
1411 | INIT_CPLUS_SPECIFIC (type); | |
1412 | } | |
1413 | return (type); | |
1414 | } | |
1415 | ||
1416 | /* Look up a fundamental type for the specified objfile. | |
1417 | May need to construct such a type if this is the first use. | |
1418 | ||
1419 | Some object file formats (ELF, COFF, etc) do not define fundamental | |
1420 | types such as "int" or "double". Others (stabs for example), do | |
1421 | define fundamental types. | |
1422 | ||
1423 | For the formats which don't provide fundamental types, gdb can create | |
bf229b4e FF |
1424 | such types, using defaults reasonable for the current language and |
1425 | the current target machine. | |
1426 | ||
1427 | NOTE: This routine is obsolescent. Each debugging format reader | |
1428 | should manage it's own fundamental types, either creating them from | |
1429 | suitable defaults or reading them from the debugging information, | |
1430 | whichever is appropriate. The DWARF reader has already been | |
1431 | fixed to do this. Once the other readers are fixed, this routine | |
1432 | will go away. Also note that fundamental types should be managed | |
1433 | on a compilation unit basis in a multi-language environment, not | |
1434 | on a linkage unit basis as is done here. */ | |
1435 | ||
1ab3bf1b JG |
1436 | |
1437 | struct type * | |
1438 | lookup_fundamental_type (objfile, typeid) | |
1439 | struct objfile *objfile; | |
1440 | int typeid; | |
1441 | { | |
1ab3bf1b JG |
1442 | register struct type **typep; |
1443 | register int nbytes; | |
1444 | ||
1445 | if (typeid < 0 || typeid >= FT_NUM_MEMBERS) | |
1446 | { | |
1447 | error ("internal error - invalid fundamental type id %d", typeid); | |
1448 | } | |
bf229b4e FF |
1449 | |
1450 | /* If this is the first time we need a fundamental type for this objfile | |
1451 | then we need to initialize the vector of type pointers. */ | |
1452 | ||
1453 | if (objfile -> fundamental_types == NULL) | |
1ab3bf1b | 1454 | { |
bf229b4e FF |
1455 | nbytes = FT_NUM_MEMBERS * sizeof (struct type *); |
1456 | objfile -> fundamental_types = (struct type **) | |
1457 | obstack_alloc (&objfile -> type_obstack, nbytes); | |
1458 | memset ((char *) objfile -> fundamental_types, 0, nbytes); | |
2dd30c72 | 1459 | OBJSTAT (objfile, n_types += FT_NUM_MEMBERS); |
1ab3bf1b | 1460 | } |
bf229b4e FF |
1461 | |
1462 | /* Look for this particular type in the fundamental type vector. If one is | |
1463 | not found, create and install one appropriate for the current language. */ | |
1464 | ||
1465 | typep = objfile -> fundamental_types + typeid; | |
1466 | if (*typep == NULL) | |
1467 | { | |
1468 | *typep = create_fundamental_type (objfile, typeid); | |
1469 | } | |
1470 | ||
1471 | return (*typep); | |
1ab3bf1b JG |
1472 | } |
1473 | ||
9c036bd8 JK |
1474 | int |
1475 | can_dereference (t) | |
1476 | struct type *t; | |
1477 | { | |
1478 | /* FIXME: Should we return true for references as well as pointers? */ | |
d1f4065e | 1479 | CHECK_TYPEDEF (t); |
9c036bd8 JK |
1480 | return |
1481 | (t != NULL | |
1482 | && TYPE_CODE (t) == TYPE_CODE_PTR | |
1483 | && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID); | |
1484 | } | |
1485 | ||
f91a9e05 PB |
1486 | /* Chill varying string and arrays are represented as follows: |
1487 | ||
1488 | struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data}; | |
1489 | ||
1490 | Return true if TYPE is such a Chill varying type. */ | |
1491 | ||
1492 | int | |
1493 | chill_varying_type (type) | |
1494 | struct type *type; | |
1495 | { | |
1496 | if (TYPE_CODE (type) != TYPE_CODE_STRUCT | |
1497 | || TYPE_NFIELDS (type) != 2 | |
1498 | || strcmp (TYPE_FIELD_NAME (type, 0), "__var_length") != 0) | |
1499 | return 0; | |
1500 | return 1; | |
1501 | } | |
1502 | ||
0239d9b3 FF |
1503 | #if MAINTENANCE_CMDS |
1504 | ||
8050a57b FF |
1505 | static void |
1506 | print_bit_vector (bits, nbits) | |
1507 | B_TYPE *bits; | |
1508 | int nbits; | |
0239d9b3 | 1509 | { |
8050a57b FF |
1510 | int bitno; |
1511 | ||
1512 | for (bitno = 0; bitno < nbits; bitno++) | |
0239d9b3 | 1513 | { |
8050a57b FF |
1514 | if ((bitno % 8) == 0) |
1515 | { | |
1516 | puts_filtered (" "); | |
1517 | } | |
1518 | if (B_TST (bits, bitno)) | |
1519 | { | |
1520 | printf_filtered ("1"); | |
1521 | } | |
1522 | else | |
1523 | { | |
1524 | printf_filtered ("0"); | |
1525 | } | |
0239d9b3 | 1526 | } |
8050a57b FF |
1527 | } |
1528 | ||
c0f1085b FF |
1529 | /* The args list is a strange beast. It is either terminated by a NULL |
1530 | pointer for varargs functions, or by a pointer to a TYPE_CODE_VOID | |
1531 | type for normal fixed argcount functions. (FIXME someday) | |
1532 | Also note the first arg should be the "this" pointer, we may not want to | |
1533 | include it since we may get into a infinitely recursive situation. */ | |
1534 | ||
1535 | static void | |
1536 | print_arg_types (args, spaces) | |
1537 | struct type **args; | |
1538 | int spaces; | |
1539 | { | |
1540 | if (args != NULL) | |
1541 | { | |
1542 | while (*args != NULL) | |
1543 | { | |
1544 | recursive_dump_type (*args, spaces + 2); | |
1545 | if ((*args++) -> code == TYPE_CODE_VOID) | |
1546 | { | |
1547 | break; | |
1548 | } | |
1549 | } | |
1550 | } | |
1551 | } | |
1552 | ||
1553 | static void | |
1554 | dump_fn_fieldlists (type, spaces) | |
1555 | struct type *type; | |
1556 | int spaces; | |
1557 | { | |
1558 | int method_idx; | |
1559 | int overload_idx; | |
1560 | struct fn_field *f; | |
1561 | ||
833e0d94 JK |
1562 | printfi_filtered (spaces, "fn_fieldlists "); |
1563 | gdb_print_address (TYPE_FN_FIELDLISTS (type), gdb_stdout); | |
1564 | printf_filtered ("\n"); | |
c0f1085b FF |
1565 | for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++) |
1566 | { | |
1567 | f = TYPE_FN_FIELDLIST1 (type, method_idx); | |
833e0d94 | 1568 | printfi_filtered (spaces + 2, "[%d] name '%s' (", |
c0f1085b | 1569 | method_idx, |
833e0d94 JK |
1570 | TYPE_FN_FIELDLIST_NAME (type, method_idx)); |
1571 | gdb_print_address (TYPE_FN_FIELDLIST_NAME (type, method_idx), | |
1572 | gdb_stdout); | |
1573 | printf_filtered (") length %d\n", | |
1574 | TYPE_FN_FIELDLIST_LENGTH (type, method_idx)); | |
c0f1085b FF |
1575 | for (overload_idx = 0; |
1576 | overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx); | |
1577 | overload_idx++) | |
1578 | { | |
833e0d94 | 1579 | printfi_filtered (spaces + 4, "[%d] physname '%s' (", |
c0f1085b | 1580 | overload_idx, |
833e0d94 | 1581 | TYPE_FN_FIELD_PHYSNAME (f, overload_idx)); |
5e678752 JK |
1582 | gdb_print_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx), |
1583 | gdb_stdout); | |
833e0d94 JK |
1584 | printf_filtered (")\n"); |
1585 | printfi_filtered (spaces + 8, "type "); | |
1586 | gdb_print_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout); | |
1587 | printf_filtered ("\n"); | |
1588 | ||
c0f1085b FF |
1589 | recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx), |
1590 | spaces + 8 + 2); | |
833e0d94 JK |
1591 | |
1592 | printfi_filtered (spaces + 8, "args "); | |
1593 | gdb_print_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); | |
1594 | printf_filtered ("\n"); | |
1595 | ||
c0f1085b | 1596 | print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces); |
833e0d94 JK |
1597 | printfi_filtered (spaces + 8, "fcontext "); |
1598 | gdb_print_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), | |
1599 | gdb_stdout); | |
1600 | printf_filtered ("\n"); | |
1601 | ||
c0f1085b FF |
1602 | printfi_filtered (spaces + 8, "is_const %d\n", |
1603 | TYPE_FN_FIELD_CONST (f, overload_idx)); | |
1604 | printfi_filtered (spaces + 8, "is_volatile %d\n", | |
1605 | TYPE_FN_FIELD_VOLATILE (f, overload_idx)); | |
1606 | printfi_filtered (spaces + 8, "is_private %d\n", | |
1607 | TYPE_FN_FIELD_PRIVATE (f, overload_idx)); | |
1608 | printfi_filtered (spaces + 8, "is_protected %d\n", | |
1609 | TYPE_FN_FIELD_PROTECTED (f, overload_idx)); | |
1610 | printfi_filtered (spaces + 8, "is_stub %d\n", | |
1611 | TYPE_FN_FIELD_STUB (f, overload_idx)); | |
d07734e3 | 1612 | printfi_filtered (spaces + 8, "voffset %u\n", |
c0f1085b FF |
1613 | TYPE_FN_FIELD_VOFFSET (f, overload_idx)); |
1614 | } | |
1615 | } | |
1616 | } | |
1617 | ||
8050a57b FF |
1618 | static void |
1619 | print_cplus_stuff (type, spaces) | |
1620 | struct type *type; | |
1621 | int spaces; | |
1622 | { | |
c0f1085b | 1623 | printfi_filtered (spaces, "n_baseclasses %d\n", |
8050a57b | 1624 | TYPE_N_BASECLASSES (type)); |
c0f1085b FF |
1625 | printfi_filtered (spaces, "nfn_fields %d\n", |
1626 | TYPE_NFN_FIELDS (type)); | |
1627 | printfi_filtered (spaces, "nfn_fields_total %d\n", | |
1628 | TYPE_NFN_FIELDS_TOTAL (type)); | |
8050a57b | 1629 | if (TYPE_N_BASECLASSES (type) > 0) |
0239d9b3 | 1630 | { |
833e0d94 JK |
1631 | printfi_filtered (spaces, "virtual_field_bits (%d bits at *", |
1632 | TYPE_N_BASECLASSES (type)); | |
1633 | gdb_print_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout); | |
1634 | printf_filtered (")"); | |
1635 | ||
8050a57b FF |
1636 | print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type), |
1637 | TYPE_N_BASECLASSES (type)); | |
1638 | puts_filtered ("\n"); | |
0239d9b3 | 1639 | } |
8050a57b | 1640 | if (TYPE_NFIELDS (type) > 0) |
0239d9b3 | 1641 | { |
8050a57b FF |
1642 | if (TYPE_FIELD_PRIVATE_BITS (type) != NULL) |
1643 | { | |
833e0d94 JK |
1644 | printfi_filtered (spaces, "private_field_bits (%d bits at *", |
1645 | TYPE_NFIELDS (type)); | |
1646 | gdb_print_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout); | |
1647 | printf_filtered (")"); | |
8050a57b FF |
1648 | print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type), |
1649 | TYPE_NFIELDS (type)); | |
1650 | puts_filtered ("\n"); | |
1651 | } | |
1652 | if (TYPE_FIELD_PROTECTED_BITS (type) != NULL) | |
0239d9b3 | 1653 | { |
833e0d94 JK |
1654 | printfi_filtered (spaces, "protected_field_bits (%d bits at *", |
1655 | TYPE_NFIELDS (type)); | |
1656 | gdb_print_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout); | |
1657 | printf_filtered (")"); | |
8050a57b FF |
1658 | print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type), |
1659 | TYPE_NFIELDS (type)); | |
1660 | puts_filtered ("\n"); | |
0239d9b3 FF |
1661 | } |
1662 | } | |
c0f1085b FF |
1663 | if (TYPE_NFN_FIELDS (type) > 0) |
1664 | { | |
1665 | dump_fn_fieldlists (type, spaces); | |
1666 | } | |
8050a57b FF |
1667 | } |
1668 | ||
2447e9af PS |
1669 | static struct obstack dont_print_type_obstack; |
1670 | ||
8050a57b FF |
1671 | void |
1672 | recursive_dump_type (type, spaces) | |
1673 | struct type *type; | |
1674 | int spaces; | |
1675 | { | |
1676 | int idx; | |
0239d9b3 | 1677 | |
2447e9af PS |
1678 | if (spaces == 0) |
1679 | obstack_begin (&dont_print_type_obstack, 0); | |
1680 | ||
1681 | if (TYPE_NFIELDS (type) > 0 | |
1682 | || (TYPE_CPLUS_SPECIFIC (type) && TYPE_NFN_FIELDS (type) > 0)) | |
1683 | { | |
1684 | struct type **first_dont_print | |
1685 | = (struct type **)obstack_base (&dont_print_type_obstack); | |
1686 | ||
1687 | int i = (struct type **)obstack_next_free (&dont_print_type_obstack) | |
1688 | - first_dont_print; | |
1689 | ||
1690 | while (--i >= 0) | |
1691 | { | |
1692 | if (type == first_dont_print[i]) | |
1693 | { | |
1694 | printfi_filtered (spaces, "type node "); | |
1695 | gdb_print_address (type, gdb_stdout); | |
1696 | printf_filtered (" <same as already seen type>\n"); | |
1697 | return; | |
1698 | } | |
1699 | } | |
1700 | ||
1701 | obstack_ptr_grow (&dont_print_type_obstack, type); | |
1702 | } | |
1703 | ||
833e0d94 JK |
1704 | printfi_filtered (spaces, "type node "); |
1705 | gdb_print_address (type, gdb_stdout); | |
1706 | printf_filtered ("\n"); | |
1707 | printfi_filtered (spaces, "name '%s' (", | |
1708 | TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>"); | |
1709 | gdb_print_address (TYPE_NAME (type), gdb_stdout); | |
1710 | printf_filtered (")\n"); | |
85999c05 | 1711 | if (TYPE_TAG_NAME (type) != NULL) |
833e0d94 JK |
1712 | { |
1713 | printfi_filtered (spaces, "tagname '%s' (", | |
1714 | TYPE_TAG_NAME (type)); | |
1715 | gdb_print_address (TYPE_TAG_NAME (type), gdb_stdout); | |
1716 | printf_filtered (")\n"); | |
1717 | } | |
c0f1085b | 1718 | printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type)); |
8050a57b | 1719 | switch (TYPE_CODE (type)) |
0239d9b3 | 1720 | { |
8050a57b | 1721 | case TYPE_CODE_UNDEF: |
c0f1085b | 1722 | printf_filtered ("(TYPE_CODE_UNDEF)"); |
8050a57b FF |
1723 | break; |
1724 | case TYPE_CODE_PTR: | |
c0f1085b | 1725 | printf_filtered ("(TYPE_CODE_PTR)"); |
8050a57b FF |
1726 | break; |
1727 | case TYPE_CODE_ARRAY: | |
c0f1085b | 1728 | printf_filtered ("(TYPE_CODE_ARRAY)"); |
8050a57b FF |
1729 | break; |
1730 | case TYPE_CODE_STRUCT: | |
c0f1085b | 1731 | printf_filtered ("(TYPE_CODE_STRUCT)"); |
8050a57b FF |
1732 | break; |
1733 | case TYPE_CODE_UNION: | |
c0f1085b | 1734 | printf_filtered ("(TYPE_CODE_UNION)"); |
8050a57b FF |
1735 | break; |
1736 | case TYPE_CODE_ENUM: | |
c0f1085b | 1737 | printf_filtered ("(TYPE_CODE_ENUM)"); |
8050a57b FF |
1738 | break; |
1739 | case TYPE_CODE_FUNC: | |
c0f1085b | 1740 | printf_filtered ("(TYPE_CODE_FUNC)"); |
8050a57b FF |
1741 | break; |
1742 | case TYPE_CODE_INT: | |
c0f1085b | 1743 | printf_filtered ("(TYPE_CODE_INT)"); |
8050a57b FF |
1744 | break; |
1745 | case TYPE_CODE_FLT: | |
c0f1085b | 1746 | printf_filtered ("(TYPE_CODE_FLT)"); |
8050a57b FF |
1747 | break; |
1748 | case TYPE_CODE_VOID: | |
c0f1085b | 1749 | printf_filtered ("(TYPE_CODE_VOID)"); |
8050a57b FF |
1750 | break; |
1751 | case TYPE_CODE_SET: | |
c0f1085b | 1752 | printf_filtered ("(TYPE_CODE_SET)"); |
8050a57b FF |
1753 | break; |
1754 | case TYPE_CODE_RANGE: | |
c0f1085b | 1755 | printf_filtered ("(TYPE_CODE_RANGE)"); |
8050a57b | 1756 | break; |
c4413e2c FF |
1757 | case TYPE_CODE_STRING: |
1758 | printf_filtered ("(TYPE_CODE_STRING)"); | |
8050a57b FF |
1759 | break; |
1760 | case TYPE_CODE_ERROR: | |
c0f1085b | 1761 | printf_filtered ("(TYPE_CODE_ERROR)"); |
8050a57b FF |
1762 | break; |
1763 | case TYPE_CODE_MEMBER: | |
c0f1085b | 1764 | printf_filtered ("(TYPE_CODE_MEMBER)"); |
8050a57b FF |
1765 | break; |
1766 | case TYPE_CODE_METHOD: | |
c0f1085b | 1767 | printf_filtered ("(TYPE_CODE_METHOD)"); |
8050a57b FF |
1768 | break; |
1769 | case TYPE_CODE_REF: | |
c0f1085b | 1770 | printf_filtered ("(TYPE_CODE_REF)"); |
8050a57b FF |
1771 | break; |
1772 | case TYPE_CODE_CHAR: | |
c0f1085b | 1773 | printf_filtered ("(TYPE_CODE_CHAR)"); |
8050a57b FF |
1774 | break; |
1775 | case TYPE_CODE_BOOL: | |
c0f1085b | 1776 | printf_filtered ("(TYPE_CODE_BOOL)"); |
8050a57b | 1777 | break; |
d1f4065e PB |
1778 | case TYPE_CODE_TYPEDEF: |
1779 | printf_filtered ("(TYPE_CODE_TYPEDEF)"); | |
1780 | break; | |
8050a57b | 1781 | default: |
c0f1085b | 1782 | printf_filtered ("(UNKNOWN TYPE CODE)"); |
8050a57b | 1783 | break; |
0239d9b3 | 1784 | } |
8050a57b | 1785 | puts_filtered ("\n"); |
c0f1085b | 1786 | printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type)); |
833e0d94 JK |
1787 | printfi_filtered (spaces, "objfile "); |
1788 | gdb_print_address (TYPE_OBJFILE (type), gdb_stdout); | |
1789 | printf_filtered ("\n"); | |
1790 | printfi_filtered (spaces, "target_type "); | |
1791 | gdb_print_address (TYPE_TARGET_TYPE (type), gdb_stdout); | |
1792 | printf_filtered ("\n"); | |
8050a57b FF |
1793 | if (TYPE_TARGET_TYPE (type) != NULL) |
1794 | { | |
1795 | recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2); | |
1796 | } | |
833e0d94 JK |
1797 | printfi_filtered (spaces, "pointer_type "); |
1798 | gdb_print_address (TYPE_POINTER_TYPE (type), gdb_stdout); | |
1799 | printf_filtered ("\n"); | |
1800 | printfi_filtered (spaces, "reference_type "); | |
1801 | gdb_print_address (TYPE_REFERENCE_TYPE (type), gdb_stdout); | |
1802 | printf_filtered ("\n"); | |
c0f1085b | 1803 | printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type)); |
8050a57b FF |
1804 | if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED) |
1805 | { | |
1806 | puts_filtered (" TYPE_FLAG_UNSIGNED"); | |
1807 | } | |
8050a57b FF |
1808 | if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) |
1809 | { | |
1810 | puts_filtered (" TYPE_FLAG_STUB"); | |
1811 | } | |
1812 | puts_filtered ("\n"); | |
833e0d94 | 1813 | printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type)); |
5e678752 | 1814 | gdb_print_address (TYPE_FIELDS (type), gdb_stdout); |
833e0d94 | 1815 | puts_filtered ("\n"); |
8050a57b FF |
1816 | for (idx = 0; idx < TYPE_NFIELDS (type); idx++) |
1817 | { | |
1818 | printfi_filtered (spaces + 2, | |
5e678752 | 1819 | "[%d] bitpos %d bitsize %d type ", |
8050a57b | 1820 | idx, TYPE_FIELD_BITPOS (type, idx), |
833e0d94 JK |
1821 | TYPE_FIELD_BITSIZE (type, idx)); |
1822 | gdb_print_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout); | |
1823 | printf_filtered (" name '%s' (", | |
1824 | TYPE_FIELD_NAME (type, idx) != NULL | |
1825 | ? TYPE_FIELD_NAME (type, idx) | |
1826 | : "<NULL>"); | |
5e678752 | 1827 | gdb_print_address (TYPE_FIELD_NAME (type, idx), gdb_stdout); |
833e0d94 | 1828 | printf_filtered (")\n"); |
8050a57b FF |
1829 | if (TYPE_FIELD_TYPE (type, idx) != NULL) |
1830 | { | |
1831 | recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4); | |
1832 | } | |
1833 | } | |
833e0d94 JK |
1834 | printfi_filtered (spaces, "vptr_basetype "); |
1835 | gdb_print_address (TYPE_VPTR_BASETYPE (type), gdb_stdout); | |
1836 | puts_filtered ("\n"); | |
8050a57b FF |
1837 | if (TYPE_VPTR_BASETYPE (type) != NULL) |
1838 | { | |
1839 | recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2); | |
1840 | } | |
c0f1085b | 1841 | printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type)); |
8050a57b | 1842 | switch (TYPE_CODE (type)) |
0239d9b3 FF |
1843 | { |
1844 | case TYPE_CODE_METHOD: | |
1845 | case TYPE_CODE_FUNC: | |
833e0d94 | 1846 | printfi_filtered (spaces, "arg_types "); |
5e678752 | 1847 | gdb_print_address (TYPE_ARG_TYPES (type), gdb_stdout); |
833e0d94 | 1848 | puts_filtered ("\n"); |
c0f1085b | 1849 | print_arg_types (TYPE_ARG_TYPES (type), spaces); |
0239d9b3 FF |
1850 | break; |
1851 | ||
1852 | case TYPE_CODE_STRUCT: | |
833e0d94 | 1853 | printfi_filtered (spaces, "cplus_stuff "); |
5e678752 | 1854 | gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); |
833e0d94 | 1855 | puts_filtered ("\n"); |
8050a57b | 1856 | print_cplus_stuff (type, spaces); |
0239d9b3 | 1857 | break; |
d07734e3 FF |
1858 | |
1859 | default: | |
1860 | /* We have to pick one of the union types to be able print and test | |
1861 | the value. Pick cplus_struct_type, even though we know it isn't | |
1862 | any particular one. */ | |
833e0d94 | 1863 | printfi_filtered (spaces, "type_specific "); |
5e678752 | 1864 | gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); |
d07734e3 FF |
1865 | if (TYPE_CPLUS_SPECIFIC (type) != NULL) |
1866 | { | |
1867 | printf_filtered (" (unknown data form)"); | |
1868 | } | |
1869 | printf_filtered ("\n"); | |
1870 | break; | |
1871 | ||
0239d9b3 | 1872 | } |
2447e9af PS |
1873 | if (spaces == 0) |
1874 | obstack_free (&dont_print_type_obstack, NULL); | |
0239d9b3 FF |
1875 | } |
1876 | ||
1877 | #endif /* MAINTENANCE_CMDS */ | |
c4413e2c FF |
1878 | |
1879 | void | |
1880 | _initialize_gdbtypes () | |
1881 | { | |
1882 | builtin_type_void = | |
1883 | init_type (TYPE_CODE_VOID, 1, | |
1884 | 0, | |
1885 | "void", (struct objfile *) NULL); | |
1886 | builtin_type_char = | |
1887 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
1888 | 0, | |
1889 | "char", (struct objfile *) NULL); | |
1890 | builtin_type_signed_char = | |
1891 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
dda398c3 | 1892 | 0, |
c4413e2c FF |
1893 | "signed char", (struct objfile *) NULL); |
1894 | builtin_type_unsigned_char = | |
1895 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
1896 | TYPE_FLAG_UNSIGNED, | |
1897 | "unsigned char", (struct objfile *) NULL); | |
1898 | builtin_type_short = | |
1899 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, | |
1900 | 0, | |
1901 | "short", (struct objfile *) NULL); | |
1902 | builtin_type_unsigned_short = | |
1903 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, | |
1904 | TYPE_FLAG_UNSIGNED, | |
1905 | "unsigned short", (struct objfile *) NULL); | |
1906 | builtin_type_int = | |
1907 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
1908 | 0, | |
1909 | "int", (struct objfile *) NULL); | |
1910 | builtin_type_unsigned_int = | |
1911 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
1912 | TYPE_FLAG_UNSIGNED, | |
1913 | "unsigned int", (struct objfile *) NULL); | |
1914 | builtin_type_long = | |
1915 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
1916 | 0, | |
1917 | "long", (struct objfile *) NULL); | |
1918 | builtin_type_unsigned_long = | |
1919 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
1920 | TYPE_FLAG_UNSIGNED, | |
1921 | "unsigned long", (struct objfile *) NULL); | |
1922 | builtin_type_long_long = | |
1923 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, | |
1924 | 0, | |
1925 | "long long", (struct objfile *) NULL); | |
1926 | builtin_type_unsigned_long_long = | |
1927 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, | |
1928 | TYPE_FLAG_UNSIGNED, | |
1929 | "unsigned long long", (struct objfile *) NULL); | |
1930 | builtin_type_float = | |
1931 | init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, | |
1932 | 0, | |
1933 | "float", (struct objfile *) NULL); | |
1934 | builtin_type_double = | |
1935 | init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, | |
1936 | 0, | |
1937 | "double", (struct objfile *) NULL); | |
1938 | builtin_type_long_double = | |
1939 | init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, | |
1940 | 0, | |
1941 | "long double", (struct objfile *) NULL); | |
1942 | builtin_type_complex = | |
ead95f8a | 1943 | init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT, |
c4413e2c FF |
1944 | 0, |
1945 | "complex", (struct objfile *) NULL); | |
ead95f8a | 1946 | TYPE_TARGET_TYPE (builtin_type_complex) = builtin_type_float; |
c4413e2c | 1947 | builtin_type_double_complex = |
ead95f8a | 1948 | init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, |
c4413e2c FF |
1949 | 0, |
1950 | "double complex", (struct objfile *) NULL); | |
ead95f8a | 1951 | TYPE_TARGET_TYPE (builtin_type_double_complex) = builtin_type_double; |
c4413e2c FF |
1952 | builtin_type_string = |
1953 | init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
1954 | 0, | |
1955 | "string", (struct objfile *) NULL); | |
980714f9 AC |
1956 | builtin_type_int8 = |
1957 | init_type (TYPE_CODE_INT, 8 / 8, | |
1958 | 0, | |
1959 | "int8_t", (struct objfile *) NULL); | |
1960 | builtin_type_uint8 = | |
1961 | init_type (TYPE_CODE_INT, 8 / 8, | |
1962 | TYPE_FLAG_UNSIGNED, | |
1963 | "uint8_t", (struct objfile *) NULL); | |
1964 | builtin_type_int16 = | |
1965 | init_type (TYPE_CODE_INT, 16 / 8, | |
1966 | 0, | |
1967 | "int16_t", (struct objfile *) NULL); | |
1968 | builtin_type_uint16 = | |
1969 | init_type (TYPE_CODE_INT, 16 / 8, | |
1970 | TYPE_FLAG_UNSIGNED, | |
1971 | "uint16_t", (struct objfile *) NULL); | |
1972 | builtin_type_int32 = | |
1973 | init_type (TYPE_CODE_INT, 32 / 8, | |
1974 | 0, | |
1975 | "int32_t", (struct objfile *) NULL); | |
1976 | builtin_type_uint32 = | |
1977 | init_type (TYPE_CODE_INT, 32 / 8, | |
1978 | TYPE_FLAG_UNSIGNED, | |
1979 | "uint32_t", (struct objfile *) NULL); | |
1980 | builtin_type_int64 = | |
1981 | init_type (TYPE_CODE_INT, 64 / 8, | |
1982 | 0, | |
1983 | "int64_t", (struct objfile *) NULL); | |
1984 | builtin_type_uint64 = | |
1985 | init_type (TYPE_CODE_INT, 64 / 8, | |
1986 | TYPE_FLAG_UNSIGNED, | |
1987 | "uint64_t", (struct objfile *) NULL); | |
1988 | /* start-sanitize-r5900 */ | |
1989 | builtin_type_int128 = | |
1990 | init_type (TYPE_CODE_INT, 128 / 8, | |
1991 | 0, | |
1992 | "int128_t", (struct objfile *) NULL); | |
1993 | builtin_type_uint128 = | |
1994 | init_type (TYPE_CODE_INT, 128 / 8, | |
1995 | TYPE_FLAG_UNSIGNED, | |
1996 | "uint128_t", (struct objfile *) NULL); | |
1997 | /* end-sanitize-r5900 */ | |
c4413e2c | 1998 | } |