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