File: | src/gnu/usr.bin/binutils/gdb/gdbtypes.c |
Warning: | line 817, column 17 The left operand of '>=' is a garbage value |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* Support routines for manipulating internal types for GDB. | |||
2 | Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, | |||
3 | 2004 Free Software Foundation, Inc. | |||
4 | Contributed by Cygnus Support, using pieces from other GDB modules. | |||
5 | ||||
6 | This file is part of GDB. | |||
7 | ||||
8 | This program is free software; you can redistribute it and/or modify | |||
9 | it under the terms of the GNU General Public License as published by | |||
10 | the Free Software Foundation; either version 2 of the License, or | |||
11 | (at your option) any later version. | |||
12 | ||||
13 | This program is distributed in the hope that it will be useful, | |||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
16 | GNU General Public License for more details. | |||
17 | ||||
18 | You should have received a copy of the GNU General Public License | |||
19 | along with this program; if not, write to the Free Software | |||
20 | Foundation, Inc., 59 Temple Place - Suite 330, | |||
21 | Boston, MA 02111-1307, USA. */ | |||
22 | ||||
23 | #include "defs.h" | |||
24 | #include "gdb_string.h" | |||
25 | #include "bfd.h" | |||
26 | #include "symtab.h" | |||
27 | #include "symfile.h" | |||
28 | #include "objfiles.h" | |||
29 | #include "gdbtypes.h" | |||
30 | #include "expression.h" | |||
31 | #include "language.h" | |||
32 | #include "target.h" | |||
33 | #include "value.h" | |||
34 | #include "demangle.h" | |||
35 | #include "complaints.h" | |||
36 | #include "gdbcmd.h" | |||
37 | #include "wrapper.h" | |||
38 | #include "cp-abi.h" | |||
39 | #include "gdb_assert.h" | |||
40 | ||||
41 | /* These variables point to the objects | |||
42 | representing the predefined C data types. */ | |||
43 | ||||
44 | struct type *builtin_type_void; | |||
45 | struct type *builtin_type_char; | |||
46 | struct type *builtin_type_true_char; | |||
47 | struct type *builtin_type_short; | |||
48 | struct type *builtin_type_int; | |||
49 | struct type *builtin_type_long; | |||
50 | struct type *builtin_type_long_long; | |||
51 | struct type *builtin_type_signed_char; | |||
52 | struct type *builtin_type_unsigned_char; | |||
53 | struct type *builtin_type_unsigned_short; | |||
54 | struct type *builtin_type_unsigned_int; | |||
55 | struct type *builtin_type_unsigned_long; | |||
56 | struct type *builtin_type_unsigned_long_long; | |||
57 | struct type *builtin_type_float; | |||
58 | struct type *builtin_type_double; | |||
59 | struct type *builtin_type_long_double; | |||
60 | struct type *builtin_type_complex; | |||
61 | struct type *builtin_type_double_complex; | |||
62 | struct type *builtin_type_string; | |||
63 | struct type *builtin_type_int0; | |||
64 | struct type *builtin_type_int8; | |||
65 | struct type *builtin_type_uint8; | |||
66 | struct type *builtin_type_int16; | |||
67 | struct type *builtin_type_uint16; | |||
68 | struct type *builtin_type_int32; | |||
69 | struct type *builtin_type_uint32; | |||
70 | struct type *builtin_type_int64; | |||
71 | struct type *builtin_type_uint64; | |||
72 | struct type *builtin_type_int128; | |||
73 | struct type *builtin_type_uint128; | |||
74 | struct type *builtin_type_bool; | |||
75 | ||||
76 | /* 128 bit long vector types */ | |||
77 | struct type *builtin_type_v2_double; | |||
78 | struct type *builtin_type_v4_float; | |||
79 | struct type *builtin_type_v2_int64; | |||
80 | struct type *builtin_type_v4_int32; | |||
81 | struct type *builtin_type_v8_int16; | |||
82 | struct type *builtin_type_v16_int8; | |||
83 | /* 64 bit long vector types */ | |||
84 | struct type *builtin_type_v2_float; | |||
85 | struct type *builtin_type_v2_int32; | |||
86 | struct type *builtin_type_v4_int16; | |||
87 | struct type *builtin_type_v8_int8; | |||
88 | ||||
89 | struct type *builtin_type_v4sf; | |||
90 | struct type *builtin_type_v4si; | |||
91 | struct type *builtin_type_v16qi; | |||
92 | struct type *builtin_type_v8qi; | |||
93 | struct type *builtin_type_v8hi; | |||
94 | struct type *builtin_type_v4hi; | |||
95 | struct type *builtin_type_v2si; | |||
96 | struct type *builtin_type_vec64; | |||
97 | struct type *builtin_type_vec64i; | |||
98 | struct type *builtin_type_vec128; | |||
99 | struct type *builtin_type_vec128i; | |||
100 | struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN]; | |||
101 | struct type *builtin_type_ieee_single_big; | |||
102 | struct type *builtin_type_ieee_single_little; | |||
103 | struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN]; | |||
104 | struct type *builtin_type_ieee_double_big; | |||
105 | struct type *builtin_type_ieee_double_little; | |||
106 | struct type *builtin_type_ieee_double_littlebyte_bigword; | |||
107 | struct type *builtin_type_i387_ext; | |||
108 | struct type *builtin_type_m68881_ext; | |||
109 | struct type *builtin_type_i960_ext; | |||
110 | struct type *builtin_type_m88110_ext; | |||
111 | struct type *builtin_type_m88110_harris_ext; | |||
112 | struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN]; | |||
113 | struct type *builtin_type_arm_ext_big; | |||
114 | struct type *builtin_type_arm_ext_littlebyte_bigword; | |||
115 | struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN]; | |||
116 | struct type *builtin_type_ia64_spill_big; | |||
117 | struct type *builtin_type_ia64_spill_little; | |||
118 | struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN]; | |||
119 | struct type *builtin_type_ia64_quad_big; | |||
120 | struct type *builtin_type_ia64_quad_little; | |||
121 | struct type *builtin_type_void_data_ptr; | |||
122 | struct type *builtin_type_void_func_ptr; | |||
123 | struct type *builtin_type_CORE_ADDR; | |||
124 | struct type *builtin_type_bfd_vma; | |||
125 | ||||
126 | int opaque_type_resolution = 1; | |||
127 | int overload_debug = 0; | |||
128 | ||||
129 | struct extra | |||
130 | { | |||
131 | char str[128]; | |||
132 | int len; | |||
133 | }; /* maximum extension is 128! FIXME */ | |||
134 | ||||
135 | static void print_bit_vector (B_TYPEunsigned char *, int); | |||
136 | static void print_arg_types (struct field *, int, int); | |||
137 | static void dump_fn_fieldlists (struct type *, int); | |||
138 | static void print_cplus_stuff (struct type *, int); | |||
139 | static void virtual_base_list_aux (struct type *dclass); | |||
140 | ||||
141 | ||||
142 | /* Alloc a new type structure and fill it with some defaults. If | |||
143 | OBJFILE is non-NULL, then allocate the space for the type structure | |||
144 | in that objfile's objfile_obstack. Otherwise allocate the new type structure | |||
145 | by xmalloc () (for permanent types). */ | |||
146 | ||||
147 | struct type * | |||
148 | alloc_type (struct objfile *objfile) | |||
149 | { | |||
150 | struct type *type; | |||
151 | ||||
152 | /* Alloc the structure and start off with all fields zeroed. */ | |||
153 | ||||
154 | if (objfile == NULL((void*)0)) | |||
155 | { | |||
156 | type = xmalloc (sizeof (struct type)); | |||
157 | memset (type, 0, sizeof (struct type)); | |||
158 | TYPE_MAIN_TYPE (type)(type)->main_type = xmalloc (sizeof (struct main_type)); | |||
159 | } | |||
160 | else | |||
161 | { | |||
162 | type = obstack_alloc (&objfile->objfile_obstack,__extension__ ({ struct obstack *__h = (&objfile->objfile_obstack ); __extension__ ({ struct obstack *__o = (__h); int __len = ( (sizeof (struct type))); if (__o->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }); __extension__ ({ struct obstack * __o1 = (__h); void *value; value = (void *) __o1->object_base ; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char * ) 0)+__o1->alignment_mask) & ~ (__o1->alignment_mask )) + (char *) 0); if (__o1->next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1-> next_free = __o1->chunk_limit; __o1->object_base = __o1 ->next_free; value; }); }) | |||
163 | sizeof (struct type))__extension__ ({ struct obstack *__h = (&objfile->objfile_obstack ); __extension__ ({ struct obstack *__o = (__h); int __len = ( (sizeof (struct type))); if (__o->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }); __extension__ ({ struct obstack * __o1 = (__h); void *value; value = (void *) __o1->object_base ; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char * ) 0)+__o1->alignment_mask) & ~ (__o1->alignment_mask )) + (char *) 0); if (__o1->next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1-> next_free = __o1->chunk_limit; __o1->object_base = __o1 ->next_free; value; }); }); | |||
164 | memset (type, 0, sizeof (struct type)); | |||
165 | TYPE_MAIN_TYPE (type)(type)->main_type = obstack_alloc (&objfile->objfile_obstack,__extension__ ({ struct obstack *__h = (&objfile->objfile_obstack ); __extension__ ({ struct obstack *__o = (__h); int __len = ( (sizeof (struct main_type))); if (__o->chunk_limit - __o-> next_free < __len) _obstack_newchunk (__o, __len); ((__o)-> next_free += (__len)); (void) 0; }); __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base ; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char * ) 0)+__o1->alignment_mask) & ~ (__o1->alignment_mask )) + (char *) 0); if (__o1->next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1-> next_free = __o1->chunk_limit; __o1->object_base = __o1 ->next_free; value; }); }) | |||
166 | sizeof (struct main_type))__extension__ ({ struct obstack *__h = (&objfile->objfile_obstack ); __extension__ ({ struct obstack *__o = (__h); int __len = ( (sizeof (struct main_type))); if (__o->chunk_limit - __o-> next_free < __len) _obstack_newchunk (__o, __len); ((__o)-> next_free += (__len)); (void) 0; }); __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base ; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char * ) 0)+__o1->alignment_mask) & ~ (__o1->alignment_mask )) + (char *) 0); if (__o1->next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1-> next_free = __o1->chunk_limit; __o1->object_base = __o1 ->next_free; value; }); }); | |||
167 | OBJSTAT (objfile, n_types++)(objfile -> stats.n_types++); | |||
168 | } | |||
169 | memset (TYPE_MAIN_TYPE (type)(type)->main_type, 0, sizeof (struct main_type)); | |||
170 | ||||
171 | /* Initialize the fields that might not be zero. */ | |||
172 | ||||
173 | TYPE_CODE (type)(type)->main_type->code = TYPE_CODE_UNDEF; | |||
174 | TYPE_OBJFILE (type)(type)->main_type->objfile = objfile; | |||
175 | TYPE_VPTR_FIELDNO (type)(type)->main_type->vptr_fieldno = -1; | |||
176 | TYPE_CHAIN (type)(type)->chain = type; /* Chain back to itself. */ | |||
177 | ||||
178 | return (type); | |||
179 | } | |||
180 | ||||
181 | /* Alloc a new type instance structure, fill it with some defaults, | |||
182 | and point it at OLDTYPE. Allocate the new type instance from the | |||
183 | same place as OLDTYPE. */ | |||
184 | ||||
185 | static struct type * | |||
186 | alloc_type_instance (struct type *oldtype) | |||
187 | { | |||
188 | struct type *type; | |||
189 | ||||
190 | /* Allocate the structure. */ | |||
191 | ||||
192 | if (TYPE_OBJFILE (oldtype)(oldtype)->main_type->objfile == NULL((void*)0)) | |||
193 | { | |||
194 | type = xmalloc (sizeof (struct type)); | |||
195 | memset (type, 0, sizeof (struct type)); | |||
196 | } | |||
197 | else | |||
198 | { | |||
199 | type = obstack_alloc (&TYPE_OBJFILE (oldtype)->objfile_obstack,__extension__ ({ struct obstack *__h = (&(oldtype)->main_type ->objfile->objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = ((sizeof (struct type))); if (__o-> chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }) | |||
200 | sizeof (struct type))__extension__ ({ struct obstack *__h = (&(oldtype)->main_type ->objfile->objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = ((sizeof (struct type))); if (__o-> chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }); | |||
201 | memset (type, 0, sizeof (struct type)); | |||
202 | } | |||
203 | TYPE_MAIN_TYPE (type)(type)->main_type = TYPE_MAIN_TYPE (oldtype)(oldtype)->main_type; | |||
204 | ||||
205 | TYPE_CHAIN (type)(type)->chain = type; /* Chain back to itself for now. */ | |||
206 | ||||
207 | return (type); | |||
208 | } | |||
209 | ||||
210 | /* Clear all remnants of the previous type at TYPE, in preparation for | |||
211 | replacing it with something else. */ | |||
212 | static void | |||
213 | smash_type (struct type *type) | |||
214 | { | |||
215 | memset (TYPE_MAIN_TYPE (type)(type)->main_type, 0, sizeof (struct main_type)); | |||
216 | ||||
217 | /* For now, delete the rings. */ | |||
218 | TYPE_CHAIN (type)(type)->chain = type; | |||
219 | ||||
220 | /* For now, leave the pointer/reference types alone. */ | |||
221 | } | |||
222 | ||||
223 | /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points | |||
224 | to a pointer to memory where the pointer type should be stored. | |||
225 | If *TYPEPTR is zero, update it to point to the pointer type we return. | |||
226 | We allocate new memory if needed. */ | |||
227 | ||||
228 | struct type * | |||
229 | make_pointer_type (struct type *type, struct type **typeptr) | |||
230 | { | |||
231 | struct type *ntype; /* New type */ | |||
232 | struct objfile *objfile; | |||
233 | ||||
234 | ntype = TYPE_POINTER_TYPE (type)(type)->pointer_type; | |||
235 | ||||
236 | if (ntype) | |||
237 | { | |||
238 | if (typeptr == 0) | |||
239 | return ntype; /* Don't care about alloc, and have new type. */ | |||
240 | else if (*typeptr == 0) | |||
241 | { | |||
242 | *typeptr = ntype; /* Tracking alloc, and we have new type. */ | |||
243 | return ntype; | |||
244 | } | |||
245 | } | |||
246 | ||||
247 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |||
248 | { | |||
249 | ntype = alloc_type (TYPE_OBJFILE (type)(type)->main_type->objfile); | |||
250 | if (typeptr) | |||
251 | *typeptr = ntype; | |||
252 | } | |||
253 | else | |||
254 | /* We have storage, but need to reset it. */ | |||
255 | { | |||
256 | ntype = *typeptr; | |||
257 | objfile = TYPE_OBJFILE (ntype)(ntype)->main_type->objfile; | |||
258 | smash_type (ntype); | |||
259 | TYPE_OBJFILE (ntype)(ntype)->main_type->objfile = objfile; | |||
260 | } | |||
261 | ||||
262 | TYPE_TARGET_TYPE (ntype)(ntype)->main_type->target_type = type; | |||
263 | TYPE_POINTER_TYPE (type)(type)->pointer_type = ntype; | |||
264 | ||||
265 | /* FIXME! Assume the machine has only one representation for pointers! */ | |||
266 | ||||
267 | TYPE_LENGTH (ntype)(ntype)->length = TARGET_PTR_BIT(gdbarch_ptr_bit (current_gdbarch)) / TARGET_CHAR_BIT8; | |||
268 | TYPE_CODE (ntype)(ntype)->main_type->code = TYPE_CODE_PTR; | |||
269 | ||||
270 | /* Mark pointers as unsigned. The target converts between pointers | |||
271 | and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and | |||
272 | ADDRESS_TO_POINTER(). */ | |||
273 | TYPE_FLAGS (ntype)(ntype)->main_type->flags |= TYPE_FLAG_UNSIGNED(1 << 0); | |||
274 | ||||
275 | if (!TYPE_POINTER_TYPE (type)(type)->pointer_type) /* Remember it, if don't have one. */ | |||
276 | TYPE_POINTER_TYPE (type)(type)->pointer_type = ntype; | |||
277 | ||||
278 | return ntype; | |||
279 | } | |||
280 | ||||
281 | /* Given a type TYPE, return a type of pointers to that type. | |||
282 | May need to construct such a type if this is the first use. */ | |||
283 | ||||
284 | struct type * | |||
285 | lookup_pointer_type (struct type *type) | |||
286 | { | |||
287 | return make_pointer_type (type, (struct type **) 0); | |||
288 | } | |||
289 | ||||
290 | /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points | |||
291 | to a pointer to memory where the reference type should be stored. | |||
292 | If *TYPEPTR is zero, update it to point to the reference type we return. | |||
293 | We allocate new memory if needed. */ | |||
294 | ||||
295 | struct type * | |||
296 | make_reference_type (struct type *type, struct type **typeptr) | |||
297 | { | |||
298 | struct type *ntype; /* New type */ | |||
299 | struct objfile *objfile; | |||
300 | ||||
301 | ntype = TYPE_REFERENCE_TYPE (type)(type)->reference_type; | |||
302 | ||||
303 | if (ntype) | |||
304 | { | |||
305 | if (typeptr == 0) | |||
306 | return ntype; /* Don't care about alloc, and have new type. */ | |||
307 | else if (*typeptr == 0) | |||
308 | { | |||
309 | *typeptr = ntype; /* Tracking alloc, and we have new type. */ | |||
310 | return ntype; | |||
311 | } | |||
312 | } | |||
313 | ||||
314 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |||
315 | { | |||
316 | ntype = alloc_type (TYPE_OBJFILE (type)(type)->main_type->objfile); | |||
317 | if (typeptr) | |||
318 | *typeptr = ntype; | |||
319 | } | |||
320 | else | |||
321 | /* We have storage, but need to reset it. */ | |||
322 | { | |||
323 | ntype = *typeptr; | |||
324 | objfile = TYPE_OBJFILE (ntype)(ntype)->main_type->objfile; | |||
325 | smash_type (ntype); | |||
326 | TYPE_OBJFILE (ntype)(ntype)->main_type->objfile = objfile; | |||
327 | } | |||
328 | ||||
329 | TYPE_TARGET_TYPE (ntype)(ntype)->main_type->target_type = type; | |||
330 | TYPE_REFERENCE_TYPE (type)(type)->reference_type = ntype; | |||
331 | ||||
332 | /* FIXME! Assume the machine has only one representation for references, | |||
333 | and that it matches the (only) representation for pointers! */ | |||
334 | ||||
335 | TYPE_LENGTH (ntype)(ntype)->length = TARGET_PTR_BIT(gdbarch_ptr_bit (current_gdbarch)) / TARGET_CHAR_BIT8; | |||
336 | TYPE_CODE (ntype)(ntype)->main_type->code = TYPE_CODE_REF; | |||
337 | ||||
338 | if (!TYPE_REFERENCE_TYPE (type)(type)->reference_type) /* Remember it, if don't have one. */ | |||
339 | TYPE_REFERENCE_TYPE (type)(type)->reference_type = ntype; | |||
340 | ||||
341 | return ntype; | |||
342 | } | |||
343 | ||||
344 | /* Same as above, but caller doesn't care about memory allocation details. */ | |||
345 | ||||
346 | struct type * | |||
347 | lookup_reference_type (struct type *type) | |||
348 | { | |||
349 | return make_reference_type (type, (struct type **) 0); | |||
350 | } | |||
351 | ||||
352 | /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points | |||
353 | to a pointer to memory where the function type should be stored. | |||
354 | If *TYPEPTR is zero, update it to point to the function type we return. | |||
355 | We allocate new memory if needed. */ | |||
356 | ||||
357 | struct type * | |||
358 | make_function_type (struct type *type, struct type **typeptr) | |||
359 | { | |||
360 | struct type *ntype; /* New type */ | |||
361 | struct objfile *objfile; | |||
362 | ||||
363 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |||
364 | { | |||
365 | ntype = alloc_type (TYPE_OBJFILE (type)(type)->main_type->objfile); | |||
366 | if (typeptr) | |||
367 | *typeptr = ntype; | |||
368 | } | |||
369 | else | |||
370 | /* We have storage, but need to reset it. */ | |||
371 | { | |||
372 | ntype = *typeptr; | |||
373 | objfile = TYPE_OBJFILE (ntype)(ntype)->main_type->objfile; | |||
374 | smash_type (ntype); | |||
375 | TYPE_OBJFILE (ntype)(ntype)->main_type->objfile = objfile; | |||
376 | } | |||
377 | ||||
378 | TYPE_TARGET_TYPE (ntype)(ntype)->main_type->target_type = type; | |||
379 | ||||
380 | TYPE_LENGTH (ntype)(ntype)->length = 1; | |||
381 | TYPE_CODE (ntype)(ntype)->main_type->code = TYPE_CODE_FUNC; | |||
382 | ||||
383 | return ntype; | |||
384 | } | |||
385 | ||||
386 | ||||
387 | /* Given a type TYPE, return a type of functions that return that type. | |||
388 | May need to construct such a type if this is the first use. */ | |||
389 | ||||
390 | struct type * | |||
391 | lookup_function_type (struct type *type) | |||
392 | { | |||
393 | return make_function_type (type, (struct type **) 0); | |||
394 | } | |||
395 | ||||
396 | /* Identify address space identifier by name -- | |||
397 | return the integer flag defined in gdbtypes.h. */ | |||
398 | extern int | |||
399 | address_space_name_to_int (char *space_identifier) | |||
400 | { | |||
401 | struct gdbarch *gdbarch = current_gdbarch; | |||
402 | int type_flags; | |||
403 | /* Check for known address space delimiters. */ | |||
404 | if (!strcmp (space_identifier, "code")) | |||
405 | return TYPE_FLAG_CODE_SPACE(1 << 9); | |||
406 | else if (!strcmp (space_identifier, "data")) | |||
407 | return TYPE_FLAG_DATA_SPACE(1 << 10); | |||
408 | else if (gdbarch_address_class_name_to_type_flags_p (gdbarch) | |||
409 | && gdbarch_address_class_name_to_type_flags (gdbarch, | |||
410 | space_identifier, | |||
411 | &type_flags)) | |||
412 | return type_flags; | |||
413 | else | |||
414 | error ("Unknown address space specifier: \"%s\"", space_identifier); | |||
415 | } | |||
416 | ||||
417 | /* Identify address space identifier by integer flag as defined in | |||
418 | gdbtypes.h -- return the string version of the adress space name. */ | |||
419 | ||||
420 | const char * | |||
421 | address_space_int_to_name (int space_flag) | |||
422 | { | |||
423 | struct gdbarch *gdbarch = current_gdbarch; | |||
424 | if (space_flag & TYPE_FLAG_CODE_SPACE(1 << 9)) | |||
425 | return "code"; | |||
426 | else if (space_flag & TYPE_FLAG_DATA_SPACE(1 << 10)) | |||
427 | return "data"; | |||
428 | else if ((space_flag & TYPE_FLAG_ADDRESS_CLASS_ALL((1 << 13) | (1 << 14))) | |||
429 | && gdbarch_address_class_type_flags_to_name_p (gdbarch)) | |||
430 | return gdbarch_address_class_type_flags_to_name (gdbarch, space_flag); | |||
431 | else | |||
432 | return NULL((void*)0); | |||
433 | } | |||
434 | ||||
435 | /* Create a new type with instance flags NEW_FLAGS, based on TYPE. | |||
436 | If STORAGE is non-NULL, create the new type instance there. */ | |||
437 | ||||
438 | static struct type * | |||
439 | make_qualified_type (struct type *type, int new_flags, | |||
440 | struct type *storage) | |||
441 | { | |||
442 | struct type *ntype; | |||
443 | ||||
444 | ntype = type; | |||
445 | do { | |||
446 | if (TYPE_INSTANCE_FLAGS (ntype)(ntype)->instance_flags == new_flags) | |||
447 | return ntype; | |||
448 | ntype = TYPE_CHAIN (ntype)(ntype)->chain; | |||
449 | } while (ntype != type); | |||
450 | ||||
451 | /* Create a new type instance. */ | |||
452 | if (storage == NULL((void*)0)) | |||
453 | ntype = alloc_type_instance (type); | |||
454 | else | |||
455 | { | |||
456 | ntype = storage; | |||
457 | TYPE_MAIN_TYPE (ntype)(ntype)->main_type = TYPE_MAIN_TYPE (type)(type)->main_type; | |||
458 | TYPE_CHAIN (ntype)(ntype)->chain = ntype; | |||
459 | } | |||
460 | ||||
461 | /* Pointers or references to the original type are not relevant to | |||
462 | the new type. */ | |||
463 | TYPE_POINTER_TYPE (ntype)(ntype)->pointer_type = (struct type *) 0; | |||
464 | TYPE_REFERENCE_TYPE (ntype)(ntype)->reference_type = (struct type *) 0; | |||
465 | ||||
466 | /* Chain the new qualified type to the old type. */ | |||
467 | TYPE_CHAIN (ntype)(ntype)->chain = TYPE_CHAIN (type)(type)->chain; | |||
468 | TYPE_CHAIN (type)(type)->chain = ntype; | |||
469 | ||||
470 | /* Now set the instance flags and return the new type. */ | |||
471 | TYPE_INSTANCE_FLAGS (ntype)(ntype)->instance_flags = new_flags; | |||
472 | ||||
473 | /* Set length of new type to that of the original type. */ | |||
474 | TYPE_LENGTH (ntype)(ntype)->length = TYPE_LENGTH (type)(type)->length; | |||
475 | ||||
476 | return ntype; | |||
477 | } | |||
478 | ||||
479 | /* Make an address-space-delimited variant of a type -- a type that | |||
480 | is identical to the one supplied except that it has an address | |||
481 | space attribute attached to it (such as "code" or "data"). | |||
482 | ||||
483 | The space attributes "code" and "data" are for Harvard architectures. | |||
484 | The address space attributes are for architectures which have | |||
485 | alternately sized pointers or pointers with alternate representations. */ | |||
486 | ||||
487 | struct type * | |||
488 | make_type_with_address_space (struct type *type, int space_flag) | |||
489 | { | |||
490 | struct type *ntype; | |||
491 | int new_flags = ((TYPE_INSTANCE_FLAGS (type)(type)->instance_flags | |||
492 | & ~(TYPE_FLAG_CODE_SPACE(1 << 9) | TYPE_FLAG_DATA_SPACE(1 << 10) | |||
493 | | TYPE_FLAG_ADDRESS_CLASS_ALL((1 << 13) | (1 << 14)))) | |||
494 | | space_flag); | |||
495 | ||||
496 | return make_qualified_type (type, new_flags, NULL((void*)0)); | |||
497 | } | |||
498 | ||||
499 | /* Make a "c-v" variant of a type -- a type that is identical to the | |||
500 | one supplied except that it may have const or volatile attributes | |||
501 | CNST is a flag for setting the const attribute | |||
502 | VOLTL is a flag for setting the volatile attribute | |||
503 | TYPE is the base type whose variant we are creating. | |||
504 | TYPEPTR, if nonzero, points | |||
505 | to a pointer to memory where the reference type should be stored. | |||
506 | If *TYPEPTR is zero, update it to point to the reference type we return. | |||
507 | We allocate new memory if needed. */ | |||
508 | ||||
509 | struct type * | |||
510 | make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr) | |||
511 | { | |||
512 | struct type *ntype; /* New type */ | |||
513 | struct type *tmp_type = type; /* tmp type */ | |||
514 | struct objfile *objfile; | |||
515 | ||||
516 | int new_flags = (TYPE_INSTANCE_FLAGS (type)(type)->instance_flags | |||
517 | & ~(TYPE_FLAG_CONST(1 << 5) | TYPE_FLAG_VOLATILE(1 << 6))); | |||
518 | ||||
519 | if (cnst) | |||
520 | new_flags |= TYPE_FLAG_CONST(1 << 5); | |||
521 | ||||
522 | if (voltl) | |||
523 | new_flags |= TYPE_FLAG_VOLATILE(1 << 6); | |||
524 | ||||
525 | if (typeptr && *typeptr != NULL((void*)0)) | |||
526 | { | |||
527 | /* Objfile is per-core-type. This const-qualified type had best | |||
528 | belong to the same objfile as the type it is qualifying, unless | |||
529 | we are overwriting a stub type, in which case the safest thing | |||
530 | to do is to copy the core type into the new objfile. */ | |||
531 | ||||
532 | gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type)((void) (((*typeptr)->main_type->objfile == (type)-> main_type->objfile || ((*typeptr)->main_type->flags & (1 << 2))) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c" , 533, "%s: Assertion `%s' failed.", __PRETTY_FUNCTION__, "TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type) || TYPE_STUB (*typeptr)" ), 0))) | |||
533 | || TYPE_STUB (*typeptr))((void) (((*typeptr)->main_type->objfile == (type)-> main_type->objfile || ((*typeptr)->main_type->flags & (1 << 2))) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c" , 533, "%s: Assertion `%s' failed.", __PRETTY_FUNCTION__, "TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type) || TYPE_STUB (*typeptr)" ), 0))); | |||
534 | if (TYPE_OBJFILE (*typeptr)(*typeptr)->main_type->objfile != TYPE_OBJFILE (type)(type)->main_type->objfile) | |||
535 | { | |||
536 | TYPE_MAIN_TYPE (*typeptr)(*typeptr)->main_type | |||
537 | = TYPE_ALLOC (*typeptr, sizeof (struct main_type))((*typeptr)->main_type->objfile != ((void*)0) ? __extension__ ({ struct obstack *__h = (&(*typeptr)->main_type-> objfile -> objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = ((sizeof (struct main_type))); if ( __o->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }) : xmalloc (sizeof (struct main_type))); | |||
538 | *TYPE_MAIN_TYPE (*typeptr)(*typeptr)->main_type | |||
539 | = *TYPE_MAIN_TYPE (type)(type)->main_type; | |||
540 | } | |||
541 | } | |||
542 | ||||
543 | ntype = make_qualified_type (type, new_flags, typeptr ? *typeptr : NULL((void*)0)); | |||
544 | ||||
545 | if (typeptr != NULL((void*)0)) | |||
546 | *typeptr = ntype; | |||
547 | ||||
548 | return ntype; | |||
549 | } | |||
550 | ||||
551 | /* Replace the contents of ntype with the type *type. This changes the | |||
552 | contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus | |||
553 | the changes are propogated to all types in the TYPE_CHAIN. | |||
554 | ||||
555 | In order to build recursive types, it's inevitable that we'll need | |||
556 | to update types in place --- but this sort of indiscriminate | |||
557 | smashing is ugly, and needs to be replaced with something more | |||
558 | controlled. TYPE_MAIN_TYPE is a step in this direction; it's not | |||
559 | clear if more steps are needed. */ | |||
560 | void | |||
561 | replace_type (struct type *ntype, struct type *type) | |||
562 | { | |||
563 | struct type *chain; | |||
564 | ||||
565 | *TYPE_MAIN_TYPE (ntype)(ntype)->main_type = *TYPE_MAIN_TYPE (type)(type)->main_type; | |||
566 | ||||
567 | /* The type length is not a part of the main type. Update it for each | |||
568 | type on the variant chain. */ | |||
569 | chain = ntype; | |||
570 | do { | |||
571 | /* Assert that this element of the chain has no address-class bits | |||
572 | set in its flags. Such type variants might have type lengths | |||
573 | which are supposed to be different from the non-address-class | |||
574 | variants. This assertion shouldn't ever be triggered because | |||
575 | symbol readers which do construct address-class variants don't | |||
576 | call replace_type(). */ | |||
577 | gdb_assert (TYPE_ADDRESS_CLASS_ALL (chain) == 0)((void) ((((chain)->instance_flags & ((1 << 13) | (1 << 14))) == 0) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c" , 577, "%s: Assertion `%s' failed.", __PRETTY_FUNCTION__, "TYPE_ADDRESS_CLASS_ALL (chain) == 0" ), 0))); | |||
578 | ||||
579 | TYPE_LENGTH (ntype)(ntype)->length = TYPE_LENGTH (type)(type)->length; | |||
580 | chain = TYPE_CHAIN (chain)(chain)->chain; | |||
581 | } while (ntype != chain); | |||
582 | ||||
583 | /* Assert that the two types have equivalent instance qualifiers. | |||
584 | This should be true for at least all of our debug readers. */ | |||
585 | gdb_assert (TYPE_INSTANCE_FLAGS (ntype) == TYPE_INSTANCE_FLAGS (type))((void) (((ntype)->instance_flags == (type)->instance_flags ) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c" , 585, "%s: Assertion `%s' failed.", __PRETTY_FUNCTION__, "TYPE_INSTANCE_FLAGS (ntype) == TYPE_INSTANCE_FLAGS (type)" ), 0))); | |||
586 | } | |||
587 | ||||
588 | /* Implement direct support for MEMBER_TYPE in GNU C++. | |||
589 | May need to construct such a type if this is the first use. | |||
590 | The TYPE is the type of the member. The DOMAIN is the type | |||
591 | of the aggregate that the member belongs to. */ | |||
592 | ||||
593 | struct type * | |||
594 | lookup_member_type (struct type *type, struct type *domain) | |||
595 | { | |||
596 | struct type *mtype; | |||
597 | ||||
598 | mtype = alloc_type (TYPE_OBJFILE (type)(type)->main_type->objfile); | |||
599 | smash_to_member_type (mtype, domain, type); | |||
600 | return (mtype); | |||
601 | } | |||
602 | ||||
603 | /* Allocate a stub method whose return type is TYPE. | |||
604 | This apparently happens for speed of symbol reading, since parsing | |||
605 | out the arguments to the method is cpu-intensive, the way we are doing | |||
606 | it. So, we will fill in arguments later. | |||
607 | This always returns a fresh type. */ | |||
608 | ||||
609 | struct type * | |||
610 | allocate_stub_method (struct type *type) | |||
611 | { | |||
612 | struct type *mtype; | |||
613 | ||||
614 | mtype = init_type (TYPE_CODE_METHOD, 1, TYPE_FLAG_STUB(1 << 2), NULL((void*)0), | |||
615 | TYPE_OBJFILE (type)(type)->main_type->objfile); | |||
616 | TYPE_TARGET_TYPE (mtype)(mtype)->main_type->target_type = type; | |||
617 | /* _DOMAIN_TYPE (mtype) = unknown yet */ | |||
618 | return (mtype); | |||
619 | } | |||
620 | ||||
621 | /* Create a range type using either a blank type supplied in RESULT_TYPE, | |||
622 | or creating a new type, inheriting the objfile from INDEX_TYPE. | |||
623 | ||||
624 | Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to | |||
625 | HIGH_BOUND, inclusive. | |||
626 | ||||
627 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |||
628 | sure it is TYPE_CODE_UNDEF before we bash it into a range type? */ | |||
629 | ||||
630 | struct type * | |||
631 | create_range_type (struct type *result_type, struct type *index_type, | |||
632 | int low_bound, int high_bound) | |||
633 | { | |||
634 | if (result_type == NULL((void*)0)) | |||
635 | { | |||
636 | result_type = alloc_type (TYPE_OBJFILE (index_type)(index_type)->main_type->objfile); | |||
637 | } | |||
638 | TYPE_CODE (result_type)(result_type)->main_type->code = TYPE_CODE_RANGE; | |||
639 | TYPE_TARGET_TYPE (result_type)(result_type)->main_type->target_type = index_type; | |||
640 | if (TYPE_STUB (index_type)((index_type)->main_type->flags & (1 << 2))) | |||
641 | TYPE_FLAGS (result_type)(result_type)->main_type->flags |= TYPE_FLAG_TARGET_STUB(1 << 3); | |||
642 | else | |||
643 | TYPE_LENGTH (result_type)(result_type)->length = TYPE_LENGTH (check_typedef (index_type))(check_typedef (index_type))->length; | |||
644 | TYPE_NFIELDS (result_type)(result_type)->main_type->nfields = 2; | |||
645 | TYPE_FIELDS (result_type)(result_type)->main_type->fields = (struct field *) | |||
646 | TYPE_ALLOC (result_type, 2 * sizeof (struct field))((result_type)->main_type->objfile != ((void*)0) ? __extension__ ({ struct obstack *__h = (&(result_type)->main_type-> objfile -> objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = ((2 * sizeof (struct field))); if ( __o->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }) : xmalloc (2 * sizeof (struct field))); | |||
647 | memset (TYPE_FIELDS (result_type)(result_type)->main_type->fields, 0, 2 * sizeof (struct field)); | |||
648 | TYPE_FIELD_BITPOS (result_type, 0)(((result_type)->main_type->fields[0]).loc.bitpos) = low_bound; | |||
649 | TYPE_FIELD_BITPOS (result_type, 1)(((result_type)->main_type->fields[1]).loc.bitpos) = high_bound; | |||
650 | TYPE_FIELD_TYPE (result_type, 0)(((result_type)->main_type->fields[0]).type) = builtin_type_int; /* FIXME */ | |||
651 | TYPE_FIELD_TYPE (result_type, 1)(((result_type)->main_type->fields[1]).type) = builtin_type_int; /* FIXME */ | |||
652 | ||||
653 | if (low_bound >= 0) | |||
654 | TYPE_FLAGS (result_type)(result_type)->main_type->flags |= TYPE_FLAG_UNSIGNED(1 << 0); | |||
655 | ||||
656 | return (result_type); | |||
657 | } | |||
658 | ||||
659 | /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE. | |||
660 | Return 1 of type is a range type, 0 if it is discrete (and bounds | |||
661 | will fit in LONGEST), or -1 otherwise. */ | |||
662 | ||||
663 | int | |||
664 | get_discrete_bounds (struct type *type, LONGESTlong *lowp, LONGESTlong *highp) | |||
665 | { | |||
666 | CHECK_TYPEDEF (type)(type) = check_typedef (type); | |||
667 | switch (TYPE_CODE (type)(type)->main_type->code) | |||
668 | { | |||
669 | case TYPE_CODE_RANGE: | |||
670 | *lowp = TYPE_LOW_BOUND (type)(((type)->main_type->fields[0]).loc.bitpos); | |||
671 | *highp = TYPE_HIGH_BOUND (type)(((type)->main_type->fields[1]).loc.bitpos); | |||
672 | return 1; | |||
673 | case TYPE_CODE_ENUM: | |||
674 | if (TYPE_NFIELDS (type)(type)->main_type->nfields > 0) | |||
675 | { | |||
676 | /* The enums may not be sorted by value, so search all | |||
677 | entries */ | |||
678 | int i; | |||
679 | ||||
680 | *lowp = *highp = TYPE_FIELD_BITPOS (type, 0)(((type)->main_type->fields[0]).loc.bitpos); | |||
681 | for (i = 0; i < TYPE_NFIELDS (type)(type)->main_type->nfields; i++) | |||
682 | { | |||
683 | if (TYPE_FIELD_BITPOS (type, i)(((type)->main_type->fields[i]).loc.bitpos) < *lowp) | |||
684 | *lowp = TYPE_FIELD_BITPOS (type, i)(((type)->main_type->fields[i]).loc.bitpos); | |||
685 | if (TYPE_FIELD_BITPOS (type, i)(((type)->main_type->fields[i]).loc.bitpos) > *highp) | |||
686 | *highp = TYPE_FIELD_BITPOS (type, i)(((type)->main_type->fields[i]).loc.bitpos); | |||
687 | } | |||
688 | ||||
689 | /* Set unsigned indicator if warranted. */ | |||
690 | if (*lowp >= 0) | |||
691 | { | |||
692 | TYPE_FLAGS (type)(type)->main_type->flags |= TYPE_FLAG_UNSIGNED(1 << 0); | |||
693 | } | |||
694 | } | |||
695 | else | |||
696 | { | |||
697 | *lowp = 0; | |||
698 | *highp = -1; | |||
699 | } | |||
700 | return 0; | |||
701 | case TYPE_CODE_BOOL: | |||
702 | *lowp = 0; | |||
703 | *highp = 1; | |||
704 | return 0; | |||
705 | case TYPE_CODE_INT: | |||
706 | if (TYPE_LENGTH (type)(type)->length > sizeof (LONGESTlong)) /* Too big */ | |||
707 | return -1; | |||
708 | if (!TYPE_UNSIGNED (type)((type)->main_type->flags & (1 << 0))) | |||
709 | { | |||
710 | *lowp = -(1 << (TYPE_LENGTH (type)(type)->length * TARGET_CHAR_BIT8 - 1)); | |||
711 | *highp = -*lowp - 1; | |||
712 | return 0; | |||
713 | } | |||
714 | /* ... fall through for unsigned ints ... */ | |||
715 | case TYPE_CODE_CHAR: | |||
716 | *lowp = 0; | |||
717 | /* This round-about calculation is to avoid shifting by | |||
718 | TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work | |||
719 | if TYPE_LENGTH (type) == sizeof (LONGEST). */ | |||
720 | *highp = 1 << (TYPE_LENGTH (type)(type)->length * TARGET_CHAR_BIT8 - 1); | |||
721 | *highp = (*highp - 1) | *highp; | |||
722 | return 0; | |||
723 | default: | |||
724 | return -1; | |||
725 | } | |||
726 | } | |||
727 | ||||
728 | /* Create an array type using either a blank type supplied in RESULT_TYPE, | |||
729 | or creating a new type, inheriting the objfile from RANGE_TYPE. | |||
730 | ||||
731 | Elements will be of type ELEMENT_TYPE, the indices will be of type | |||
732 | RANGE_TYPE. | |||
733 | ||||
734 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |||
735 | sure it is TYPE_CODE_UNDEF before we bash it into an array type? */ | |||
736 | ||||
737 | struct type * | |||
738 | create_array_type (struct type *result_type, struct type *element_type, | |||
739 | struct type *range_type) | |||
740 | { | |||
741 | LONGESTlong low_bound, high_bound; | |||
742 | ||||
743 | if (result_type == NULL((void*)0)) | |||
744 | { | |||
745 | result_type = alloc_type (TYPE_OBJFILE (range_type)(range_type)->main_type->objfile); | |||
746 | } | |||
747 | TYPE_CODE (result_type)(result_type)->main_type->code = TYPE_CODE_ARRAY; | |||
748 | TYPE_TARGET_TYPE (result_type)(result_type)->main_type->target_type = element_type; | |||
749 | if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) | |||
750 | low_bound = high_bound = 0; | |||
751 | CHECK_TYPEDEF (element_type)(element_type) = check_typedef (element_type); | |||
752 | TYPE_LENGTH (result_type)(result_type)->length = | |||
753 | TYPE_LENGTH (element_type)(element_type)->length * (high_bound - low_bound + 1); | |||
754 | TYPE_NFIELDS (result_type)(result_type)->main_type->nfields = 1; | |||
755 | TYPE_FIELDS (result_type)(result_type)->main_type->fields = | |||
756 | (struct field *) TYPE_ALLOC (result_type, sizeof (struct field))((result_type)->main_type->objfile != ((void*)0) ? __extension__ ({ struct obstack *__h = (&(result_type)->main_type-> objfile -> objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = ((sizeof (struct field))); if (__o ->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }) : xmalloc (sizeof (struct field))); | |||
757 | memset (TYPE_FIELDS (result_type)(result_type)->main_type->fields, 0, sizeof (struct field)); | |||
758 | TYPE_FIELD_TYPE (result_type, 0)(((result_type)->main_type->fields[0]).type) = range_type; | |||
759 | TYPE_VPTR_FIELDNO (result_type)(result_type)->main_type->vptr_fieldno = -1; | |||
760 | ||||
761 | /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */ | |||
762 | if (TYPE_LENGTH (result_type)(result_type)->length == 0) | |||
763 | TYPE_FLAGS (result_type)(result_type)->main_type->flags |= TYPE_FLAG_TARGET_STUB(1 << 3); | |||
764 | ||||
765 | return (result_type); | |||
766 | } | |||
767 | ||||
768 | /* Create a string type using either a blank type supplied in RESULT_TYPE, | |||
769 | or creating a new type. String types are similar enough to array of | |||
770 | char types that we can use create_array_type to build the basic type | |||
771 | and then bash it into a string type. | |||
772 | ||||
773 | For fixed length strings, the range type contains 0 as the lower | |||
774 | bound and the length of the string minus one as the upper bound. | |||
775 | ||||
776 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |||
777 | sure it is TYPE_CODE_UNDEF before we bash it into a string type? */ | |||
778 | ||||
779 | struct type * | |||
780 | create_string_type (struct type *result_type, struct type *range_type) | |||
781 | { | |||
782 | struct type *string_char_type; | |||
783 | ||||
784 | string_char_type = language_string_char_type (current_language, | |||
785 | current_gdbarch); | |||
786 | result_type = create_array_type (result_type, | |||
787 | string_char_type, | |||
788 | range_type); | |||
789 | TYPE_CODE (result_type)(result_type)->main_type->code = TYPE_CODE_STRING; | |||
790 | return (result_type); | |||
791 | } | |||
792 | ||||
793 | struct type * | |||
794 | create_set_type (struct type *result_type, struct type *domain_type) | |||
795 | { | |||
796 | LONGESTlong low_bound, high_bound, bit_length; | |||
| ||||
797 | if (result_type == NULL((void*)0)) | |||
798 | { | |||
799 | result_type = alloc_type (TYPE_OBJFILE (domain_type)(domain_type)->main_type->objfile); | |||
800 | } | |||
801 | TYPE_CODE (result_type)(result_type)->main_type->code = TYPE_CODE_SET; | |||
802 | TYPE_NFIELDS (result_type)(result_type)->main_type->nfields = 1; | |||
803 | TYPE_FIELDS (result_type)(result_type)->main_type->fields = (struct field *) | |||
804 | TYPE_ALLOC (result_type, 1 * sizeof (struct field))((result_type)->main_type->objfile != ((void*)0) ? __extension__ ({ struct obstack *__h = (&(result_type)->main_type-> objfile -> objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = ((1 * sizeof (struct field))); if ( __o->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }) : xmalloc (1 * sizeof (struct field))); | |||
805 | memset (TYPE_FIELDS (result_type)(result_type)->main_type->fields, 0, sizeof (struct field)); | |||
806 | ||||
807 | if (!TYPE_STUB (domain_type)((domain_type)->main_type->flags & (1 << 2))) | |||
808 | { | |||
809 | if (get_discrete_bounds (domain_type, &low_bound, &high_bound) < 0) | |||
810 | low_bound = high_bound = 0; | |||
811 | bit_length = high_bound - low_bound + 1; | |||
812 | TYPE_LENGTH (result_type)(result_type)->length | |||
813 | = (bit_length + TARGET_CHAR_BIT8 - 1) / TARGET_CHAR_BIT8; | |||
814 | } | |||
815 | TYPE_FIELD_TYPE (result_type, 0)(((result_type)->main_type->fields[0]).type) = domain_type; | |||
816 | ||||
817 | if (low_bound >= 0) | |||
| ||||
818 | TYPE_FLAGS (result_type)(result_type)->main_type->flags |= TYPE_FLAG_UNSIGNED(1 << 0); | |||
819 | ||||
820 | return (result_type); | |||
821 | } | |||
822 | ||||
823 | /* Construct and return a type of the form: | |||
824 | struct NAME { ELT_TYPE ELT_NAME[N]; } | |||
825 | We use these types for SIMD registers. For example, the type of | |||
826 | the SSE registers on the late x86-family processors is: | |||
827 | struct __builtin_v4sf { float f[4]; } | |||
828 | built by the function call: | |||
829 | init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4) | |||
830 | The type returned is a permanent type, allocated using malloc; it | |||
831 | doesn't live in any objfile's obstack. */ | |||
832 | static struct type * | |||
833 | init_simd_type (char *name, | |||
834 | struct type *elt_type, | |||
835 | char *elt_name, | |||
836 | int n) | |||
837 | { | |||
838 | struct type *simd_type; | |||
839 | struct type *array_type; | |||
840 | ||||
841 | simd_type = init_composite_type (name, TYPE_CODE_STRUCT); | |||
842 | array_type = create_array_type (0, elt_type, | |||
843 | create_range_type (0, builtin_type_int, | |||
844 | 0, n-1)); | |||
845 | append_composite_type_field (simd_type, elt_name, array_type); | |||
846 | return simd_type; | |||
847 | } | |||
848 | ||||
849 | static struct type * | |||
850 | init_vector_type (struct type *elt_type, int n) | |||
851 | { | |||
852 | struct type *array_type; | |||
853 | ||||
854 | array_type = create_array_type (0, elt_type, | |||
855 | create_range_type (0, builtin_type_int, | |||
856 | 0, n-1)); | |||
857 | TYPE_FLAGS (array_type)(array_type)->main_type->flags |= TYPE_FLAG_VECTOR(1 << 12); | |||
858 | return array_type; | |||
859 | } | |||
860 | ||||
861 | static struct type * | |||
862 | build_builtin_type_vec64 (void) | |||
863 | { | |||
864 | /* Construct a type for the 64 bit registers. The type we're | |||
865 | building is this: */ | |||
866 | #if 0 | |||
867 | union __gdb_builtin_type_vec64 | |||
868 | { | |||
869 | int64_t uint64; | |||
870 | float v2_float[2]; | |||
871 | int32_t v2_int32[2]; | |||
872 | int16_t v4_int16[4]; | |||
873 | int8_t v8_int8[8]; | |||
874 | }; | |||
875 | #endif | |||
876 | ||||
877 | struct type *t; | |||
878 | ||||
879 | t = init_composite_type ("__gdb_builtin_type_vec64", TYPE_CODE_UNION); | |||
880 | append_composite_type_field (t, "uint64", builtin_type_int64); | |||
881 | append_composite_type_field (t, "v2_float", builtin_type_v2_float); | |||
882 | append_composite_type_field (t, "v2_int32", builtin_type_v2_int32); | |||
883 | append_composite_type_field (t, "v4_int16", builtin_type_v4_int16); | |||
884 | append_composite_type_field (t, "v8_int8", builtin_type_v8_int8); | |||
885 | ||||
886 | TYPE_FLAGS (t)(t)->main_type->flags |= TYPE_FLAG_VECTOR(1 << 12); | |||
887 | TYPE_NAME (t)(t)->main_type->name = "builtin_type_vec64"; | |||
888 | return t; | |||
889 | } | |||
890 | ||||
891 | static struct type * | |||
892 | build_builtin_type_vec64i (void) | |||
893 | { | |||
894 | /* Construct a type for the 64 bit registers. The type we're | |||
895 | building is this: */ | |||
896 | #if 0 | |||
897 | union __gdb_builtin_type_vec64i | |||
898 | { | |||
899 | int64_t uint64; | |||
900 | int32_t v2_int32[2]; | |||
901 | int16_t v4_int16[4]; | |||
902 | int8_t v8_int8[8]; | |||
903 | }; | |||
904 | #endif | |||
905 | ||||
906 | struct type *t; | |||
907 | ||||
908 | t = init_composite_type ("__gdb_builtin_type_vec64i", TYPE_CODE_UNION); | |||
909 | append_composite_type_field (t, "uint64", builtin_type_int64); | |||
910 | append_composite_type_field (t, "v2_int32", builtin_type_v2_int32); | |||
911 | append_composite_type_field (t, "v4_int16", builtin_type_v4_int16); | |||
912 | append_composite_type_field (t, "v8_int8", builtin_type_v8_int8); | |||
913 | ||||
914 | TYPE_FLAGS (t)(t)->main_type->flags |= TYPE_FLAG_VECTOR(1 << 12); | |||
915 | TYPE_NAME (t)(t)->main_type->name = "builtin_type_vec64i"; | |||
916 | return t; | |||
917 | } | |||
918 | ||||
919 | static struct type * | |||
920 | build_builtin_type_vec128 (void) | |||
921 | { | |||
922 | /* Construct a type for the 128 bit registers. The type we're | |||
923 | building is this: */ | |||
924 | #if 0 | |||
925 | union __gdb_builtin_type_vec128 | |||
926 | { | |||
927 | int128_t uint128; | |||
928 | float v4_float[4]; | |||
929 | int32_t v4_int32[4]; | |||
930 | int16_t v8_int16[8]; | |||
931 | int8_t v16_int8[16]; | |||
932 | }; | |||
933 | #endif | |||
934 | ||||
935 | struct type *t; | |||
936 | ||||
937 | t = init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION); | |||
938 | append_composite_type_field (t, "uint128", builtin_type_int128); | |||
939 | append_composite_type_field (t, "v4_float", builtin_type_v4_float); | |||
940 | append_composite_type_field (t, "v4_int32", builtin_type_v4_int32); | |||
941 | append_composite_type_field (t, "v8_int16", builtin_type_v8_int16); | |||
942 | append_composite_type_field (t, "v16_int8", builtin_type_v16_int8); | |||
943 | ||||
944 | TYPE_FLAGS (t)(t)->main_type->flags |= TYPE_FLAG_VECTOR(1 << 12); | |||
945 | TYPE_NAME (t)(t)->main_type->name = "builtin_type_vec128"; | |||
946 | return t; | |||
947 | } | |||
948 | ||||
949 | static struct type * | |||
950 | build_builtin_type_vec128i (void) | |||
951 | { | |||
952 | /* 128-bit Intel SIMD registers */ | |||
953 | struct type *t; | |||
954 | ||||
955 | t = init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION); | |||
956 | append_composite_type_field (t, "v4_float", builtin_type_v4_float); | |||
957 | append_composite_type_field (t, "v2_double", builtin_type_v2_double); | |||
958 | append_composite_type_field (t, "v16_int8", builtin_type_v16_int8); | |||
959 | append_composite_type_field (t, "v8_int16", builtin_type_v8_int16); | |||
960 | append_composite_type_field (t, "v4_int32", builtin_type_v4_int32); | |||
961 | append_composite_type_field (t, "v2_int64", builtin_type_v2_int64); | |||
962 | append_composite_type_field (t, "uint128", builtin_type_int128); | |||
963 | ||||
964 | TYPE_FLAGS (t)(t)->main_type->flags |= TYPE_FLAG_VECTOR(1 << 12); | |||
965 | TYPE_NAME (t)(t)->main_type->name = "builtin_type_vec128i"; | |||
966 | return t; | |||
967 | } | |||
968 | ||||
969 | /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. | |||
970 | A MEMBER is a wierd thing -- it amounts to a typed offset into | |||
971 | a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't | |||
972 | include the offset (that's the value of the MEMBER itself), but does | |||
973 | include the structure type into which it points (for some reason). | |||
974 | ||||
975 | When "smashing" the type, we preserve the objfile that the | |||
976 | old type pointed to, since we aren't changing where the type is actually | |||
977 | allocated. */ | |||
978 | ||||
979 | void | |||
980 | smash_to_member_type (struct type *type, struct type *domain, | |||
981 | struct type *to_type) | |||
982 | { | |||
983 | struct objfile *objfile; | |||
984 | ||||
985 | objfile = TYPE_OBJFILE (type)(type)->main_type->objfile; | |||
986 | ||||
987 | smash_type (type); | |||
988 | TYPE_OBJFILE (type)(type)->main_type->objfile = objfile; | |||
989 | TYPE_TARGET_TYPE (type)(type)->main_type->target_type = to_type; | |||
990 | TYPE_DOMAIN_TYPE (type)(type)->main_type->vptr_basetype = domain; | |||
991 | TYPE_LENGTH (type)(type)->length = 1; /* In practice, this is never needed. */ | |||
992 | TYPE_CODE (type)(type)->main_type->code = TYPE_CODE_MEMBER; | |||
993 | } | |||
994 | ||||
995 | /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE. | |||
996 | METHOD just means `function that gets an extra "this" argument'. | |||
997 | ||||
998 | When "smashing" the type, we preserve the objfile that the | |||
999 | old type pointed to, since we aren't changing where the type is actually | |||
1000 | allocated. */ | |||
1001 | ||||
1002 | void | |||
1003 | smash_to_method_type (struct type *type, struct type *domain, | |||
1004 | struct type *to_type, struct field *args, | |||
1005 | int nargs, int varargs) | |||
1006 | { | |||
1007 | struct objfile *objfile; | |||
1008 | ||||
1009 | objfile = TYPE_OBJFILE (type)(type)->main_type->objfile; | |||
1010 | ||||
1011 | smash_type (type); | |||
1012 | TYPE_OBJFILE (type)(type)->main_type->objfile = objfile; | |||
1013 | TYPE_TARGET_TYPE (type)(type)->main_type->target_type = to_type; | |||
1014 | TYPE_DOMAIN_TYPE (type)(type)->main_type->vptr_basetype = domain; | |||
1015 | TYPE_FIELDS (type)(type)->main_type->fields = args; | |||
1016 | TYPE_NFIELDS (type)(type)->main_type->nfields = nargs; | |||
1017 | if (varargs) | |||
1018 | TYPE_FLAGS (type)(type)->main_type->flags |= TYPE_FLAG_VARARGS(1 << 11); | |||
1019 | TYPE_LENGTH (type)(type)->length = 1; /* In practice, this is never needed. */ | |||
1020 | TYPE_CODE (type)(type)->main_type->code = TYPE_CODE_METHOD; | |||
1021 | } | |||
1022 | ||||
1023 | /* Return a typename for a struct/union/enum type without "struct ", | |||
1024 | "union ", or "enum ". If the type has a NULL name, return NULL. */ | |||
1025 | ||||
1026 | char * | |||
1027 | type_name_no_tag (const struct type *type) | |||
1028 | { | |||
1029 | if (TYPE_TAG_NAME (type)(type)->main_type->tag_name != NULL((void*)0)) | |||
1030 | return TYPE_TAG_NAME (type)(type)->main_type->tag_name; | |||
1031 | ||||
1032 | /* Is there code which expects this to return the name if there is no | |||
1033 | tag name? My guess is that this is mainly used for C++ in cases where | |||
1034 | the two will always be the same. */ | |||
1035 | return TYPE_NAME (type)(type)->main_type->name; | |||
1036 | } | |||
1037 | ||||
1038 | /* Lookup a typedef or primitive type named NAME, | |||
1039 | visible in lexical block BLOCK. | |||
1040 | If NOERR is nonzero, return zero if NAME is not suitably defined. */ | |||
1041 | ||||
1042 | struct type * | |||
1043 | lookup_typename (char *name, struct block *block, int noerr) | |||
1044 | { | |||
1045 | struct symbol *sym; | |||
1046 | struct type *tmp; | |||
1047 | ||||
1048 | sym = lookup_symbol (name, block, VAR_DOMAIN, 0, (struct symtab **) NULL((void*)0)); | |||
1049 | if (sym == NULL((void*)0) || SYMBOL_CLASS (sym)(sym)->aclass != LOC_TYPEDEF) | |||
1050 | { | |||
1051 | tmp = language_lookup_primitive_type_by_name (current_language, | |||
1052 | current_gdbarch, | |||
1053 | name); | |||
1054 | if (tmp) | |||
1055 | { | |||
1056 | return (tmp); | |||
1057 | } | |||
1058 | else if (!tmp && noerr) | |||
1059 | { | |||
1060 | return (NULL((void*)0)); | |||
1061 | } | |||
1062 | else | |||
1063 | { | |||
1064 | error ("No type named %s.", name); | |||
1065 | } | |||
1066 | } | |||
1067 | return (SYMBOL_TYPE (sym)(sym)->type); | |||
1068 | } | |||
1069 | ||||
1070 | struct type * | |||
1071 | lookup_unsigned_typename (char *name) | |||
1072 | { | |||
1073 | char *uns = alloca (strlen (name) + 10)__builtin_alloca(strlen (name) + 10); | |||
1074 | ||||
1075 | strcpy (uns, "unsigned "); | |||
1076 | strcpy (uns + 9, name); | |||
1077 | return (lookup_typename (uns, (struct block *) NULL((void*)0), 0)); | |||
1078 | } | |||
1079 | ||||
1080 | struct type * | |||
1081 | lookup_signed_typename (char *name) | |||
1082 | { | |||
1083 | struct type *t; | |||
1084 | char *uns = alloca (strlen (name) + 8)__builtin_alloca(strlen (name) + 8); | |||
1085 | ||||
1086 | strcpy (uns, "signed "); | |||
1087 | strcpy (uns + 7, name); | |||
1088 | t = lookup_typename (uns, (struct block *) NULL((void*)0), 1); | |||
1089 | /* If we don't find "signed FOO" just try again with plain "FOO". */ | |||
1090 | if (t != NULL((void*)0)) | |||
1091 | return t; | |||
1092 | return lookup_typename (name, (struct block *) NULL((void*)0), 0); | |||
1093 | } | |||
1094 | ||||
1095 | /* Lookup a structure type named "struct NAME", | |||
1096 | visible in lexical block BLOCK. */ | |||
1097 | ||||
1098 | struct type * | |||
1099 | lookup_struct (char *name, struct block *block) | |||
1100 | { | |||
1101 | struct symbol *sym; | |||
1102 | ||||
1103 | sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0, | |||
1104 | (struct symtab **) NULL((void*)0)); | |||
1105 | ||||
1106 | if (sym == NULL((void*)0)) | |||
1107 | { | |||
1108 | error ("No struct type named %s.", name); | |||
1109 | } | |||
1110 | if (TYPE_CODE (SYMBOL_TYPE (sym))((sym)->type)->main_type->code != TYPE_CODE_STRUCT) | |||
1111 | { | |||
1112 | error ("This context has class, union or enum %s, not a struct.", name); | |||
1113 | } | |||
1114 | return (SYMBOL_TYPE (sym)(sym)->type); | |||
1115 | } | |||
1116 | ||||
1117 | /* Lookup a union type named "union NAME", | |||
1118 | visible in lexical block BLOCK. */ | |||
1119 | ||||
1120 | struct type * | |||
1121 | lookup_union (char *name, struct block *block) | |||
1122 | { | |||
1123 | struct symbol *sym; | |||
1124 | struct type *t; | |||
1125 | ||||
1126 | sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0, | |||
1127 | (struct symtab **) NULL((void*)0)); | |||
1128 | ||||
1129 | if (sym == NULL((void*)0)) | |||
1130 | error ("No union type named %s.", name); | |||
1131 | ||||
1132 | t = SYMBOL_TYPE (sym)(sym)->type; | |||
1133 | ||||
1134 | if (TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_UNION) | |||
1135 | return (t); | |||
1136 | ||||
1137 | /* C++ unions may come out with TYPE_CODE_CLASS, but we look at | |||
1138 | * a further "declared_type" field to discover it is really a union. | |||
1139 | */ | |||
1140 | if (HAVE_CPLUS_STRUCT (t)((t)->main_type->type_specific.cplus_stuff != &cplus_struct_default )) | |||
1141 | if (TYPE_DECLARED_TYPE (t)(t)->main_type->type_specific.cplus_stuff->declared_type == DECLARED_TYPE_UNION1) | |||
1142 | return (t); | |||
1143 | ||||
1144 | /* If we get here, it's not a union */ | |||
1145 | error ("This context has class, struct or enum %s, not a union.", name); | |||
1146 | } | |||
1147 | ||||
1148 | ||||
1149 | /* Lookup an enum type named "enum NAME", | |||
1150 | visible in lexical block BLOCK. */ | |||
1151 | ||||
1152 | struct type * | |||
1153 | lookup_enum (char *name, struct block *block) | |||
1154 | { | |||
1155 | struct symbol *sym; | |||
1156 | ||||
1157 | sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0, | |||
1158 | (struct symtab **) NULL((void*)0)); | |||
1159 | if (sym == NULL((void*)0)) | |||
1160 | { | |||
1161 | error ("No enum type named %s.", name); | |||
1162 | } | |||
1163 | if (TYPE_CODE (SYMBOL_TYPE (sym))((sym)->type)->main_type->code != TYPE_CODE_ENUM) | |||
1164 | { | |||
1165 | error ("This context has class, struct or union %s, not an enum.", name); | |||
1166 | } | |||
1167 | return (SYMBOL_TYPE (sym)(sym)->type); | |||
1168 | } | |||
1169 | ||||
1170 | /* Lookup a template type named "template NAME<TYPE>", | |||
1171 | visible in lexical block BLOCK. */ | |||
1172 | ||||
1173 | struct type * | |||
1174 | lookup_template_type (char *name, struct type *type, struct block *block) | |||
1175 | { | |||
1176 | struct symbol *sym; | |||
1177 | char *nam = (char *) alloca (strlen (name) + strlen (TYPE_NAME (type)) + 4)__builtin_alloca(strlen (name) + strlen ((type)->main_type ->name) + 4); | |||
1178 | strcpy (nam, name); | |||
1179 | strcat (nam, "<"); | |||
1180 | strcat (nam, TYPE_NAME (type)(type)->main_type->name); | |||
1181 | strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */ | |||
1182 | ||||
1183 | sym = lookup_symbol (nam, block, VAR_DOMAIN, 0, (struct symtab **) NULL((void*)0)); | |||
1184 | ||||
1185 | if (sym == NULL((void*)0)) | |||
1186 | { | |||
1187 | error ("No template type named %s.", name); | |||
1188 | } | |||
1189 | if (TYPE_CODE (SYMBOL_TYPE (sym))((sym)->type)->main_type->code != TYPE_CODE_STRUCT) | |||
1190 | { | |||
1191 | error ("This context has class, union or enum %s, not a struct.", name); | |||
1192 | } | |||
1193 | return (SYMBOL_TYPE (sym)(sym)->type); | |||
1194 | } | |||
1195 | ||||
1196 | /* Given a type TYPE, lookup the type of the component of type named NAME. | |||
1197 | ||||
1198 | TYPE can be either a struct or union, or a pointer or reference to a struct or | |||
1199 | union. If it is a pointer or reference, its target type is automatically used. | |||
1200 | Thus '.' and '->' are interchangable, as specified for the definitions of the | |||
1201 | expression element types STRUCTOP_STRUCT and STRUCTOP_PTR. | |||
1202 | ||||
1203 | If NOERR is nonzero, return zero if NAME is not suitably defined. | |||
1204 | If NAME is the name of a baseclass type, return that type. */ | |||
1205 | ||||
1206 | struct type * | |||
1207 | lookup_struct_elt_type (struct type *type, char *name, int noerr) | |||
1208 | { | |||
1209 | int i; | |||
1210 | ||||
1211 | for (;;) | |||
1212 | { | |||
1213 | CHECK_TYPEDEF (type)(type) = check_typedef (type); | |||
1214 | if (TYPE_CODE (type)(type)->main_type->code != TYPE_CODE_PTR | |||
1215 | && TYPE_CODE (type)(type)->main_type->code != TYPE_CODE_REF) | |||
1216 | break; | |||
1217 | type = TYPE_TARGET_TYPE (type)(type)->main_type->target_type; | |||
1218 | } | |||
1219 | ||||
1220 | if (TYPE_CODE (type)(type)->main_type->code != TYPE_CODE_STRUCT && | |||
1221 | TYPE_CODE (type)(type)->main_type->code != TYPE_CODE_UNION) | |||
1222 | { | |||
1223 | target_terminal_ours ()(*current_target.to_terminal_ours) (); | |||
1224 | gdb_flush (gdb_stdout); | |||
1225 | fprintf_unfiltered (gdb_stderr, "Type "); | |||
1226 | type_print (type, "", gdb_stderr, -1); | |||
1227 | error (" is not a structure or union type."); | |||
1228 | } | |||
1229 | ||||
1230 | #if 0 | |||
1231 | /* FIXME: This change put in by Michael seems incorrect for the case where | |||
1232 | the structure tag name is the same as the member name. I.E. when doing | |||
1233 | "ptype bell->bar" for "struct foo { int bar; int foo; } bell;" | |||
1234 | Disabled by fnf. */ | |||
1235 | { | |||
1236 | char *typename; | |||
1237 | ||||
1238 | typename = type_name_no_tag (type); | |||
1239 | if (typename != NULL((void*)0) && strcmp (typename, name) == 0) | |||
1240 | return type; | |||
1241 | } | |||
1242 | #endif | |||
1243 | ||||
1244 | for (i = TYPE_NFIELDS (type)(type)->main_type->nfields - 1; i >= TYPE_N_BASECLASSES (type)(type)->main_type->type_specific.cplus_stuff->n_baseclasses; i--) | |||
1245 | { | |||
1246 | char *t_field_name = TYPE_FIELD_NAME (type, i)(((type)->main_type->fields[i]).name); | |||
1247 | ||||
1248 | if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) | |||
1249 | { | |||
1250 | return TYPE_FIELD_TYPE (type, i)(((type)->main_type->fields[i]).type); | |||
1251 | } | |||
1252 | } | |||
1253 | ||||
1254 | /* OK, it's not in this class. Recursively check the baseclasses. */ | |||
1255 | for (i = TYPE_N_BASECLASSES (type)(type)->main_type->type_specific.cplus_stuff->n_baseclasses - 1; i >= 0; i--) | |||
1256 | { | |||
1257 | struct type *t; | |||
1258 | ||||
1259 | t = lookup_struct_elt_type (TYPE_BASECLASS (type, i)(type)->main_type->fields[i].type, name, noerr); | |||
1260 | if (t != NULL((void*)0)) | |||
1261 | { | |||
1262 | return t; | |||
1263 | } | |||
1264 | } | |||
1265 | ||||
1266 | if (noerr) | |||
1267 | { | |||
1268 | return NULL((void*)0); | |||
1269 | } | |||
1270 | ||||
1271 | target_terminal_ours ()(*current_target.to_terminal_ours) (); | |||
1272 | gdb_flush (gdb_stdout); | |||
1273 | fprintf_unfiltered (gdb_stderr, "Type "); | |||
1274 | type_print (type, "", gdb_stderr, -1); | |||
1275 | fprintf_unfiltered (gdb_stderr, " has no component named "); | |||
1276 | fputs_filtered (name, gdb_stderr); | |||
1277 | error ("."); | |||
1278 | return (struct type *) -1; /* For lint */ | |||
1279 | } | |||
1280 | ||||
1281 | /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE | |||
1282 | valid. Callers should be aware that in some cases (for example, | |||
1283 | the type or one of its baseclasses is a stub type and we are | |||
1284 | debugging a .o file), this function will not be able to find the virtual | |||
1285 | function table pointer, and vptr_fieldno will remain -1 and vptr_basetype | |||
1286 | will remain NULL. */ | |||
1287 | ||||
1288 | void | |||
1289 | fill_in_vptr_fieldno (struct type *type) | |||
1290 | { | |||
1291 | CHECK_TYPEDEF (type)(type) = check_typedef (type); | |||
1292 | ||||
1293 | if (TYPE_VPTR_FIELDNO (type)(type)->main_type->vptr_fieldno < 0) | |||
1294 | { | |||
1295 | int i; | |||
1296 | ||||
1297 | /* We must start at zero in case the first (and only) baseclass is | |||
1298 | virtual (and hence we cannot share the table pointer). */ | |||
1299 | for (i = 0; i < TYPE_N_BASECLASSES (type)(type)->main_type->type_specific.cplus_stuff->n_baseclasses; i++) | |||
1300 | { | |||
1301 | struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)(type)->main_type->fields[i].type); | |||
1302 | fill_in_vptr_fieldno (baseclass); | |||
1303 | if (TYPE_VPTR_FIELDNO (baseclass)(baseclass)->main_type->vptr_fieldno >= 0) | |||
1304 | { | |||
1305 | TYPE_VPTR_FIELDNO (type)(type)->main_type->vptr_fieldno = TYPE_VPTR_FIELDNO (baseclass)(baseclass)->main_type->vptr_fieldno; | |||
1306 | TYPE_VPTR_BASETYPE (type)(type)->main_type->vptr_basetype = TYPE_VPTR_BASETYPE (baseclass)(baseclass)->main_type->vptr_basetype; | |||
1307 | break; | |||
1308 | } | |||
1309 | } | |||
1310 | } | |||
1311 | } | |||
1312 | ||||
1313 | /* Find the method and field indices for the destructor in class type T. | |||
1314 | Return 1 if the destructor was found, otherwise, return 0. */ | |||
1315 | ||||
1316 | int | |||
1317 | get_destructor_fn_field (struct type *t, int *method_indexp, int *field_indexp) | |||
1318 | { | |||
1319 | int i; | |||
1320 | ||||
1321 | for (i = 0; i < TYPE_NFN_FIELDS (t)(t)->main_type->type_specific.cplus_stuff->nfn_fields; i++) | |||
1322 | { | |||
1323 | int j; | |||
1324 | struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i)(t)->main_type->type_specific.cplus_stuff->fn_fieldlists [i].fn_fields; | |||
1325 | ||||
1326 | for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (t, i)(t)->main_type->type_specific.cplus_stuff->fn_fieldlists [i].length; j++) | |||
1327 | { | |||
1328 | if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f, j)(f)[j].physname) != 0) | |||
1329 | { | |||
1330 | *method_indexp = i; | |||
1331 | *field_indexp = j; | |||
1332 | return 1; | |||
1333 | } | |||
1334 | } | |||
1335 | } | |||
1336 | return 0; | |||
1337 | } | |||
1338 | ||||
1339 | static void | |||
1340 | stub_noname_complaint (void) | |||
1341 | { | |||
1342 | complaint (&symfile_complaints, "stub type has NULL name"); | |||
1343 | } | |||
1344 | ||||
1345 | /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989. | |||
1346 | ||||
1347 | If this is a stubbed struct (i.e. declared as struct foo *), see if | |||
1348 | we can find a full definition in some other file. If so, copy this | |||
1349 | definition, so we can use it in future. There used to be a comment (but | |||
1350 | not any code) that if we don't find a full definition, we'd set a flag | |||
1351 | so we don't spend time in the future checking the same type. That would | |||
1352 | be a mistake, though--we might load in more symbols which contain a | |||
1353 | full definition for the type. | |||
1354 | ||||
1355 | This used to be coded as a macro, but I don't think it is called | |||
1356 | often enough to merit such treatment. */ | |||
1357 | ||||
1358 | /* Find the real type of TYPE. This function returns the real type, after | |||
1359 | removing all layers of typedefs and completing opaque or stub types. | |||
1360 | Completion changes the TYPE argument, but stripping of typedefs does | |||
1361 | not. */ | |||
1362 | ||||
1363 | struct type * | |||
1364 | check_typedef (struct type *type) | |||
1365 | { | |||
1366 | struct type *orig_type = type; | |||
1367 | int is_const, is_volatile; | |||
1368 | ||||
1369 | while (TYPE_CODE (type)(type)->main_type->code == TYPE_CODE_TYPEDEF) | |||
1370 | { | |||
1371 | if (!TYPE_TARGET_TYPE (type)(type)->main_type->target_type) | |||
1372 | { | |||
1373 | char *name; | |||
1374 | struct symbol *sym; | |||
1375 | ||||
1376 | /* It is dangerous to call lookup_symbol if we are currently | |||
1377 | reading a symtab. Infinite recursion is one danger. */ | |||
1378 | if (currently_reading_symtab) | |||
1379 | return type; | |||
1380 | ||||
1381 | name = type_name_no_tag (type); | |||
1382 | /* FIXME: shouldn't we separately check the TYPE_NAME and the | |||
1383 | TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN | |||
1384 | as appropriate? (this code was written before TYPE_NAME and | |||
1385 | TYPE_TAG_NAME were separate). */ | |||
1386 | if (name == NULL((void*)0)) | |||
1387 | { | |||
1388 | stub_noname_complaint (); | |||
1389 | return type; | |||
1390 | } | |||
1391 | sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, | |||
1392 | (struct symtab **) NULL((void*)0)); | |||
1393 | if (sym) | |||
1394 | TYPE_TARGET_TYPE (type)(type)->main_type->target_type = SYMBOL_TYPE (sym)(sym)->type; | |||
1395 | else | |||
1396 | TYPE_TARGET_TYPE (type)(type)->main_type->target_type = alloc_type (NULL((void*)0)); /* TYPE_CODE_UNDEF */ | |||
1397 | } | |||
1398 | type = TYPE_TARGET_TYPE (type)(type)->main_type->target_type; | |||
1399 | } | |||
1400 | ||||
1401 | is_const = TYPE_CONST (type)((type)->instance_flags & (1 << 5)); | |||
1402 | is_volatile = TYPE_VOLATILE (type)((type)->instance_flags & (1 << 6)); | |||
1403 | ||||
1404 | /* If this is a struct/class/union with no fields, then check whether a | |||
1405 | full definition exists somewhere else. This is for systems where a | |||
1406 | type definition with no fields is issued for such types, instead of | |||
1407 | identifying them as stub types in the first place */ | |||
1408 | ||||
1409 | if (TYPE_IS_OPAQUE (type)((((type)->main_type->code == TYPE_CODE_STRUCT) || ((type )->main_type->code == TYPE_CODE_UNION)) && ((type )->main_type->nfields == 0) && ((type)->main_type ->type_specific.cplus_stuff && ((type)->main_type ->type_specific.cplus_stuff->nfn_fields == 0))) && opaque_type_resolution && !currently_reading_symtab) | |||
1410 | { | |||
1411 | char *name = type_name_no_tag (type); | |||
1412 | struct type *newtype; | |||
1413 | if (name == NULL((void*)0)) | |||
1414 | { | |||
1415 | stub_noname_complaint (); | |||
1416 | return type; | |||
1417 | } | |||
1418 | newtype = lookup_transparent_type (name); | |||
1419 | if (newtype) | |||
1420 | make_cv_type (is_const, is_volatile, newtype, &type); | |||
1421 | } | |||
1422 | /* Otherwise, rely on the stub flag being set for opaque/stubbed types */ | |||
1423 | else if (TYPE_STUB (type)((type)->main_type->flags & (1 << 2)) && !currently_reading_symtab) | |||
1424 | { | |||
1425 | char *name = type_name_no_tag (type); | |||
1426 | /* FIXME: shouldn't we separately check the TYPE_NAME and the | |||
1427 | TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN | |||
1428 | as appropriate? (this code was written before TYPE_NAME and | |||
1429 | TYPE_TAG_NAME were separate). */ | |||
1430 | struct symbol *sym; | |||
1431 | if (name == NULL((void*)0)) | |||
1432 | { | |||
1433 | stub_noname_complaint (); | |||
1434 | return type; | |||
1435 | } | |||
1436 | sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL((void*)0)); | |||
1437 | if (sym) | |||
1438 | make_cv_type (is_const, is_volatile, SYMBOL_TYPE (sym)(sym)->type, &type); | |||
1439 | } | |||
1440 | ||||
1441 | if (TYPE_TARGET_STUB (type)((type)->main_type->flags & (1 << 3))) | |||
1442 | { | |||
1443 | struct type *range_type; | |||
1444 | struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type)(type)->main_type->target_type); | |||
1445 | ||||
1446 | if (TYPE_STUB (target_type)((target_type)->main_type->flags & (1 << 2)) || TYPE_TARGET_STUB (target_type)((target_type)->main_type->flags & (1 << 3))) | |||
1447 | { | |||
1448 | } | |||
1449 | else if (TYPE_CODE (type)(type)->main_type->code == TYPE_CODE_ARRAY | |||
1450 | && TYPE_NFIELDS (type)(type)->main_type->nfields == 1 | |||
1451 | && (TYPE_CODE (range_type = TYPE_FIELD_TYPE (type, 0))(range_type = (((type)->main_type->fields[0]).type))-> main_type->code | |||
1452 | == TYPE_CODE_RANGE)) | |||
1453 | { | |||
1454 | /* Now recompute the length of the array type, based on its | |||
1455 | number of elements and the target type's length. */ | |||
1456 | TYPE_LENGTH (type)(type)->length = | |||
1457 | ((TYPE_FIELD_BITPOS (range_type, 1)(((range_type)->main_type->fields[1]).loc.bitpos) | |||
1458 | - TYPE_FIELD_BITPOS (range_type, 0)(((range_type)->main_type->fields[0]).loc.bitpos) | |||
1459 | + 1) | |||
1460 | * TYPE_LENGTH (target_type)(target_type)->length); | |||
1461 | TYPE_FLAGS (type)(type)->main_type->flags &= ~TYPE_FLAG_TARGET_STUB(1 << 3); | |||
1462 | } | |||
1463 | else if (TYPE_CODE (type)(type)->main_type->code == TYPE_CODE_RANGE) | |||
1464 | { | |||
1465 | TYPE_LENGTH (type)(type)->length = TYPE_LENGTH (target_type)(target_type)->length; | |||
1466 | TYPE_FLAGS (type)(type)->main_type->flags &= ~TYPE_FLAG_TARGET_STUB(1 << 3); | |||
1467 | } | |||
1468 | } | |||
1469 | /* Cache TYPE_LENGTH for future use. */ | |||
1470 | TYPE_LENGTH (orig_type)(orig_type)->length = TYPE_LENGTH (type)(type)->length; | |||
1471 | return type; | |||
1472 | } | |||
1473 | ||||
1474 | /* Parse a type expression in the string [P..P+LENGTH). If an error occurs, | |||
1475 | silently return builtin_type_void. */ | |||
1476 | ||||
1477 | static struct type * | |||
1478 | safe_parse_type (char *p, int length) | |||
1479 | { | |||
1480 | struct ui_file *saved_gdb_stderr; | |||
1481 | struct type *type; | |||
1482 | ||||
1483 | /* Suppress error messages. */ | |||
1484 | saved_gdb_stderr = gdb_stderr; | |||
1485 | gdb_stderr = ui_file_new (); | |||
1486 | ||||
1487 | /* Call parse_and_eval_type() without fear of longjmp()s. */ | |||
1488 | if (!gdb_parse_and_eval_type (p, length, &type)) | |||
1489 | type = builtin_type_void; | |||
1490 | ||||
1491 | /* Stop suppressing error messages. */ | |||
1492 | ui_file_delete (gdb_stderr); | |||
1493 | gdb_stderr = saved_gdb_stderr; | |||
1494 | ||||
1495 | return type; | |||
1496 | } | |||
1497 | ||||
1498 | /* Ugly hack to convert method stubs into method types. | |||
1499 | ||||
1500 | He ain't kiddin'. This demangles the name of the method into a string | |||
1501 | including argument types, parses out each argument type, generates | |||
1502 | a string casting a zero to that type, evaluates the string, and stuffs | |||
1503 | the resulting type into an argtype vector!!! Then it knows the type | |||
1504 | of the whole function (including argument types for overloading), | |||
1505 | which info used to be in the stab's but was removed to hack back | |||
1506 | the space required for them. */ | |||
1507 | ||||
1508 | static void | |||
1509 | check_stub_method (struct type *type, int method_id, int signature_id) | |||
1510 | { | |||
1511 | struct fn_field *f; | |||
1512 | char *mangled_name = gdb_mangle_name (type, method_id, signature_id); | |||
1513 | char *demangled_name = cplus_demangle (mangled_name, | |||
1514 | DMGL_PARAMS(1 << 0) | DMGL_ANSI(1 << 1)); | |||
1515 | char *argtypetext, *p; | |||
1516 | int depth = 0, argcount = 1; | |||
1517 | struct field *argtypes; | |||
1518 | struct type *mtype; | |||
1519 | ||||
1520 | /* Make sure we got back a function string that we can use. */ | |||
1521 | if (demangled_name) | |||
1522 | p = strchr (demangled_name, '('); | |||
1523 | else | |||
1524 | p = NULL((void*)0); | |||
1525 | ||||
1526 | if (demangled_name == NULL((void*)0) || p == NULL((void*)0)) | |||
1527 | error ("Internal: Cannot demangle mangled name `%s'.", mangled_name); | |||
1528 | ||||
1529 | /* Now, read in the parameters that define this type. */ | |||
1530 | p += 1; | |||
1531 | argtypetext = p; | |||
1532 | while (*p) | |||
1533 | { | |||
1534 | if (*p == '(' || *p == '<') | |||
1535 | { | |||
1536 | depth += 1; | |||
1537 | } | |||
1538 | else if (*p == ')' || *p == '>') | |||
1539 | { | |||
1540 | depth -= 1; | |||
1541 | } | |||
1542 | else if (*p == ',' && depth == 0) | |||
1543 | { | |||
1544 | argcount += 1; | |||
1545 | } | |||
1546 | ||||
1547 | p += 1; | |||
1548 | } | |||
1549 | ||||
1550 | /* If we read one argument and it was ``void'', don't count it. */ | |||
1551 | if (strncmp (argtypetext, "(void)", 6) == 0) | |||
1552 | argcount -= 1; | |||
1553 | ||||
1554 | /* We need one extra slot, for the THIS pointer. */ | |||
1555 | ||||
1556 | argtypes = (struct field *) | |||
1557 | TYPE_ALLOC (type, (argcount + 1) * sizeof (struct field))((type)->main_type->objfile != ((void*)0) ? __extension__ ({ struct obstack *__h = (&(type)->main_type->objfile -> objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = (((argcount + 1) * sizeof (struct field ))); if (__o->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }) : xmalloc ((argcount + 1) * sizeof (struct field))); | |||
1558 | p = argtypetext; | |||
1559 | ||||
1560 | /* Add THIS pointer for non-static methods. */ | |||
1561 | f = TYPE_FN_FIELDLIST1 (type, method_id)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_id].fn_fields; | |||
1562 | if (TYPE_FN_FIELD_STATIC_P (f, signature_id)((f)[signature_id].voffset == 1)) | |||
1563 | argcount = 0; | |||
1564 | else | |||
1565 | { | |||
1566 | argtypes[0].type = lookup_pointer_type (type); | |||
1567 | argcount = 1; | |||
1568 | } | |||
1569 | ||||
1570 | if (*p != ')') /* () means no args, skip while */ | |||
1571 | { | |||
1572 | depth = 0; | |||
1573 | while (*p) | |||
1574 | { | |||
1575 | if (depth <= 0 && (*p == ',' || *p == ')')) | |||
1576 | { | |||
1577 | /* Avoid parsing of ellipsis, they will be handled below. | |||
1578 | Also avoid ``void'' as above. */ | |||
1579 | if (strncmp (argtypetext, "...", p - argtypetext) != 0 | |||
1580 | && strncmp (argtypetext, "void", p - argtypetext) != 0) | |||
1581 | { | |||
1582 | argtypes[argcount].type = | |||
1583 | safe_parse_type (argtypetext, p - argtypetext); | |||
1584 | argcount += 1; | |||
1585 | } | |||
1586 | argtypetext = p + 1; | |||
1587 | } | |||
1588 | ||||
1589 | if (*p == '(' || *p == '<') | |||
1590 | { | |||
1591 | depth += 1; | |||
1592 | } | |||
1593 | else if (*p == ')' || *p == '>') | |||
1594 | { | |||
1595 | depth -= 1; | |||
1596 | } | |||
1597 | ||||
1598 | p += 1; | |||
1599 | } | |||
1600 | } | |||
1601 | ||||
1602 | TYPE_FN_FIELD_PHYSNAME (f, signature_id)(f)[signature_id].physname = mangled_name; | |||
1603 | ||||
1604 | /* Now update the old "stub" type into a real type. */ | |||
1605 | mtype = TYPE_FN_FIELD_TYPE (f, signature_id)(f)[signature_id].type; | |||
1606 | TYPE_DOMAIN_TYPE (mtype)(mtype)->main_type->vptr_basetype = type; | |||
1607 | TYPE_FIELDS (mtype)(mtype)->main_type->fields = argtypes; | |||
1608 | TYPE_NFIELDS (mtype)(mtype)->main_type->nfields = argcount; | |||
1609 | TYPE_FLAGS (mtype)(mtype)->main_type->flags &= ~TYPE_FLAG_STUB(1 << 2); | |||
1610 | TYPE_FN_FIELD_STUB (f, signature_id)((f)[signature_id].is_stub) = 0; | |||
1611 | if (p[-2] == '.') | |||
1612 | TYPE_FLAGS (mtype)(mtype)->main_type->flags |= TYPE_FLAG_VARARGS(1 << 11); | |||
1613 | ||||
1614 | xfree (demangled_name); | |||
1615 | } | |||
1616 | ||||
1617 | /* This is the external interface to check_stub_method, above. This function | |||
1618 | unstubs all of the signatures for TYPE's METHOD_ID method name. After | |||
1619 | calling this function TYPE_FN_FIELD_STUB will be cleared for each signature | |||
1620 | and TYPE_FN_FIELDLIST_NAME will be correct. | |||
1621 | ||||
1622 | This function unfortunately can not die until stabs do. */ | |||
1623 | ||||
1624 | void | |||
1625 | check_stub_method_group (struct type *type, int method_id) | |||
1626 | { | |||
1627 | int len = TYPE_FN_FIELDLIST_LENGTH (type, method_id)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_id].length; | |||
1628 | struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_id].fn_fields; | |||
1629 | int j, found_stub = 0; | |||
1630 | ||||
1631 | for (j = 0; j < len; j++) | |||
1632 | if (TYPE_FN_FIELD_STUB (f, j)((f)[j].is_stub)) | |||
1633 | { | |||
1634 | found_stub = 1; | |||
1635 | check_stub_method (type, method_id, j); | |||
1636 | } | |||
1637 | ||||
1638 | /* GNU v3 methods with incorrect names were corrected when we read in | |||
1639 | type information, because it was cheaper to do it then. The only GNU v2 | |||
1640 | methods with incorrect method names are operators and destructors; | |||
1641 | destructors were also corrected when we read in type information. | |||
1642 | ||||
1643 | Therefore the only thing we need to handle here are v2 operator | |||
1644 | names. */ | |||
1645 | if (found_stub && strncmp (TYPE_FN_FIELD_PHYSNAME (f, 0)(f)[0].physname, "_Z", 2) != 0) | |||
1646 | { | |||
1647 | int ret; | |||
1648 | char dem_opname[256]; | |||
1649 | ||||
1650 | ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_id].name, | |||
1651 | dem_opname, DMGL_ANSI(1 << 1)); | |||
1652 | if (!ret) | |||
1653 | ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_id].name, | |||
1654 | dem_opname, 0); | |||
1655 | if (ret) | |||
1656 | TYPE_FN_FIELDLIST_NAME (type, method_id)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_id].name = xstrdup (dem_opname); | |||
1657 | } | |||
1658 | } | |||
1659 | ||||
1660 | const struct cplus_struct_type cplus_struct_default; | |||
1661 | ||||
1662 | void | |||
1663 | allocate_cplus_struct_type (struct type *type) | |||
1664 | { | |||
1665 | if (!HAVE_CPLUS_STRUCT (type)((type)->main_type->type_specific.cplus_stuff != &cplus_struct_default )) | |||
1666 | { | |||
1667 | TYPE_CPLUS_SPECIFIC (type)(type)->main_type->type_specific.cplus_stuff = (struct cplus_struct_type *) | |||
1668 | TYPE_ALLOC (type, sizeof (struct cplus_struct_type))((type)->main_type->objfile != ((void*)0) ? __extension__ ({ struct obstack *__h = (&(type)->main_type->objfile -> objfile_obstack); __extension__ ({ struct obstack *__o = (__h); int __len = ((sizeof (struct cplus_struct_type))); if (__o->chunk_limit - __o->next_free < __len) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len)); (void) 0; }) ; __extension__ ({ struct obstack *__o1 = (__h); void *value; value = (void *) __o1->object_base; if (__o1->next_free == value) __o1->maybe_empty_object = 1; __o1->next_free = (((((__o1->next_free) - (char *) 0)+__o1->alignment_mask ) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1-> next_free - (char *)__o1->chunk > __o1->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit ; __o1->object_base = __o1->next_free; value; }); }) : xmalloc (sizeof (struct cplus_struct_type))); | |||
1669 | *(TYPE_CPLUS_SPECIFIC (type)(type)->main_type->type_specific.cplus_stuff) = cplus_struct_default; | |||
1670 | } | |||
1671 | } | |||
1672 | ||||
1673 | /* Helper function to initialize the standard scalar types. | |||
1674 | ||||
1675 | If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy | |||
1676 | of the string pointed to by name in the objfile_obstack for that objfile, | |||
1677 | and initialize the type name to that copy. There are places (mipsread.c | |||
1678 | in particular, where init_type is called with a NULL value for NAME). */ | |||
1679 | ||||
1680 | struct type * | |||
1681 | init_type (enum type_code code, int length, int flags, char *name, | |||
1682 | struct objfile *objfile) | |||
1683 | { | |||
1684 | struct type *type; | |||
1685 | ||||
1686 | type = alloc_type (objfile); | |||
1687 | TYPE_CODE (type)(type)->main_type->code = code; | |||
1688 | TYPE_LENGTH (type)(type)->length = length; | |||
1689 | TYPE_FLAGS (type)(type)->main_type->flags |= flags; | |||
1690 | if ((name != NULL((void*)0)) && (objfile != NULL((void*)0))) | |||
1691 | { | |||
1692 | TYPE_NAME (type)(type)->main_type->name = | |||
1693 | obsavestring (name, strlen (name), &objfile->objfile_obstack); | |||
1694 | } | |||
1695 | else | |||
1696 | { | |||
1697 | TYPE_NAME (type)(type)->main_type->name = name; | |||
1698 | } | |||
1699 | ||||
1700 | /* C++ fancies. */ | |||
1701 | ||||
1702 | if (name && strcmp (name, "char") == 0) | |||
1703 | TYPE_FLAGS (type)(type)->main_type->flags |= TYPE_FLAG_NOSIGN(1 << 1); | |||
1704 | ||||
1705 | if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION | |||
1706 | || code == TYPE_CODE_NAMESPACE) | |||
1707 | { | |||
1708 | INIT_CPLUS_SPECIFIC (type)((type)->main_type->type_specific.cplus_stuff=(struct cplus_struct_type *)&cplus_struct_default); | |||
1709 | } | |||
1710 | return (type); | |||
1711 | } | |||
1712 | ||||
1713 | /* Helper function. Create an empty composite type. */ | |||
1714 | ||||
1715 | struct type * | |||
1716 | init_composite_type (char *name, enum type_code code) | |||
1717 | { | |||
1718 | struct type *t; | |||
1719 | gdb_assert (code == TYPE_CODE_STRUCT((void) ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION ) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c" , 1720, "%s: Assertion `%s' failed.", __PRETTY_FUNCTION__, "code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION" ), 0))) | |||
1720 | || code == TYPE_CODE_UNION)((void) ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION ) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c" , 1720, "%s: Assertion `%s' failed.", __PRETTY_FUNCTION__, "code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION" ), 0))); | |||
1721 | t = init_type (code, 0, 0, NULL((void*)0), NULL((void*)0)); | |||
1722 | TYPE_TAG_NAME (t)(t)->main_type->tag_name = name; | |||
1723 | return t; | |||
1724 | } | |||
1725 | ||||
1726 | /* Helper function. Append a field to a composite type. */ | |||
1727 | ||||
1728 | void | |||
1729 | append_composite_type_field (struct type *t, char *name, struct type *field) | |||
1730 | { | |||
1731 | struct field *f; | |||
1732 | TYPE_NFIELDS (t)(t)->main_type->nfields = TYPE_NFIELDS (t)(t)->main_type->nfields + 1; | |||
1733 | TYPE_FIELDS (t)(t)->main_type->fields = xrealloc (TYPE_FIELDS (t)(t)->main_type->fields, | |||
1734 | sizeof (struct field) * TYPE_NFIELDS (t)(t)->main_type->nfields); | |||
1735 | f = &(TYPE_FIELDS (t)(t)->main_type->fields[TYPE_NFIELDS (t)(t)->main_type->nfields - 1]); | |||
1736 | memset (f, 0, sizeof f[0]); | |||
1737 | FIELD_TYPE (f[0])((f[0]).type) = field; | |||
1738 | FIELD_NAME (f[0])((f[0]).name) = name; | |||
1739 | if (TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_UNION) | |||
1740 | { | |||
1741 | if (TYPE_LENGTH (t)(t)->length < TYPE_LENGTH (field)(field)->length) | |||
1742 | TYPE_LENGTH (t)(t)->length = TYPE_LENGTH (field)(field)->length; | |||
1743 | } | |||
1744 | else if (TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_STRUCT) | |||
1745 | { | |||
1746 | TYPE_LENGTH (t)(t)->length = TYPE_LENGTH (t)(t)->length + TYPE_LENGTH (field)(field)->length; | |||
1747 | if (TYPE_NFIELDS (t)(t)->main_type->nfields > 1) | |||
1748 | { | |||
1749 | FIELD_BITPOS (f[0])((f[0]).loc.bitpos) = (FIELD_BITPOS (f[-1])((f[-1]).loc.bitpos) | |||
1750 | + TYPE_LENGTH (field)(field)->length * TARGET_CHAR_BIT8); | |||
1751 | } | |||
1752 | } | |||
1753 | } | |||
1754 | ||||
1755 | /* Look up a fundamental type for the specified objfile. | |||
1756 | May need to construct such a type if this is the first use. | |||
1757 | ||||
1758 | Some object file formats (ELF, COFF, etc) do not define fundamental | |||
1759 | types such as "int" or "double". Others (stabs for example), do | |||
1760 | define fundamental types. | |||
1761 | ||||
1762 | For the formats which don't provide fundamental types, gdb can create | |||
1763 | such types, using defaults reasonable for the current language and | |||
1764 | the current target machine. | |||
1765 | ||||
1766 | NOTE: This routine is obsolescent. Each debugging format reader | |||
1767 | should manage it's own fundamental types, either creating them from | |||
1768 | suitable defaults or reading them from the debugging information, | |||
1769 | whichever is appropriate. The DWARF reader has already been | |||
1770 | fixed to do this. Once the other readers are fixed, this routine | |||
1771 | will go away. Also note that fundamental types should be managed | |||
1772 | on a compilation unit basis in a multi-language environment, not | |||
1773 | on a linkage unit basis as is done here. */ | |||
1774 | ||||
1775 | ||||
1776 | struct type * | |||
1777 | lookup_fundamental_type (struct objfile *objfile, int typeid) | |||
1778 | { | |||
1779 | struct type **typep; | |||
1780 | int nbytes; | |||
1781 | ||||
1782 | if (typeid < 0 || typeid >= FT_NUM_MEMBERS29) | |||
1783 | { | |||
1784 | error ("internal error - invalid fundamental type id %d", typeid); | |||
1785 | } | |||
1786 | ||||
1787 | /* If this is the first time we need a fundamental type for this objfile | |||
1788 | then we need to initialize the vector of type pointers. */ | |||
1789 | ||||
1790 | if (objfile->fundamental_types == NULL((void*)0)) | |||
1791 | { | |||
1792 | nbytes = FT_NUM_MEMBERS29 * sizeof (struct type *); | |||
1793 | objfile->fundamental_types = (struct type **) | |||
1794 | obstack_alloc (&objfile->objfile_obstack, nbytes)__extension__ ({ struct obstack *__h = (&objfile->objfile_obstack ); __extension__ ({ struct obstack *__o = (__h); int __len = ( (nbytes)); if (__o->chunk_limit - __o->next_free < __len ) _obstack_newchunk (__o, __len); ((__o)->next_free += (__len )); (void) 0; }); __extension__ ({ struct obstack *__o1 = (__h ); void *value; value = (void *) __o1->object_base; if (__o1 ->next_free == value) __o1->maybe_empty_object = 1; __o1 ->next_free = (((((__o1->next_free) - (char *) 0)+__o1-> alignment_mask) & ~ (__o1->alignment_mask)) + (char *) 0); if (__o1->next_free - (char *)__o1->chunk > __o1 ->chunk_limit - (char *)__o1->chunk) __o1->next_free = __o1->chunk_limit; __o1->object_base = __o1->next_free ; value; }); }); | |||
1795 | memset ((char *) objfile->fundamental_types, 0, nbytes); | |||
1796 | OBJSTAT (objfile, n_types += FT_NUM_MEMBERS)(objfile -> stats.n_types += 29); | |||
1797 | } | |||
1798 | ||||
1799 | /* Look for this particular type in the fundamental type vector. If one is | |||
1800 | not found, create and install one appropriate for the current language. */ | |||
1801 | ||||
1802 | typep = objfile->fundamental_types + typeid; | |||
1803 | if (*typep == NULL((void*)0)) | |||
1804 | { | |||
1805 | *typep = create_fundamental_type (objfile, typeid)(current_language->la_fund_type(objfile, typeid)); | |||
1806 | } | |||
1807 | ||||
1808 | return (*typep); | |||
1809 | } | |||
1810 | ||||
1811 | int | |||
1812 | can_dereference (struct type *t) | |||
1813 | { | |||
1814 | /* FIXME: Should we return true for references as well as pointers? */ | |||
1815 | CHECK_TYPEDEF (t)(t) = check_typedef (t); | |||
1816 | return | |||
1817 | (t != NULL((void*)0) | |||
1818 | && TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_PTR | |||
1819 | && TYPE_CODE (TYPE_TARGET_TYPE (t))((t)->main_type->target_type)->main_type->code != TYPE_CODE_VOID); | |||
1820 | } | |||
1821 | ||||
1822 | int | |||
1823 | is_integral_type (struct type *t) | |||
1824 | { | |||
1825 | CHECK_TYPEDEF (t)(t) = check_typedef (t); | |||
1826 | return | |||
1827 | ((t != NULL((void*)0)) | |||
1828 | && ((TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_INT) | |||
1829 | || (TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_ENUM) | |||
1830 | || (TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_CHAR) | |||
1831 | || (TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_RANGE) | |||
1832 | || (TYPE_CODE (t)(t)->main_type->code == TYPE_CODE_BOOL))); | |||
1833 | } | |||
1834 | ||||
1835 | /* Check whether BASE is an ancestor or base class or DCLASS | |||
1836 | Return 1 if so, and 0 if not. | |||
1837 | Note: callers may want to check for identity of the types before | |||
1838 | calling this function -- identical types are considered to satisfy | |||
1839 | the ancestor relationship even if they're identical */ | |||
1840 | ||||
1841 | int | |||
1842 | is_ancestor (struct type *base, struct type *dclass) | |||
1843 | { | |||
1844 | int i; | |||
1845 | ||||
1846 | CHECK_TYPEDEF (base)(base) = check_typedef (base); | |||
1847 | CHECK_TYPEDEF (dclass)(dclass) = check_typedef (dclass); | |||
1848 | ||||
1849 | if (base == dclass) | |||
1850 | return 1; | |||
1851 | if (TYPE_NAME (base)(base)->main_type->name && TYPE_NAME (dclass)(dclass)->main_type->name && | |||
1852 | !strcmp (TYPE_NAME (base)(base)->main_type->name, TYPE_NAME (dclass)(dclass)->main_type->name)) | |||
1853 | return 1; | |||
1854 | ||||
1855 | for (i = 0; i < TYPE_N_BASECLASSES (dclass)(dclass)->main_type->type_specific.cplus_stuff->n_baseclasses; i++) | |||
1856 | if (is_ancestor (base, TYPE_BASECLASS (dclass, i)(dclass)->main_type->fields[i].type)) | |||
1857 | return 1; | |||
1858 | ||||
1859 | return 0; | |||
1860 | } | |||
1861 | ||||
1862 | ||||
1863 | ||||
1864 | /* See whether DCLASS has a virtual table. This routine is aimed at | |||
1865 | the HP/Taligent ANSI C++ runtime model, and may not work with other | |||
1866 | runtime models. Return 1 => Yes, 0 => No. */ | |||
1867 | ||||
1868 | int | |||
1869 | has_vtable (struct type *dclass) | |||
1870 | { | |||
1871 | /* In the HP ANSI C++ runtime model, a class has a vtable only if it | |||
1872 | has virtual functions or virtual bases. */ | |||
1873 | ||||
1874 | int i; | |||
1875 | ||||
1876 | if (TYPE_CODE (dclass)(dclass)->main_type->code != TYPE_CODE_CLASSTYPE_CODE_STRUCT) | |||
1877 | return 0; | |||
1878 | ||||
1879 | /* First check for the presence of virtual bases */ | |||
1880 | if (TYPE_FIELD_VIRTUAL_BITS (dclass)(dclass)->main_type->type_specific.cplus_stuff->virtual_field_bits) | |||
1881 | for (i = 0; i < TYPE_N_BASECLASSES (dclass)(dclass)->main_type->type_specific.cplus_stuff->n_baseclasses; i++) | |||
1882 | if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i)(((dclass)->main_type->type_specific.cplus_stuff->virtual_field_bits )[(i)>>3] & (1 << ((i)&7)))) | |||
1883 | return 1; | |||
1884 | ||||
1885 | /* Next check for virtual functions */ | |||
1886 | if (TYPE_FN_FIELDLISTS (dclass)(dclass)->main_type->type_specific.cplus_stuff->fn_fieldlists) | |||
1887 | for (i = 0; i < TYPE_NFN_FIELDS (dclass)(dclass)->main_type->type_specific.cplus_stuff->nfn_fields; i++) | |||
1888 | if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, i), 0)(((dclass)->main_type->type_specific.cplus_stuff->fn_fieldlists [i].fn_fields)[0].voffset > 1)) | |||
1889 | return 1; | |||
1890 | ||||
1891 | /* Recurse on non-virtual bases to see if any of them needs a vtable */ | |||
1892 | if (TYPE_FIELD_VIRTUAL_BITS (dclass)(dclass)->main_type->type_specific.cplus_stuff->virtual_field_bits) | |||
1893 | for (i = 0; i < TYPE_N_BASECLASSES (dclass)(dclass)->main_type->type_specific.cplus_stuff->n_baseclasses; i++) | |||
1894 | if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i)(((dclass)->main_type->type_specific.cplus_stuff->virtual_field_bits )[(i)>>3] & (1 << ((i)&7)))) && | |||
1895 | (has_vtable (TYPE_FIELD_TYPE (dclass, i)(((dclass)->main_type->fields[i]).type)))) | |||
1896 | return 1; | |||
1897 | ||||
1898 | /* Well, maybe we don't need a virtual table */ | |||
1899 | return 0; | |||
1900 | } | |||
1901 | ||||
1902 | /* Return a pointer to the "primary base class" of DCLASS. | |||
1903 | ||||
1904 | A NULL return indicates that DCLASS has no primary base, or that it | |||
1905 | couldn't be found (insufficient information). | |||
1906 | ||||
1907 | This routine is aimed at the HP/Taligent ANSI C++ runtime model, | |||
1908 | and may not work with other runtime models. */ | |||
1909 | ||||
1910 | struct type * | |||
1911 | primary_base_class (struct type *dclass) | |||
1912 | { | |||
1913 | /* In HP ANSI C++'s runtime model, a "primary base class" of a class | |||
1914 | is the first directly inherited, non-virtual base class that | |||
1915 | requires a virtual table */ | |||
1916 | ||||
1917 | int i; | |||
1918 | ||||
1919 | if (TYPE_CODE (dclass)(dclass)->main_type->code != TYPE_CODE_CLASSTYPE_CODE_STRUCT) | |||
1920 | return NULL((void*)0); | |||
1921 | ||||
1922 | for (i = 0; i < TYPE_N_BASECLASSES (dclass)(dclass)->main_type->type_specific.cplus_stuff->n_baseclasses; i++) | |||
1923 | if (!TYPE_FIELD_VIRTUAL (dclass, i)((dclass)->main_type->type_specific.cplus_stuff->virtual_field_bits == ((void*)0) ? 0 : (((dclass)->main_type->type_specific .cplus_stuff->virtual_field_bits)[((i))>>3] & (1 << (((i))&7)))) && | |||
1924 | has_vtable (TYPE_FIELD_TYPE (dclass, i)(((dclass)->main_type->fields[i]).type))) | |||
1925 | return TYPE_FIELD_TYPE (dclass, i)(((dclass)->main_type->fields[i]).type); | |||
1926 | ||||
1927 | return NULL((void*)0); | |||
1928 | } | |||
1929 | ||||
1930 | /* Global manipulated by virtual_base_list[_aux]() */ | |||
1931 | ||||
1932 | static struct vbase *current_vbase_list = NULL((void*)0); | |||
1933 | ||||
1934 | /* Return a pointer to a null-terminated list of struct vbase | |||
1935 | items. The vbasetype pointer of each item in the list points to the | |||
1936 | type information for a virtual base of the argument DCLASS. | |||
1937 | ||||
1938 | Helper function for virtual_base_list(). | |||
1939 | Note: the list goes backward, right-to-left. virtual_base_list() | |||
1940 | copies the items out in reverse order. */ | |||
1941 | ||||
1942 | static void | |||
1943 | virtual_base_list_aux (struct type *dclass) | |||
1944 | { | |||
1945 | struct vbase *tmp_vbase; | |||
1946 | int i; | |||
1947 | ||||
1948 | if (TYPE_CODE (dclass)(dclass)->main_type->code != TYPE_CODE_CLASSTYPE_CODE_STRUCT) | |||
1949 | return; | |||
1950 | ||||
1951 | for (i = 0; i < TYPE_N_BASECLASSES (dclass)(dclass)->main_type->type_specific.cplus_stuff->n_baseclasses; i++) | |||
1952 | { | |||
1953 | /* Recurse on this ancestor, first */ | |||
1954 | virtual_base_list_aux (TYPE_FIELD_TYPE (dclass, i)(((dclass)->main_type->fields[i]).type)); | |||
1955 | ||||
1956 | /* If this current base is itself virtual, add it to the list */ | |||
1957 | if (BASETYPE_VIA_VIRTUAL (dclass, i)((dclass)->main_type->type_specific.cplus_stuff->virtual_field_bits == ((void*)0) ? 0 : (((dclass)->main_type->type_specific .cplus_stuff->virtual_field_bits)[((i))>>3] & (1 << (((i))&7))))) | |||
1958 | { | |||
1959 | struct type *basetype = TYPE_FIELD_TYPE (dclass, i)(((dclass)->main_type->fields[i]).type); | |||
1960 | ||||
1961 | /* Check if base already recorded */ | |||
1962 | tmp_vbase = current_vbase_list; | |||
1963 | while (tmp_vbase) | |||
1964 | { | |||
1965 | if (tmp_vbase->vbasetype == basetype) | |||
1966 | break; /* found it */ | |||
1967 | tmp_vbase = tmp_vbase->next; | |||
1968 | } | |||
1969 | ||||
1970 | if (!tmp_vbase) /* normal exit from loop */ | |||
1971 | { | |||
1972 | /* Allocate new item for this virtual base */ | |||
1973 | tmp_vbase = (struct vbase *) xmalloc (sizeof (struct vbase)); | |||
1974 | ||||
1975 | /* Stick it on at the end of the list */ | |||
1976 | tmp_vbase->vbasetype = basetype; | |||
1977 | tmp_vbase->next = current_vbase_list; | |||
1978 | current_vbase_list = tmp_vbase; | |||
1979 | } | |||
1980 | } /* if virtual */ | |||
1981 | } /* for loop over bases */ | |||
1982 | } | |||
1983 | ||||
1984 | ||||
1985 | /* Compute the list of virtual bases in the right order. Virtual | |||
1986 | bases are laid out in the object's memory area in order of their | |||
1987 | occurrence in a depth-first, left-to-right search through the | |||
1988 | ancestors. | |||
1989 | ||||
1990 | Argument DCLASS is the type whose virtual bases are required. | |||
1991 | Return value is the address of a null-terminated array of pointers | |||
1992 | to struct type items. | |||
1993 | ||||
1994 | This routine is aimed at the HP/Taligent ANSI C++ runtime model, | |||
1995 | and may not work with other runtime models. | |||
1996 | ||||
1997 | This routine merely hands off the argument to virtual_base_list_aux() | |||
1998 | and then copies the result into an array to save space. */ | |||
1999 | ||||
2000 | struct type ** | |||
2001 | virtual_base_list (struct type *dclass) | |||
2002 | { | |||
2003 | struct vbase *tmp_vbase; | |||
2004 | struct vbase *tmp_vbase_2; | |||
2005 | int i; | |||
2006 | int count; | |||
2007 | struct type **vbase_array; | |||
2008 | ||||
2009 | current_vbase_list = NULL((void*)0); | |||
2010 | virtual_base_list_aux (dclass); | |||
2011 | ||||
2012 | for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL((void*)0); i++, tmp_vbase = tmp_vbase->next) | |||
2013 | /* no body */ ; | |||
2014 | ||||
2015 | count = i; | |||
2016 | ||||
2017 | vbase_array = (struct type **) xmalloc ((count + 1) * sizeof (struct type *)); | |||
2018 | ||||
2019 | for (i = count - 1, tmp_vbase = current_vbase_list; i >= 0; i--, tmp_vbase = tmp_vbase->next) | |||
2020 | vbase_array[i] = tmp_vbase->vbasetype; | |||
2021 | ||||
2022 | /* Get rid of constructed chain */ | |||
2023 | tmp_vbase_2 = tmp_vbase = current_vbase_list; | |||
2024 | while (tmp_vbase) | |||
2025 | { | |||
2026 | tmp_vbase = tmp_vbase->next; | |||
2027 | xfree (tmp_vbase_2); | |||
2028 | tmp_vbase_2 = tmp_vbase; | |||
2029 | } | |||
2030 | ||||
2031 | vbase_array[count] = NULL((void*)0); | |||
2032 | return vbase_array; | |||
2033 | } | |||
2034 | ||||
2035 | /* Return the length of the virtual base list of the type DCLASS. */ | |||
2036 | ||||
2037 | int | |||
2038 | virtual_base_list_length (struct type *dclass) | |||
2039 | { | |||
2040 | int i; | |||
2041 | struct vbase *tmp_vbase; | |||
2042 | ||||
2043 | current_vbase_list = NULL((void*)0); | |||
2044 | virtual_base_list_aux (dclass); | |||
2045 | ||||
2046 | for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL((void*)0); i++, tmp_vbase = tmp_vbase->next) | |||
2047 | /* no body */ ; | |||
2048 | return i; | |||
2049 | } | |||
2050 | ||||
2051 | /* Return the number of elements of the virtual base list of the type | |||
2052 | DCLASS, ignoring those appearing in the primary base (and its | |||
2053 | primary base, recursively). */ | |||
2054 | ||||
2055 | int | |||
2056 | virtual_base_list_length_skip_primaries (struct type *dclass) | |||
2057 | { | |||
2058 | int i; | |||
2059 | struct vbase *tmp_vbase; | |||
2060 | struct type *primary; | |||
2061 | ||||
2062 | primary = TYPE_RUNTIME_PTR (dclass)((dclass)->main_type->type_specific.cplus_stuff->runtime_ptr ) ? TYPE_PRIMARY_BASE (dclass)(((dclass)->main_type->type_specific.cplus_stuff->runtime_ptr )->primary_base) : NULL((void*)0); | |||
2063 | ||||
2064 | if (!primary) | |||
2065 | return virtual_base_list_length (dclass); | |||
2066 | ||||
2067 | current_vbase_list = NULL((void*)0); | |||
2068 | virtual_base_list_aux (dclass); | |||
2069 | ||||
2070 | for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL((void*)0); tmp_vbase = tmp_vbase->next) | |||
2071 | { | |||
2072 | if (virtual_base_index (tmp_vbase->vbasetype, primary) >= 0) | |||
2073 | continue; | |||
2074 | i++; | |||
2075 | } | |||
2076 | return i; | |||
2077 | } | |||
2078 | ||||
2079 | ||||
2080 | /* Return the index (position) of type BASE, which is a virtual base | |||
2081 | class of DCLASS, in the latter's virtual base list. A return of -1 | |||
2082 | indicates "not found" or a problem. */ | |||
2083 | ||||
2084 | int | |||
2085 | virtual_base_index (struct type *base, struct type *dclass) | |||
2086 | { | |||
2087 | struct type *vbase; | |||
2088 | int i; | |||
2089 | ||||
2090 | if ((TYPE_CODE (dclass)(dclass)->main_type->code != TYPE_CODE_CLASSTYPE_CODE_STRUCT) || | |||
2091 | (TYPE_CODE (base)(base)->main_type->code != TYPE_CODE_CLASSTYPE_CODE_STRUCT)) | |||
2092 | return -1; | |||
2093 | ||||
2094 | i = 0; | |||
2095 | vbase = virtual_base_list (dclass)[0]; | |||
2096 | while (vbase) | |||
2097 | { | |||
2098 | if (vbase == base) | |||
2099 | break; | |||
2100 | vbase = virtual_base_list (dclass)[++i]; | |||
2101 | } | |||
2102 | ||||
2103 | return vbase ? i : -1; | |||
2104 | } | |||
2105 | ||||
2106 | ||||
2107 | ||||
2108 | /* Return the index (position) of type BASE, which is a virtual base | |||
2109 | class of DCLASS, in the latter's virtual base list. Skip over all | |||
2110 | bases that may appear in the virtual base list of the primary base | |||
2111 | class of DCLASS (recursively). A return of -1 indicates "not | |||
2112 | found" or a problem. */ | |||
2113 | ||||
2114 | int | |||
2115 | virtual_base_index_skip_primaries (struct type *base, struct type *dclass) | |||
2116 | { | |||
2117 | struct type *vbase; | |||
2118 | int i, j; | |||
2119 | struct type *primary; | |||
2120 | ||||
2121 | if ((TYPE_CODE (dclass)(dclass)->main_type->code != TYPE_CODE_CLASSTYPE_CODE_STRUCT) || | |||
2122 | (TYPE_CODE (base)(base)->main_type->code != TYPE_CODE_CLASSTYPE_CODE_STRUCT)) | |||
2123 | return -1; | |||
2124 | ||||
2125 | primary = TYPE_RUNTIME_PTR (dclass)((dclass)->main_type->type_specific.cplus_stuff->runtime_ptr ) ? TYPE_PRIMARY_BASE (dclass)(((dclass)->main_type->type_specific.cplus_stuff->runtime_ptr )->primary_base) : NULL((void*)0); | |||
2126 | ||||
2127 | j = -1; | |||
2128 | i = 0; | |||
2129 | vbase = virtual_base_list (dclass)[0]; | |||
2130 | while (vbase) | |||
2131 | { | |||
2132 | if (!primary || (virtual_base_index_skip_primaries (vbase, primary) < 0)) | |||
2133 | j++; | |||
2134 | if (vbase == base) | |||
2135 | break; | |||
2136 | vbase = virtual_base_list (dclass)[++i]; | |||
2137 | } | |||
2138 | ||||
2139 | return vbase ? j : -1; | |||
2140 | } | |||
2141 | ||||
2142 | /* Return position of a derived class DCLASS in the list of | |||
2143 | * primary bases starting with the remotest ancestor. | |||
2144 | * Position returned is 0-based. */ | |||
2145 | ||||
2146 | int | |||
2147 | class_index_in_primary_list (struct type *dclass) | |||
2148 | { | |||
2149 | struct type *pbc; /* primary base class */ | |||
2150 | ||||
2151 | /* Simply recurse on primary base */ | |||
2152 | pbc = TYPE_PRIMARY_BASE (dclass)(((dclass)->main_type->type_specific.cplus_stuff->runtime_ptr )->primary_base); | |||
2153 | if (pbc) | |||
2154 | return 1 + class_index_in_primary_list (pbc); | |||
2155 | else | |||
2156 | return 0; | |||
2157 | } | |||
2158 | ||||
2159 | /* Return a count of the number of virtual functions a type has. | |||
2160 | * This includes all the virtual functions it inherits from its | |||
2161 | * base classes too. | |||
2162 | */ | |||
2163 | ||||
2164 | /* pai: FIXME This doesn't do the right thing: count redefined virtual | |||
2165 | * functions only once (latest redefinition) | |||
2166 | */ | |||
2167 | ||||
2168 | int | |||
2169 | count_virtual_fns (struct type *dclass) | |||
2170 | { | |||
2171 | int fn, oi; /* function and overloaded instance indices */ | |||
2172 | int vfuncs; /* count to return */ | |||
2173 | ||||
2174 | /* recurse on bases that can share virtual table */ | |||
2175 | struct type *pbc = primary_base_class (dclass); | |||
2176 | if (pbc) | |||
2177 | vfuncs = count_virtual_fns (pbc); | |||
2178 | else | |||
2179 | vfuncs = 0; | |||
2180 | ||||
2181 | for (fn = 0; fn < TYPE_NFN_FIELDS (dclass)(dclass)->main_type->type_specific.cplus_stuff->nfn_fields; fn++) | |||
2182 | for (oi = 0; oi < TYPE_FN_FIELDLIST_LENGTH (dclass, fn)(dclass)->main_type->type_specific.cplus_stuff->fn_fieldlists [fn].length; oi++) | |||
2183 | if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, fn), oi)(((dclass)->main_type->type_specific.cplus_stuff->fn_fieldlists [fn].fn_fields)[oi].voffset > 1)) | |||
2184 | vfuncs++; | |||
2185 | ||||
2186 | return vfuncs; | |||
2187 | } | |||
2188 | ||||
2189 | ||||
2190 | ||||
2191 | /* Functions for overload resolution begin here */ | |||
2192 | ||||
2193 | /* Compare two badness vectors A and B and return the result. | |||
2194 | * 0 => A and B are identical | |||
2195 | * 1 => A and B are incomparable | |||
2196 | * 2 => A is better than B | |||
2197 | * 3 => A is worse than B */ | |||
2198 | ||||
2199 | int | |||
2200 | compare_badness (struct badness_vector *a, struct badness_vector *b) | |||
2201 | { | |||
2202 | int i; | |||
2203 | int tmp; | |||
2204 | short found_pos = 0; /* any positives in c? */ | |||
2205 | short found_neg = 0; /* any negatives in c? */ | |||
2206 | ||||
2207 | /* differing lengths => incomparable */ | |||
2208 | if (a->length != b->length) | |||
2209 | return 1; | |||
2210 | ||||
2211 | /* Subtract b from a */ | |||
2212 | for (i = 0; i < a->length; i++) | |||
2213 | { | |||
2214 | tmp = a->rank[i] - b->rank[i]; | |||
2215 | if (tmp > 0) | |||
2216 | found_pos = 1; | |||
2217 | else if (tmp < 0) | |||
2218 | found_neg = 1; | |||
2219 | } | |||
2220 | ||||
2221 | if (found_pos) | |||
2222 | { | |||
2223 | if (found_neg) | |||
2224 | return 1; /* incomparable */ | |||
2225 | else | |||
2226 | return 3; /* A > B */ | |||
2227 | } | |||
2228 | else | |||
2229 | /* no positives */ | |||
2230 | { | |||
2231 | if (found_neg) | |||
2232 | return 2; /* A < B */ | |||
2233 | else | |||
2234 | return 0; /* A == B */ | |||
2235 | } | |||
2236 | } | |||
2237 | ||||
2238 | /* Rank a function by comparing its parameter types (PARMS, length NPARMS), | |||
2239 | * to the types of an argument list (ARGS, length NARGS). | |||
2240 | * Return a pointer to a badness vector. This has NARGS + 1 entries. */ | |||
2241 | ||||
2242 | struct badness_vector * | |||
2243 | rank_function (struct type **parms, int nparms, struct type **args, int nargs) | |||
2244 | { | |||
2245 | int i; | |||
2246 | struct badness_vector *bv; | |||
2247 | int min_len = nparms < nargs ? nparms : nargs; | |||
2248 | ||||
2249 | bv = xmalloc (sizeof (struct badness_vector)); | |||
2250 | bv->length = nargs + 1; /* add 1 for the length-match rank */ | |||
2251 | bv->rank = xmalloc ((nargs + 1) * sizeof (int)); | |||
2252 | ||||
2253 | /* First compare the lengths of the supplied lists. | |||
2254 | * If there is a mismatch, set it to a high value. */ | |||
2255 | ||||
2256 | /* pai/1997-06-03 FIXME: when we have debug info about default | |||
2257 | * arguments and ellipsis parameter lists, we should consider those | |||
2258 | * and rank the length-match more finely. */ | |||
2259 | ||||
2260 | LENGTH_MATCH (bv)((bv)->rank[0]) = (nargs != nparms) ? LENGTH_MISMATCH_BADNESS100 : 0; | |||
2261 | ||||
2262 | /* Now rank all the parameters of the candidate function */ | |||
2263 | for (i = 1; i <= min_len; i++) | |||
2264 | bv->rank[i] = rank_one_type (parms[i-1], args[i-1]); | |||
2265 | ||||
2266 | /* If more arguments than parameters, add dummy entries */ | |||
2267 | for (i = min_len + 1; i <= nargs; i++) | |||
2268 | bv->rank[i] = TOO_FEW_PARAMS_BADNESS100; | |||
2269 | ||||
2270 | return bv; | |||
2271 | } | |||
2272 | ||||
2273 | /* Compare the names of two integer types, assuming that any sign | |||
2274 | qualifiers have been checked already. We do it this way because | |||
2275 | there may be an "int" in the name of one of the types. */ | |||
2276 | ||||
2277 | static int | |||
2278 | integer_types_same_name_p (const char *first, const char *second) | |||
2279 | { | |||
2280 | int first_p, second_p; | |||
2281 | ||||
2282 | /* If both are shorts, return 1; if neither is a short, keep checking. */ | |||
2283 | first_p = (strstr (first, "short") != NULL((void*)0)); | |||
2284 | second_p = (strstr (second, "short") != NULL((void*)0)); | |||
2285 | if (first_p && second_p) | |||
2286 | return 1; | |||
2287 | if (first_p || second_p) | |||
2288 | return 0; | |||
2289 | ||||
2290 | /* Likewise for long. */ | |||
2291 | first_p = (strstr (first, "long") != NULL((void*)0)); | |||
2292 | second_p = (strstr (second, "long") != NULL((void*)0)); | |||
2293 | if (first_p && second_p) | |||
2294 | return 1; | |||
2295 | if (first_p || second_p) | |||
2296 | return 0; | |||
2297 | ||||
2298 | /* Likewise for char. */ | |||
2299 | first_p = (strstr (first, "char") != NULL((void*)0)); | |||
2300 | second_p = (strstr (second, "char") != NULL((void*)0)); | |||
2301 | if (first_p && second_p) | |||
2302 | return 1; | |||
2303 | if (first_p || second_p) | |||
2304 | return 0; | |||
2305 | ||||
2306 | /* They must both be ints. */ | |||
2307 | return 1; | |||
2308 | } | |||
2309 | ||||
2310 | /* Compare one type (PARM) for compatibility with another (ARG). | |||
2311 | * PARM is intended to be the parameter type of a function; and | |||
2312 | * ARG is the supplied argument's type. This function tests if | |||
2313 | * the latter can be converted to the former. | |||
2314 | * | |||
2315 | * Return 0 if they are identical types; | |||
2316 | * Otherwise, return an integer which corresponds to how compatible | |||
2317 | * PARM is to ARG. The higher the return value, the worse the match. | |||
2318 | * Generally the "bad" conversions are all uniformly assigned a 100 */ | |||
2319 | ||||
2320 | int | |||
2321 | rank_one_type (struct type *parm, struct type *arg) | |||
2322 | { | |||
2323 | /* Identical type pointers */ | |||
2324 | /* However, this still doesn't catch all cases of same type for arg | |||
2325 | * and param. The reason is that builtin types are different from | |||
2326 | * the same ones constructed from the object. */ | |||
2327 | if (parm == arg) | |||
2328 | return 0; | |||
2329 | ||||
2330 | /* Resolve typedefs */ | |||
2331 | if (TYPE_CODE (parm)(parm)->main_type->code == TYPE_CODE_TYPEDEF) | |||
2332 | parm = check_typedef (parm); | |||
2333 | if (TYPE_CODE (arg)(arg)->main_type->code == TYPE_CODE_TYPEDEF) | |||
2334 | arg = check_typedef (arg); | |||
2335 | ||||
2336 | /* | |||
2337 | Well, damnit, if the names are exactly the same, | |||
2338 | i'll say they are exactly the same. This happens when we generate | |||
2339 | method stubs. The types won't point to the same address, but they | |||
2340 | really are the same. | |||
2341 | */ | |||
2342 | ||||
2343 | if (TYPE_NAME (parm)(parm)->main_type->name && TYPE_NAME (arg)(arg)->main_type->name && | |||
2344 | !strcmp (TYPE_NAME (parm)(parm)->main_type->name, TYPE_NAME (arg)(arg)->main_type->name)) | |||
2345 | return 0; | |||
2346 | ||||
2347 | /* Check if identical after resolving typedefs */ | |||
2348 | if (parm == arg) | |||
2349 | return 0; | |||
2350 | ||||
2351 | /* See through references, since we can almost make non-references | |||
2352 | references. */ | |||
2353 | if (TYPE_CODE (arg)(arg)->main_type->code == TYPE_CODE_REF) | |||
2354 | return (rank_one_type (parm, TYPE_TARGET_TYPE (arg)(arg)->main_type->target_type) | |||
2355 | + REFERENCE_CONVERSION_BADNESS2); | |||
2356 | if (TYPE_CODE (parm)(parm)->main_type->code == TYPE_CODE_REF) | |||
2357 | return (rank_one_type (TYPE_TARGET_TYPE (parm)(parm)->main_type->target_type, arg) | |||
2358 | + REFERENCE_CONVERSION_BADNESS2); | |||
2359 | if (overload_debug) | |||
2360 | /* Debugging only. */ | |||
2361 | fprintf_filtered (gdb_stderr,"------ Arg is %s [%d], parm is %s [%d]\n", | |||
2362 | TYPE_NAME (arg)(arg)->main_type->name, TYPE_CODE (arg)(arg)->main_type->code, TYPE_NAME (parm)(parm)->main_type->name, TYPE_CODE (parm)(parm)->main_type->code); | |||
2363 | ||||
2364 | /* x -> y means arg of type x being supplied for parameter of type y */ | |||
2365 | ||||
2366 | switch (TYPE_CODE (parm)(parm)->main_type->code) | |||
2367 | { | |||
2368 | case TYPE_CODE_PTR: | |||
2369 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2370 | { | |||
2371 | case TYPE_CODE_PTR: | |||
2372 | if (TYPE_CODE (TYPE_TARGET_TYPE (parm))((parm)->main_type->target_type)->main_type->code == TYPE_CODE_VOID) | |||
2373 | return VOID_PTR_CONVERSION_BADNESS2; | |||
2374 | else | |||
2375 | return rank_one_type (TYPE_TARGET_TYPE (parm)(parm)->main_type->target_type, TYPE_TARGET_TYPE (arg)(arg)->main_type->target_type); | |||
2376 | case TYPE_CODE_ARRAY: | |||
2377 | return rank_one_type (TYPE_TARGET_TYPE (parm)(parm)->main_type->target_type, TYPE_TARGET_TYPE (arg)(arg)->main_type->target_type); | |||
2378 | case TYPE_CODE_FUNC: | |||
2379 | return rank_one_type (TYPE_TARGET_TYPE (parm)(parm)->main_type->target_type, arg); | |||
2380 | case TYPE_CODE_INT: | |||
2381 | case TYPE_CODE_ENUM: | |||
2382 | case TYPE_CODE_CHAR: | |||
2383 | case TYPE_CODE_RANGE: | |||
2384 | case TYPE_CODE_BOOL: | |||
2385 | return POINTER_CONVERSION_BADNESS2; | |||
2386 | default: | |||
2387 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2388 | } | |||
2389 | case TYPE_CODE_ARRAY: | |||
2390 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2391 | { | |||
2392 | case TYPE_CODE_PTR: | |||
2393 | case TYPE_CODE_ARRAY: | |||
2394 | return rank_one_type (TYPE_TARGET_TYPE (parm)(parm)->main_type->target_type, TYPE_TARGET_TYPE (arg)(arg)->main_type->target_type); | |||
2395 | default: | |||
2396 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2397 | } | |||
2398 | case TYPE_CODE_FUNC: | |||
2399 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2400 | { | |||
2401 | case TYPE_CODE_PTR: /* funcptr -> func */ | |||
2402 | return rank_one_type (parm, TYPE_TARGET_TYPE (arg)(arg)->main_type->target_type); | |||
2403 | default: | |||
2404 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2405 | } | |||
2406 | case TYPE_CODE_INT: | |||
2407 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2408 | { | |||
2409 | case TYPE_CODE_INT: | |||
2410 | if (TYPE_LENGTH (arg)(arg)->length == TYPE_LENGTH (parm)(parm)->length) | |||
2411 | { | |||
2412 | /* Deal with signed, unsigned, and plain chars and | |||
2413 | signed and unsigned ints */ | |||
2414 | if (TYPE_NOSIGN (parm)((parm)->main_type->flags & (1 << 1))) | |||
2415 | { | |||
2416 | /* This case only for character types */ | |||
2417 | if (TYPE_NOSIGN (arg)((arg)->main_type->flags & (1 << 1))) /* plain char -> plain char */ | |||
2418 | return 0; | |||
2419 | else | |||
2420 | return INTEGER_CONVERSION_BADNESS2; /* signed/unsigned char -> plain char */ | |||
2421 | } | |||
2422 | else if (TYPE_UNSIGNED (parm)((parm)->main_type->flags & (1 << 0))) | |||
2423 | { | |||
2424 | if (TYPE_UNSIGNED (arg)((arg)->main_type->flags & (1 << 0))) | |||
2425 | { | |||
2426 | /* unsigned int -> unsigned int, or unsigned long -> unsigned long */ | |||
2427 | if (integer_types_same_name_p (TYPE_NAME (parm)(parm)->main_type->name, TYPE_NAME (arg)(arg)->main_type->name)) | |||
2428 | return 0; | |||
2429 | else if (integer_types_same_name_p (TYPE_NAME (arg)(arg)->main_type->name, "int") | |||
2430 | && integer_types_same_name_p (TYPE_NAME (parm)(parm)->main_type->name, "long")) | |||
2431 | return INTEGER_PROMOTION_BADNESS1; /* unsigned int -> unsigned long */ | |||
2432 | else | |||
2433 | return INTEGER_CONVERSION_BADNESS2; /* unsigned long -> unsigned int */ | |||
2434 | } | |||
2435 | else | |||
2436 | { | |||
2437 | if (integer_types_same_name_p (TYPE_NAME (arg)(arg)->main_type->name, "long") | |||
2438 | && integer_types_same_name_p (TYPE_NAME (parm)(parm)->main_type->name, "int")) | |||
2439 | return INTEGER_CONVERSION_BADNESS2; /* signed long -> unsigned int */ | |||
2440 | else | |||
2441 | return INTEGER_CONVERSION_BADNESS2; /* signed int/long -> unsigned int/long */ | |||
2442 | } | |||
2443 | } | |||
2444 | else if (!TYPE_NOSIGN (arg)((arg)->main_type->flags & (1 << 1)) && !TYPE_UNSIGNED (arg)((arg)->main_type->flags & (1 << 0))) | |||
2445 | { | |||
2446 | if (integer_types_same_name_p (TYPE_NAME (parm)(parm)->main_type->name, TYPE_NAME (arg)(arg)->main_type->name)) | |||
2447 | return 0; | |||
2448 | else if (integer_types_same_name_p (TYPE_NAME (arg)(arg)->main_type->name, "int") | |||
2449 | && integer_types_same_name_p (TYPE_NAME (parm)(parm)->main_type->name, "long")) | |||
2450 | return INTEGER_PROMOTION_BADNESS1; | |||
2451 | else | |||
2452 | return INTEGER_CONVERSION_BADNESS2; | |||
2453 | } | |||
2454 | else | |||
2455 | return INTEGER_CONVERSION_BADNESS2; | |||
2456 | } | |||
2457 | else if (TYPE_LENGTH (arg)(arg)->length < TYPE_LENGTH (parm)(parm)->length) | |||
2458 | return INTEGER_PROMOTION_BADNESS1; | |||
2459 | else | |||
2460 | return INTEGER_CONVERSION_BADNESS2; | |||
2461 | case TYPE_CODE_ENUM: | |||
2462 | case TYPE_CODE_CHAR: | |||
2463 | case TYPE_CODE_RANGE: | |||
2464 | case TYPE_CODE_BOOL: | |||
2465 | return INTEGER_PROMOTION_BADNESS1; | |||
2466 | case TYPE_CODE_FLT: | |||
2467 | return INT_FLOAT_CONVERSION_BADNESS2; | |||
2468 | case TYPE_CODE_PTR: | |||
2469 | return NS_POINTER_CONVERSION_BADNESS10; | |||
2470 | default: | |||
2471 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2472 | } | |||
2473 | break; | |||
2474 | case TYPE_CODE_ENUM: | |||
2475 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2476 | { | |||
2477 | case TYPE_CODE_INT: | |||
2478 | case TYPE_CODE_CHAR: | |||
2479 | case TYPE_CODE_RANGE: | |||
2480 | case TYPE_CODE_BOOL: | |||
2481 | case TYPE_CODE_ENUM: | |||
2482 | return INTEGER_CONVERSION_BADNESS2; | |||
2483 | case TYPE_CODE_FLT: | |||
2484 | return INT_FLOAT_CONVERSION_BADNESS2; | |||
2485 | default: | |||
2486 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2487 | } | |||
2488 | break; | |||
2489 | case TYPE_CODE_CHAR: | |||
2490 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2491 | { | |||
2492 | case TYPE_CODE_RANGE: | |||
2493 | case TYPE_CODE_BOOL: | |||
2494 | case TYPE_CODE_ENUM: | |||
2495 | return INTEGER_CONVERSION_BADNESS2; | |||
2496 | case TYPE_CODE_FLT: | |||
2497 | return INT_FLOAT_CONVERSION_BADNESS2; | |||
2498 | case TYPE_CODE_INT: | |||
2499 | if (TYPE_LENGTH (arg)(arg)->length > TYPE_LENGTH (parm)(parm)->length) | |||
2500 | return INTEGER_CONVERSION_BADNESS2; | |||
2501 | else if (TYPE_LENGTH (arg)(arg)->length < TYPE_LENGTH (parm)(parm)->length) | |||
2502 | return INTEGER_PROMOTION_BADNESS1; | |||
2503 | /* >>> !! else fall through !! <<< */ | |||
2504 | case TYPE_CODE_CHAR: | |||
2505 | /* Deal with signed, unsigned, and plain chars for C++ | |||
2506 | and with int cases falling through from previous case */ | |||
2507 | if (TYPE_NOSIGN (parm)((parm)->main_type->flags & (1 << 1))) | |||
2508 | { | |||
2509 | if (TYPE_NOSIGN (arg)((arg)->main_type->flags & (1 << 1))) | |||
2510 | return 0; | |||
2511 | else | |||
2512 | return INTEGER_CONVERSION_BADNESS2; | |||
2513 | } | |||
2514 | else if (TYPE_UNSIGNED (parm)((parm)->main_type->flags & (1 << 0))) | |||
2515 | { | |||
2516 | if (TYPE_UNSIGNED (arg)((arg)->main_type->flags & (1 << 0))) | |||
2517 | return 0; | |||
2518 | else | |||
2519 | return INTEGER_PROMOTION_BADNESS1; | |||
2520 | } | |||
2521 | else if (!TYPE_NOSIGN (arg)((arg)->main_type->flags & (1 << 1)) && !TYPE_UNSIGNED (arg)((arg)->main_type->flags & (1 << 0))) | |||
2522 | return 0; | |||
2523 | else | |||
2524 | return INTEGER_CONVERSION_BADNESS2; | |||
2525 | default: | |||
2526 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2527 | } | |||
2528 | break; | |||
2529 | case TYPE_CODE_RANGE: | |||
2530 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2531 | { | |||
2532 | case TYPE_CODE_INT: | |||
2533 | case TYPE_CODE_CHAR: | |||
2534 | case TYPE_CODE_RANGE: | |||
2535 | case TYPE_CODE_BOOL: | |||
2536 | case TYPE_CODE_ENUM: | |||
2537 | return INTEGER_CONVERSION_BADNESS2; | |||
2538 | case TYPE_CODE_FLT: | |||
2539 | return INT_FLOAT_CONVERSION_BADNESS2; | |||
2540 | default: | |||
2541 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2542 | } | |||
2543 | break; | |||
2544 | case TYPE_CODE_BOOL: | |||
2545 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2546 | { | |||
2547 | case TYPE_CODE_INT: | |||
2548 | case TYPE_CODE_CHAR: | |||
2549 | case TYPE_CODE_RANGE: | |||
2550 | case TYPE_CODE_ENUM: | |||
2551 | case TYPE_CODE_FLT: | |||
2552 | case TYPE_CODE_PTR: | |||
2553 | return BOOLEAN_CONVERSION_BADNESS2; | |||
2554 | case TYPE_CODE_BOOL: | |||
2555 | return 0; | |||
2556 | default: | |||
2557 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2558 | } | |||
2559 | break; | |||
2560 | case TYPE_CODE_FLT: | |||
2561 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2562 | { | |||
2563 | case TYPE_CODE_FLT: | |||
2564 | if (TYPE_LENGTH (arg)(arg)->length < TYPE_LENGTH (parm)(parm)->length) | |||
2565 | return FLOAT_PROMOTION_BADNESS1; | |||
2566 | else if (TYPE_LENGTH (arg)(arg)->length == TYPE_LENGTH (parm)(parm)->length) | |||
2567 | return 0; | |||
2568 | else | |||
2569 | return FLOAT_CONVERSION_BADNESS2; | |||
2570 | case TYPE_CODE_INT: | |||
2571 | case TYPE_CODE_BOOL: | |||
2572 | case TYPE_CODE_ENUM: | |||
2573 | case TYPE_CODE_RANGE: | |||
2574 | case TYPE_CODE_CHAR: | |||
2575 | return INT_FLOAT_CONVERSION_BADNESS2; | |||
2576 | default: | |||
2577 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2578 | } | |||
2579 | break; | |||
2580 | case TYPE_CODE_COMPLEX: | |||
2581 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2582 | { /* Strictly not needed for C++, but... */ | |||
2583 | case TYPE_CODE_FLT: | |||
2584 | return FLOAT_PROMOTION_BADNESS1; | |||
2585 | case TYPE_CODE_COMPLEX: | |||
2586 | return 0; | |||
2587 | default: | |||
2588 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2589 | } | |||
2590 | break; | |||
2591 | case TYPE_CODE_STRUCT: | |||
2592 | /* currently same as TYPE_CODE_CLASS */ | |||
2593 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2594 | { | |||
2595 | case TYPE_CODE_STRUCT: | |||
2596 | /* Check for derivation */ | |||
2597 | if (is_ancestor (parm, arg)) | |||
2598 | return BASE_CONVERSION_BADNESS2; | |||
2599 | /* else fall through */ | |||
2600 | default: | |||
2601 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2602 | } | |||
2603 | break; | |||
2604 | case TYPE_CODE_UNION: | |||
2605 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2606 | { | |||
2607 | case TYPE_CODE_UNION: | |||
2608 | default: | |||
2609 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2610 | } | |||
2611 | break; | |||
2612 | case TYPE_CODE_MEMBER: | |||
2613 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2614 | { | |||
2615 | default: | |||
2616 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2617 | } | |||
2618 | break; | |||
2619 | case TYPE_CODE_METHOD: | |||
2620 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2621 | { | |||
2622 | ||||
2623 | default: | |||
2624 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2625 | } | |||
2626 | break; | |||
2627 | case TYPE_CODE_REF: | |||
2628 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2629 | { | |||
2630 | ||||
2631 | default: | |||
2632 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2633 | } | |||
2634 | ||||
2635 | break; | |||
2636 | case TYPE_CODE_SET: | |||
2637 | switch (TYPE_CODE (arg)(arg)->main_type->code) | |||
2638 | { | |||
2639 | /* Not in C++ */ | |||
2640 | case TYPE_CODE_SET: | |||
2641 | return rank_one_type (TYPE_FIELD_TYPE (parm, 0)(((parm)->main_type->fields[0]).type), TYPE_FIELD_TYPE (arg, 0)(((arg)->main_type->fields[0]).type)); | |||
2642 | default: | |||
2643 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2644 | } | |||
2645 | break; | |||
2646 | case TYPE_CODE_VOID: | |||
2647 | default: | |||
2648 | return INCOMPATIBLE_TYPE_BADNESS100; | |||
2649 | } /* switch (TYPE_CODE (arg)) */ | |||
2650 | } | |||
2651 | ||||
2652 | ||||
2653 | /* End of functions for overload resolution */ | |||
2654 | ||||
2655 | static void | |||
2656 | print_bit_vector (B_TYPEunsigned char *bits, int nbits) | |||
2657 | { | |||
2658 | int bitno; | |||
2659 | ||||
2660 | for (bitno = 0; bitno < nbits; bitno++) | |||
2661 | { | |||
2662 | if ((bitno % 8) == 0) | |||
2663 | { | |||
2664 | puts_filtered (" "); | |||
2665 | } | |||
2666 | if (B_TST (bits, bitno)((bits)[(bitno)>>3] & (1 << ((bitno)&7)))) | |||
2667 | { | |||
2668 | printf_filtered ("1"); | |||
2669 | } | |||
2670 | else | |||
2671 | { | |||
2672 | printf_filtered ("0"); | |||
2673 | } | |||
2674 | } | |||
2675 | } | |||
2676 | ||||
2677 | /* Note the first arg should be the "this" pointer, we may not want to | |||
2678 | include it since we may get into a infinitely recursive situation. */ | |||
2679 | ||||
2680 | static void | |||
2681 | print_arg_types (struct field *args, int nargs, int spaces) | |||
2682 | { | |||
2683 | if (args != NULL((void*)0)) | |||
2684 | { | |||
2685 | int i; | |||
2686 | ||||
2687 | for (i = 0; i < nargs; i++) | |||
2688 | recursive_dump_type (args[i].type, spaces + 2); | |||
2689 | } | |||
2690 | } | |||
2691 | ||||
2692 | static void | |||
2693 | dump_fn_fieldlists (struct type *type, int spaces) | |||
2694 | { | |||
2695 | int method_idx; | |||
2696 | int overload_idx; | |||
2697 | struct fn_field *f; | |||
2698 | ||||
2699 | printfi_filtered (spaces, "fn_fieldlists "); | |||
2700 | gdb_print_host_address (TYPE_FN_FIELDLISTS (type)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists, gdb_stdout); | |||
2701 | printf_filtered ("\n"); | |||
2702 | for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type)(type)->main_type->type_specific.cplus_stuff->nfn_fields; method_idx++) | |||
2703 | { | |||
2704 | f = TYPE_FN_FIELDLIST1 (type, method_idx)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_idx].fn_fields; | |||
2705 | printfi_filtered (spaces + 2, "[%d] name '%s' (", | |||
2706 | method_idx, | |||
2707 | TYPE_FN_FIELDLIST_NAME (type, method_idx)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_idx].name); | |||
2708 | gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_idx].name, | |||
2709 | gdb_stdout); | |||
2710 | printf_filtered (") length %d\n", | |||
2711 | TYPE_FN_FIELDLIST_LENGTH (type, method_idx)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_idx].length); | |||
2712 | for (overload_idx = 0; | |||
2713 | overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx)(type)->main_type->type_specific.cplus_stuff->fn_fieldlists [method_idx].length; | |||
2714 | overload_idx++) | |||
2715 | { | |||
2716 | printfi_filtered (spaces + 4, "[%d] physname '%s' (", | |||
2717 | overload_idx, | |||
2718 | TYPE_FN_FIELD_PHYSNAME (f, overload_idx)(f)[overload_idx].physname); | |||
2719 | gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx)(f)[overload_idx].physname, | |||
2720 | gdb_stdout); | |||
2721 | printf_filtered (")\n"); | |||
2722 | printfi_filtered (spaces + 8, "type "); | |||
2723 | gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx)(f)[overload_idx].type, gdb_stdout); | |||
2724 | printf_filtered ("\n"); | |||
2725 | ||||
2726 | recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx)(f)[overload_idx].type, | |||
2727 | spaces + 8 + 2); | |||
2728 | ||||
2729 | printfi_filtered (spaces + 8, "args "); | |||
2730 | gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx)((f)[overload_idx].type)->main_type->fields, gdb_stdout); | |||
2731 | printf_filtered ("\n"); | |||
2732 | ||||
2733 | print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx)((f)[overload_idx].type)->main_type->fields, | |||
2734 | TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, overload_idx))((f)[overload_idx].type)->main_type->nfields, | |||
2735 | spaces); | |||
2736 | printfi_filtered (spaces + 8, "fcontext "); | |||
2737 | gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx)((f)[overload_idx].fcontext), | |||
2738 | gdb_stdout); | |||
2739 | printf_filtered ("\n"); | |||
2740 | ||||
2741 | printfi_filtered (spaces + 8, "is_const %d\n", | |||
2742 | TYPE_FN_FIELD_CONST (f, overload_idx)((f)[overload_idx].is_const)); | |||
2743 | printfi_filtered (spaces + 8, "is_volatile %d\n", | |||
2744 | TYPE_FN_FIELD_VOLATILE (f, overload_idx)((f)[overload_idx].is_volatile)); | |||
2745 | printfi_filtered (spaces + 8, "is_private %d\n", | |||
2746 | TYPE_FN_FIELD_PRIVATE (f, overload_idx)((f)[overload_idx].is_private)); | |||
2747 | printfi_filtered (spaces + 8, "is_protected %d\n", | |||
2748 | TYPE_FN_FIELD_PROTECTED (f, overload_idx)((f)[overload_idx].is_protected)); | |||
2749 | printfi_filtered (spaces + 8, "is_stub %d\n", | |||
2750 | TYPE_FN_FIELD_STUB (f, overload_idx)((f)[overload_idx].is_stub)); | |||
2751 | printfi_filtered (spaces + 8, "voffset %u\n", | |||
2752 | TYPE_FN_FIELD_VOFFSET (f, overload_idx)((f)[overload_idx].voffset-2)); | |||
2753 | } | |||
2754 | } | |||
2755 | } | |||
2756 | ||||
2757 | static void | |||
2758 | print_cplus_stuff (struct type *type, int spaces) | |||
2759 | { | |||
2760 | printfi_filtered (spaces, "n_baseclasses %d\n", | |||
2761 | TYPE_N_BASECLASSES (type)(type)->main_type->type_specific.cplus_stuff->n_baseclasses); | |||
2762 | printfi_filtered (spaces, "nfn_fields %d\n", | |||
2763 | TYPE_NFN_FIELDS (type)(type)->main_type->type_specific.cplus_stuff->nfn_fields); | |||
2764 | printfi_filtered (spaces, "nfn_fields_total %d\n", | |||
2765 | TYPE_NFN_FIELDS_TOTAL (type)(type)->main_type->type_specific.cplus_stuff->nfn_fields_total); | |||
2766 | if (TYPE_N_BASECLASSES (type)(type)->main_type->type_specific.cplus_stuff->n_baseclasses > 0) | |||
2767 | { | |||
2768 | printfi_filtered (spaces, "virtual_field_bits (%d bits at *", | |||
2769 | TYPE_N_BASECLASSES (type)(type)->main_type->type_specific.cplus_stuff->n_baseclasses); | |||
2770 | gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type)(type)->main_type->type_specific.cplus_stuff->virtual_field_bits, gdb_stdout); | |||
2771 | printf_filtered (")"); | |||
2772 | ||||
2773 | print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type)(type)->main_type->type_specific.cplus_stuff->virtual_field_bits, | |||
2774 | TYPE_N_BASECLASSES (type)(type)->main_type->type_specific.cplus_stuff->n_baseclasses); | |||
2775 | puts_filtered ("\n"); | |||
2776 | } | |||
2777 | if (TYPE_NFIELDS (type)(type)->main_type->nfields > 0) | |||
2778 | { | |||
2779 | if (TYPE_FIELD_PRIVATE_BITS (type)(type)->main_type->type_specific.cplus_stuff->private_field_bits != NULL((void*)0)) | |||
2780 | { | |||
2781 | printfi_filtered (spaces, "private_field_bits (%d bits at *", | |||
2782 | TYPE_NFIELDS (type)(type)->main_type->nfields); | |||
2783 | gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type)(type)->main_type->type_specific.cplus_stuff->private_field_bits, gdb_stdout); | |||
2784 | printf_filtered (")"); | |||
2785 | print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type)(type)->main_type->type_specific.cplus_stuff->private_field_bits, | |||
2786 | TYPE_NFIELDS (type)(type)->main_type->nfields); | |||
2787 | puts_filtered ("\n"); | |||
2788 | } | |||
2789 | if (TYPE_FIELD_PROTECTED_BITS (type)(type)->main_type->type_specific.cplus_stuff->protected_field_bits != NULL((void*)0)) | |||
2790 | { | |||
2791 | printfi_filtered (spaces, "protected_field_bits (%d bits at *", | |||
2792 | TYPE_NFIELDS (type)(type)->main_type->nfields); | |||
2793 | gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type)(type)->main_type->type_specific.cplus_stuff->protected_field_bits, gdb_stdout); | |||
2794 | printf_filtered (")"); | |||
2795 | print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type)(type)->main_type->type_specific.cplus_stuff->protected_field_bits, | |||
2796 | TYPE_NFIELDS (type)(type)->main_type->nfields); | |||
2797 | puts_filtered ("\n"); | |||
2798 | } | |||
2799 | } | |||
2800 | if (TYPE_NFN_FIELDS (type)(type)->main_type->type_specific.cplus_stuff->nfn_fields > 0) | |||
2801 | { | |||
2802 | dump_fn_fieldlists (type, spaces); | |||
2803 | } | |||
2804 | } | |||
2805 | ||||
2806 | static void | |||
2807 | print_bound_type (int bt) | |||
2808 | { | |||
2809 | switch (bt) | |||
2810 | { | |||
2811 | case BOUND_CANNOT_BE_DETERMINED: | |||
2812 | printf_filtered ("(BOUND_CANNOT_BE_DETERMINED)"); | |||
2813 | break; | |||
2814 | case BOUND_BY_REF_ON_STACK: | |||
2815 | printf_filtered ("(BOUND_BY_REF_ON_STACK)"); | |||
2816 | break; | |||
2817 | case BOUND_BY_VALUE_ON_STACK: | |||
2818 | printf_filtered ("(BOUND_BY_VALUE_ON_STACK)"); | |||
2819 | break; | |||
2820 | case BOUND_BY_REF_IN_REG: | |||
2821 | printf_filtered ("(BOUND_BY_REF_IN_REG)"); | |||
2822 | break; | |||
2823 | case BOUND_BY_VALUE_IN_REG: | |||
2824 | printf_filtered ("(BOUND_BY_VALUE_IN_REG)"); | |||
2825 | break; | |||
2826 | case BOUND_SIMPLE: | |||
2827 | printf_filtered ("(BOUND_SIMPLE)"); | |||
2828 | break; | |||
2829 | default: | |||
2830 | printf_filtered ("(unknown bound type)"); | |||
2831 | break; | |||
2832 | } | |||
2833 | } | |||
2834 | ||||
2835 | static struct obstack dont_print_type_obstack; | |||
2836 | ||||
2837 | void | |||
2838 | recursive_dump_type (struct type *type, int spaces) | |||
2839 | { | |||
2840 | int idx; | |||
2841 | ||||
2842 | if (spaces == 0) | |||
2843 | obstack_begin (&dont_print_type_obstack, 0)_obstack_begin ((&dont_print_type_obstack), (0), 0, (void *(*) (long)) xmalloc, (void (*) (void *)) xfree); | |||
2844 | ||||
2845 | if (TYPE_NFIELDS (type)(type)->main_type->nfields > 0 | |||
2846 | || (TYPE_CPLUS_SPECIFIC (type)(type)->main_type->type_specific.cplus_stuff && TYPE_NFN_FIELDS (type)(type)->main_type->type_specific.cplus_stuff->nfn_fields > 0)) | |||
2847 | { | |||
2848 | struct type **first_dont_print | |||
2849 | = (struct type **) obstack_base (&dont_print_type_obstack)((&dont_print_type_obstack)->object_base); | |||
2850 | ||||
2851 | int i = (struct type **) obstack_next_free (&dont_print_type_obstack)((&dont_print_type_obstack)->next_free) | |||
2852 | - first_dont_print; | |||
2853 | ||||
2854 | while (--i >= 0) | |||
2855 | { | |||
2856 | if (type == first_dont_print[i]) | |||
2857 | { | |||
2858 | printfi_filtered (spaces, "type node "); | |||
2859 | gdb_print_host_address (type, gdb_stdout); | |||
2860 | printf_filtered (" <same as already seen type>\n"); | |||
2861 | return; | |||
2862 | } | |||
2863 | } | |||
2864 | ||||
2865 | obstack_ptr_grow (&dont_print_type_obstack, type)__extension__ ({ struct obstack *__o = (&dont_print_type_obstack ); if (__o->next_free + sizeof (void *) > __o->chunk_limit ) _obstack_newchunk (__o, sizeof (void *)); __extension__ ({ struct obstack *__o1 = (__o); *(const void **) __o1->next_free = (type); __o1->next_free += sizeof (const void *); (void) 0 ; }); }); | |||
2866 | } | |||
2867 | ||||
2868 | printfi_filtered (spaces, "type node "); | |||
2869 | gdb_print_host_address (type, gdb_stdout); | |||
2870 | printf_filtered ("\n"); | |||
2871 | printfi_filtered (spaces, "name '%s' (", | |||
2872 | TYPE_NAME (type)(type)->main_type->name ? TYPE_NAME (type)(type)->main_type->name : "<NULL>"); | |||
2873 | gdb_print_host_address (TYPE_NAME (type)(type)->main_type->name, gdb_stdout); | |||
2874 | printf_filtered (")\n"); | |||
2875 | printfi_filtered (spaces, "tagname '%s' (", | |||
2876 | TYPE_TAG_NAME (type)(type)->main_type->tag_name ? TYPE_TAG_NAME (type)(type)->main_type->tag_name : "<NULL>"); | |||
2877 | gdb_print_host_address (TYPE_TAG_NAME (type)(type)->main_type->tag_name, gdb_stdout); | |||
2878 | printf_filtered (")\n"); | |||
2879 | printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type)(type)->main_type->code); | |||
2880 | switch (TYPE_CODE (type)(type)->main_type->code) | |||
2881 | { | |||
2882 | case TYPE_CODE_UNDEF: | |||
2883 | printf_filtered ("(TYPE_CODE_UNDEF)"); | |||
2884 | break; | |||
2885 | case TYPE_CODE_PTR: | |||
2886 | printf_filtered ("(TYPE_CODE_PTR)"); | |||
2887 | break; | |||
2888 | case TYPE_CODE_ARRAY: | |||
2889 | printf_filtered ("(TYPE_CODE_ARRAY)"); | |||
2890 | break; | |||
2891 | case TYPE_CODE_STRUCT: | |||
2892 | printf_filtered ("(TYPE_CODE_STRUCT)"); | |||
2893 | break; | |||
2894 | case TYPE_CODE_UNION: | |||
2895 | printf_filtered ("(TYPE_CODE_UNION)"); | |||
2896 | break; | |||
2897 | case TYPE_CODE_ENUM: | |||
2898 | printf_filtered ("(TYPE_CODE_ENUM)"); | |||
2899 | break; | |||
2900 | case TYPE_CODE_FUNC: | |||
2901 | printf_filtered ("(TYPE_CODE_FUNC)"); | |||
2902 | break; | |||
2903 | case TYPE_CODE_INT: | |||
2904 | printf_filtered ("(TYPE_CODE_INT)"); | |||
2905 | break; | |||
2906 | case TYPE_CODE_FLT: | |||
2907 | printf_filtered ("(TYPE_CODE_FLT)"); | |||
2908 | break; | |||
2909 | case TYPE_CODE_VOID: | |||
2910 | printf_filtered ("(TYPE_CODE_VOID)"); | |||
2911 | break; | |||
2912 | case TYPE_CODE_SET: | |||
2913 | printf_filtered ("(TYPE_CODE_SET)"); | |||
2914 | break; | |||
2915 | case TYPE_CODE_RANGE: | |||
2916 | printf_filtered ("(TYPE_CODE_RANGE)"); | |||
2917 | break; | |||
2918 | case TYPE_CODE_STRING: | |||
2919 | printf_filtered ("(TYPE_CODE_STRING)"); | |||
2920 | break; | |||
2921 | case TYPE_CODE_BITSTRING: | |||
2922 | printf_filtered ("(TYPE_CODE_BITSTRING)"); | |||
2923 | break; | |||
2924 | case TYPE_CODE_ERROR: | |||
2925 | printf_filtered ("(TYPE_CODE_ERROR)"); | |||
2926 | break; | |||
2927 | case TYPE_CODE_MEMBER: | |||
2928 | printf_filtered ("(TYPE_CODE_MEMBER)"); | |||
2929 | break; | |||
2930 | case TYPE_CODE_METHOD: | |||
2931 | printf_filtered ("(TYPE_CODE_METHOD)"); | |||
2932 | break; | |||
2933 | case TYPE_CODE_REF: | |||
2934 | printf_filtered ("(TYPE_CODE_REF)"); | |||
2935 | break; | |||
2936 | case TYPE_CODE_CHAR: | |||
2937 | printf_filtered ("(TYPE_CODE_CHAR)"); | |||
2938 | break; | |||
2939 | case TYPE_CODE_BOOL: | |||
2940 | printf_filtered ("(TYPE_CODE_BOOL)"); | |||
2941 | break; | |||
2942 | case TYPE_CODE_COMPLEX: | |||
2943 | printf_filtered ("(TYPE_CODE_COMPLEX)"); | |||
2944 | break; | |||
2945 | case TYPE_CODE_TYPEDEF: | |||
2946 | printf_filtered ("(TYPE_CODE_TYPEDEF)"); | |||
2947 | break; | |||
2948 | case TYPE_CODE_TEMPLATE: | |||
2949 | printf_filtered ("(TYPE_CODE_TEMPLATE)"); | |||
2950 | break; | |||
2951 | case TYPE_CODE_TEMPLATE_ARG: | |||
2952 | printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)"); | |||
2953 | break; | |||
2954 | case TYPE_CODE_NAMESPACE: | |||
2955 | printf_filtered ("(TYPE_CODE_NAMESPACE)"); | |||
2956 | break; | |||
2957 | default: | |||
2958 | printf_filtered ("(UNKNOWN TYPE CODE)"); | |||
2959 | break; | |||
2960 | } | |||
2961 | puts_filtered ("\n"); | |||
2962 | printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type)(type)->length); | |||
2963 | printfi_filtered (spaces, "upper_bound_type 0x%x ", | |||
2964 | TYPE_ARRAY_UPPER_BOUND_TYPE (type)(type)->main_type->upper_bound_type); | |||
2965 | print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type)(type)->main_type->upper_bound_type); | |||
2966 | puts_filtered ("\n"); | |||
2967 | printfi_filtered (spaces, "lower_bound_type 0x%x ", | |||
2968 | TYPE_ARRAY_LOWER_BOUND_TYPE (type)(type)->main_type->lower_bound_type); | |||
2969 | print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type)(type)->main_type->lower_bound_type); | |||
2970 | puts_filtered ("\n"); | |||
2971 | printfi_filtered (spaces, "objfile "); | |||
2972 | gdb_print_host_address (TYPE_OBJFILE (type)(type)->main_type->objfile, gdb_stdout); | |||
2973 | printf_filtered ("\n"); | |||
2974 | printfi_filtered (spaces, "target_type "); | |||
2975 | gdb_print_host_address (TYPE_TARGET_TYPE (type)(type)->main_type->target_type, gdb_stdout); | |||
2976 | printf_filtered ("\n"); | |||
2977 | if (TYPE_TARGET_TYPE (type)(type)->main_type->target_type != NULL((void*)0)) | |||
2978 | { | |||
2979 | recursive_dump_type (TYPE_TARGET_TYPE (type)(type)->main_type->target_type, spaces + 2); | |||
2980 | } | |||
2981 | printfi_filtered (spaces, "pointer_type "); | |||
2982 | gdb_print_host_address (TYPE_POINTER_TYPE (type)(type)->pointer_type, gdb_stdout); | |||
2983 | printf_filtered ("\n"); | |||
2984 | printfi_filtered (spaces, "reference_type "); | |||
2985 | gdb_print_host_address (TYPE_REFERENCE_TYPE (type)(type)->reference_type, gdb_stdout); | |||
2986 | printf_filtered ("\n"); | |||
2987 | printfi_filtered (spaces, "type_chain "); | |||
2988 | gdb_print_host_address (TYPE_CHAIN (type)(type)->chain, gdb_stdout); | |||
2989 | printf_filtered ("\n"); | |||
2990 | printfi_filtered (spaces, "instance_flags 0x%x", TYPE_INSTANCE_FLAGS (type)(type)->instance_flags); | |||
2991 | if (TYPE_CONST (type)((type)->instance_flags & (1 << 5))) | |||
2992 | { | |||
2993 | puts_filtered (" TYPE_FLAG_CONST"); | |||
2994 | } | |||
2995 | if (TYPE_VOLATILE (type)((type)->instance_flags & (1 << 6))) | |||
2996 | { | |||
2997 | puts_filtered (" TYPE_FLAG_VOLATILE"); | |||
2998 | } | |||
2999 | if (TYPE_CODE_SPACE (type)((type)->instance_flags & (1 << 9))) | |||
3000 | { | |||
3001 | puts_filtered (" TYPE_FLAG_CODE_SPACE"); | |||
3002 | } | |||
3003 | if (TYPE_DATA_SPACE (type)((type)->instance_flags & (1 << 10))) | |||
3004 | { | |||
3005 | puts_filtered (" TYPE_FLAG_DATA_SPACE"); | |||
3006 | } | |||
3007 | if (TYPE_ADDRESS_CLASS_1 (type)((type)->instance_flags & (1 << 13))) | |||
3008 | { | |||
3009 | puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_1"); | |||
3010 | } | |||
3011 | if (TYPE_ADDRESS_CLASS_2 (type)((type)->instance_flags & (1 << 14))) | |||
3012 | { | |||
3013 | puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_2"); | |||
3014 | } | |||
3015 | puts_filtered ("\n"); | |||
3016 | printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type)(type)->main_type->flags); | |||
3017 | if (TYPE_UNSIGNED (type)((type)->main_type->flags & (1 << 0))) | |||
3018 | { | |||
3019 | puts_filtered (" TYPE_FLAG_UNSIGNED"); | |||
3020 | } | |||
3021 | if (TYPE_NOSIGN (type)((type)->main_type->flags & (1 << 1))) | |||
3022 | { | |||
3023 | puts_filtered (" TYPE_FLAG_NOSIGN"); | |||
3024 | } | |||
3025 | if (TYPE_STUB (type)((type)->main_type->flags & (1 << 2))) | |||
3026 | { | |||
3027 | puts_filtered (" TYPE_FLAG_STUB"); | |||
3028 | } | |||
3029 | if (TYPE_TARGET_STUB (type)((type)->main_type->flags & (1 << 3))) | |||
3030 | { | |||
3031 | puts_filtered (" TYPE_FLAG_TARGET_STUB"); | |||
3032 | } | |||
3033 | if (TYPE_STATIC (type)((type)->main_type->flags & (1 << 4))) | |||
3034 | { | |||
3035 | puts_filtered (" TYPE_FLAG_STATIC"); | |||
3036 | } | |||
3037 | if (TYPE_PROTOTYPED (type)((type)->main_type->flags & (1 << 7))) | |||
3038 | { | |||
3039 | puts_filtered (" TYPE_FLAG_PROTOTYPED"); | |||
3040 | } | |||
3041 | if (TYPE_INCOMPLETE (type)((type)->main_type->flags & (1 << 8))) | |||
3042 | { | |||
3043 | puts_filtered (" TYPE_FLAG_INCOMPLETE"); | |||
3044 | } | |||
3045 | if (TYPE_VARARGS (type)((type)->main_type->flags & (1 << 11))) | |||
3046 | { | |||
3047 | puts_filtered (" TYPE_FLAG_VARARGS"); | |||
3048 | } | |||
3049 | /* This is used for things like AltiVec registers on ppc. Gcc emits | |||
3050 | an attribute for the array type, which tells whether or not we | |||
3051 | have a vector, instead of a regular array. */ | |||
3052 | if (TYPE_VECTOR (type)((type)->main_type->flags & (1 << 12))) | |||
3053 | { | |||
3054 | puts_filtered (" TYPE_FLAG_VECTOR"); | |||
3055 | } | |||
3056 | puts_filtered ("\n"); | |||
3057 | printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type)(type)->main_type->nfields); | |||
3058 | gdb_print_host_address (TYPE_FIELDS (type)(type)->main_type->fields, gdb_stdout); | |||
3059 | puts_filtered ("\n"); | |||
3060 | for (idx = 0; idx < TYPE_NFIELDS (type)(type)->main_type->nfields; idx++) | |||
3061 | { | |||
3062 | printfi_filtered (spaces + 2, | |||
3063 | "[%d] bitpos %d bitsize %d type ", | |||
3064 | idx, TYPE_FIELD_BITPOS (type, idx)(((type)->main_type->fields[idx]).loc.bitpos), | |||
3065 | TYPE_FIELD_BITSIZE (type, idx)(((type)->main_type->fields[idx]).bitsize)); | |||
3066 | gdb_print_host_address (TYPE_FIELD_TYPE (type, idx)(((type)->main_type->fields[idx]).type), gdb_stdout); | |||
3067 | printf_filtered (" name '%s' (", | |||
3068 | TYPE_FIELD_NAME (type, idx)(((type)->main_type->fields[idx]).name) != NULL((void*)0) | |||
3069 | ? TYPE_FIELD_NAME (type, idx)(((type)->main_type->fields[idx]).name) | |||
3070 | : "<NULL>"); | |||
3071 | gdb_print_host_address (TYPE_FIELD_NAME (type, idx)(((type)->main_type->fields[idx]).name), gdb_stdout); | |||
3072 | printf_filtered (")\n"); | |||
3073 | if (TYPE_FIELD_TYPE (type, idx)(((type)->main_type->fields[idx]).type) != NULL((void*)0)) | |||
3074 | { | |||
3075 | recursive_dump_type (TYPE_FIELD_TYPE (type, idx)(((type)->main_type->fields[idx]).type), spaces + 4); | |||
3076 | } | |||
3077 | } | |||
3078 | printfi_filtered (spaces, "vptr_basetype "); | |||
3079 | gdb_print_host_address (TYPE_VPTR_BASETYPE (type)(type)->main_type->vptr_basetype, gdb_stdout); | |||
3080 | puts_filtered ("\n"); | |||
3081 | if (TYPE_VPTR_BASETYPE (type)(type)->main_type->vptr_basetype != NULL((void*)0)) | |||
3082 | { | |||
3083 | recursive_dump_type (TYPE_VPTR_BASETYPE (type)(type)->main_type->vptr_basetype, spaces + 2); | |||
3084 | } | |||
3085 | printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type)(type)->main_type->vptr_fieldno); | |||
3086 | switch (TYPE_CODE (type)(type)->main_type->code) | |||
3087 | { | |||
3088 | case TYPE_CODE_STRUCT: | |||
3089 | printfi_filtered (spaces, "cplus_stuff "); | |||
3090 | gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type)(type)->main_type->type_specific.cplus_stuff, gdb_stdout); | |||
3091 | puts_filtered ("\n"); | |||
3092 | print_cplus_stuff (type, spaces); | |||
3093 | break; | |||
3094 | ||||
3095 | case TYPE_CODE_FLT: | |||
3096 | printfi_filtered (spaces, "floatformat "); | |||
3097 | if (TYPE_FLOATFORMAT (type)(type)->main_type->type_specific.floatformat == NULL((void*)0) | |||
3098 | || TYPE_FLOATFORMAT (type)(type)->main_type->type_specific.floatformat->name == NULL((void*)0)) | |||
3099 | puts_filtered ("(null)"); | |||
3100 | else | |||
3101 | puts_filtered (TYPE_FLOATFORMAT (type)(type)->main_type->type_specific.floatformat->name); | |||
3102 | puts_filtered ("\n"); | |||
3103 | break; | |||
3104 | ||||
3105 | default: | |||
3106 | /* We have to pick one of the union types to be able print and test | |||
3107 | the value. Pick cplus_struct_type, even though we know it isn't | |||
3108 | any particular one. */ | |||
3109 | printfi_filtered (spaces, "type_specific "); | |||
3110 | gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type)(type)->main_type->type_specific.cplus_stuff, gdb_stdout); | |||
3111 | if (TYPE_CPLUS_SPECIFIC (type)(type)->main_type->type_specific.cplus_stuff != NULL((void*)0)) | |||
3112 | { | |||
3113 | printf_filtered (" (unknown data form)"); | |||
3114 | } | |||
3115 | printf_filtered ("\n"); | |||
3116 | break; | |||
3117 | ||||
3118 | } | |||
3119 | if (spaces == 0) | |||
3120 | obstack_free (&dont_print_type_obstack, NULL)__extension__ ({ struct obstack *__o = (&dont_print_type_obstack ); void *__obj = (((void*)0)); if (__obj > (void *)__o-> chunk && __obj < (void *)__o->chunk_limit) __o-> next_free = __o->object_base = __obj; else (obstack_free) ( __o, __obj); }); | |||
3121 | } | |||
3122 | ||||
3123 | static void build_gdbtypes (void); | |||
3124 | static void | |||
3125 | build_gdbtypes (void) | |||
3126 | { | |||
3127 | builtin_type_void = | |||
3128 | init_type (TYPE_CODE_VOID, 1, | |||
3129 | 0, | |||
3130 | "void", (struct objfile *) NULL((void*)0)); | |||
3131 | builtin_type_char = | |||
3132 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3133 | (TYPE_FLAG_NOSIGN(1 << 1) | |||
3134 | | (TARGET_CHAR_SIGNED(gdbarch_char_signed (current_gdbarch)) ? 0 : TYPE_FLAG_UNSIGNED(1 << 0))), | |||
3135 | "char", (struct objfile *) NULL((void*)0)); | |||
3136 | builtin_type_true_char = | |||
3137 | init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3138 | 0, | |||
3139 | "true character", (struct objfile *) NULL((void*)0)); | |||
3140 | builtin_type_signed_char = | |||
3141 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3142 | 0, | |||
3143 | "signed char", (struct objfile *) NULL((void*)0)); | |||
3144 | builtin_type_unsigned_char = | |||
3145 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3146 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3147 | "unsigned char", (struct objfile *) NULL((void*)0)); | |||
3148 | builtin_type_short = | |||
3149 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT(gdbarch_short_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3150 | 0, | |||
3151 | "short", (struct objfile *) NULL((void*)0)); | |||
3152 | builtin_type_unsigned_short = | |||
3153 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT(gdbarch_short_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3154 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3155 | "unsigned short", (struct objfile *) NULL((void*)0)); | |||
3156 | builtin_type_int = | |||
3157 | init_type (TYPE_CODE_INT, TARGET_INT_BIT(gdbarch_int_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3158 | 0, | |||
3159 | "int", (struct objfile *) NULL((void*)0)); | |||
3160 | builtin_type_unsigned_int = | |||
3161 | init_type (TYPE_CODE_INT, TARGET_INT_BIT(gdbarch_int_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3162 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3163 | "unsigned int", (struct objfile *) NULL((void*)0)); | |||
3164 | builtin_type_long = | |||
3165 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT(gdbarch_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3166 | 0, | |||
3167 | "long", (struct objfile *) NULL((void*)0)); | |||
3168 | builtin_type_unsigned_long = | |||
3169 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT(gdbarch_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3170 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3171 | "unsigned long", (struct objfile *) NULL((void*)0)); | |||
3172 | builtin_type_long_long = | |||
3173 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT(gdbarch_long_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3174 | 0, | |||
3175 | "long long", (struct objfile *) NULL((void*)0)); | |||
3176 | builtin_type_unsigned_long_long = | |||
3177 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT(gdbarch_long_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3178 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3179 | "unsigned long long", (struct objfile *) NULL((void*)0)); | |||
3180 | builtin_type_float = | |||
3181 | init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT(gdbarch_float_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3182 | 0, | |||
3183 | "float", (struct objfile *) NULL((void*)0)); | |||
3184 | /* vinschen@redhat.com 2002-02-08: | |||
3185 | The below lines are disabled since they are doing the wrong | |||
3186 | thing for non-multiarch targets. They are setting the correct | |||
3187 | type of floats for the target but while on multiarch targets | |||
3188 | this is done everytime the architecture changes, it's done on | |||
3189 | non-multiarch targets only on startup, leaving the wrong values | |||
3190 | in even if the architecture changes (eg. from big-endian to | |||
3191 | little-endian). */ | |||
3192 | #if 0 | |||
3193 | TYPE_FLOATFORMAT (builtin_type_float)(builtin_type_float)->main_type->type_specific.floatformat = TARGET_FLOAT_FORMAT(gdbarch_float_format (current_gdbarch)); | |||
3194 | #endif | |||
3195 | builtin_type_double = | |||
3196 | init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT(gdbarch_double_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3197 | 0, | |||
3198 | "double", (struct objfile *) NULL((void*)0)); | |||
3199 | #if 0 | |||
3200 | TYPE_FLOATFORMAT (builtin_type_double)(builtin_type_double)->main_type->type_specific.floatformat = TARGET_DOUBLE_FORMAT(gdbarch_double_format (current_gdbarch)); | |||
3201 | #endif | |||
3202 | builtin_type_long_double = | |||
3203 | init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT(gdbarch_long_double_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3204 | 0, | |||
3205 | "long double", (struct objfile *) NULL((void*)0)); | |||
3206 | #if 0 | |||
3207 | TYPE_FLOATFORMAT (builtin_type_long_double)(builtin_type_long_double)->main_type->type_specific.floatformat = TARGET_LONG_DOUBLE_FORMAT(gdbarch_long_double_format (current_gdbarch)); | |||
3208 | #endif | |||
3209 | builtin_type_complex = | |||
3210 | init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT(gdbarch_float_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3211 | 0, | |||
3212 | "complex", (struct objfile *) NULL((void*)0)); | |||
3213 | TYPE_TARGET_TYPE (builtin_type_complex)(builtin_type_complex)->main_type->target_type = builtin_type_float; | |||
3214 | builtin_type_double_complex = | |||
3215 | init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT(gdbarch_double_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3216 | 0, | |||
3217 | "double complex", (struct objfile *) NULL((void*)0)); | |||
3218 | TYPE_TARGET_TYPE (builtin_type_double_complex)(builtin_type_double_complex)->main_type->target_type = builtin_type_double; | |||
3219 | builtin_type_string = | |||
3220 | init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3221 | 0, | |||
3222 | "string", (struct objfile *) NULL((void*)0)); | |||
3223 | builtin_type_bool = | |||
3224 | init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3225 | 0, | |||
3226 | "bool", (struct objfile *) NULL((void*)0)); | |||
3227 | ||||
3228 | /* Add user knob for controlling resolution of opaque types */ | |||
3229 | deprecated_add_show_from_set | |||
3230 | (add_set_cmd ("opaque-type-resolution", class_support, var_boolean, (char *) &opaque_type_resolution, | |||
3231 | "Set resolution of opaque struct/class/union types (if set before loading symbols).", | |||
3232 | &setlist), | |||
3233 | &showlist); | |||
3234 | opaque_type_resolution = 1; | |||
3235 | ||||
3236 | /* Build SIMD types. */ | |||
3237 | builtin_type_v4sf | |||
3238 | = init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4); | |||
3239 | builtin_type_v4si | |||
3240 | = init_simd_type ("__builtin_v4si", builtin_type_int32, "f", 4); | |||
3241 | builtin_type_v16qi | |||
3242 | = init_simd_type ("__builtin_v16qi", builtin_type_int8, "f", 16); | |||
3243 | builtin_type_v8qi | |||
3244 | = init_simd_type ("__builtin_v8qi", builtin_type_int8, "f", 8); | |||
3245 | builtin_type_v8hi | |||
3246 | = init_simd_type ("__builtin_v8hi", builtin_type_int16, "f", 8); | |||
3247 | builtin_type_v4hi | |||
3248 | = init_simd_type ("__builtin_v4hi", builtin_type_int16, "f", 4); | |||
3249 | builtin_type_v2si | |||
3250 | = init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2); | |||
3251 | ||||
3252 | /* 128 bit vectors. */ | |||
3253 | builtin_type_v2_double = init_vector_type (builtin_type_double, 2); | |||
3254 | builtin_type_v4_float = init_vector_type (builtin_type_float, 4); | |||
3255 | builtin_type_v2_int64 = init_vector_type (builtin_type_int64, 2); | |||
3256 | builtin_type_v4_int32 = init_vector_type (builtin_type_int32, 4); | |||
3257 | builtin_type_v8_int16 = init_vector_type (builtin_type_int16, 8); | |||
3258 | builtin_type_v16_int8 = init_vector_type (builtin_type_int8, 16); | |||
3259 | /* 64 bit vectors. */ | |||
3260 | builtin_type_v2_float = init_vector_type (builtin_type_float, 2); | |||
3261 | builtin_type_v2_int32 = init_vector_type (builtin_type_int32, 2); | |||
3262 | builtin_type_v4_int16 = init_vector_type (builtin_type_int16, 4); | |||
3263 | builtin_type_v8_int8 = init_vector_type (builtin_type_int8, 8); | |||
3264 | ||||
3265 | /* Vector types. */ | |||
3266 | builtin_type_vec64 = build_builtin_type_vec64 (); | |||
3267 | builtin_type_vec64i = build_builtin_type_vec64i (); | |||
3268 | builtin_type_vec128 = build_builtin_type_vec128 (); | |||
3269 | builtin_type_vec128i = build_builtin_type_vec128i (); | |||
3270 | ||||
3271 | /* Pointer/Address types. */ | |||
3272 | ||||
3273 | /* NOTE: on some targets, addresses and pointers are not necessarily | |||
3274 | the same --- for example, on the D10V, pointers are 16 bits long, | |||
3275 | but addresses are 32 bits long. See doc/gdbint.texinfo, | |||
3276 | ``Pointers Are Not Always Addresses''. | |||
3277 | ||||
3278 | The upshot is: | |||
3279 | - gdb's `struct type' always describes the target's | |||
3280 | representation. | |||
3281 | - gdb's `struct value' objects should always hold values in | |||
3282 | target form. | |||
3283 | - gdb's CORE_ADDR values are addresses in the unified virtual | |||
3284 | address space that the assembler and linker work with. Thus, | |||
3285 | since target_read_memory takes a CORE_ADDR as an argument, it | |||
3286 | can access any memory on the target, even if the processor has | |||
3287 | separate code and data address spaces. | |||
3288 | ||||
3289 | So, for example: | |||
3290 | - If v is a value holding a D10V code pointer, its contents are | |||
3291 | in target form: a big-endian address left-shifted two bits. | |||
3292 | - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as | |||
3293 | sizeof (void *) == 2 on the target. | |||
3294 | ||||
3295 | In this context, builtin_type_CORE_ADDR is a bit odd: it's a | |||
3296 | target type for a value the target will never see. It's only | |||
3297 | used to hold the values of (typeless) linker symbols, which are | |||
3298 | indeed in the unified virtual address space. */ | |||
3299 | builtin_type_void_data_ptr = make_pointer_type (builtin_type_void, NULL((void*)0)); | |||
3300 | builtin_type_void_func_ptr | |||
3301 | = lookup_pointer_type (lookup_function_type (builtin_type_void)); | |||
3302 | builtin_type_CORE_ADDR = | |||
3303 | init_type (TYPE_CODE_INT, TARGET_ADDR_BIT(gdbarch_addr_bit (current_gdbarch)) / 8, | |||
3304 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3305 | "__CORE_ADDR", (struct objfile *) NULL((void*)0)); | |||
3306 | builtin_type_bfd_vma = | |||
3307 | init_type (TYPE_CODE_INT, TARGET_BFD_VMA_BIT(gdbarch_bfd_vma_bit (current_gdbarch)) / 8, | |||
3308 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3309 | "__bfd_vma", (struct objfile *) NULL((void*)0)); | |||
3310 | } | |||
3311 | ||||
3312 | static struct gdbarch_data *gdbtypes_data; | |||
3313 | ||||
3314 | const struct builtin_type * | |||
3315 | builtin_type (struct gdbarch *gdbarch) | |||
3316 | { | |||
3317 | return gdbarch_data (gdbarch, gdbtypes_data); | |||
3318 | } | |||
3319 | ||||
3320 | ||||
3321 | static struct type * | |||
3322 | build_flt (int bit, char *name, const struct floatformat *floatformat) | |||
3323 | { | |||
3324 | struct type *t; | |||
3325 | if (bit <= 0 || floatformat == NULL((void*)0)) | |||
3326 | { | |||
3327 | gdb_assert (builtin_type_error != NULL)((void) ((builtin_type_error != ((void*)0)) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c", 3327, "%s: Assertion `%s' failed." , __PRETTY_FUNCTION__, "builtin_type_error != NULL"), 0))); | |||
3328 | return builtin_type_error; | |||
3329 | } | |||
3330 | t = init_type (TYPE_CODE_FLT, bit / TARGET_CHAR_BIT8, | |||
3331 | 0, name, (struct objfile *) NULL((void*)0)); | |||
3332 | TYPE_FLOATFORMAT (t)(t)->main_type->type_specific.floatformat = floatformat; | |||
3333 | return t; | |||
3334 | } | |||
3335 | ||||
3336 | static struct type * | |||
3337 | build_complex (int bit, char *name, struct type *target_type) | |||
3338 | { | |||
3339 | struct type *t; | |||
3340 | if (bit <= 0 || target_type == builtin_type_error) | |||
3341 | { | |||
3342 | gdb_assert (builtin_type_error != NULL)((void) ((builtin_type_error != ((void*)0)) ? 0 : (internal_error ("/usr/src/gnu/usr.bin/binutils/gdb/gdbtypes.c", 3342, "%s: Assertion `%s' failed." , __PRETTY_FUNCTION__, "builtin_type_error != NULL"), 0))); | |||
3343 | return builtin_type_error; | |||
3344 | } | |||
3345 | t = init_type (TYPE_CODE_COMPLEX, 2 * bit / TARGET_CHAR_BIT8, | |||
3346 | 0, name, (struct objfile *) NULL((void*)0)); | |||
3347 | TYPE_TARGET_TYPE (t)(t)->main_type->target_type = target_type; | |||
3348 | return t; | |||
3349 | } | |||
3350 | ||||
3351 | static void * | |||
3352 | gdbtypes_post_init (struct gdbarch *gdbarch) | |||
3353 | { | |||
3354 | struct builtin_type *builtin_type | |||
3355 | = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_type)((struct builtin_type *) gdbarch_obstack_zalloc ((gdbarch), sizeof (struct builtin_type))); | |||
3356 | ||||
3357 | builtin_type->builtin_void = | |||
3358 | init_type (TYPE_CODE_VOID, 1, | |||
3359 | 0, | |||
3360 | "void", (struct objfile *) NULL((void*)0)); | |||
3361 | builtin_type->builtin_char = | |||
3362 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3363 | (TYPE_FLAG_NOSIGN(1 << 1) | |||
3364 | | (TARGET_CHAR_SIGNED(gdbarch_char_signed (current_gdbarch)) ? 0 : TYPE_FLAG_UNSIGNED(1 << 0))), | |||
3365 | "char", (struct objfile *) NULL((void*)0)); | |||
3366 | builtin_type->builtin_true_char = | |||
3367 | init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3368 | 0, | |||
3369 | "true character", (struct objfile *) NULL((void*)0)); | |||
3370 | builtin_type->builtin_signed_char = | |||
3371 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3372 | 0, | |||
3373 | "signed char", (struct objfile *) NULL((void*)0)); | |||
3374 | builtin_type->builtin_unsigned_char = | |||
3375 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3376 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3377 | "unsigned char", (struct objfile *) NULL((void*)0)); | |||
3378 | builtin_type->builtin_short = | |||
3379 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT(gdbarch_short_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3380 | 0, | |||
3381 | "short", (struct objfile *) NULL((void*)0)); | |||
3382 | builtin_type->builtin_unsigned_short = | |||
3383 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT(gdbarch_short_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3384 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3385 | "unsigned short", (struct objfile *) NULL((void*)0)); | |||
3386 | builtin_type->builtin_int = | |||
3387 | init_type (TYPE_CODE_INT, TARGET_INT_BIT(gdbarch_int_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3388 | 0, | |||
3389 | "int", (struct objfile *) NULL((void*)0)); | |||
3390 | builtin_type->builtin_unsigned_int = | |||
3391 | init_type (TYPE_CODE_INT, TARGET_INT_BIT(gdbarch_int_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3392 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3393 | "unsigned int", (struct objfile *) NULL((void*)0)); | |||
3394 | builtin_type->builtin_long = | |||
3395 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT(gdbarch_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3396 | 0, | |||
3397 | "long", (struct objfile *) NULL((void*)0)); | |||
3398 | builtin_type->builtin_unsigned_long = | |||
3399 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT(gdbarch_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3400 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3401 | "unsigned long", (struct objfile *) NULL((void*)0)); | |||
3402 | builtin_type->builtin_long_long = | |||
3403 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT(gdbarch_long_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3404 | 0, | |||
3405 | "long long", (struct objfile *) NULL((void*)0)); | |||
3406 | builtin_type->builtin_unsigned_long_long = | |||
3407 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT(gdbarch_long_long_bit (current_gdbarch)) / TARGET_CHAR_BIT8, | |||
3408 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3409 | "unsigned long long", (struct objfile *) NULL((void*)0)); | |||
3410 | builtin_type->builtin_float | |||
3411 | = build_flt (gdbarch_float_bit (gdbarch), "float", | |||
3412 | gdbarch_float_format (gdbarch)); | |||
3413 | builtin_type->builtin_double | |||
3414 | = build_flt (gdbarch_double_bit (gdbarch), "double", | |||
3415 | gdbarch_double_format (gdbarch)); | |||
3416 | builtin_type->builtin_long_double | |||
3417 | = build_flt (gdbarch_long_double_bit (gdbarch), "long double", | |||
3418 | gdbarch_long_double_format (gdbarch)); | |||
3419 | builtin_type->builtin_complex | |||
3420 | = build_complex (gdbarch_float_bit (gdbarch), "complex", | |||
3421 | builtin_type->builtin_float); | |||
3422 | builtin_type->builtin_double_complex | |||
3423 | = build_complex (gdbarch_double_bit (gdbarch), "double complex", | |||
3424 | builtin_type->builtin_double); | |||
3425 | builtin_type->builtin_string = | |||
3426 | init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3427 | 0, | |||
3428 | "string", (struct objfile *) NULL((void*)0)); | |||
3429 | builtin_type->builtin_bool = | |||
3430 | init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT8 / TARGET_CHAR_BIT8, | |||
3431 | 0, | |||
3432 | "bool", (struct objfile *) NULL((void*)0)); | |||
3433 | ||||
3434 | /* Pointer/Address types. */ | |||
3435 | ||||
3436 | /* NOTE: on some targets, addresses and pointers are not necessarily | |||
3437 | the same --- for example, on the D10V, pointers are 16 bits long, | |||
3438 | but addresses are 32 bits long. See doc/gdbint.texinfo, | |||
3439 | ``Pointers Are Not Always Addresses''. | |||
3440 | ||||
3441 | The upshot is: | |||
3442 | - gdb's `struct type' always describes the target's | |||
3443 | representation. | |||
3444 | - gdb's `struct value' objects should always hold values in | |||
3445 | target form. | |||
3446 | - gdb's CORE_ADDR values are addresses in the unified virtual | |||
3447 | address space that the assembler and linker work with. Thus, | |||
3448 | since target_read_memory takes a CORE_ADDR as an argument, it | |||
3449 | can access any memory on the target, even if the processor has | |||
3450 | separate code and data address spaces. | |||
3451 | ||||
3452 | So, for example: | |||
3453 | - If v is a value holding a D10V code pointer, its contents are | |||
3454 | in target form: a big-endian address left-shifted two bits. | |||
3455 | - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as | |||
3456 | sizeof (void *) == 2 on the target. | |||
3457 | ||||
3458 | In this context, builtin_type->CORE_ADDR is a bit odd: it's a | |||
3459 | target type for a value the target will never see. It's only | |||
3460 | used to hold the values of (typeless) linker symbols, which are | |||
3461 | indeed in the unified virtual address space. */ | |||
3462 | builtin_type->builtin_data_ptr | |||
3463 | = make_pointer_type (builtin_type->builtin_void, NULL((void*)0)); | |||
3464 | builtin_type->builtin_func_ptr | |||
3465 | = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void)); | |||
3466 | builtin_type->builtin_core_addr = | |||
3467 | init_type (TYPE_CODE_INT, TARGET_ADDR_BIT(gdbarch_addr_bit (current_gdbarch)) / 8, | |||
3468 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3469 | "__CORE_ADDR", (struct objfile *) NULL((void*)0)); | |||
3470 | ||||
3471 | return builtin_type; | |||
3472 | } | |||
3473 | ||||
3474 | extern void _initialize_gdbtypes (void); | |||
3475 | void | |||
3476 | _initialize_gdbtypes (void) | |||
3477 | { | |||
3478 | struct cmd_list_element *c; | |||
3479 | ||||
3480 | builtin_type_int0 = | |||
3481 | init_type (TYPE_CODE_INT, 0 / 8, | |||
3482 | 0, | |||
3483 | "int0_t", (struct objfile *) NULL((void*)0)); | |||
3484 | builtin_type_int8 = | |||
3485 | init_type (TYPE_CODE_INT, 8 / 8, | |||
3486 | 0, | |||
3487 | "int8_t", (struct objfile *) NULL((void*)0)); | |||
3488 | builtin_type_uint8 = | |||
3489 | init_type (TYPE_CODE_INT, 8 / 8, | |||
3490 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3491 | "uint8_t", (struct objfile *) NULL((void*)0)); | |||
3492 | builtin_type_int16 = | |||
3493 | init_type (TYPE_CODE_INT, 16 / 8, | |||
3494 | 0, | |||
3495 | "int16_t", (struct objfile *) NULL((void*)0)); | |||
3496 | builtin_type_uint16 = | |||
3497 | init_type (TYPE_CODE_INT, 16 / 8, | |||
3498 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3499 | "uint16_t", (struct objfile *) NULL((void*)0)); | |||
3500 | builtin_type_int32 = | |||
3501 | init_type (TYPE_CODE_INT, 32 / 8, | |||
3502 | 0, | |||
3503 | "int32_t", (struct objfile *) NULL((void*)0)); | |||
3504 | builtin_type_uint32 = | |||
3505 | init_type (TYPE_CODE_INT, 32 / 8, | |||
3506 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3507 | "uint32_t", (struct objfile *) NULL((void*)0)); | |||
3508 | builtin_type_int64 = | |||
3509 | init_type (TYPE_CODE_INT, 64 / 8, | |||
3510 | 0, | |||
3511 | "int64_t", (struct objfile *) NULL((void*)0)); | |||
3512 | builtin_type_uint64 = | |||
3513 | init_type (TYPE_CODE_INT, 64 / 8, | |||
3514 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3515 | "uint64_t", (struct objfile *) NULL((void*)0)); | |||
3516 | builtin_type_int128 = | |||
3517 | init_type (TYPE_CODE_INT, 128 / 8, | |||
3518 | 0, | |||
3519 | "int128_t", (struct objfile *) NULL((void*)0)); | |||
3520 | builtin_type_uint128 = | |||
3521 | init_type (TYPE_CODE_INT, 128 / 8, | |||
3522 | TYPE_FLAG_UNSIGNED(1 << 0), | |||
3523 | "uint128_t", (struct objfile *) NULL((void*)0)); | |||
3524 | ||||
3525 | build_gdbtypes (); | |||
3526 | ||||
3527 | gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); | |||
3528 | ||||
3529 | /* FIXME - For the moment, handle types by swapping them in and out. | |||
3530 | Should be using the per-architecture data-pointer and a large | |||
3531 | struct. */ | |||
3532 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void)deprecated_register_gdbarch_swap (&(builtin_type_void), sizeof ((builtin_type_void)), ((void*)0)); | |||
3533 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_char)deprecated_register_gdbarch_swap (&(builtin_type_char), sizeof ((builtin_type_char)), ((void*)0)); | |||
3534 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_short)deprecated_register_gdbarch_swap (&(builtin_type_short), sizeof ((builtin_type_short)), ((void*)0)); | |||
3535 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_int)deprecated_register_gdbarch_swap (&(builtin_type_int), sizeof ((builtin_type_int)), ((void*)0)); | |||
3536 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long)deprecated_register_gdbarch_swap (&(builtin_type_long), sizeof ((builtin_type_long)), ((void*)0)); | |||
3537 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_long)deprecated_register_gdbarch_swap (&(builtin_type_long_long ), sizeof ((builtin_type_long_long)), ((void*)0)); | |||
3538 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_signed_char)deprecated_register_gdbarch_swap (&(builtin_type_signed_char ), sizeof ((builtin_type_signed_char)), ((void*)0)); | |||
3539 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_char)deprecated_register_gdbarch_swap (&(builtin_type_unsigned_char ), sizeof ((builtin_type_unsigned_char)), ((void*)0)); | |||
3540 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_short)deprecated_register_gdbarch_swap (&(builtin_type_unsigned_short ), sizeof ((builtin_type_unsigned_short)), ((void*)0)); | |||
3541 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_int)deprecated_register_gdbarch_swap (&(builtin_type_unsigned_int ), sizeof ((builtin_type_unsigned_int)), ((void*)0)); | |||
3542 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long)deprecated_register_gdbarch_swap (&(builtin_type_unsigned_long ), sizeof ((builtin_type_unsigned_long)), ((void*)0)); | |||
3543 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long_long)deprecated_register_gdbarch_swap (&(builtin_type_unsigned_long_long ), sizeof ((builtin_type_unsigned_long_long)), ((void*)0)); | |||
3544 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_float)deprecated_register_gdbarch_swap (&(builtin_type_float), sizeof ((builtin_type_float)), ((void*)0)); | |||
3545 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double)deprecated_register_gdbarch_swap (&(builtin_type_double), sizeof ((builtin_type_double)), ((void*)0)); | |||
3546 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_double)deprecated_register_gdbarch_swap (&(builtin_type_long_double ), sizeof ((builtin_type_long_double)), ((void*)0)); | |||
3547 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_complex)deprecated_register_gdbarch_swap (&(builtin_type_complex) , sizeof ((builtin_type_complex)), ((void*)0)); | |||
3548 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double_complex)deprecated_register_gdbarch_swap (&(builtin_type_double_complex ), sizeof ((builtin_type_double_complex)), ((void*)0)); | |||
3549 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_string)deprecated_register_gdbarch_swap (&(builtin_type_string), sizeof ((builtin_type_string)), ((void*)0)); | |||
3550 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4sf)deprecated_register_gdbarch_swap (&(builtin_type_v4sf), sizeof ((builtin_type_v4sf)), ((void*)0)); | |||
3551 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4si)deprecated_register_gdbarch_swap (&(builtin_type_v4si), sizeof ((builtin_type_v4si)), ((void*)0)); | |||
3552 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16qi)deprecated_register_gdbarch_swap (&(builtin_type_v16qi), sizeof ((builtin_type_v16qi)), ((void*)0)); | |||
3553 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8qi)deprecated_register_gdbarch_swap (&(builtin_type_v8qi), sizeof ((builtin_type_v8qi)), ((void*)0)); | |||
3554 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8hi)deprecated_register_gdbarch_swap (&(builtin_type_v8hi), sizeof ((builtin_type_v8hi)), ((void*)0)); | |||
3555 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4hi)deprecated_register_gdbarch_swap (&(builtin_type_v4hi), sizeof ((builtin_type_v4hi)), ((void*)0)); | |||
3556 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2si)deprecated_register_gdbarch_swap (&(builtin_type_v2si), sizeof ((builtin_type_v2si)), ((void*)0)); | |||
3557 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_double)deprecated_register_gdbarch_swap (&(builtin_type_v2_double ), sizeof ((builtin_type_v2_double)), ((void*)0)); | |||
3558 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_float)deprecated_register_gdbarch_swap (&(builtin_type_v4_float ), sizeof ((builtin_type_v4_float)), ((void*)0)); | |||
3559 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int64)deprecated_register_gdbarch_swap (&(builtin_type_v2_int64 ), sizeof ((builtin_type_v2_int64)), ((void*)0)); | |||
3560 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int32)deprecated_register_gdbarch_swap (&(builtin_type_v4_int32 ), sizeof ((builtin_type_v4_int32)), ((void*)0)); | |||
3561 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int16)deprecated_register_gdbarch_swap (&(builtin_type_v8_int16 ), sizeof ((builtin_type_v8_int16)), ((void*)0)); | |||
3562 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16_int8)deprecated_register_gdbarch_swap (&(builtin_type_v16_int8 ), sizeof ((builtin_type_v16_int8)), ((void*)0)); | |||
3563 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_float)deprecated_register_gdbarch_swap (&(builtin_type_v2_float ), sizeof ((builtin_type_v2_float)), ((void*)0)); | |||
3564 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int32)deprecated_register_gdbarch_swap (&(builtin_type_v2_int32 ), sizeof ((builtin_type_v2_int32)), ((void*)0)); | |||
3565 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int8)deprecated_register_gdbarch_swap (&(builtin_type_v8_int8) , sizeof ((builtin_type_v8_int8)), ((void*)0)); | |||
3566 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int16)deprecated_register_gdbarch_swap (&(builtin_type_v4_int16 ), sizeof ((builtin_type_v4_int16)), ((void*)0)); | |||
3567 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_vec128)deprecated_register_gdbarch_swap (&(builtin_type_vec128), sizeof ((builtin_type_vec128)), ((void*)0)); | |||
3568 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_vec128i)deprecated_register_gdbarch_swap (&(builtin_type_vec128i) , sizeof ((builtin_type_vec128i)), ((void*)0)); | |||
3569 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr)deprecated_register_gdbarch_swap (&(builtin_type_void_data_ptr ), sizeof ((builtin_type_void_data_ptr)), ((void*)0)); | |||
3570 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr)deprecated_register_gdbarch_swap (&(builtin_type_void_func_ptr ), sizeof ((builtin_type_void_func_ptr)), ((void*)0)); | |||
3571 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR)deprecated_register_gdbarch_swap (&(builtin_type_CORE_ADDR ), sizeof ((builtin_type_CORE_ADDR)), ((void*)0)); | |||
3572 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma)deprecated_register_gdbarch_swap (&(builtin_type_bfd_vma) , sizeof ((builtin_type_bfd_vma)), ((void*)0)); | |||
3573 | deprecated_register_gdbarch_swap (NULL((void*)0), 0, build_gdbtypes); | |||
3574 | ||||
3575 | /* Note: These types do not need to be swapped - they are target | |||
3576 | neutral. */ | |||
3577 | builtin_type_ieee_single_big = | |||
3578 | init_type (TYPE_CODE_FLT, floatformat_ieee_single_big.totalsize / 8, | |||
3579 | 0, "builtin_type_ieee_single_big", NULL((void*)0)); | |||
3580 | TYPE_FLOATFORMAT (builtin_type_ieee_single_big)(builtin_type_ieee_single_big)->main_type->type_specific .floatformat = &floatformat_ieee_single_big; | |||
3581 | builtin_type_ieee_single_little = | |||
3582 | init_type (TYPE_CODE_FLT, floatformat_ieee_single_little.totalsize / 8, | |||
3583 | 0, "builtin_type_ieee_single_little", NULL((void*)0)); | |||
3584 | TYPE_FLOATFORMAT (builtin_type_ieee_single_little)(builtin_type_ieee_single_little)->main_type->type_specific .floatformat = &floatformat_ieee_single_little; | |||
3585 | builtin_type_ieee_single[BFD_ENDIAN_BIG] | |||
3586 | = build_flt (floatformat_ieee_single_big.totalsize, | |||
3587 | "builtin_type_ieee_single_big", | |||
3588 | &floatformat_ieee_single_big); | |||
3589 | builtin_type_ieee_single[BFD_ENDIAN_LITTLE] | |||
3590 | = build_flt (floatformat_ieee_single_little.totalsize, | |||
3591 | "builtin_type_ieee_single_little", | |||
3592 | &floatformat_ieee_single_little); | |||
3593 | builtin_type_ieee_double_big = | |||
3594 | init_type (TYPE_CODE_FLT, floatformat_ieee_double_big.totalsize / 8, | |||
3595 | 0, "builtin_type_ieee_double_big", NULL((void*)0)); | |||
3596 | TYPE_FLOATFORMAT (builtin_type_ieee_double_big)(builtin_type_ieee_double_big)->main_type->type_specific .floatformat = &floatformat_ieee_double_big; | |||
3597 | builtin_type_ieee_double_little = | |||
3598 | init_type (TYPE_CODE_FLT, floatformat_ieee_double_little.totalsize / 8, | |||
3599 | 0, "builtin_type_ieee_double_little", NULL((void*)0)); | |||
3600 | TYPE_FLOATFORMAT (builtin_type_ieee_double_little)(builtin_type_ieee_double_little)->main_type->type_specific .floatformat = &floatformat_ieee_double_little; | |||
3601 | builtin_type_ieee_double[BFD_ENDIAN_BIG] | |||
3602 | = build_flt (floatformat_ieee_double_big.totalsize, | |||
3603 | "builtin_type_ieee_double_big", | |||
3604 | &floatformat_ieee_double_big); | |||
3605 | builtin_type_ieee_double[BFD_ENDIAN_LITTLE] | |||
3606 | = build_flt (floatformat_ieee_double_little.totalsize, | |||
3607 | "builtin_type_ieee_double_little", | |||
3608 | &floatformat_ieee_double_little); | |||
3609 | builtin_type_ieee_double_littlebyte_bigword = | |||
3610 | init_type (TYPE_CODE_FLT, floatformat_ieee_double_littlebyte_bigword.totalsize / 8, | |||
3611 | 0, "builtin_type_ieee_double_littlebyte_bigword", NULL((void*)0)); | |||
3612 | TYPE_FLOATFORMAT (builtin_type_ieee_double_littlebyte_bigword)(builtin_type_ieee_double_littlebyte_bigword)->main_type-> type_specific.floatformat = &floatformat_ieee_double_littlebyte_bigword; | |||
3613 | builtin_type_i387_ext = | |||
3614 | init_type (TYPE_CODE_FLT, floatformat_i387_ext.totalsize / 8, | |||
3615 | 0, "builtin_type_i387_ext", NULL((void*)0)); | |||
3616 | TYPE_FLOATFORMAT (builtin_type_i387_ext)(builtin_type_i387_ext)->main_type->type_specific.floatformat = &floatformat_i387_ext; | |||
3617 | builtin_type_m68881_ext = | |||
3618 | init_type (TYPE_CODE_FLT, floatformat_m68881_ext.totalsize / 8, | |||
3619 | 0, "builtin_type_m68881_ext", NULL((void*)0)); | |||
3620 | TYPE_FLOATFORMAT (builtin_type_m68881_ext)(builtin_type_m68881_ext)->main_type->type_specific.floatformat = &floatformat_m68881_ext; | |||
3621 | builtin_type_i960_ext = | |||
3622 | init_type (TYPE_CODE_FLT, floatformat_i960_ext.totalsize / 8, | |||
3623 | 0, "builtin_type_i960_ext", NULL((void*)0)); | |||
3624 | TYPE_FLOATFORMAT (builtin_type_i960_ext)(builtin_type_i960_ext)->main_type->type_specific.floatformat = &floatformat_i960_ext; | |||
3625 | builtin_type_m88110_ext = | |||
3626 | init_type (TYPE_CODE_FLT, floatformat_m88110_ext.totalsize / 8, | |||
3627 | 0, "builtin_type_m88110_ext", NULL((void*)0)); | |||
3628 | TYPE_FLOATFORMAT (builtin_type_m88110_ext)(builtin_type_m88110_ext)->main_type->type_specific.floatformat = &floatformat_m88110_ext; | |||
3629 | builtin_type_m88110_harris_ext = | |||
3630 | init_type (TYPE_CODE_FLT, floatformat_m88110_harris_ext.totalsize / 8, | |||
3631 | 0, "builtin_type_m88110_harris_ext", NULL((void*)0)); | |||
3632 | TYPE_FLOATFORMAT (builtin_type_m88110_harris_ext)(builtin_type_m88110_harris_ext)->main_type->type_specific .floatformat = &floatformat_m88110_harris_ext; | |||
3633 | builtin_type_arm_ext_big = | |||
3634 | init_type (TYPE_CODE_FLT, floatformat_arm_ext_big.totalsize / 8, | |||
3635 | 0, "builtin_type_arm_ext_big", NULL((void*)0)); | |||
3636 | TYPE_FLOATFORMAT (builtin_type_arm_ext_big)(builtin_type_arm_ext_big)->main_type->type_specific.floatformat = &floatformat_arm_ext_big; | |||
3637 | builtin_type_arm_ext_littlebyte_bigword = | |||
3638 | init_type (TYPE_CODE_FLT, floatformat_arm_ext_littlebyte_bigword.totalsize / 8, | |||
3639 | 0, "builtin_type_arm_ext_littlebyte_bigword", NULL((void*)0)); | |||
3640 | TYPE_FLOATFORMAT (builtin_type_arm_ext_littlebyte_bigword)(builtin_type_arm_ext_littlebyte_bigword)->main_type->type_specific .floatformat = &floatformat_arm_ext_littlebyte_bigword; | |||
3641 | builtin_type_arm_ext[BFD_ENDIAN_BIG] | |||
3642 | = build_flt (floatformat_arm_ext_big.totalsize, | |||
3643 | "builtin_type_arm_ext_big", | |||
3644 | &floatformat_arm_ext_big); | |||
3645 | builtin_type_arm_ext[BFD_ENDIAN_LITTLE] | |||
3646 | = build_flt (floatformat_arm_ext_littlebyte_bigword.totalsize, | |||
3647 | "builtin_type_arm_ext_littlebyte_bigword", | |||
3648 | &floatformat_arm_ext_littlebyte_bigword); | |||
3649 | builtin_type_ia64_spill_big = | |||
3650 | init_type (TYPE_CODE_FLT, floatformat_ia64_spill_big.totalsize / 8, | |||
3651 | 0, "builtin_type_ia64_spill_big", NULL((void*)0)); | |||
3652 | TYPE_FLOATFORMAT (builtin_type_ia64_spill_big)(builtin_type_ia64_spill_big)->main_type->type_specific .floatformat = &floatformat_ia64_spill_big; | |||
3653 | builtin_type_ia64_spill_little = | |||
3654 | init_type (TYPE_CODE_FLT, floatformat_ia64_spill_little.totalsize / 8, | |||
3655 | 0, "builtin_type_ia64_spill_little", NULL((void*)0)); | |||
3656 | TYPE_FLOATFORMAT (builtin_type_ia64_spill_little)(builtin_type_ia64_spill_little)->main_type->type_specific .floatformat = &floatformat_ia64_spill_little; | |||
3657 | builtin_type_ia64_spill[BFD_ENDIAN_BIG] | |||
3658 | = build_flt (floatformat_ia64_spill_big.totalsize, | |||
3659 | "builtin_type_ia64_spill_big", | |||
3660 | &floatformat_ia64_spill_big); | |||
3661 | builtin_type_ia64_spill[BFD_ENDIAN_LITTLE] | |||
3662 | = build_flt (floatformat_ia64_spill_little.totalsize, | |||
3663 | "builtin_type_ia64_spill_little", | |||
3664 | &floatformat_ia64_spill_little); | |||
3665 | builtin_type_ia64_quad_big = | |||
3666 | init_type (TYPE_CODE_FLT, floatformat_ia64_quad_big.totalsize / 8, | |||
3667 | 0, "builtin_type_ia64_quad_big", NULL((void*)0)); | |||
3668 | TYPE_FLOATFORMAT (builtin_type_ia64_quad_big)(builtin_type_ia64_quad_big)->main_type->type_specific. floatformat = &floatformat_ia64_quad_big; | |||
3669 | builtin_type_ia64_quad_little = | |||
3670 | init_type (TYPE_CODE_FLT, floatformat_ia64_quad_little.totalsize / 8, | |||
3671 | 0, "builtin_type_ia64_quad_little", NULL((void*)0)); | |||
3672 | TYPE_FLOATFORMAT (builtin_type_ia64_quad_little)(builtin_type_ia64_quad_little)->main_type->type_specific .floatformat = &floatformat_ia64_quad_little; | |||
3673 | builtin_type_ia64_quad[BFD_ENDIAN_BIG] | |||
3674 | = build_flt (floatformat_ia64_quad_big.totalsize, | |||
3675 | "builtin_type_ia64_quad_big", | |||
3676 | &floatformat_ia64_quad_big); | |||
3677 | builtin_type_ia64_quad[BFD_ENDIAN_LITTLE] | |||
3678 | = build_flt (floatformat_ia64_quad_little.totalsize, | |||
3679 | "builtin_type_ia64_quad_little", | |||
3680 | &floatformat_ia64_quad_little); | |||
3681 | ||||
3682 | deprecated_add_show_from_set | |||
3683 | (add_set_cmd ("overload", no_class, var_zinteger, (char *) &overload_debug, | |||
3684 | "Set debugging of C++ overloading.\n\ | |||
3685 | When enabled, ranking of the functions is displayed.", &setdebuglist), | |||
3686 | &showdebuglist); | |||
3687 | } |