]>
Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Support routines for decoding "stabs" debugging information format. |
2 | Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998 | |
c5aa993b | 3 | Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
c906108c | 11 | |
c5aa993b JM |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
c906108c | 16 | |
c5aa993b JM |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
21 | |
22 | /* Support routines for reading and decoding debugging information in | |
23 | the "stabs" format. This format is used with many systems that use | |
24 | the a.out object file format, as well as some systems that use | |
25 | COFF or ELF where the stabs data is placed in a special section. | |
26 | Avoid placing any object file format specific code in this file. */ | |
27 | ||
28 | #include "defs.h" | |
29 | #include "gdb_string.h" | |
30 | #include "bfd.h" | |
31 | #include "obstack.h" | |
32 | #include "symtab.h" | |
33 | #include "gdbtypes.h" | |
34 | #include "expression.h" | |
35 | #include "symfile.h" | |
36 | #include "objfiles.h" | |
37 | #include "aout/stab_gnu.h" /* We always use GNU stabs, not native */ | |
38 | #include "libaout.h" | |
39 | #include "aout/aout64.h" | |
40 | #include "gdb-stabs.h" | |
41 | #include "buildsym.h" | |
42 | #include "complaints.h" | |
43 | #include "demangle.h" | |
44 | #include "language.h" | |
45 | ||
46 | #include <ctype.h> | |
47 | ||
48 | /* Ask stabsread.h to define the vars it normally declares `extern'. */ | |
c5aa993b JM |
49 | #define EXTERN |
50 | /**/ | |
c906108c SS |
51 | #include "stabsread.h" /* Our own declarations */ |
52 | #undef EXTERN | |
53 | ||
392a587b JM |
54 | extern void _initialize_stabsread PARAMS ((void)); |
55 | ||
c906108c SS |
56 | /* The routines that read and process a complete stabs for a C struct or |
57 | C++ class pass lists of data member fields and lists of member function | |
58 | fields in an instance of a field_info structure, as defined below. | |
59 | This is part of some reorganization of low level C++ support and is | |
60 | expected to eventually go away... (FIXME) */ | |
61 | ||
62 | struct field_info | |
c5aa993b JM |
63 | { |
64 | struct nextfield | |
65 | { | |
66 | struct nextfield *next; | |
c906108c | 67 | |
c5aa993b JM |
68 | /* This is the raw visibility from the stab. It is not checked |
69 | for being one of the visibilities we recognize, so code which | |
70 | examines this field better be able to deal. */ | |
71 | int visibility; | |
c906108c | 72 | |
c5aa993b JM |
73 | struct field field; |
74 | } | |
75 | *list; | |
76 | struct next_fnfieldlist | |
77 | { | |
78 | struct next_fnfieldlist *next; | |
79 | struct fn_fieldlist fn_fieldlist; | |
80 | } | |
81 | *fnlist; | |
82 | }; | |
c906108c SS |
83 | |
84 | static void | |
85 | read_one_struct_field PARAMS ((struct field_info *, char **, char *, | |
86 | struct type *, struct objfile *)); | |
87 | ||
c5aa993b JM |
88 | static char * |
89 | get_substring PARAMS ((char **, int)); | |
c906108c SS |
90 | |
91 | static struct type * | |
c5aa993b | 92 | dbx_alloc_type PARAMS ((int[2], struct objfile *)); |
c906108c | 93 | |
c2d11a7d | 94 | static long read_huge_number PARAMS ((char **, int, int *)); |
c906108c SS |
95 | |
96 | static struct type *error_type PARAMS ((char **, struct objfile *)); | |
97 | ||
98 | static void | |
99 | patch_block_stabs PARAMS ((struct pending *, struct pending_stabs *, | |
100 | struct objfile *)); | |
101 | ||
102 | static void | |
103 | fix_common_block PARAMS ((struct symbol *, int)); | |
104 | ||
105 | static int | |
106 | read_type_number PARAMS ((char **, int *)); | |
107 | ||
108 | static struct type * | |
c5aa993b | 109 | read_range_type PARAMS ((char **, int[2], struct objfile *)); |
c906108c SS |
110 | |
111 | static struct type * | |
c5aa993b | 112 | read_sun_builtin_type PARAMS ((char **, int[2], struct objfile *)); |
c906108c SS |
113 | |
114 | static struct type * | |
c5aa993b | 115 | read_sun_floating_type PARAMS ((char **, int[2], struct objfile *)); |
c906108c SS |
116 | |
117 | static struct type * | |
c5aa993b | 118 | read_enum_type PARAMS ((char **, struct type *, struct objfile *)); |
c906108c SS |
119 | |
120 | static struct type * | |
c5aa993b | 121 | rs6000_builtin_type PARAMS ((int)); |
c906108c SS |
122 | |
123 | static int | |
124 | read_member_functions PARAMS ((struct field_info *, char **, struct type *, | |
125 | struct objfile *)); | |
126 | ||
127 | static int | |
128 | read_struct_fields PARAMS ((struct field_info *, char **, struct type *, | |
129 | struct objfile *)); | |
130 | ||
131 | static int | |
132 | read_baseclasses PARAMS ((struct field_info *, char **, struct type *, | |
133 | struct objfile *)); | |
134 | ||
135 | static int | |
136 | read_tilde_fields PARAMS ((struct field_info *, char **, struct type *, | |
137 | struct objfile *)); | |
138 | ||
139 | static int | |
140 | attach_fn_fields_to_type PARAMS ((struct field_info *, struct type *)); | |
141 | ||
142 | static int | |
143 | attach_fields_to_type PARAMS ((struct field_info *, struct type *, | |
144 | struct objfile *)); | |
145 | ||
146 | static struct type * | |
c5aa993b | 147 | read_struct_type PARAMS ((char **, struct type *, struct objfile *)); |
c906108c SS |
148 | |
149 | static struct type * | |
c5aa993b | 150 | read_array_type PARAMS ((char **, struct type *, struct objfile *)); |
c906108c SS |
151 | |
152 | static struct type ** | |
c5aa993b | 153 | read_args PARAMS ((char **, int, struct objfile *)); |
c906108c SS |
154 | |
155 | static int | |
156 | read_cpp_abbrev PARAMS ((struct field_info *, char **, struct type *, | |
157 | struct objfile *)); | |
158 | ||
159 | /* new functions added for cfront support */ | |
160 | ||
161 | static int | |
162 | copy_cfront_struct_fields PARAMS ((struct field_info *, struct type *, | |
c5aa993b | 163 | struct objfile *)); |
c906108c SS |
164 | |
165 | static char * | |
c5aa993b | 166 | get_cfront_method_physname PARAMS ((char *)); |
c906108c SS |
167 | |
168 | static int | |
c5aa993b | 169 | read_cfront_baseclasses PARAMS ((struct field_info *, char **, |
c906108c SS |
170 | struct type *, struct objfile *)); |
171 | ||
172 | static int | |
c5aa993b | 173 | read_cfront_static_fields PARAMS ((struct field_info *, char **, |
c906108c SS |
174 | struct type *, struct objfile *)); |
175 | static int | |
c5aa993b | 176 | read_cfront_member_functions PARAMS ((struct field_info *, char **, |
c906108c SS |
177 | struct type *, struct objfile *)); |
178 | ||
179 | /* end new functions added for cfront support */ | |
180 | ||
181 | static void | |
c5aa993b | 182 | add_live_range PARAMS ((struct objfile *, struct symbol *, |
c906108c SS |
183 | CORE_ADDR, CORE_ADDR)); |
184 | ||
185 | static int | |
186 | resolve_live_range PARAMS ((struct objfile *, struct symbol *, char *)); | |
187 | ||
188 | static int | |
189 | process_reference PARAMS ((char **string)); | |
190 | ||
191 | static CORE_ADDR | |
c5aa993b | 192 | ref_search_value PARAMS ((int refnum)); |
c906108c SS |
193 | |
194 | static int | |
195 | resolve_symbol_reference PARAMS ((struct objfile *, struct symbol *, char *)); | |
196 | ||
7be570e7 JM |
197 | void stabsread_clear_cache PARAMS ((void)); |
198 | ||
c5aa993b JM |
199 | static const char vptr_name[] = |
200 | {'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'}; | |
201 | static const char vb_name[] = | |
202 | {'_', 'v', 'b', CPLUS_MARKER, '\0'}; | |
c906108c SS |
203 | |
204 | /* Define this as 1 if a pcc declaration of a char or short argument | |
205 | gives the correct address. Otherwise assume pcc gives the | |
206 | address of the corresponding int, which is not the same on a | |
207 | big-endian machine. */ | |
208 | ||
7a292a7a | 209 | #if !defined (BELIEVE_PCC_PROMOTION) |
c906108c SS |
210 | #define BELIEVE_PCC_PROMOTION 0 |
211 | #endif | |
7a292a7a SS |
212 | #if !defined (BELIEVE_PCC_PROMOTION_TYPE) |
213 | #define BELIEVE_PCC_PROMOTION_TYPE 0 | |
214 | #endif | |
c906108c SS |
215 | |
216 | static struct complaint invalid_cpp_abbrev_complaint = | |
c5aa993b | 217 | {"invalid C++ abbreviation `%s'", 0, 0}; |
c906108c SS |
218 | |
219 | static struct complaint invalid_cpp_type_complaint = | |
c5aa993b | 220 | {"C++ abbreviated type name unknown at symtab pos %d", 0, 0}; |
c906108c SS |
221 | |
222 | static struct complaint member_fn_complaint = | |
c5aa993b | 223 | {"member function type missing, got '%c'", 0, 0}; |
c906108c SS |
224 | |
225 | static struct complaint const_vol_complaint = | |
c5aa993b | 226 | {"const/volatile indicator missing, got '%c'", 0, 0}; |
c906108c SS |
227 | |
228 | static struct complaint error_type_complaint = | |
c5aa993b | 229 | {"debug info mismatch between compiler and debugger", 0, 0}; |
c906108c SS |
230 | |
231 | static struct complaint invalid_member_complaint = | |
c5aa993b | 232 | {"invalid (minimal) member type data format at symtab pos %d.", 0, 0}; |
c906108c SS |
233 | |
234 | static struct complaint range_type_base_complaint = | |
c5aa993b | 235 | {"base type %d of range type is not defined", 0, 0}; |
c906108c SS |
236 | |
237 | static struct complaint reg_value_complaint = | |
c5aa993b | 238 | {"register number %d too large (max %d) in symbol %s", 0, 0}; |
c906108c SS |
239 | |
240 | static struct complaint vtbl_notfound_complaint = | |
c5aa993b | 241 | {"virtual function table pointer not found when defining class `%s'", 0, 0}; |
c906108c SS |
242 | |
243 | static struct complaint unrecognized_cplus_name_complaint = | |
c5aa993b | 244 | {"Unknown C++ symbol name `%s'", 0, 0}; |
c906108c SS |
245 | |
246 | static struct complaint rs6000_builtin_complaint = | |
c5aa993b | 247 | {"Unknown builtin type %d", 0, 0}; |
c906108c SS |
248 | |
249 | static struct complaint unresolved_sym_chain_complaint = | |
c5aa993b | 250 | {"%s: common block `%s' from global_sym_chain unresolved", 0, 0}; |
c906108c SS |
251 | |
252 | static struct complaint stabs_general_complaint = | |
c5aa993b | 253 | {"%s", 0, 0}; |
c906108c SS |
254 | |
255 | static struct complaint lrs_general_complaint = | |
c5aa993b | 256 | {"%s", 0, 0}; |
c906108c SS |
257 | |
258 | /* Make a list of forward references which haven't been defined. */ | |
259 | ||
260 | static struct type **undef_types; | |
261 | static int undef_types_allocated; | |
262 | static int undef_types_length; | |
263 | static struct symbol *current_symbol = NULL; | |
264 | ||
265 | /* Check for and handle cretinous stabs symbol name continuation! */ | |
266 | #define STABS_CONTINUE(pp,objfile) \ | |
267 | do { \ | |
268 | if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \ | |
269 | *(pp) = next_symbol_text (objfile); \ | |
270 | } while (0) | |
271 | \f | |
272 | /* FIXME: These probably should be our own types (like rs6000_builtin_type | |
273 | has its own types) rather than builtin_type_*. */ | |
c5aa993b JM |
274 | static struct type **os9k_type_vector[] = |
275 | { | |
276 | 0, | |
277 | &builtin_type_int, | |
278 | &builtin_type_char, | |
279 | &builtin_type_long, | |
280 | &builtin_type_short, | |
281 | &builtin_type_unsigned_char, | |
282 | &builtin_type_unsigned_short, | |
283 | &builtin_type_unsigned_long, | |
284 | &builtin_type_unsigned_int, | |
285 | &builtin_type_float, | |
286 | &builtin_type_double, | |
287 | &builtin_type_void, | |
288 | &builtin_type_long_double | |
c906108c SS |
289 | }; |
290 | ||
291 | static void os9k_init_type_vector PARAMS ((struct type **)); | |
292 | ||
293 | static void | |
c5aa993b JM |
294 | os9k_init_type_vector (tv) |
295 | struct type **tv; | |
c906108c | 296 | { |
745b8ca0 | 297 | unsigned int i; |
c5aa993b | 298 | for (i = 0; i < sizeof (os9k_type_vector) / sizeof (struct type **); i++) |
c906108c SS |
299 | tv[i] = (os9k_type_vector[i] == 0 ? 0 : *(os9k_type_vector[i])); |
300 | } | |
301 | ||
302 | /* Look up a dbx type-number pair. Return the address of the slot | |
303 | where the type for that number-pair is stored. | |
304 | The number-pair is in TYPENUMS. | |
305 | ||
306 | This can be used for finding the type associated with that pair | |
307 | or for associating a new type with the pair. */ | |
308 | ||
309 | struct type ** | |
310 | dbx_lookup_type (typenums) | |
311 | int typenums[2]; | |
312 | { | |
313 | register int filenum = typenums[0]; | |
314 | register int index = typenums[1]; | |
315 | unsigned old_len; | |
316 | register int real_filenum; | |
317 | register struct header_file *f; | |
318 | int f_orig_length; | |
319 | ||
320 | if (filenum == -1) /* -1,-1 is for temporary types. */ | |
321 | return 0; | |
322 | ||
323 | if (filenum < 0 || filenum >= n_this_object_header_files) | |
324 | { | |
c5aa993b JM |
325 | static struct complaint msg = |
326 | {"\ | |
c906108c | 327 | Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.", |
c5aa993b | 328 | 0, 0}; |
c906108c SS |
329 | complain (&msg, filenum, index, symnum); |
330 | goto error_return; | |
331 | } | |
332 | ||
333 | if (filenum == 0) | |
334 | { | |
335 | if (index < 0) | |
336 | { | |
337 | /* Caller wants address of address of type. We think | |
338 | that negative (rs6k builtin) types will never appear as | |
339 | "lvalues", (nor should they), so we stuff the real type | |
340 | pointer into a temp, and return its address. If referenced, | |
341 | this will do the right thing. */ | |
342 | static struct type *temp_type; | |
343 | ||
c5aa993b | 344 | temp_type = rs6000_builtin_type (index); |
c906108c SS |
345 | return &temp_type; |
346 | } | |
347 | ||
348 | /* Type is defined outside of header files. | |
c5aa993b | 349 | Find it in this object file's type vector. */ |
c906108c SS |
350 | if (index >= type_vector_length) |
351 | { | |
352 | old_len = type_vector_length; | |
353 | if (old_len == 0) | |
354 | { | |
355 | type_vector_length = INITIAL_TYPE_VECTOR_LENGTH; | |
356 | type_vector = (struct type **) | |
357 | xmalloc (type_vector_length * sizeof (struct type *)); | |
358 | } | |
359 | while (index >= type_vector_length) | |
360 | { | |
361 | type_vector_length *= 2; | |
362 | } | |
363 | type_vector = (struct type **) | |
364 | xrealloc ((char *) type_vector, | |
365 | (type_vector_length * sizeof (struct type *))); | |
366 | memset (&type_vector[old_len], 0, | |
367 | (type_vector_length - old_len) * sizeof (struct type *)); | |
368 | ||
369 | if (os9k_stabs) | |
370 | /* Deal with OS9000 fundamental types. */ | |
371 | os9k_init_type_vector (type_vector); | |
372 | } | |
373 | return (&type_vector[index]); | |
374 | } | |
375 | else | |
376 | { | |
377 | real_filenum = this_object_header_files[filenum]; | |
378 | ||
379 | if (real_filenum >= N_HEADER_FILES (current_objfile)) | |
380 | { | |
381 | struct type *temp_type; | |
382 | struct type **temp_type_p; | |
383 | ||
384 | warning ("GDB internal error: bad real_filenum"); | |
385 | ||
386 | error_return: | |
387 | temp_type = init_type (TYPE_CODE_ERROR, 0, 0, NULL, NULL); | |
388 | temp_type_p = (struct type **) xmalloc (sizeof (struct type *)); | |
389 | *temp_type_p = temp_type; | |
390 | return temp_type_p; | |
391 | } | |
392 | ||
393 | f = HEADER_FILES (current_objfile) + real_filenum; | |
394 | ||
395 | f_orig_length = f->length; | |
396 | if (index >= f_orig_length) | |
397 | { | |
398 | while (index >= f->length) | |
399 | { | |
400 | f->length *= 2; | |
401 | } | |
402 | f->vector = (struct type **) | |
403 | xrealloc ((char *) f->vector, f->length * sizeof (struct type *)); | |
404 | memset (&f->vector[f_orig_length], 0, | |
405 | (f->length - f_orig_length) * sizeof (struct type *)); | |
406 | } | |
407 | return (&f->vector[index]); | |
408 | } | |
409 | } | |
410 | ||
411 | /* Make sure there is a type allocated for type numbers TYPENUMS | |
412 | and return the type object. | |
413 | This can create an empty (zeroed) type object. | |
414 | TYPENUMS may be (-1, -1) to return a new type object that is not | |
415 | put into the type vector, and so may not be referred to by number. */ | |
416 | ||
417 | static struct type * | |
418 | dbx_alloc_type (typenums, objfile) | |
419 | int typenums[2]; | |
420 | struct objfile *objfile; | |
421 | { | |
422 | register struct type **type_addr; | |
423 | ||
424 | if (typenums[0] == -1) | |
425 | { | |
426 | return (alloc_type (objfile)); | |
427 | } | |
428 | ||
429 | type_addr = dbx_lookup_type (typenums); | |
430 | ||
431 | /* If we are referring to a type not known at all yet, | |
432 | allocate an empty type for it. | |
433 | We will fill it in later if we find out how. */ | |
434 | if (*type_addr == 0) | |
435 | { | |
436 | *type_addr = alloc_type (objfile); | |
437 | } | |
438 | ||
439 | return (*type_addr); | |
440 | } | |
441 | ||
442 | /* for all the stabs in a given stab vector, build appropriate types | |
443 | and fix their symbols in given symbol vector. */ | |
444 | ||
445 | static void | |
446 | patch_block_stabs (symbols, stabs, objfile) | |
447 | struct pending *symbols; | |
448 | struct pending_stabs *stabs; | |
449 | struct objfile *objfile; | |
450 | { | |
451 | int ii; | |
452 | char *name; | |
453 | char *pp; | |
454 | struct symbol *sym; | |
455 | ||
456 | if (stabs) | |
457 | { | |
c5aa993b | 458 | |
c906108c | 459 | /* for all the stab entries, find their corresponding symbols and |
c5aa993b JM |
460 | patch their types! */ |
461 | ||
c906108c SS |
462 | for (ii = 0; ii < stabs->count; ++ii) |
463 | { | |
464 | name = stabs->stab[ii]; | |
c5aa993b | 465 | pp = (char *) strchr (name, ':'); |
c906108c SS |
466 | while (pp[1] == ':') |
467 | { | |
c5aa993b JM |
468 | pp += 2; |
469 | pp = (char *) strchr (pp, ':'); | |
c906108c | 470 | } |
c5aa993b | 471 | sym = find_symbol_in_list (symbols, name, pp - name); |
c906108c SS |
472 | if (!sym) |
473 | { | |
474 | /* FIXME-maybe: it would be nice if we noticed whether | |
c5aa993b JM |
475 | the variable was defined *anywhere*, not just whether |
476 | it is defined in this compilation unit. But neither | |
477 | xlc or GCC seem to need such a definition, and until | |
478 | we do psymtabs (so that the minimal symbols from all | |
479 | compilation units are available now), I'm not sure | |
480 | how to get the information. */ | |
c906108c SS |
481 | |
482 | /* On xcoff, if a global is defined and never referenced, | |
c5aa993b JM |
483 | ld will remove it from the executable. There is then |
484 | a N_GSYM stab for it, but no regular (C_EXT) symbol. */ | |
c906108c SS |
485 | sym = (struct symbol *) |
486 | obstack_alloc (&objfile->symbol_obstack, | |
487 | sizeof (struct symbol)); | |
488 | ||
489 | memset (sym, 0, sizeof (struct symbol)); | |
490 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
491 | SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT; | |
492 | SYMBOL_NAME (sym) = | |
493 | obsavestring (name, pp - name, &objfile->symbol_obstack); | |
494 | pp += 2; | |
c5aa993b | 495 | if (*(pp - 1) == 'F' || *(pp - 1) == 'f') |
c906108c SS |
496 | { |
497 | /* I don't think the linker does this with functions, | |
498 | so as far as I know this is never executed. | |
499 | But it doesn't hurt to check. */ | |
500 | SYMBOL_TYPE (sym) = | |
501 | lookup_function_type (read_type (&pp, objfile)); | |
502 | } | |
503 | else | |
504 | { | |
505 | SYMBOL_TYPE (sym) = read_type (&pp, objfile); | |
506 | } | |
507 | add_symbol_to_list (sym, &global_symbols); | |
508 | } | |
509 | else | |
510 | { | |
511 | pp += 2; | |
c5aa993b | 512 | if (*(pp - 1) == 'F' || *(pp - 1) == 'f') |
c906108c SS |
513 | { |
514 | SYMBOL_TYPE (sym) = | |
515 | lookup_function_type (read_type (&pp, objfile)); | |
516 | } | |
517 | else | |
518 | { | |
519 | SYMBOL_TYPE (sym) = read_type (&pp, objfile); | |
520 | } | |
521 | } | |
522 | } | |
523 | } | |
524 | } | |
c906108c | 525 | \f |
c5aa993b | 526 | |
c906108c SS |
527 | /* Read a number by which a type is referred to in dbx data, |
528 | or perhaps read a pair (FILENUM, TYPENUM) in parentheses. | |
529 | Just a single number N is equivalent to (0,N). | |
530 | Return the two numbers by storing them in the vector TYPENUMS. | |
531 | TYPENUMS will then be used as an argument to dbx_lookup_type. | |
532 | ||
533 | Returns 0 for success, -1 for error. */ | |
534 | ||
535 | static int | |
536 | read_type_number (pp, typenums) | |
537 | register char **pp; | |
538 | register int *typenums; | |
539 | { | |
540 | int nbits; | |
541 | if (**pp == '(') | |
542 | { | |
543 | (*pp)++; | |
544 | typenums[0] = read_huge_number (pp, ',', &nbits); | |
c5aa993b JM |
545 | if (nbits != 0) |
546 | return -1; | |
c906108c | 547 | typenums[1] = read_huge_number (pp, ')', &nbits); |
c5aa993b JM |
548 | if (nbits != 0) |
549 | return -1; | |
c906108c SS |
550 | } |
551 | else | |
552 | { | |
553 | typenums[0] = 0; | |
554 | typenums[1] = read_huge_number (pp, 0, &nbits); | |
c5aa993b JM |
555 | if (nbits != 0) |
556 | return -1; | |
c906108c SS |
557 | } |
558 | return 0; | |
559 | } | |
c906108c | 560 | \f |
c5aa993b | 561 | |
c906108c SS |
562 | #define VISIBILITY_PRIVATE '0' /* Stabs character for private field */ |
563 | #define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */ | |
564 | #define VISIBILITY_PUBLIC '2' /* Stabs character for public field */ | |
565 | #define VISIBILITY_IGNORE '9' /* Optimized out or zero length */ | |
566 | ||
567 | #define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */ | |
568 | #define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */ | |
569 | ||
570 | /* This code added to support parsing of ARM/Cfront stabs strings */ | |
571 | ||
572 | /* Get substring from string up to char c, advance string pointer past | |
573 | suibstring. */ | |
574 | ||
c5aa993b | 575 | static char * |
c906108c | 576 | get_substring (p, c) |
c5aa993b JM |
577 | char **p; |
578 | int c; | |
c906108c SS |
579 | { |
580 | char *str; | |
581 | str = *p; | |
582 | *p = strchr (*p, c); | |
c5aa993b | 583 | if (*p) |
c906108c SS |
584 | { |
585 | **p = 0; | |
586 | (*p)++; | |
587 | } | |
c5aa993b | 588 | else |
c906108c SS |
589 | str = 0; |
590 | return str; | |
591 | } | |
592 | ||
593 | /* Physname gets strcat'd onto sname in order to recreate the mangled | |
594 | name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make | |
595 | the physname look like that of g++ - take out the initial mangling | |
596 | eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */ | |
597 | ||
c5aa993b | 598 | static char * |
c906108c | 599 | get_cfront_method_physname (fname) |
c5aa993b | 600 | char *fname; |
c906108c SS |
601 | { |
602 | int len = 0; | |
603 | /* FIXME would like to make this generic for g++ too, but | |
604 | that is already handled in read_member_funcctions */ | |
c5aa993b | 605 | char *p = fname; |
c906108c SS |
606 | |
607 | /* search ahead to find the start of the mangled suffix */ | |
c5aa993b JM |
608 | if (*p == '_' && *(p + 1) == '_') /* compiler generated; probably a ctor/dtor */ |
609 | p += 2; | |
610 | while (p && (unsigned) ((p + 1) - fname) < strlen (fname) && *(p + 1) != '_') | |
c906108c | 611 | p = strchr (p, '_'); |
c5aa993b JM |
612 | if (!(p && *p == '_' && *(p + 1) == '_')) |
613 | error ("Invalid mangled function name %s", fname); | |
614 | p += 2; /* advance past '__' */ | |
c906108c SS |
615 | |
616 | /* struct name length and name of type should come next; advance past it */ | |
617 | while (isdigit (*p)) | |
618 | { | |
619 | len = len * 10 + (*p - '0'); | |
620 | p++; | |
621 | } | |
622 | p += len; | |
623 | ||
624 | return p; | |
625 | } | |
626 | ||
627 | /* Read base classes within cfront class definition. | |
628 | eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;; | |
c5aa993b | 629 | ^^^^^^^^^^^^^^^^^^ |
c906108c | 630 | |
c5aa993b JM |
631 | A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;; |
632 | ^ | |
633 | */ | |
c906108c SS |
634 | |
635 | static int | |
c5aa993b JM |
636 | read_cfront_baseclasses (fip, pp, type, objfile) |
637 | struct field_info *fip; | |
638 | struct objfile *objfile; | |
639 | char **pp; | |
640 | struct type *type; | |
c906108c | 641 | { |
c5aa993b JM |
642 | static struct complaint msg_unknown = |
643 | {"\ | |
c906108c | 644 | Unsupported token in stabs string %s.\n", |
c5aa993b JM |
645 | 0, 0}; |
646 | static struct complaint msg_notfound = | |
647 | {"\ | |
c906108c | 648 | Unable to find base type for %s.\n", |
c5aa993b | 649 | 0, 0}; |
c906108c | 650 | int bnum = 0; |
c5aa993b | 651 | char *p; |
c906108c SS |
652 | int i; |
653 | struct nextfield *new; | |
654 | ||
655 | if (**pp == ';') /* no base classes; return */ | |
656 | { | |
657 | ++(*pp); | |
658 | return 1; | |
659 | } | |
660 | ||
661 | /* first count base classes so we can allocate space before parsing */ | |
662 | for (p = *pp; p && *p && *p != ';'; p++) | |
663 | { | |
664 | if (*p == ' ') | |
665 | bnum++; | |
666 | } | |
c5aa993b | 667 | bnum++; /* add one more for last one */ |
c906108c SS |
668 | |
669 | /* now parse the base classes until we get to the start of the methods | |
670 | (code extracted and munged from read_baseclasses) */ | |
671 | ALLOCATE_CPLUS_STRUCT_TYPE (type); | |
c5aa993b | 672 | TYPE_N_BASECLASSES (type) = bnum; |
c906108c SS |
673 | |
674 | /* allocate space */ | |
675 | { | |
676 | int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type)); | |
677 | char *pointer; | |
678 | ||
679 | pointer = (char *) TYPE_ALLOC (type, num_bytes); | |
680 | TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer; | |
681 | } | |
682 | B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type)); | |
683 | ||
684 | for (i = 0; i < TYPE_N_BASECLASSES (type); i++) | |
685 | { | |
686 | new = (struct nextfield *) xmalloc (sizeof (struct nextfield)); | |
687 | make_cleanup (free, new); | |
688 | memset (new, 0, sizeof (struct nextfield)); | |
c5aa993b JM |
689 | new->next = fip->list; |
690 | fip->list = new; | |
691 | FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */ | |
c906108c SS |
692 | |
693 | STABS_CONTINUE (pp, objfile); | |
694 | ||
695 | /* virtual? eg: v2@Bvir */ | |
c5aa993b JM |
696 | if (**pp == 'v') |
697 | { | |
698 | SET_TYPE_FIELD_VIRTUAL (type, i); | |
699 | ++(*pp); | |
c906108c SS |
700 | } |
701 | ||
702 | /* access? eg: 2@Bvir */ | |
c5aa993b | 703 | /* Note: protected inheritance not supported in cfront */ |
c906108c | 704 | switch (*(*pp)++) |
c5aa993b JM |
705 | { |
706 | case CFRONT_VISIBILITY_PRIVATE: | |
707 | new->visibility = VISIBILITY_PRIVATE; | |
708 | break; | |
709 | case CFRONT_VISIBILITY_PUBLIC: | |
710 | new->visibility = VISIBILITY_PUBLIC; | |
711 | break; | |
712 | default: | |
713 | /* Bad visibility format. Complain and treat it as | |
714 | public. */ | |
715 | { | |
716 | static struct complaint msg = | |
717 | { | |
718 | "Unknown visibility `%c' for baseclass", 0, 0}; | |
719 | complain (&msg, new->visibility); | |
720 | new->visibility = VISIBILITY_PUBLIC; | |
721 | } | |
722 | } | |
c906108c SS |
723 | |
724 | /* "@" comes next - eg: @Bvir */ | |
c5aa993b JM |
725 | if (**pp != '@') |
726 | { | |
727 | complain (&msg_unknown, *pp); | |
728 | return 1; | |
c906108c SS |
729 | } |
730 | ++(*pp); | |
731 | ||
732 | ||
c5aa993b JM |
733 | /* Set the bit offset of the portion of the object corresponding |
734 | to this baseclass. Always zero in the absence of | |
735 | multiple inheritance. */ | |
736 | /* Unable to read bit position from stabs; | |
737 | Assuming no multiple inheritance for now FIXME! */ | |
738 | /* We may have read this in the structure definition; | |
739 | now we should fixup the members to be the actual base classes */ | |
740 | FIELD_BITPOS (new->field) = 0; | |
c906108c | 741 | |
c5aa993b JM |
742 | /* Get the base class name and type */ |
743 | { | |
744 | char *bname; /* base class name */ | |
745 | struct symbol *bsym; /* base class */ | |
746 | char *p1, *p2; | |
747 | p1 = strchr (*pp, ' '); | |
748 | p2 = strchr (*pp, ';'); | |
749 | if (p1 < p2) | |
750 | bname = get_substring (pp, ' '); | |
751 | else | |
752 | bname = get_substring (pp, ';'); | |
753 | if (!bname || !*bname) | |
c906108c | 754 | { |
c5aa993b JM |
755 | complain (&msg_unknown, *pp); |
756 | return 1; | |
757 | } | |
758 | /* FIXME! attach base info to type */ | |
759 | bsym = lookup_symbol (bname, 0, STRUCT_NAMESPACE, 0, 0); /*demangled_name */ | |
760 | if (bsym) | |
761 | { | |
762 | new->field.type = SYMBOL_TYPE (bsym); | |
763 | new->field.name = type_name_no_tag (new->field.type); | |
c906108c | 764 | } |
c5aa993b JM |
765 | else |
766 | { | |
767 | complain (&msg_notfound, *pp); | |
768 | return 1; | |
769 | } | |
770 | } | |
c906108c SS |
771 | |
772 | /* If more base classes to parse, loop again. | |
773 | We ate the last ' ' or ';' in get_substring, | |
774 | so on exit we will have skipped the trailing ';' */ | |
775 | /* if invalid, return 0; add code to detect - FIXME! */ | |
776 | } | |
777 | return 1; | |
778 | } | |
779 | ||
780 | /* read cfront member functions. | |
781 | pp points to string starting with list of functions | |
782 | eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;; | |
c5aa993b JM |
783 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
784 | A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;; | |
785 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
786 | */ | |
c906108c SS |
787 | |
788 | static int | |
789 | read_cfront_member_functions (fip, pp, type, objfile) | |
790 | struct field_info *fip; | |
791 | char **pp; | |
792 | struct type *type; | |
793 | struct objfile *objfile; | |
794 | { | |
795 | /* This code extracted from read_member_functions | |
796 | so as to do the similar thing for our funcs */ | |
797 | ||
798 | int nfn_fields = 0; | |
799 | int length = 0; | |
800 | /* Total number of member functions defined in this class. If the class | |
801 | defines two `f' functions, and one `g' function, then this will have | |
802 | the value 3. */ | |
803 | int total_length = 0; | |
804 | int i; | |
805 | struct next_fnfield | |
806 | { | |
807 | struct next_fnfield *next; | |
808 | struct fn_field fn_field; | |
c5aa993b JM |
809 | } |
810 | *sublist; | |
c906108c SS |
811 | struct type *look_ahead_type; |
812 | struct next_fnfieldlist *new_fnlist; | |
813 | struct next_fnfield *new_sublist; | |
814 | char *main_fn_name; | |
c5aa993b JM |
815 | char *fname; |
816 | struct symbol *ref_func = 0; | |
817 | ||
c906108c SS |
818 | /* Process each list until we find the end of the member functions. |
819 | eg: p = "__ct__1AFv foo__1AFv ;;;" */ | |
820 | ||
c5aa993b | 821 | STABS_CONTINUE (pp, objfile); /* handle \\ */ |
c906108c | 822 | |
c5aa993b | 823 | while (**pp != ';' && (fname = get_substring (pp, ' '), fname)) |
c906108c SS |
824 | { |
825 | int is_static = 0; | |
826 | int sublist_count = 0; | |
c5aa993b JM |
827 | char *pname; |
828 | if (fname[0] == '*') /* static member */ | |
829 | { | |
830 | is_static = 1; | |
831 | sublist_count++; | |
832 | fname++; | |
833 | } | |
834 | ref_func = lookup_symbol (fname, 0, VAR_NAMESPACE, 0, 0); /* demangled name */ | |
835 | if (!ref_func) | |
836 | { | |
837 | static struct complaint msg = | |
838 | {"\ | |
c906108c | 839 | Unable to find function symbol for %s\n", |
c5aa993b | 840 | 0, 0}; |
c906108c SS |
841 | complain (&msg, fname); |
842 | continue; | |
843 | } | |
844 | sublist = NULL; | |
845 | look_ahead_type = NULL; | |
846 | length = 0; | |
c5aa993b | 847 | |
c906108c | 848 | new_fnlist = (struct next_fnfieldlist *) |
c5aa993b | 849 | xmalloc (sizeof (struct next_fnfieldlist)); |
c906108c SS |
850 | make_cleanup (free, new_fnlist); |
851 | memset (new_fnlist, 0, sizeof (struct next_fnfieldlist)); | |
c5aa993b | 852 | |
c906108c SS |
853 | /* The following is code to work around cfront generated stabs. |
854 | The stabs contains full mangled name for each field. | |
855 | We try to demangle the name and extract the field name out of it. */ | |
856 | { | |
c5aa993b JM |
857 | char *dem, *dem_p, *dem_args; |
858 | int dem_len; | |
859 | dem = cplus_demangle (fname, DMGL_ANSI | DMGL_PARAMS); | |
860 | if (dem != NULL) | |
861 | { | |
862 | dem_p = strrchr (dem, ':'); | |
863 | if (dem_p != 0 && *(dem_p - 1) == ':') | |
864 | dem_p++; | |
c906108c | 865 | /* get rid of args */ |
c5aa993b | 866 | dem_args = strchr (dem_p, '('); |
c906108c SS |
867 | if (dem_args == NULL) |
868 | dem_len = strlen (dem_p); | |
869 | else | |
c5aa993b JM |
870 | dem_len = dem_args - dem_p; |
871 | main_fn_name = | |
872 | obsavestring (dem_p, dem_len, &objfile->type_obstack); | |
873 | } | |
874 | else | |
875 | { | |
876 | main_fn_name = | |
877 | obsavestring (fname, strlen (fname), &objfile->type_obstack); | |
878 | } | |
879 | } /* end of code for cfront work around */ | |
880 | ||
881 | new_fnlist->fn_fieldlist.name = main_fn_name; | |
882 | ||
883 | /*-------------------------------------------------*/ | |
884 | /* Set up the sublists | |
885 | Sublists are stuff like args, static, visibility, etc. | |
886 | so in ARM, we have to set that info some other way. | |
887 | Multiple sublists happen if overloading | |
888 | eg: foo::26=##1;:;2A.; | |
889 | In g++, we'd loop here thru all the sublists... */ | |
890 | ||
891 | new_sublist = | |
892 | (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield)); | |
893 | make_cleanup (free, new_sublist); | |
894 | memset (new_sublist, 0, sizeof (struct next_fnfield)); | |
895 | ||
896 | /* eat 1; from :;2A.; */ | |
897 | new_sublist->fn_field.type = SYMBOL_TYPE (ref_func); /* normally takes a read_type */ | |
898 | /* Make this type look like a method stub for gdb */ | |
899 | TYPE_FLAGS (new_sublist->fn_field.type) |= TYPE_FLAG_STUB; | |
900 | TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD; | |
901 | ||
902 | /* If this is just a stub, then we don't have the real name here. */ | |
903 | if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB) | |
904 | { | |
905 | if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type)) | |
906 | TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type; | |
907 | new_sublist->fn_field.is_stub = 1; | |
908 | } | |
c906108c | 909 | |
c5aa993b JM |
910 | /* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i |
911 | physname gets strcat'd in order to recreate the onto mangled name */ | |
912 | pname = get_cfront_method_physname (fname); | |
913 | new_sublist->fn_field.physname = savestring (pname, strlen (pname)); | |
c906108c | 914 | |
c5aa993b JM |
915 | |
916 | /* Set this member function's visibility fields. | |
917 | Unable to distinguish access from stabs definition! | |
c906108c | 918 | Assuming public for now. FIXME! |
c5aa993b JM |
919 | (for private, set new_sublist->fn_field.is_private = 1, |
920 | for public, set new_sublist->fn_field.is_protected = 1) */ | |
921 | ||
922 | /* Unable to distinguish const/volatile from stabs definition! | |
923 | Assuming normal for now. FIXME! */ | |
924 | ||
925 | new_sublist->fn_field.is_const = 0; | |
926 | new_sublist->fn_field.is_volatile = 0; /* volatile not implemented in cfront */ | |
927 | ||
928 | /* Set virtual/static function info | |
929 | How to get vtable offsets ? | |
930 | Assuming normal for now FIXME!! | |
931 | For vtables, figure out from whence this virtual function came. | |
932 | It may belong to virtual function table of | |
933 | one of its baseclasses. | |
934 | set: | |
935 | new_sublist -> fn_field.voffset = vtable offset, | |
936 | new_sublist -> fn_field.fcontext = look_ahead_type; | |
937 | where look_ahead_type is type of baseclass */ | |
938 | if (is_static) | |
939 | new_sublist->fn_field.voffset = VOFFSET_STATIC; | |
940 | else /* normal member function. */ | |
941 | new_sublist->fn_field.voffset = 0; | |
942 | new_sublist->fn_field.fcontext = 0; | |
943 | ||
944 | ||
945 | /* Prepare new sublist */ | |
946 | new_sublist->next = sublist; | |
947 | sublist = new_sublist; | |
948 | length++; | |
949 | ||
950 | /* In g++, we loop thu sublists - now we set from functions. */ | |
951 | new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *) | |
952 | obstack_alloc (&objfile->type_obstack, | |
953 | sizeof (struct fn_field) * length); | |
954 | memset (new_fnlist->fn_fieldlist.fn_fields, 0, | |
955 | sizeof (struct fn_field) * length); | |
956 | for (i = length; (i--, sublist); sublist = sublist->next) | |
957 | { | |
958 | new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field; | |
959 | } | |
960 | ||
961 | new_fnlist->fn_fieldlist.length = length; | |
962 | new_fnlist->next = fip->fnlist; | |
963 | fip->fnlist = new_fnlist; | |
964 | nfn_fields++; | |
965 | total_length += length; | |
966 | STABS_CONTINUE (pp, objfile); /* handle \\ */ | |
967 | } /* end of loop */ | |
c906108c SS |
968 | |
969 | if (nfn_fields) | |
970 | { | |
971 | /* type should already have space */ | |
972 | TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *) | |
c5aa993b | 973 | TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields); |
c906108c | 974 | memset (TYPE_FN_FIELDLISTS (type), 0, |
c5aa993b | 975 | sizeof (struct fn_fieldlist) * nfn_fields); |
c906108c SS |
976 | TYPE_NFN_FIELDS (type) = nfn_fields; |
977 | TYPE_NFN_FIELDS_TOTAL (type) = total_length; | |
978 | } | |
979 | ||
980 | /* end of scope for reading member func */ | |
981 | ||
982 | /* eg: ";;" */ | |
983 | ||
984 | /* Skip trailing ';' and bump count of number of fields seen */ | |
985 | if (**pp == ';') | |
986 | (*pp)++; | |
987 | else | |
988 | return 0; | |
989 | return 1; | |
990 | } | |
991 | ||
992 | /* This routine fixes up partial cfront types that were created | |
993 | while parsing the stabs. The main need for this function is | |
994 | to add information such as methods to classes. | |
995 | Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */ | |
996 | int | |
997 | resolve_cfront_continuation (objfile, sym, p) | |
c5aa993b JM |
998 | struct objfile *objfile; |
999 | struct symbol *sym; | |
1000 | char *p; | |
c906108c | 1001 | { |
c5aa993b JM |
1002 | struct symbol *ref_sym = 0; |
1003 | char *sname; | |
c906108c SS |
1004 | /* snarfed from read_struct_type */ |
1005 | struct field_info fi; | |
1006 | struct type *type; | |
1007 | struct cleanup *back_to; | |
1008 | ||
1009 | /* Need to make sure that fi isn't gunna conflict with struct | |
1010 | in case struct already had some fnfs */ | |
1011 | fi.list = NULL; | |
c5aa993b | 1012 | fi.fnlist = NULL; |
c906108c SS |
1013 | back_to = make_cleanup (null_cleanup, 0); |
1014 | ||
1015 | /* We only accept structs, classes and unions at the moment. | |
1016 | Other continuation types include t (typedef), r (long dbl), ... | |
1017 | We may want to add support for them as well; | |
1018 | right now they are handled by duplicating the symbol information | |
1019 | into the type information (see define_symbol) */ | |
c5aa993b JM |
1020 | if (*p != 's' /* structs */ |
1021 | && *p != 'c' /* class */ | |
1022 | && *p != 'u') /* union */ | |
1023 | return 0; /* only handle C++ types */ | |
1024 | p++; | |
c906108c SS |
1025 | |
1026 | /* Get symbol typs name and validate | |
1027 | eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */ | |
1028 | sname = get_substring (&p, ';'); | |
c5aa993b | 1029 | if (!sname || strcmp (sname, SYMBOL_NAME (sym))) |
c906108c SS |
1030 | error ("Internal error: base symbol type name does not match\n"); |
1031 | ||
1032 | /* Find symbol's internal gdb reference using demangled_name. | |
1033 | This is the real sym that we want; | |
1034 | sym was a temp hack to make debugger happy */ | |
c5aa993b JM |
1035 | ref_sym = lookup_symbol (SYMBOL_NAME (sym), 0, STRUCT_NAMESPACE, 0, 0); |
1036 | type = SYMBOL_TYPE (ref_sym); | |
c906108c SS |
1037 | |
1038 | ||
1039 | /* Now read the baseclasses, if any, read the regular C struct or C++ | |
1040 | class member fields, attach the fields to the type, read the C++ | |
1041 | member functions, attach them to the type, and then read any tilde | |
1042 | field (baseclass specifier for the class holding the main vtable). */ | |
1043 | ||
1044 | if (!read_cfront_baseclasses (&fi, &p, type, objfile) | |
c5aa993b JM |
1045 | /* g++ does this next, but cfront already did this: |
1046 | || !read_struct_fields (&fi, &p, type, objfile) */ | |
c906108c SS |
1047 | || !copy_cfront_struct_fields (&fi, type, objfile) |
1048 | || !read_cfront_member_functions (&fi, &p, type, objfile) | |
1049 | || !read_cfront_static_fields (&fi, &p, type, objfile) | |
1050 | || !attach_fields_to_type (&fi, type, objfile) | |
1051 | || !attach_fn_fields_to_type (&fi, type) | |
c5aa993b JM |
1052 | /* g++ does this next, but cfront doesn't seem to have this: |
1053 | || !read_tilde_fields (&fi, &p, type, objfile) */ | |
1054 | ) | |
c906108c SS |
1055 | { |
1056 | type = error_type (&p, objfile); | |
1057 | } | |
1058 | ||
1059 | do_cleanups (back_to); | |
c5aa993b | 1060 | return 0; |
c906108c SS |
1061 | } |
1062 | /* End of code added to support parsing of ARM/Cfront stabs strings */ | |
1063 | ||
1064 | ||
1065 | /* This routine fixes up symbol references/aliases to point to the original | |
1066 | symbol definition. Returns 0 on failure, non-zero on success. */ | |
1067 | ||
1068 | static int | |
1069 | resolve_symbol_reference (objfile, sym, p) | |
c5aa993b JM |
1070 | struct objfile *objfile; |
1071 | struct symbol *sym; | |
1072 | char *p; | |
c906108c SS |
1073 | { |
1074 | int refnum; | |
c5aa993b | 1075 | struct symbol *ref_sym = 0; |
c906108c SS |
1076 | struct alias_list *alias; |
1077 | ||
1078 | /* If this is not a symbol reference return now. */ | |
1079 | if (*p != '#') | |
c5aa993b | 1080 | return 0; |
c906108c SS |
1081 | |
1082 | /* Use "#<num>" as the name; we'll fix the name later. | |
1083 | We stored the original symbol name as "#<id>=<name>" | |
1084 | so we can now search for "#<id>" to resolving the reference. | |
1085 | We'll fix the names later by removing the "#<id>" or "#<id>=" */ | |
1086 | ||
c5aa993b | 1087 | /*---------------------------------------------------------*/ |
c906108c SS |
1088 | /* Get the reference id number, and |
1089 | advance p past the names so we can parse the rest. | |
c5aa993b JM |
1090 | eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */ |
1091 | /*---------------------------------------------------------*/ | |
c906108c SS |
1092 | |
1093 | /* This gets reference name from string. sym may not have a name. */ | |
1094 | ||
1095 | /* Get the reference number associated with the reference id in the | |
1096 | gdb stab string. From that reference number, get the main/primary | |
1097 | symbol for this alias. */ | |
1098 | refnum = process_reference (&p); | |
1099 | ref_sym = ref_search (refnum); | |
1100 | if (!ref_sym) | |
1101 | { | |
1102 | complain (&lrs_general_complaint, "symbol for reference not found"); | |
1103 | return 0; | |
1104 | } | |
1105 | ||
1106 | /* Parse the stab of the referencing symbol | |
1107 | now that we have the referenced symbol. | |
1108 | Add it as a new symbol and a link back to the referenced symbol. | |
1109 | eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */ | |
1110 | ||
1111 | ||
1112 | /* If the stab symbol table and string contain: | |
c5aa993b JM |
1113 | RSYM 0 5 00000000 868 #15=z:r(0,1) |
1114 | LBRAC 0 0 00000000 899 #5= | |
1115 | SLINE 0 16 00000003 923 #6= | |
c906108c | 1116 | Then the same symbols can be later referenced by: |
c5aa993b | 1117 | RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6) |
c906108c SS |
1118 | This is used in live range splitting to: |
1119 | 1) specify that a symbol (#15) is actually just a new storage | |
c5aa993b | 1120 | class for a symbol (#15=z) which was previously defined. |
c906108c | 1121 | 2) specify that the beginning and ending ranges for a symbol |
c5aa993b JM |
1122 | (#15) are the values of the beginning (#5) and ending (#6) |
1123 | symbols. */ | |
1124 | ||
1125 | /* Read number as reference id. | |
1126 | eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */ | |
1127 | /* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT; | |
1128 | in case of "l(0,0)"? */ | |
1129 | ||
1130 | /*--------------------------------------------------*/ | |
1131 | /* Add this symbol to the reference list. */ | |
1132 | /*--------------------------------------------------*/ | |
c906108c SS |
1133 | |
1134 | alias = (struct alias_list *) obstack_alloc (&objfile->type_obstack, | |
1135 | sizeof (struct alias_list)); | |
1136 | if (!alias) | |
1137 | { | |
1138 | complain (&lrs_general_complaint, "Unable to allocate alias list memory"); | |
1139 | return 0; | |
1140 | } | |
1141 | ||
1142 | alias->next = 0; | |
1143 | alias->sym = sym; | |
1144 | ||
1145 | if (!SYMBOL_ALIASES (ref_sym)) | |
1146 | { | |
1147 | SYMBOL_ALIASES (ref_sym) = alias; | |
1148 | } | |
1149 | else | |
1150 | { | |
1151 | struct alias_list *temp; | |
1152 | ||
1153 | /* Get to the end of the list. */ | |
1154 | for (temp = SYMBOL_ALIASES (ref_sym); | |
1155 | temp->next; | |
1156 | temp = temp->next) | |
1157 | ; | |
1158 | temp->next = alias; | |
1159 | } | |
1160 | ||
c5aa993b JM |
1161 | /* Want to fix up name so that other functions (eg. valops) |
1162 | will correctly print the name. | |
1163 | Don't add_symbol_to_list so that lookup_symbol won't find it. | |
1164 | nope... needed for fixups. */ | |
1165 | SYMBOL_NAME (sym) = SYMBOL_NAME (ref_sym); | |
c906108c SS |
1166 | |
1167 | /* Done! */ | |
1168 | return 1; | |
1169 | } | |
1170 | ||
1171 | /* Structure for storing pointers to reference definitions for fast lookup | |
1172 | during "process_later". */ | |
1173 | ||
1174 | struct ref_map | |
1175 | { | |
1176 | char *stabs; | |
1177 | CORE_ADDR value; | |
1178 | struct symbol *sym; | |
1179 | }; | |
1180 | ||
1181 | #define MAX_CHUNK_REFS 100 | |
1182 | #define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map)) | |
1183 | #define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE) | |
1184 | ||
c5aa993b | 1185 | static struct ref_map *ref_map; |
c906108c SS |
1186 | |
1187 | /* Ptr to free cell in chunk's linked list. */ | |
c5aa993b | 1188 | static int ref_count = 0; |
c906108c SS |
1189 | |
1190 | /* Number of chunks malloced. */ | |
1191 | static int ref_chunk = 0; | |
1192 | ||
7be570e7 JM |
1193 | /* This file maintains a cache of stabs aliases found in the symbol |
1194 | table. If the symbol table changes, this cache must be cleared | |
1195 | or we are left holding onto data in invalid obstacks. */ | |
1196 | void | |
1197 | stabsread_clear_cache () | |
1198 | { | |
1199 | ref_count = 0; | |
1200 | ref_chunk = 0; | |
1201 | } | |
1202 | ||
c906108c SS |
1203 | /* Create array of pointers mapping refids to symbols and stab strings. |
1204 | Add pointers to reference definition symbols and/or their values as we | |
1205 | find them, using their reference numbers as our index. | |
1206 | These will be used later when we resolve references. */ | |
1207 | void | |
1208 | ref_add (refnum, sym, stabs, value) | |
1209 | int refnum; | |
1210 | struct symbol *sym; | |
1211 | char *stabs; | |
1212 | CORE_ADDR value; | |
1213 | { | |
1214 | if (ref_count == 0) | |
1215 | ref_chunk = 0; | |
1216 | if (refnum >= ref_count) | |
1217 | ref_count = refnum + 1; | |
1218 | if (ref_count > ref_chunk * MAX_CHUNK_REFS) | |
1219 | { | |
c5aa993b | 1220 | int new_slots = ref_count - ref_chunk * MAX_CHUNK_REFS; |
c906108c SS |
1221 | int new_chunks = new_slots / MAX_CHUNK_REFS + 1; |
1222 | ref_map = (struct ref_map *) | |
1223 | xrealloc (ref_map, REF_MAP_SIZE (ref_chunk + new_chunks)); | |
1224 | memset (ref_map + ref_chunk * MAX_CHUNK_REFS, 0, new_chunks * REF_CHUNK_SIZE); | |
1225 | ref_chunk += new_chunks; | |
1226 | } | |
1227 | ref_map[refnum].stabs = stabs; | |
1228 | ref_map[refnum].sym = sym; | |
1229 | ref_map[refnum].value = value; | |
1230 | } | |
1231 | ||
1232 | /* Return defined sym for the reference REFNUM. */ | |
1233 | struct symbol * | |
1234 | ref_search (refnum) | |
1235 | int refnum; | |
1236 | { | |
1237 | if (refnum < 0 || refnum > ref_count) | |
1238 | return 0; | |
1239 | return ref_map[refnum].sym; | |
1240 | } | |
1241 | ||
1242 | /* Return value for the reference REFNUM. */ | |
1243 | ||
1244 | static CORE_ADDR | |
1245 | ref_search_value (refnum) | |
1246 | int refnum; | |
1247 | { | |
1248 | if (refnum < 0 || refnum > ref_count) | |
1249 | return 0; | |
1250 | return ref_map[refnum].value; | |
1251 | } | |
c5aa993b | 1252 | |
c906108c SS |
1253 | /* Parse a reference id in STRING and return the resulting |
1254 | reference number. Move STRING beyond the reference id. */ | |
1255 | ||
c5aa993b | 1256 | static int |
c906108c | 1257 | process_reference (string) |
c5aa993b | 1258 | char **string; |
c906108c SS |
1259 | { |
1260 | char *p; | |
1261 | int refnum = 0; | |
1262 | ||
c5aa993b JM |
1263 | if (**string != '#') |
1264 | return 0; | |
1265 | ||
c906108c SS |
1266 | /* Advance beyond the initial '#'. */ |
1267 | p = *string + 1; | |
1268 | ||
1269 | /* Read number as reference id. */ | |
1270 | while (*p && isdigit (*p)) | |
1271 | { | |
1272 | refnum = refnum * 10 + *p - '0'; | |
1273 | p++; | |
1274 | } | |
1275 | *string = p; | |
1276 | return refnum; | |
1277 | } | |
1278 | ||
1279 | /* If STRING defines a reference, store away a pointer to the reference | |
1280 | definition for later use. Return the reference number. */ | |
1281 | ||
1282 | int | |
1283 | symbol_reference_defined (string) | |
1284 | char **string; | |
1285 | { | |
1286 | char *p = *string; | |
1287 | int refnum = 0; | |
1288 | ||
1289 | refnum = process_reference (&p); | |
1290 | ||
1291 | /* Defining symbols end in '=' */ | |
c5aa993b | 1292 | if (*p == '=') |
c906108c | 1293 | { |
c5aa993b | 1294 | /* Symbol is being defined here. */ |
c906108c SS |
1295 | *string = p + 1; |
1296 | return refnum; | |
1297 | } | |
1298 | else | |
1299 | { | |
1300 | /* Must be a reference. Either the symbol has already been defined, | |
1301 | or this is a forward reference to it. */ | |
1302 | *string = p; | |
1303 | return -1; | |
1304 | } | |
1305 | } | |
1306 | ||
1307 | /* ARGSUSED */ | |
1308 | struct symbol * | |
1309 | define_symbol (valu, string, desc, type, objfile) | |
1310 | CORE_ADDR valu; | |
1311 | char *string; | |
1312 | int desc; | |
1313 | int type; | |
1314 | struct objfile *objfile; | |
1315 | { | |
1316 | register struct symbol *sym; | |
1317 | char *p = (char *) strchr (string, ':'); | |
1318 | int deftype; | |
1319 | int synonym = 0; | |
1320 | register int i; | |
1321 | ||
1322 | /* We would like to eliminate nameless symbols, but keep their types. | |
1323 | E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer | |
1324 | to type 2, but, should not create a symbol to address that type. Since | |
1325 | the symbol will be nameless, there is no way any user can refer to it. */ | |
1326 | ||
1327 | int nameless; | |
1328 | ||
1329 | /* Ignore syms with empty names. */ | |
1330 | if (string[0] == 0) | |
1331 | return 0; | |
1332 | ||
1333 | /* Ignore old-style symbols from cc -go */ | |
1334 | if (p == 0) | |
1335 | return 0; | |
1336 | ||
1337 | while (p[1] == ':') | |
1338 | { | |
c5aa993b JM |
1339 | p += 2; |
1340 | p = strchr (p, ':'); | |
c906108c SS |
1341 | } |
1342 | ||
1343 | /* If a nameless stab entry, all we need is the type, not the symbol. | |
1344 | e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */ | |
1345 | nameless = (p == string || ((string[0] == ' ') && (string[1] == ':'))); | |
1346 | ||
c5aa993b JM |
1347 | current_symbol = sym = (struct symbol *) |
1348 | obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); | |
c906108c SS |
1349 | memset (sym, 0, sizeof (struct symbol)); |
1350 | ||
1351 | switch (type & N_TYPE) | |
1352 | { | |
1353 | case N_TEXT: | |
b8fbeb18 | 1354 | SYMBOL_SECTION (sym) = SECT_OFF_TEXT (objfile); |
c906108c SS |
1355 | break; |
1356 | case N_DATA: | |
b8fbeb18 | 1357 | SYMBOL_SECTION (sym) = SECT_OFF_DATA (objfile); |
c906108c SS |
1358 | break; |
1359 | case N_BSS: | |
b8fbeb18 | 1360 | SYMBOL_SECTION (sym) = SECT_OFF_BSS (objfile); |
c906108c SS |
1361 | break; |
1362 | } | |
1363 | ||
1364 | if (processing_gcc_compilation) | |
1365 | { | |
1366 | /* GCC 2.x puts the line number in desc. SunOS apparently puts in the | |
c5aa993b JM |
1367 | number of bytes occupied by a type or object, which we ignore. */ |
1368 | SYMBOL_LINE (sym) = desc; | |
c906108c SS |
1369 | } |
1370 | else | |
1371 | { | |
c5aa993b | 1372 | SYMBOL_LINE (sym) = 0; /* unknown */ |
c906108c SS |
1373 | } |
1374 | ||
1375 | if (is_cplus_marker (string[0])) | |
1376 | { | |
1377 | /* Special GNU C++ names. */ | |
1378 | switch (string[1]) | |
1379 | { | |
c5aa993b JM |
1380 | case 't': |
1381 | SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"), | |
1382 | &objfile->symbol_obstack); | |
1383 | break; | |
c906108c | 1384 | |
c5aa993b JM |
1385 | case 'v': /* $vtbl_ptr_type */ |
1386 | /* Was: SYMBOL_NAME (sym) = "vptr"; */ | |
1387 | goto normal; | |
c906108c | 1388 | |
c5aa993b JM |
1389 | case 'e': |
1390 | SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"), | |
1391 | &objfile->symbol_obstack); | |
1392 | break; | |
c906108c | 1393 | |
c5aa993b JM |
1394 | case '_': |
1395 | /* This was an anonymous type that was never fixed up. */ | |
1396 | goto normal; | |
c906108c SS |
1397 | |
1398 | #ifdef STATIC_TRANSFORM_NAME | |
c5aa993b JM |
1399 | case 'X': |
1400 | /* SunPRO (3.0 at least) static variable encoding. */ | |
1401 | goto normal; | |
c906108c SS |
1402 | #endif |
1403 | ||
c5aa993b JM |
1404 | default: |
1405 | complain (&unrecognized_cplus_name_complaint, string); | |
1406 | goto normal; /* Do *something* with it */ | |
c906108c SS |
1407 | } |
1408 | } | |
1409 | else if (string[0] == '#') | |
1410 | { | |
1411 | /* Special GNU C extension for referencing symbols. */ | |
1412 | char *s; | |
1413 | int refnum, nlen; | |
1414 | ||
1415 | /* If STRING defines a new reference id, then add it to the | |
c5aa993b JM |
1416 | reference map. Else it must be referring to a previously |
1417 | defined symbol, so add it to the alias list of the previously | |
1418 | defined symbol. */ | |
c906108c SS |
1419 | s = string; |
1420 | refnum = symbol_reference_defined (&s); | |
1421 | if (refnum >= 0) | |
c5aa993b JM |
1422 | ref_add (refnum, sym, string, SYMBOL_VALUE (sym)); |
1423 | else if (!resolve_symbol_reference (objfile, sym, string)) | |
1424 | return NULL; | |
c906108c SS |
1425 | |
1426 | /* S..P contains the name of the symbol. We need to store | |
c5aa993b | 1427 | the correct name into SYMBOL_NAME. */ |
c906108c SS |
1428 | nlen = p - s; |
1429 | if (refnum >= 0) | |
1430 | { | |
1431 | if (nlen > 0) | |
1432 | { | |
1433 | SYMBOL_NAME (sym) = (char *) | |
c5aa993b | 1434 | obstack_alloc (&objfile->symbol_obstack, nlen); |
c906108c SS |
1435 | strncpy (SYMBOL_NAME (sym), s, nlen); |
1436 | SYMBOL_NAME (sym)[nlen] = '\0'; | |
1437 | SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); | |
1438 | } | |
1439 | else | |
1440 | /* FIXME! Want SYMBOL_NAME (sym) = 0; | |
1441 | Get error if leave name 0. So give it something. */ | |
1442 | { | |
1443 | nlen = p - string; | |
c5aa993b JM |
1444 | SYMBOL_NAME (sym) = (char *) |
1445 | obstack_alloc (&objfile->symbol_obstack, nlen); | |
c906108c SS |
1446 | strncpy (SYMBOL_NAME (sym), string, nlen); |
1447 | SYMBOL_NAME (sym)[nlen] = '\0'; | |
1448 | SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); | |
1449 | } | |
1450 | } | |
1451 | /* Advance STRING beyond the reference id. */ | |
1452 | string = s; | |
1453 | } | |
1454 | else | |
1455 | { | |
1456 | normal: | |
c5aa993b JM |
1457 | SYMBOL_LANGUAGE (sym) = current_subfile->language; |
1458 | SYMBOL_NAME (sym) = (char *) | |
1459 | obstack_alloc (&objfile->symbol_obstack, ((p - string) + 1)); | |
c906108c SS |
1460 | /* Open-coded memcpy--saves function call time. */ |
1461 | /* FIXME: Does it really? Try replacing with simple strcpy and | |
c5aa993b | 1462 | try it on an executable with a large symbol table. */ |
c906108c | 1463 | /* FIXME: considering that gcc can open code memcpy anyway, I |
c5aa993b | 1464 | doubt it. xoxorich. */ |
c906108c SS |
1465 | { |
1466 | register char *p1 = string; | |
1467 | register char *p2 = SYMBOL_NAME (sym); | |
1468 | while (p1 != p) | |
1469 | { | |
1470 | *p2++ = *p1++; | |
1471 | } | |
1472 | *p2++ = '\0'; | |
1473 | } | |
1474 | ||
1475 | /* If this symbol is from a C++ compilation, then attempt to cache the | |
c5aa993b JM |
1476 | demangled form for future reference. This is a typical time versus |
1477 | space tradeoff, that was decided in favor of time because it sped up | |
1478 | C++ symbol lookups by a factor of about 20. */ | |
c906108c SS |
1479 | |
1480 | SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack); | |
1481 | } | |
1482 | p++; | |
1483 | ||
1484 | /* Determine the type of name being defined. */ | |
1485 | #if 0 | |
1486 | /* Getting GDB to correctly skip the symbol on an undefined symbol | |
1487 | descriptor and not ever dump core is a very dodgy proposition if | |
1488 | we do things this way. I say the acorn RISC machine can just | |
1489 | fix their compiler. */ | |
1490 | /* The Acorn RISC machine's compiler can put out locals that don't | |
1491 | start with "234=" or "(3,4)=", so assume anything other than the | |
1492 | deftypes we know how to handle is a local. */ | |
1493 | if (!strchr ("cfFGpPrStTvVXCR", *p)) | |
1494 | #else | |
1495 | if (isdigit (*p) || *p == '(' || *p == '-') | |
1496 | #endif | |
1497 | deftype = 'l'; | |
1498 | else | |
1499 | deftype = *p++; | |
1500 | ||
1501 | switch (deftype) | |
1502 | { | |
1503 | case 'c': | |
1504 | /* c is a special case, not followed by a type-number. | |
c5aa993b JM |
1505 | SYMBOL:c=iVALUE for an integer constant symbol. |
1506 | SYMBOL:c=rVALUE for a floating constant symbol. | |
1507 | SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol. | |
1508 | e.g. "b:c=e6,0" for "const b = blob1" | |
1509 | (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ | |
c906108c SS |
1510 | if (*p != '=') |
1511 | { | |
1512 | SYMBOL_CLASS (sym) = LOC_CONST; | |
1513 | SYMBOL_TYPE (sym) = error_type (&p, objfile); | |
1514 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1515 | add_symbol_to_list (sym, &file_symbols); | |
1516 | return sym; | |
1517 | } | |
1518 | ++p; | |
1519 | switch (*p++) | |
1520 | { | |
1521 | case 'r': | |
1522 | { | |
1523 | double d = atof (p); | |
1524 | char *dbl_valu; | |
1525 | ||
1526 | /* FIXME-if-picky-about-floating-accuracy: Should be using | |
1527 | target arithmetic to get the value. real.c in GCC | |
1528 | probably has the necessary code. */ | |
1529 | ||
1530 | /* FIXME: lookup_fundamental_type is a hack. We should be | |
1531 | creating a type especially for the type of float constants. | |
1532 | Problem is, what type should it be? | |
1533 | ||
1534 | Also, what should the name of this type be? Should we | |
1535 | be using 'S' constants (see stabs.texinfo) instead? */ | |
1536 | ||
1537 | SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile, | |
1538 | FT_DBL_PREC_FLOAT); | |
1539 | dbl_valu = (char *) | |
c5aa993b | 1540 | obstack_alloc (&objfile->symbol_obstack, |
c906108c SS |
1541 | TYPE_LENGTH (SYMBOL_TYPE (sym))); |
1542 | store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)), d); | |
1543 | SYMBOL_VALUE_BYTES (sym) = dbl_valu; | |
1544 | SYMBOL_CLASS (sym) = LOC_CONST_BYTES; | |
1545 | } | |
1546 | break; | |
1547 | case 'i': | |
1548 | { | |
1549 | /* Defining integer constants this way is kind of silly, | |
1550 | since 'e' constants allows the compiler to give not | |
1551 | only the value, but the type as well. C has at least | |
1552 | int, long, unsigned int, and long long as constant | |
1553 | types; other languages probably should have at least | |
1554 | unsigned as well as signed constants. */ | |
1555 | ||
1556 | /* We just need one int constant type for all objfiles. | |
1557 | It doesn't depend on languages or anything (arguably its | |
1558 | name should be a language-specific name for a type of | |
1559 | that size, but I'm inclined to say that if the compiler | |
1560 | wants a nice name for the type, it can use 'e'). */ | |
1561 | static struct type *int_const_type; | |
1562 | ||
1563 | /* Yes, this is as long as a *host* int. That is because we | |
1564 | use atoi. */ | |
1565 | if (int_const_type == NULL) | |
1566 | int_const_type = | |
1567 | init_type (TYPE_CODE_INT, | |
1568 | sizeof (int) * HOST_CHAR_BIT / TARGET_CHAR_BIT, 0, | |
1569 | "integer constant", | |
c5aa993b | 1570 | (struct objfile *) NULL); |
c906108c SS |
1571 | SYMBOL_TYPE (sym) = int_const_type; |
1572 | SYMBOL_VALUE (sym) = atoi (p); | |
1573 | SYMBOL_CLASS (sym) = LOC_CONST; | |
1574 | } | |
1575 | break; | |
1576 | case 'e': | |
1577 | /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value | |
1578 | can be represented as integral. | |
1579 | e.g. "b:c=e6,0" for "const b = blob1" | |
1580 | (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */ | |
1581 | { | |
1582 | SYMBOL_CLASS (sym) = LOC_CONST; | |
1583 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1584 | ||
1585 | if (*p != ',') | |
1586 | { | |
1587 | SYMBOL_TYPE (sym) = error_type (&p, objfile); | |
1588 | break; | |
1589 | } | |
1590 | ++p; | |
1591 | ||
1592 | /* If the value is too big to fit in an int (perhaps because | |
1593 | it is unsigned), or something like that, we silently get | |
1594 | a bogus value. The type and everything else about it is | |
1595 | correct. Ideally, we should be using whatever we have | |
1596 | available for parsing unsigned and long long values, | |
1597 | however. */ | |
1598 | SYMBOL_VALUE (sym) = atoi (p); | |
1599 | } | |
1600 | break; | |
1601 | default: | |
1602 | { | |
1603 | SYMBOL_CLASS (sym) = LOC_CONST; | |
1604 | SYMBOL_TYPE (sym) = error_type (&p, objfile); | |
1605 | } | |
1606 | } | |
1607 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1608 | add_symbol_to_list (sym, &file_symbols); | |
1609 | return sym; | |
1610 | ||
1611 | case 'C': | |
1612 | /* The name of a caught exception. */ | |
1613 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1614 | SYMBOL_CLASS (sym) = LOC_LABEL; | |
1615 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1616 | SYMBOL_VALUE_ADDRESS (sym) = valu; | |
1617 | add_symbol_to_list (sym, &local_symbols); | |
1618 | break; | |
1619 | ||
1620 | case 'f': | |
1621 | /* A static function definition. */ | |
1622 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1623 | SYMBOL_CLASS (sym) = LOC_BLOCK; | |
1624 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1625 | add_symbol_to_list (sym, &file_symbols); | |
1626 | /* fall into process_function_types. */ | |
1627 | ||
1628 | process_function_types: | |
1629 | /* Function result types are described as the result type in stabs. | |
c5aa993b JM |
1630 | We need to convert this to the function-returning-type-X type |
1631 | in GDB. E.g. "int" is converted to "function returning int". */ | |
c906108c SS |
1632 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC) |
1633 | SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym)); | |
1634 | ||
1635 | /* All functions in C++ have prototypes. */ | |
1636 | if (SYMBOL_LANGUAGE (sym) == language_cplus) | |
1637 | TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED; | |
1638 | ||
1639 | /* fall into process_prototype_types */ | |
1640 | ||
1641 | process_prototype_types: | |
1642 | /* Sun acc puts declared types of arguments here. */ | |
1643 | if (*p == ';') | |
1644 | { | |
1645 | struct type *ftype = SYMBOL_TYPE (sym); | |
1646 | int nsemi = 0; | |
1647 | int nparams = 0; | |
1648 | char *p1 = p; | |
1649 | ||
1650 | /* Obtain a worst case guess for the number of arguments | |
1651 | by counting the semicolons. */ | |
1652 | while (*p1) | |
1653 | { | |
1654 | if (*p1++ == ';') | |
1655 | nsemi++; | |
1656 | } | |
1657 | ||
1658 | /* Allocate parameter information fields and fill them in. */ | |
1659 | TYPE_FIELDS (ftype) = (struct field *) | |
1660 | TYPE_ALLOC (ftype, nsemi * sizeof (struct field)); | |
1661 | while (*p++ == ';') | |
1662 | { | |
1663 | struct type *ptype; | |
1664 | ||
1665 | /* A type number of zero indicates the start of varargs. | |
c5aa993b | 1666 | FIXME: GDB currently ignores vararg functions. */ |
c906108c SS |
1667 | if (p[0] == '0' && p[1] == '\0') |
1668 | break; | |
1669 | ptype = read_type (&p, objfile); | |
1670 | ||
1671 | /* The Sun compilers mark integer arguments, which should | |
c5aa993b JM |
1672 | be promoted to the width of the calling conventions, with |
1673 | a type which references itself. This type is turned into | |
1674 | a TYPE_CODE_VOID type by read_type, and we have to turn | |
1675 | it back into builtin_type_int here. | |
1676 | FIXME: Do we need a new builtin_type_promoted_int_arg ? */ | |
c906108c SS |
1677 | if (TYPE_CODE (ptype) == TYPE_CODE_VOID) |
1678 | ptype = builtin_type_int; | |
1679 | TYPE_FIELD_TYPE (ftype, nparams++) = ptype; | |
1680 | } | |
1681 | TYPE_NFIELDS (ftype) = nparams; | |
1682 | TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED; | |
1683 | } | |
1684 | break; | |
1685 | ||
1686 | case 'F': | |
1687 | /* A global function definition. */ | |
1688 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1689 | SYMBOL_CLASS (sym) = LOC_BLOCK; | |
1690 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1691 | add_symbol_to_list (sym, &global_symbols); | |
1692 | goto process_function_types; | |
1693 | ||
1694 | case 'G': | |
1695 | /* For a class G (global) symbol, it appears that the | |
c5aa993b JM |
1696 | value is not correct. It is necessary to search for the |
1697 | corresponding linker definition to find the value. | |
1698 | These definitions appear at the end of the namelist. */ | |
c906108c SS |
1699 | SYMBOL_TYPE (sym) = read_type (&p, objfile); |
1700 | SYMBOL_CLASS (sym) = LOC_STATIC; | |
1701 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1702 | /* Don't add symbol references to global_sym_chain. | |
c5aa993b JM |
1703 | Symbol references don't have valid names and wont't match up with |
1704 | minimal symbols when the global_sym_chain is relocated. | |
1705 | We'll fixup symbol references when we fixup the defining symbol. */ | |
c906108c SS |
1706 | if (SYMBOL_NAME (sym) && SYMBOL_NAME (sym)[0] != '#') |
1707 | { | |
c5aa993b JM |
1708 | i = hashname (SYMBOL_NAME (sym)); |
1709 | SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i]; | |
1710 | global_sym_chain[i] = sym; | |
c906108c SS |
1711 | } |
1712 | add_symbol_to_list (sym, &global_symbols); | |
1713 | break; | |
1714 | ||
1715 | /* This case is faked by a conditional above, | |
c5aa993b JM |
1716 | when there is no code letter in the dbx data. |
1717 | Dbx data never actually contains 'l'. */ | |
c906108c SS |
1718 | case 's': |
1719 | case 'l': | |
1720 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1721 | SYMBOL_CLASS (sym) = LOC_LOCAL; | |
1722 | SYMBOL_VALUE (sym) = valu; | |
1723 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1724 | add_symbol_to_list (sym, &local_symbols); | |
1725 | break; | |
1726 | ||
1727 | case 'p': | |
1728 | if (*p == 'F') | |
1729 | /* pF is a two-letter code that means a function parameter in Fortran. | |
1730 | The type-number specifies the type of the return value. | |
1731 | Translate it into a pointer-to-function type. */ | |
1732 | { | |
1733 | p++; | |
1734 | SYMBOL_TYPE (sym) | |
1735 | = lookup_pointer_type | |
c5aa993b | 1736 | (lookup_function_type (read_type (&p, objfile))); |
c906108c SS |
1737 | } |
1738 | else | |
1739 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1740 | ||
1741 | /* Normally this is a parameter, a LOC_ARG. On the i960, it | |
c5aa993b | 1742 | can also be a LOC_LOCAL_ARG depending on symbol type. */ |
c906108c SS |
1743 | #ifndef DBX_PARM_SYMBOL_CLASS |
1744 | #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG | |
1745 | #endif | |
1746 | ||
1747 | SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type); | |
1748 | SYMBOL_VALUE (sym) = valu; | |
1749 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1750 | add_symbol_to_list (sym, &local_symbols); | |
1751 | ||
1752 | if (TARGET_BYTE_ORDER != BIG_ENDIAN) | |
1753 | { | |
1754 | /* On little-endian machines, this crud is never necessary, | |
1755 | and, if the extra bytes contain garbage, is harmful. */ | |
1756 | break; | |
1757 | } | |
1758 | ||
1759 | /* If it's gcc-compiled, if it says `short', believe it. */ | |
1760 | if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION) | |
1761 | break; | |
1762 | ||
7a292a7a SS |
1763 | if (!BELIEVE_PCC_PROMOTION) |
1764 | { | |
1765 | /* This is the signed type which arguments get promoted to. */ | |
1766 | static struct type *pcc_promotion_type; | |
1767 | /* This is the unsigned type which arguments get promoted to. */ | |
1768 | static struct type *pcc_unsigned_promotion_type; | |
c5aa993b | 1769 | |
7a292a7a SS |
1770 | /* Call it "int" because this is mainly C lossage. */ |
1771 | if (pcc_promotion_type == NULL) | |
1772 | pcc_promotion_type = | |
1773 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
1774 | 0, "int", NULL); | |
c5aa993b | 1775 | |
7a292a7a SS |
1776 | if (pcc_unsigned_promotion_type == NULL) |
1777 | pcc_unsigned_promotion_type = | |
1778 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
1779 | TYPE_FLAG_UNSIGNED, "unsigned int", NULL); | |
c5aa993b | 1780 | |
7a292a7a SS |
1781 | if (BELIEVE_PCC_PROMOTION_TYPE) |
1782 | { | |
1783 | /* This is defined on machines (e.g. sparc) where we | |
c5aa993b JM |
1784 | should believe the type of a PCC 'short' argument, |
1785 | but shouldn't believe the address (the address is the | |
1786 | address of the corresponding int). | |
1787 | ||
1788 | My guess is that this correction, as opposed to | |
1789 | changing the parameter to an 'int' (as done below, | |
1790 | for PCC on most machines), is the right thing to do | |
1791 | on all machines, but I don't want to risk breaking | |
1792 | something that already works. On most PCC machines, | |
1793 | the sparc problem doesn't come up because the calling | |
1794 | function has to zero the top bytes (not knowing | |
1795 | whether the called function wants an int or a short), | |
1796 | so there is little practical difference between an | |
1797 | int and a short (except perhaps what happens when the | |
1798 | GDB user types "print short_arg = 0x10000;"). | |
1799 | ||
1800 | Hacked for SunOS 4.1 by [email protected]. In 4.1, the | |
1801 | compiler actually produces the correct address (we | |
1802 | don't need to fix it up). I made this code adapt so | |
1803 | that it will offset the symbol if it was pointing at | |
1804 | an int-aligned location and not otherwise. This way | |
1805 | you can use the same gdb for 4.0.x and 4.1 systems. | |
1806 | ||
1807 | If the parameter is shorter than an int, and is | |
1808 | integral (e.g. char, short, or unsigned equivalent), | |
1809 | and is claimed to be passed on an integer boundary, | |
1810 | don't believe it! Offset the parameter's address to | |
1811 | the tail-end of that integer. */ | |
1812 | ||
7a292a7a SS |
1813 | if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type) |
1814 | && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT | |
c5aa993b | 1815 | && 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (pcc_promotion_type)) |
7a292a7a SS |
1816 | { |
1817 | SYMBOL_VALUE (sym) += TYPE_LENGTH (pcc_promotion_type) | |
1818 | - TYPE_LENGTH (SYMBOL_TYPE (sym)); | |
1819 | } | |
1820 | break; | |
1821 | } | |
1822 | else | |
1823 | { | |
1824 | /* If PCC says a parameter is a short or a char, | |
c5aa993b | 1825 | it is really an int. */ |
7a292a7a SS |
1826 | if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type) |
1827 | && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT) | |
1828 | { | |
1829 | SYMBOL_TYPE (sym) = | |
1830 | TYPE_UNSIGNED (SYMBOL_TYPE (sym)) | |
1831 | ? pcc_unsigned_promotion_type | |
1832 | : pcc_promotion_type; | |
1833 | } | |
1834 | break; | |
1835 | } | |
1836 | } | |
c906108c SS |
1837 | |
1838 | case 'P': | |
1839 | /* acc seems to use P to declare the prototypes of functions that | |
1840 | are referenced by this file. gdb is not prepared to deal | |
1841 | with this extra information. FIXME, it ought to. */ | |
1842 | if (type == N_FUN) | |
1843 | { | |
1844 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1845 | goto process_prototype_types; | |
1846 | } | |
c5aa993b | 1847 | /*FALLTHROUGH */ |
c906108c SS |
1848 | |
1849 | case 'R': | |
1850 | /* Parameter which is in a register. */ | |
1851 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1852 | SYMBOL_CLASS (sym) = LOC_REGPARM; | |
1853 | SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); | |
1854 | if (SYMBOL_VALUE (sym) >= NUM_REGS) | |
1855 | { | |
1856 | complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS, | |
1857 | SYMBOL_SOURCE_NAME (sym)); | |
c5aa993b | 1858 | SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ |
c906108c SS |
1859 | } |
1860 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1861 | add_symbol_to_list (sym, &local_symbols); | |
1862 | break; | |
1863 | ||
1864 | case 'r': | |
1865 | /* Register variable (either global or local). */ | |
1866 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1867 | SYMBOL_CLASS (sym) = LOC_REGISTER; | |
1868 | SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); | |
1869 | if (SYMBOL_VALUE (sym) >= NUM_REGS) | |
1870 | { | |
1871 | complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS, | |
1872 | SYMBOL_SOURCE_NAME (sym)); | |
c5aa993b | 1873 | SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ |
c906108c SS |
1874 | } |
1875 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1876 | if (within_function) | |
1877 | { | |
1878 | /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same | |
1879 | name to represent an argument passed in a register. | |
1880 | GCC uses 'P' for the same case. So if we find such a symbol pair | |
1881 | we combine it into one 'P' symbol. For Sun cc we need to do this | |
1882 | regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out | |
1883 | the 'p' symbol even if it never saves the argument onto the stack. | |
1884 | ||
1885 | On most machines, we want to preserve both symbols, so that | |
1886 | we can still get information about what is going on with the | |
1887 | stack (VAX for computing args_printed, using stack slots instead | |
1888 | of saved registers in backtraces, etc.). | |
1889 | ||
1890 | Note that this code illegally combines | |
c5aa993b | 1891 | main(argc) struct foo argc; { register struct foo argc; } |
c906108c SS |
1892 | but this case is considered pathological and causes a warning |
1893 | from a decent compiler. */ | |
1894 | ||
1895 | if (local_symbols | |
1896 | && local_symbols->nsyms > 0 | |
1897 | #ifndef USE_REGISTER_NOT_ARG | |
d03e67c9 | 1898 | && REG_STRUCT_HAS_ADDR_P () |
c906108c SS |
1899 | && REG_STRUCT_HAS_ADDR (processing_gcc_compilation, |
1900 | SYMBOL_TYPE (sym)) | |
1901 | && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT | |
1902 | || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION | |
1903 | || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET | |
1904 | || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING) | |
1905 | #endif | |
c5aa993b | 1906 | ) |
c906108c SS |
1907 | { |
1908 | struct symbol *prev_sym; | |
1909 | prev_sym = local_symbols->symbol[local_symbols->nsyms - 1]; | |
1910 | if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG | |
1911 | || SYMBOL_CLASS (prev_sym) == LOC_ARG) | |
c5aa993b | 1912 | && STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME (sym))) |
c906108c SS |
1913 | { |
1914 | SYMBOL_CLASS (prev_sym) = LOC_REGPARM; | |
1915 | /* Use the type from the LOC_REGISTER; that is the type | |
1916 | that is actually in that register. */ | |
1917 | SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym); | |
1918 | SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym); | |
1919 | sym = prev_sym; | |
1920 | break; | |
1921 | } | |
1922 | } | |
c5aa993b | 1923 | add_symbol_to_list (sym, &local_symbols); |
c906108c SS |
1924 | } |
1925 | else | |
c5aa993b | 1926 | add_symbol_to_list (sym, &file_symbols); |
c906108c SS |
1927 | break; |
1928 | ||
1929 | case 'S': | |
1930 | /* Static symbol at top level of file */ | |
1931 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1932 | SYMBOL_CLASS (sym) = LOC_STATIC; | |
1933 | SYMBOL_VALUE_ADDRESS (sym) = valu; | |
1934 | #ifdef STATIC_TRANSFORM_NAME | |
1935 | if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym))) | |
c5aa993b JM |
1936 | { |
1937 | struct minimal_symbol *msym; | |
1938 | msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile); | |
1939 | if (msym != NULL) | |
1940 | { | |
1941 | SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)); | |
1942 | SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym); | |
1943 | } | |
1944 | } | |
c906108c SS |
1945 | #endif |
1946 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1947 | add_symbol_to_list (sym, &file_symbols); | |
1948 | break; | |
1949 | ||
1950 | case 't': | |
1951 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
1952 | ||
1953 | /* For a nameless type, we don't want a create a symbol, thus we | |
c5aa993b JM |
1954 | did not use `sym'. Return without further processing. */ |
1955 | if (nameless) | |
1956 | return NULL; | |
c906108c SS |
1957 | |
1958 | SYMBOL_CLASS (sym) = LOC_TYPEDEF; | |
1959 | SYMBOL_VALUE (sym) = valu; | |
1960 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
1961 | /* C++ vagaries: we may have a type which is derived from | |
c5aa993b JM |
1962 | a base type which did not have its name defined when the |
1963 | derived class was output. We fill in the derived class's | |
1964 | base part member's name here in that case. */ | |
c906108c SS |
1965 | if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL) |
1966 | if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT | |
1967 | || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION) | |
1968 | && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym))) | |
1969 | { | |
1970 | int j; | |
1971 | for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--) | |
1972 | if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0) | |
1973 | TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) = | |
1974 | type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j)); | |
1975 | } | |
1976 | ||
1977 | if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL) | |
1978 | { | |
1979 | /* gcc-2.6 or later (when using -fvtable-thunks) | |
1980 | emits a unique named type for a vtable entry. | |
1981 | Some gdb code depends on that specific name. */ | |
1982 | extern const char vtbl_ptr_name[]; | |
1983 | ||
1984 | if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR | |
1985 | && strcmp (SYMBOL_NAME (sym), vtbl_ptr_name)) | |
1986 | || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC) | |
1987 | { | |
1988 | /* If we are giving a name to a type such as "pointer to | |
c5aa993b JM |
1989 | foo" or "function returning foo", we better not set |
1990 | the TYPE_NAME. If the program contains "typedef char | |
1991 | *caddr_t;", we don't want all variables of type char | |
1992 | * to print as caddr_t. This is not just a | |
1993 | consequence of GDB's type management; PCC and GCC (at | |
1994 | least through version 2.4) both output variables of | |
1995 | either type char * or caddr_t with the type number | |
1996 | defined in the 't' symbol for caddr_t. If a future | |
1997 | compiler cleans this up it GDB is not ready for it | |
1998 | yet, but if it becomes ready we somehow need to | |
1999 | disable this check (without breaking the PCC/GCC2.4 | |
2000 | case). | |
2001 | ||
2002 | Sigh. | |
2003 | ||
2004 | Fortunately, this check seems not to be necessary | |
2005 | for anything except pointers or functions. */ | |
c906108c SS |
2006 | } |
2007 | else | |
2008 | TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_NAME (sym); | |
2009 | } | |
2010 | ||
2011 | add_symbol_to_list (sym, &file_symbols); | |
2012 | break; | |
2013 | ||
2014 | case 'T': | |
2015 | /* Struct, union, or enum tag. For GNU C++, this can be be followed | |
c5aa993b | 2016 | by 't' which means we are typedef'ing it as well. */ |
c906108c SS |
2017 | synonym = *p == 't'; |
2018 | ||
2019 | if (synonym) | |
2020 | p++; | |
2021 | /* The semantics of C++ state that "struct foo { ... }" also defines | |
c5aa993b JM |
2022 | a typedef for "foo". Unfortunately, cfront never makes the typedef |
2023 | when translating C++ into C. We make the typedef here so that | |
2024 | "ptype foo" works as expected for cfront translated code. */ | |
c906108c SS |
2025 | else if (current_subfile->language == language_cplus) |
2026 | synonym = 1; | |
2027 | ||
2028 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
2029 | ||
2030 | /* For a nameless type, we don't want a create a symbol, thus we | |
c5aa993b JM |
2031 | did not use `sym'. Return without further processing. */ |
2032 | if (nameless) | |
2033 | return NULL; | |
c906108c SS |
2034 | |
2035 | SYMBOL_CLASS (sym) = LOC_TYPEDEF; | |
2036 | SYMBOL_VALUE (sym) = valu; | |
2037 | SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE; | |
2038 | if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0) | |
2039 | TYPE_TAG_NAME (SYMBOL_TYPE (sym)) | |
c5aa993b | 2040 | = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym)); |
c906108c SS |
2041 | add_symbol_to_list (sym, &file_symbols); |
2042 | ||
2043 | if (synonym) | |
2044 | { | |
2045 | /* Clone the sym and then modify it. */ | |
2046 | register struct symbol *typedef_sym = (struct symbol *) | |
c5aa993b | 2047 | obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); |
c906108c SS |
2048 | *typedef_sym = *sym; |
2049 | SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF; | |
2050 | SYMBOL_VALUE (typedef_sym) = valu; | |
2051 | SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE; | |
2052 | if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0) | |
2053 | TYPE_NAME (SYMBOL_TYPE (sym)) | |
c5aa993b | 2054 | = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym)); |
c906108c SS |
2055 | add_symbol_to_list (typedef_sym, &file_symbols); |
2056 | } | |
2057 | break; | |
2058 | ||
2059 | case 'V': | |
2060 | /* Static symbol of local scope */ | |
2061 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
2062 | SYMBOL_CLASS (sym) = LOC_STATIC; | |
2063 | SYMBOL_VALUE_ADDRESS (sym) = valu; | |
2064 | #ifdef STATIC_TRANSFORM_NAME | |
2065 | if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym))) | |
c5aa993b JM |
2066 | { |
2067 | struct minimal_symbol *msym; | |
2068 | msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile); | |
2069 | if (msym != NULL) | |
2070 | { | |
2071 | SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)); | |
2072 | SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym); | |
2073 | } | |
2074 | } | |
c906108c SS |
2075 | #endif |
2076 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
2077 | if (os9k_stabs) | |
2078 | add_symbol_to_list (sym, &global_symbols); | |
2079 | else | |
2080 | add_symbol_to_list (sym, &local_symbols); | |
2081 | break; | |
2082 | ||
2083 | case 'v': | |
2084 | /* Reference parameter */ | |
2085 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
2086 | SYMBOL_CLASS (sym) = LOC_REF_ARG; | |
2087 | SYMBOL_VALUE (sym) = valu; | |
2088 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
2089 | add_symbol_to_list (sym, &local_symbols); | |
2090 | break; | |
2091 | ||
2092 | case 'a': | |
2093 | /* Reference parameter which is in a register. */ | |
2094 | SYMBOL_TYPE (sym) = read_type (&p, objfile); | |
2095 | SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; | |
2096 | SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu); | |
2097 | if (SYMBOL_VALUE (sym) >= NUM_REGS) | |
2098 | { | |
2099 | complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS, | |
2100 | SYMBOL_SOURCE_NAME (sym)); | |
c5aa993b | 2101 | SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */ |
c906108c SS |
2102 | } |
2103 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
2104 | add_symbol_to_list (sym, &local_symbols); | |
2105 | break; | |
2106 | ||
2107 | case 'X': | |
2108 | /* This is used by Sun FORTRAN for "function result value". | |
c5aa993b JM |
2109 | Sun claims ("dbx and dbxtool interfaces", 2nd ed) |
2110 | that Pascal uses it too, but when I tried it Pascal used | |
2111 | "x:3" (local symbol) instead. */ | |
c906108c SS |
2112 | SYMBOL_TYPE (sym) = read_type (&p, objfile); |
2113 | SYMBOL_CLASS (sym) = LOC_LOCAL; | |
2114 | SYMBOL_VALUE (sym) = valu; | |
2115 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
2116 | add_symbol_to_list (sym, &local_symbols); | |
2117 | break; | |
2118 | ||
c5aa993b JM |
2119 | /* New code added to support cfront stabs strings. |
2120 | Note: case 'P' already handled above */ | |
c906108c SS |
2121 | case 'Z': |
2122 | /* Cfront type continuation coming up! | |
c5aa993b JM |
2123 | Find the original definition and add to it. |
2124 | We'll have to do this for the typedef too, | |
2125 | since we cloned the symbol to define a type in read_type. | |
2126 | Stabs info examples: | |
2127 | __1C :Ztl | |
2128 | foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24)) | |
2129 | C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;; | |
2130 | where C is the name of the class. | |
2131 | Unfortunately, we can't lookup the original symbol yet 'cuz | |
2132 | we haven't finished reading all the symbols. | |
2133 | Instead, we save it for processing later */ | |
c906108c | 2134 | process_later (sym, p, resolve_cfront_continuation); |
c5aa993b JM |
2135 | SYMBOL_TYPE (sym) = error_type (&p, objfile); /* FIXME! change later */ |
2136 | SYMBOL_CLASS (sym) = LOC_CONST; | |
2137 | SYMBOL_VALUE (sym) = 0; | |
c906108c SS |
2138 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; |
2139 | /* Don't add to list - we'll delete it later when | |
2140 | we add the continuation to the real sym */ | |
2141 | return sym; | |
2142 | /* End of new code added to support cfront stabs strings */ | |
2143 | ||
2144 | default: | |
2145 | SYMBOL_TYPE (sym) = error_type (&p, objfile); | |
2146 | SYMBOL_CLASS (sym) = LOC_CONST; | |
2147 | SYMBOL_VALUE (sym) = 0; | |
2148 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
2149 | add_symbol_to_list (sym, &file_symbols); | |
2150 | break; | |
2151 | } | |
2152 | ||
2153 | /* When passing structures to a function, some systems sometimes pass | |
2154 | the address in a register, not the structure itself. */ | |
2155 | ||
d03e67c9 AC |
2156 | if (REG_STRUCT_HAS_ADDR_P () |
2157 | && REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym)) | |
2158 | && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG)) | |
c906108c SS |
2159 | { |
2160 | struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym)); | |
2161 | ||
2162 | if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT) | |
2163 | || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION) | |
2164 | || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING) | |
2165 | || (TYPE_CODE (symbol_type) == TYPE_CODE_SET)) | |
2166 | { | |
2167 | /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert | |
2168 | LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */ | |
2169 | if (SYMBOL_CLASS (sym) == LOC_REGPARM) | |
2170 | SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR; | |
2171 | /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th | |
2172 | and subsequent arguments on the sparc, for example). */ | |
2173 | else if (SYMBOL_CLASS (sym) == LOC_ARG) | |
2174 | SYMBOL_CLASS (sym) = LOC_REF_ARG; | |
2175 | } | |
2176 | } | |
2177 | ||
2178 | /* Is there more to parse? For example LRS/alias information? */ | |
2179 | while (*p && *p == ';') | |
2180 | { | |
2181 | p++; | |
7a292a7a | 2182 | if (*p && p[0] == 'l' && p[1] == '(') |
c5aa993b JM |
2183 | { |
2184 | /* GNU extensions for live range splitting may be appended to | |
2185 | the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */ | |
c906108c SS |
2186 | |
2187 | /* Resolve the live range and add it to SYM's live range list. */ | |
2188 | if (!resolve_live_range (objfile, sym, p)) | |
2189 | return NULL; | |
2190 | ||
2191 | /* Find end of live range info. */ | |
2192 | p = strchr (p, ')'); | |
c5aa993b | 2193 | if (!*p || *p != ')') |
c906108c SS |
2194 | { |
2195 | complain (&lrs_general_complaint, "live range format not recognized"); | |
2196 | return NULL; | |
2197 | } | |
c5aa993b JM |
2198 | p++; |
2199 | } | |
c906108c SS |
2200 | } |
2201 | return sym; | |
2202 | } | |
2203 | ||
2204 | /* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns | |
2205 | non-zero on success, zero otherwise. */ | |
2206 | ||
2207 | static int | |
2208 | resolve_live_range (objfile, sym, p) | |
2209 | struct objfile *objfile; | |
2210 | struct symbol *sym; | |
2211 | char *p; | |
2212 | { | |
2213 | int refnum; | |
2214 | CORE_ADDR start, end; | |
2215 | ||
2216 | /* Sanity check the beginning of the stabs string. */ | |
2217 | if (!*p || *p != 'l') | |
2218 | { | |
2219 | complain (&lrs_general_complaint, "live range string 1"); | |
2220 | return 0; | |
2221 | } | |
2222 | p++; | |
2223 | ||
2224 | if (!*p || *p != '(') | |
2225 | { | |
2226 | complain (&lrs_general_complaint, "live range string 2"); | |
2227 | return 0; | |
2228 | } | |
2229 | p++; | |
c5aa993b | 2230 | |
c906108c SS |
2231 | /* Get starting value of range and advance P past the reference id. |
2232 | ||
2233 | ?!? In theory, the process_reference should never fail, but we should | |
2234 | catch that case just in case the compiler scrogged the stabs. */ | |
2235 | refnum = process_reference (&p); | |
2236 | start = ref_search_value (refnum); | |
2237 | if (!start) | |
2238 | { | |
2239 | complain (&lrs_general_complaint, "Live range symbol not found 1"); | |
2240 | return 0; | |
2241 | } | |
2242 | ||
2243 | if (!*p || *p != ',') | |
2244 | { | |
2245 | complain (&lrs_general_complaint, "live range string 3"); | |
2246 | return 0; | |
2247 | } | |
2248 | p++; | |
2249 | ||
2250 | /* Get ending value of range and advance P past the reference id. | |
2251 | ||
2252 | ?!? In theory, the process_reference should never fail, but we should | |
2253 | catch that case just in case the compiler scrogged the stabs. */ | |
2254 | refnum = process_reference (&p); | |
2255 | end = ref_search_value (refnum); | |
2256 | if (!end) | |
2257 | { | |
2258 | complain (&lrs_general_complaint, "Live range symbol not found 2"); | |
2259 | return 0; | |
2260 | } | |
2261 | ||
2262 | if (!*p || *p != ')') | |
2263 | { | |
2264 | complain (&lrs_general_complaint, "live range string 4"); | |
2265 | return 0; | |
2266 | } | |
2267 | ||
2268 | /* Now that we know the bounds of the range, add it to the | |
2269 | symbol. */ | |
2270 | add_live_range (objfile, sym, start, end); | |
2271 | ||
2272 | return 1; | |
2273 | } | |
2274 | ||
2275 | /* Add a new live range defined by START and END to the symbol SYM | |
2276 | in objfile OBJFILE. */ | |
2277 | ||
2278 | static void | |
2279 | add_live_range (objfile, sym, start, end) | |
2280 | struct objfile *objfile; | |
2281 | struct symbol *sym; | |
2282 | CORE_ADDR start, end; | |
2283 | { | |
2284 | struct range_list *r, *rs; | |
2285 | ||
2286 | if (start >= end) | |
2287 | { | |
2288 | complain (&lrs_general_complaint, "end of live range follows start"); | |
2289 | return; | |
2290 | } | |
2291 | ||
2292 | /* Alloc new live range structure. */ | |
2293 | r = (struct range_list *) | |
c5aa993b | 2294 | obstack_alloc (&objfile->type_obstack, |
c906108c SS |
2295 | sizeof (struct range_list)); |
2296 | r->start = start; | |
2297 | r->end = end; | |
2298 | r->next = 0; | |
2299 | ||
2300 | /* Append this range to the symbol's range list. */ | |
2301 | if (!SYMBOL_RANGES (sym)) | |
2302 | SYMBOL_RANGES (sym) = r; | |
2303 | else | |
2304 | { | |
2305 | /* Get the last range for the symbol. */ | |
2306 | for (rs = SYMBOL_RANGES (sym); rs->next; rs = rs->next) | |
2307 | ; | |
2308 | rs->next = r; | |
2309 | } | |
2310 | } | |
c906108c | 2311 | \f |
c5aa993b | 2312 | |
c906108c SS |
2313 | /* Skip rest of this symbol and return an error type. |
2314 | ||
2315 | General notes on error recovery: error_type always skips to the | |
2316 | end of the symbol (modulo cretinous dbx symbol name continuation). | |
2317 | Thus code like this: | |
2318 | ||
2319 | if (*(*pp)++ != ';') | |
c5aa993b | 2320 | return error_type (pp, objfile); |
c906108c SS |
2321 | |
2322 | is wrong because if *pp starts out pointing at '\0' (typically as the | |
2323 | result of an earlier error), it will be incremented to point to the | |
2324 | start of the next symbol, which might produce strange results, at least | |
2325 | if you run off the end of the string table. Instead use | |
2326 | ||
2327 | if (**pp != ';') | |
c5aa993b | 2328 | return error_type (pp, objfile); |
c906108c SS |
2329 | ++*pp; |
2330 | ||
2331 | or | |
2332 | ||
2333 | if (**pp != ';') | |
c5aa993b | 2334 | foo = error_type (pp, objfile); |
c906108c | 2335 | else |
c5aa993b | 2336 | ++*pp; |
c906108c SS |
2337 | |
2338 | And in case it isn't obvious, the point of all this hair is so the compiler | |
2339 | can define new types and new syntaxes, and old versions of the | |
2340 | debugger will be able to read the new symbol tables. */ | |
2341 | ||
2342 | static struct type * | |
2343 | error_type (pp, objfile) | |
2344 | char **pp; | |
2345 | struct objfile *objfile; | |
2346 | { | |
2347 | complain (&error_type_complaint); | |
2348 | while (1) | |
2349 | { | |
2350 | /* Skip to end of symbol. */ | |
2351 | while (**pp != '\0') | |
2352 | { | |
2353 | (*pp)++; | |
2354 | } | |
2355 | ||
2356 | /* Check for and handle cretinous dbx symbol name continuation! */ | |
2357 | if ((*pp)[-1] == '\\' || (*pp)[-1] == '?') | |
2358 | { | |
2359 | *pp = next_symbol_text (objfile); | |
2360 | } | |
2361 | else | |
2362 | { | |
2363 | break; | |
2364 | } | |
2365 | } | |
2366 | return (builtin_type_error); | |
2367 | } | |
c906108c | 2368 | \f |
c5aa993b | 2369 | |
c906108c SS |
2370 | /* Read type information or a type definition; return the type. Even |
2371 | though this routine accepts either type information or a type | |
2372 | definition, the distinction is relevant--some parts of stabsread.c | |
2373 | assume that type information starts with a digit, '-', or '(' in | |
2374 | deciding whether to call read_type. */ | |
2375 | ||
2376 | struct type * | |
2377 | read_type (pp, objfile) | |
2378 | register char **pp; | |
2379 | struct objfile *objfile; | |
2380 | { | |
2381 | register struct type *type = 0; | |
2382 | struct type *type1; | |
2383 | int typenums[2]; | |
2384 | char type_descriptor; | |
2385 | ||
2386 | /* Size in bits of type if specified by a type attribute, or -1 if | |
2387 | there is no size attribute. */ | |
2388 | int type_size = -1; | |
2389 | ||
2390 | /* Used to distinguish string and bitstring from char-array and set. */ | |
2391 | int is_string = 0; | |
2392 | ||
2393 | /* Read type number if present. The type number may be omitted. | |
2394 | for instance in a two-dimensional array declared with type | |
2395 | "ar1;1;10;ar1;1;10;4". */ | |
2396 | if ((**pp >= '0' && **pp <= '9') | |
2397 | || **pp == '(' | |
2398 | || **pp == '-') | |
2399 | { | |
2400 | if (read_type_number (pp, typenums) != 0) | |
2401 | return error_type (pp, objfile); | |
c5aa993b | 2402 | |
c906108c | 2403 | /* Type is not being defined here. Either it already exists, |
c5aa993b JM |
2404 | or this is a forward reference to it. dbx_alloc_type handles |
2405 | both cases. */ | |
c906108c SS |
2406 | if (**pp != '=') |
2407 | return dbx_alloc_type (typenums, objfile); | |
2408 | ||
2409 | /* Type is being defined here. */ | |
2410 | /* Skip the '='. | |
c5aa993b JM |
2411 | Also skip the type descriptor - we get it below with (*pp)[-1]. */ |
2412 | (*pp) += 2; | |
c906108c SS |
2413 | } |
2414 | else | |
2415 | { | |
2416 | /* 'typenums=' not present, type is anonymous. Read and return | |
c5aa993b | 2417 | the definition, but don't put it in the type vector. */ |
c906108c SS |
2418 | typenums[0] = typenums[1] = -1; |
2419 | (*pp)++; | |
2420 | } | |
2421 | ||
c5aa993b | 2422 | again: |
c906108c SS |
2423 | type_descriptor = (*pp)[-1]; |
2424 | switch (type_descriptor) | |
2425 | { | |
2426 | case 'x': | |
2427 | { | |
2428 | enum type_code code; | |
2429 | ||
2430 | /* Used to index through file_symbols. */ | |
2431 | struct pending *ppt; | |
2432 | int i; | |
c5aa993b | 2433 | |
c906108c SS |
2434 | /* Name including "struct", etc. */ |
2435 | char *type_name; | |
c5aa993b | 2436 | |
c906108c SS |
2437 | { |
2438 | char *from, *to, *p, *q1, *q2; | |
c5aa993b | 2439 | |
c906108c SS |
2440 | /* Set the type code according to the following letter. */ |
2441 | switch ((*pp)[0]) | |
2442 | { | |
2443 | case 's': | |
2444 | code = TYPE_CODE_STRUCT; | |
2445 | break; | |
2446 | case 'u': | |
2447 | code = TYPE_CODE_UNION; | |
2448 | break; | |
2449 | case 'e': | |
2450 | code = TYPE_CODE_ENUM; | |
2451 | break; | |
2452 | default: | |
2453 | { | |
2454 | /* Complain and keep going, so compilers can invent new | |
2455 | cross-reference types. */ | |
2456 | static struct complaint msg = | |
c5aa993b | 2457 | {"Unrecognized cross-reference type `%c'", 0, 0}; |
c906108c SS |
2458 | complain (&msg, (*pp)[0]); |
2459 | code = TYPE_CODE_STRUCT; | |
2460 | break; | |
2461 | } | |
2462 | } | |
c5aa993b | 2463 | |
c906108c SS |
2464 | q1 = strchr (*pp, '<'); |
2465 | p = strchr (*pp, ':'); | |
2466 | if (p == NULL) | |
2467 | return error_type (pp, objfile); | |
2468 | if (q1 && p > q1 && p[1] == ':') | |
2469 | { | |
2470 | int nesting_level = 0; | |
2471 | for (q2 = q1; *q2; q2++) | |
2472 | { | |
2473 | if (*q2 == '<') | |
2474 | nesting_level++; | |
2475 | else if (*q2 == '>') | |
2476 | nesting_level--; | |
2477 | else if (*q2 == ':' && nesting_level == 0) | |
2478 | break; | |
2479 | } | |
2480 | p = q2; | |
2481 | if (*p != ':') | |
2482 | return error_type (pp, objfile); | |
2483 | } | |
c5aa993b JM |
2484 | to = type_name = |
2485 | (char *) obstack_alloc (&objfile->type_obstack, p - *pp + 1); | |
2486 | ||
c906108c SS |
2487 | /* Copy the name. */ |
2488 | from = *pp + 1; | |
c5aa993b | 2489 | while (from < p) |
c906108c SS |
2490 | *to++ = *from++; |
2491 | *to = '\0'; | |
c5aa993b | 2492 | |
c906108c SS |
2493 | /* Set the pointer ahead of the name which we just read, and |
2494 | the colon. */ | |
2495 | *pp = from + 1; | |
2496 | } | |
2497 | ||
2498 | /* Now check to see whether the type has already been | |
2499 | declared. This was written for arrays of cross-referenced | |
2500 | types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty | |
2501 | sure it is not necessary anymore. But it might be a good | |
2502 | idea, to save a little memory. */ | |
2503 | ||
2504 | for (ppt = file_symbols; ppt; ppt = ppt->next) | |
2505 | for (i = 0; i < ppt->nsyms; i++) | |
2506 | { | |
2507 | struct symbol *sym = ppt->symbol[i]; | |
2508 | ||
2509 | if (SYMBOL_CLASS (sym) == LOC_TYPEDEF | |
2510 | && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE | |
2511 | && (TYPE_CODE (SYMBOL_TYPE (sym)) == code) | |
2512 | && STREQ (SYMBOL_NAME (sym), type_name)) | |
2513 | { | |
c5aa993b | 2514 | obstack_free (&objfile->type_obstack, type_name); |
c906108c SS |
2515 | type = SYMBOL_TYPE (sym); |
2516 | return type; | |
2517 | } | |
2518 | } | |
2519 | ||
2520 | /* Didn't find the type to which this refers, so we must | |
2521 | be dealing with a forward reference. Allocate a type | |
2522 | structure for it, and keep track of it so we can | |
2523 | fill in the rest of the fields when we get the full | |
2524 | type. */ | |
2525 | type = dbx_alloc_type (typenums, objfile); | |
2526 | TYPE_CODE (type) = code; | |
2527 | TYPE_TAG_NAME (type) = type_name; | |
c5aa993b | 2528 | INIT_CPLUS_SPECIFIC (type); |
c906108c SS |
2529 | TYPE_FLAGS (type) |= TYPE_FLAG_STUB; |
2530 | ||
2531 | add_undefined_type (type); | |
2532 | return type; | |
2533 | } | |
2534 | ||
c5aa993b | 2535 | case '-': /* RS/6000 built-in type */ |
c906108c SS |
2536 | case '0': |
2537 | case '1': | |
2538 | case '2': | |
2539 | case '3': | |
2540 | case '4': | |
2541 | case '5': | |
2542 | case '6': | |
2543 | case '7': | |
2544 | case '8': | |
2545 | case '9': | |
2546 | case '(': | |
2547 | (*pp)--; | |
2548 | ||
2549 | /* We deal with something like t(1,2)=(3,4)=... which | |
c5aa993b | 2550 | the Lucid compiler and recent gcc versions (post 2.7.3) use. */ |
c906108c SS |
2551 | |
2552 | /* Allocate and enter the typedef type first. | |
c5aa993b | 2553 | This handles recursive types. */ |
c906108c SS |
2554 | type = dbx_alloc_type (typenums, objfile); |
2555 | TYPE_CODE (type) = TYPE_CODE_TYPEDEF; | |
c5aa993b JM |
2556 | { |
2557 | struct type *xtype = read_type (pp, objfile); | |
c906108c SS |
2558 | if (type == xtype) |
2559 | { | |
2560 | /* It's being defined as itself. That means it is "void". */ | |
2561 | TYPE_CODE (type) = TYPE_CODE_VOID; | |
2562 | TYPE_LENGTH (type) = 1; | |
2563 | } | |
2564 | else if (type_size >= 0 || is_string) | |
2565 | { | |
2566 | *type = *xtype; | |
2567 | TYPE_NAME (type) = NULL; | |
2568 | TYPE_TAG_NAME (type) = NULL; | |
2569 | } | |
2570 | else | |
2571 | { | |
2572 | TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB; | |
2573 | TYPE_TARGET_TYPE (type) = xtype; | |
2574 | } | |
2575 | } | |
2576 | break; | |
2577 | ||
c5aa993b JM |
2578 | /* In the following types, we must be sure to overwrite any existing |
2579 | type that the typenums refer to, rather than allocating a new one | |
2580 | and making the typenums point to the new one. This is because there | |
2581 | may already be pointers to the existing type (if it had been | |
2582 | forward-referenced), and we must change it to a pointer, function, | |
2583 | reference, or whatever, *in-place*. */ | |
c906108c SS |
2584 | |
2585 | case '*': | |
2586 | type1 = read_type (pp, objfile); | |
2587 | type = make_pointer_type (type1, dbx_lookup_type (typenums)); | |
2588 | break; | |
2589 | ||
c5aa993b | 2590 | case '&': /* Reference to another type */ |
c906108c SS |
2591 | type1 = read_type (pp, objfile); |
2592 | type = make_reference_type (type1, dbx_lookup_type (typenums)); | |
2593 | break; | |
2594 | ||
c5aa993b | 2595 | case 'f': /* Function returning another type */ |
c906108c SS |
2596 | if (os9k_stabs && **pp == '(') |
2597 | { | |
2598 | /* Function prototype; parse it. | |
2599 | We must conditionalize this on os9k_stabs because otherwise | |
2600 | it could be confused with a Sun-style (1,3) typenumber | |
2601 | (I think). */ | |
2602 | struct type *t; | |
2603 | ++*pp; | |
2604 | while (**pp != ')') | |
c5aa993b JM |
2605 | { |
2606 | t = read_type (pp, objfile); | |
2607 | if (**pp == ',') | |
2608 | ++ * pp; | |
2609 | } | |
c906108c SS |
2610 | } |
2611 | type1 = read_type (pp, objfile); | |
2612 | type = make_function_type (type1, dbx_lookup_type (typenums)); | |
2613 | break; | |
2614 | ||
c5aa993b JM |
2615 | case 'k': /* Const qualifier on some type (Sun) */ |
2616 | case 'c': /* Const qualifier on some type (OS9000) */ | |
c906108c | 2617 | /* Because 'c' means other things to AIX and 'k' is perfectly good, |
c5aa993b | 2618 | only accept 'c' in the os9k_stabs case. */ |
c906108c SS |
2619 | if (type_descriptor == 'c' && !os9k_stabs) |
2620 | return error_type (pp, objfile); | |
2621 | type = read_type (pp, objfile); | |
2622 | /* FIXME! For now, we ignore const and volatile qualifiers. */ | |
2623 | break; | |
2624 | ||
c5aa993b JM |
2625 | case 'B': /* Volatile qual on some type (Sun) */ |
2626 | case 'i': /* Volatile qual on some type (OS9000) */ | |
c906108c | 2627 | /* Because 'i' means other things to AIX and 'B' is perfectly good, |
c5aa993b | 2628 | only accept 'i' in the os9k_stabs case. */ |
c906108c SS |
2629 | if (type_descriptor == 'i' && !os9k_stabs) |
2630 | return error_type (pp, objfile); | |
2631 | type = read_type (pp, objfile); | |
2632 | /* FIXME! For now, we ignore const and volatile qualifiers. */ | |
2633 | break; | |
2634 | ||
2635 | case '@': | |
c5aa993b JM |
2636 | if (isdigit (**pp) || **pp == '(' || **pp == '-') |
2637 | { /* Member (class & variable) type */ | |
c906108c SS |
2638 | /* FIXME -- we should be doing smash_to_XXX types here. */ |
2639 | ||
2640 | struct type *domain = read_type (pp, objfile); | |
2641 | struct type *memtype; | |
2642 | ||
2643 | if (**pp != ',') | |
2644 | /* Invalid member type data format. */ | |
2645 | return error_type (pp, objfile); | |
2646 | ++*pp; | |
2647 | ||
2648 | memtype = read_type (pp, objfile); | |
2649 | type = dbx_alloc_type (typenums, objfile); | |
2650 | smash_to_member_type (type, domain, memtype); | |
2651 | } | |
c5aa993b JM |
2652 | else |
2653 | /* type attribute */ | |
c906108c SS |
2654 | { |
2655 | char *attr = *pp; | |
2656 | /* Skip to the semicolon. */ | |
2657 | while (**pp != ';' && **pp != '\0') | |
2658 | ++(*pp); | |
2659 | if (**pp == '\0') | |
2660 | return error_type (pp, objfile); | |
2661 | else | |
c5aa993b | 2662 | ++ * pp; /* Skip the semicolon. */ |
c906108c SS |
2663 | |
2664 | switch (*attr) | |
2665 | { | |
2666 | case 's': | |
2667 | type_size = atoi (attr + 1); | |
2668 | if (type_size <= 0) | |
2669 | type_size = -1; | |
2670 | break; | |
2671 | ||
2672 | case 'S': | |
2673 | is_string = 1; | |
2674 | break; | |
2675 | ||
2676 | default: | |
2677 | /* Ignore unrecognized type attributes, so future compilers | |
c5aa993b | 2678 | can invent new ones. */ |
c906108c SS |
2679 | break; |
2680 | } | |
2681 | ++*pp; | |
2682 | goto again; | |
2683 | } | |
2684 | break; | |
2685 | ||
c5aa993b | 2686 | case '#': /* Method (class & fn) type */ |
c906108c SS |
2687 | if ((*pp)[0] == '#') |
2688 | { | |
2689 | /* We'll get the parameter types from the name. */ | |
2690 | struct type *return_type; | |
2691 | ||
2692 | (*pp)++; | |
2693 | return_type = read_type (pp, objfile); | |
2694 | if (*(*pp)++ != ';') | |
2695 | complain (&invalid_member_complaint, symnum); | |
2696 | type = allocate_stub_method (return_type); | |
2697 | if (typenums[0] != -1) | |
2698 | *dbx_lookup_type (typenums) = type; | |
2699 | } | |
2700 | else | |
2701 | { | |
2702 | struct type *domain = read_type (pp, objfile); | |
2703 | struct type *return_type; | |
2704 | struct type **args; | |
2705 | ||
2706 | if (**pp != ',') | |
2707 | /* Invalid member type data format. */ | |
2708 | return error_type (pp, objfile); | |
2709 | else | |
2710 | ++(*pp); | |
2711 | ||
2712 | return_type = read_type (pp, objfile); | |
2713 | args = read_args (pp, ';', objfile); | |
2714 | type = dbx_alloc_type (typenums, objfile); | |
2715 | smash_to_method_type (type, domain, return_type, args); | |
2716 | } | |
2717 | break; | |
2718 | ||
c5aa993b | 2719 | case 'r': /* Range type */ |
c906108c SS |
2720 | type = read_range_type (pp, typenums, objfile); |
2721 | if (typenums[0] != -1) | |
2722 | *dbx_lookup_type (typenums) = type; | |
2723 | break; | |
2724 | ||
2725 | case 'b': | |
2726 | if (os9k_stabs) | |
2727 | /* Const and volatile qualified type. */ | |
2728 | type = read_type (pp, objfile); | |
2729 | else | |
2730 | { | |
2731 | /* Sun ACC builtin int type */ | |
2732 | type = read_sun_builtin_type (pp, typenums, objfile); | |
2733 | if (typenums[0] != -1) | |
2734 | *dbx_lookup_type (typenums) = type; | |
2735 | } | |
2736 | break; | |
2737 | ||
c5aa993b | 2738 | case 'R': /* Sun ACC builtin float type */ |
c906108c SS |
2739 | type = read_sun_floating_type (pp, typenums, objfile); |
2740 | if (typenums[0] != -1) | |
2741 | *dbx_lookup_type (typenums) = type; | |
2742 | break; | |
c5aa993b JM |
2743 | |
2744 | case 'e': /* Enumeration type */ | |
c906108c SS |
2745 | type = dbx_alloc_type (typenums, objfile); |
2746 | type = read_enum_type (pp, type, objfile); | |
2747 | if (typenums[0] != -1) | |
2748 | *dbx_lookup_type (typenums) = type; | |
2749 | break; | |
2750 | ||
c5aa993b JM |
2751 | case 's': /* Struct type */ |
2752 | case 'u': /* Union type */ | |
c906108c SS |
2753 | type = dbx_alloc_type (typenums, objfile); |
2754 | switch (type_descriptor) | |
2755 | { | |
c5aa993b JM |
2756 | case 's': |
2757 | TYPE_CODE (type) = TYPE_CODE_STRUCT; | |
2758 | break; | |
2759 | case 'u': | |
2760 | TYPE_CODE (type) = TYPE_CODE_UNION; | |
2761 | break; | |
c906108c SS |
2762 | } |
2763 | type = read_struct_type (pp, type, objfile); | |
2764 | break; | |
2765 | ||
c5aa993b | 2766 | case 'a': /* Array type */ |
c906108c SS |
2767 | if (**pp != 'r') |
2768 | return error_type (pp, objfile); | |
2769 | ++*pp; | |
c5aa993b | 2770 | |
c906108c SS |
2771 | type = dbx_alloc_type (typenums, objfile); |
2772 | type = read_array_type (pp, type, objfile); | |
2773 | if (is_string) | |
2774 | TYPE_CODE (type) = TYPE_CODE_STRING; | |
2775 | break; | |
2776 | ||
2777 | case 'S': | |
2778 | type1 = read_type (pp, objfile); | |
c5aa993b | 2779 | type = create_set_type ((struct type *) NULL, type1); |
c906108c SS |
2780 | if (is_string) |
2781 | TYPE_CODE (type) = TYPE_CODE_BITSTRING; | |
2782 | if (typenums[0] != -1) | |
2783 | *dbx_lookup_type (typenums) = type; | |
2784 | break; | |
2785 | ||
2786 | default: | |
2787 | --*pp; /* Go back to the symbol in error */ | |
c5aa993b | 2788 | /* Particularly important if it was \0! */ |
c906108c SS |
2789 | return error_type (pp, objfile); |
2790 | } | |
2791 | ||
2792 | if (type == 0) | |
2793 | { | |
2794 | warning ("GDB internal error, type is NULL in stabsread.c\n"); | |
2795 | return error_type (pp, objfile); | |
2796 | } | |
2797 | ||
2798 | /* Size specified in a type attribute overrides any other size. */ | |
2799 | if (type_size != -1) | |
2800 | TYPE_LENGTH (type) = (type_size + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT; | |
2801 | ||
2802 | return type; | |
2803 | } | |
2804 | \f | |
2805 | /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1. | |
2806 | Return the proper type node for a given builtin type number. */ | |
2807 | ||
2808 | static struct type * | |
2809 | rs6000_builtin_type (typenum) | |
2810 | int typenum; | |
2811 | { | |
2812 | /* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */ | |
2813 | #define NUMBER_RECOGNIZED 34 | |
2814 | /* This includes an empty slot for type number -0. */ | |
2815 | static struct type *negative_types[NUMBER_RECOGNIZED + 1]; | |
2816 | struct type *rettype = NULL; | |
2817 | ||
2818 | if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED) | |
2819 | { | |
2820 | complain (&rs6000_builtin_complaint, typenum); | |
2821 | return builtin_type_error; | |
2822 | } | |
2823 | if (negative_types[-typenum] != NULL) | |
2824 | return negative_types[-typenum]; | |
2825 | ||
2826 | #if TARGET_CHAR_BIT != 8 | |
c5aa993b | 2827 | #error This code wrong for TARGET_CHAR_BIT not 8 |
c906108c SS |
2828 | /* These definitions all assume that TARGET_CHAR_BIT is 8. I think |
2829 | that if that ever becomes not true, the correct fix will be to | |
2830 | make the size in the struct type to be in bits, not in units of | |
2831 | TARGET_CHAR_BIT. */ | |
2832 | #endif | |
2833 | ||
2834 | switch (-typenum) | |
2835 | { | |
2836 | case 1: | |
2837 | /* The size of this and all the other types are fixed, defined | |
c5aa993b JM |
2838 | by the debugging format. If there is a type called "int" which |
2839 | is other than 32 bits, then it should use a new negative type | |
2840 | number (or avoid negative type numbers for that case). | |
2841 | See stabs.texinfo. */ | |
c906108c SS |
2842 | rettype = init_type (TYPE_CODE_INT, 4, 0, "int", NULL); |
2843 | break; | |
2844 | case 2: | |
2845 | rettype = init_type (TYPE_CODE_INT, 1, 0, "char", NULL); | |
2846 | break; | |
2847 | case 3: | |
2848 | rettype = init_type (TYPE_CODE_INT, 2, 0, "short", NULL); | |
2849 | break; | |
2850 | case 4: | |
2851 | rettype = init_type (TYPE_CODE_INT, 4, 0, "long", NULL); | |
2852 | break; | |
2853 | case 5: | |
2854 | rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, | |
2855 | "unsigned char", NULL); | |
2856 | break; | |
2857 | case 6: | |
2858 | rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", NULL); | |
2859 | break; | |
2860 | case 7: | |
2861 | rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, | |
2862 | "unsigned short", NULL); | |
2863 | break; | |
2864 | case 8: | |
2865 | rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, | |
2866 | "unsigned int", NULL); | |
2867 | break; | |
2868 | case 9: | |
2869 | rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, | |
2870 | "unsigned", NULL); | |
2871 | case 10: | |
2872 | rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED, | |
2873 | "unsigned long", NULL); | |
2874 | break; | |
2875 | case 11: | |
2876 | rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL); | |
2877 | break; | |
2878 | case 12: | |
2879 | /* IEEE single precision (32 bit). */ | |
2880 | rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL); | |
2881 | break; | |
2882 | case 13: | |
2883 | /* IEEE double precision (64 bit). */ | |
2884 | rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL); | |
2885 | break; | |
2886 | case 14: | |
2887 | /* This is an IEEE double on the RS/6000, and different machines with | |
c5aa993b JM |
2888 | different sizes for "long double" should use different negative |
2889 | type numbers. See stabs.texinfo. */ | |
c906108c SS |
2890 | rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", NULL); |
2891 | break; | |
2892 | case 15: | |
2893 | rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", NULL); | |
2894 | break; | |
2895 | case 16: | |
2896 | rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED, | |
2897 | "boolean", NULL); | |
2898 | break; | |
2899 | case 17: | |
2900 | rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", NULL); | |
2901 | break; | |
2902 | case 18: | |
2903 | rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", NULL); | |
2904 | break; | |
2905 | case 19: | |
2906 | rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", NULL); | |
2907 | break; | |
2908 | case 20: | |
2909 | rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED, | |
2910 | "character", NULL); | |
2911 | break; | |
2912 | case 21: | |
2913 | rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED, | |
2914 | "logical*1", NULL); | |
2915 | break; | |
2916 | case 22: | |
2917 | rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED, | |
2918 | "logical*2", NULL); | |
2919 | break; | |
2920 | case 23: | |
2921 | rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED, | |
2922 | "logical*4", NULL); | |
2923 | break; | |
2924 | case 24: | |
2925 | rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED, | |
2926 | "logical", NULL); | |
2927 | break; | |
2928 | case 25: | |
2929 | /* Complex type consisting of two IEEE single precision values. */ | |
2930 | rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL); | |
2931 | break; | |
2932 | case 26: | |
2933 | /* Complex type consisting of two IEEE double precision values. */ | |
2934 | rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL); | |
2935 | break; | |
2936 | case 27: | |
2937 | rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL); | |
2938 | break; | |
2939 | case 28: | |
2940 | rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", NULL); | |
2941 | break; | |
2942 | case 29: | |
2943 | rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", NULL); | |
2944 | break; | |
2945 | case 30: | |
2946 | rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL); | |
2947 | break; | |
2948 | case 31: | |
2949 | rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL); | |
2950 | break; | |
2951 | case 32: | |
2952 | rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, | |
2953 | "unsigned long long", NULL); | |
2954 | break; | |
2955 | case 33: | |
2956 | rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED, | |
2957 | "logical*8", NULL); | |
2958 | break; | |
2959 | case 34: | |
2960 | rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL); | |
2961 | break; | |
2962 | } | |
2963 | negative_types[-typenum] = rettype; | |
2964 | return rettype; | |
2965 | } | |
2966 | \f | |
2967 | /* This page contains subroutines of read_type. */ | |
2968 | ||
2969 | /* Read member function stabs info for C++ classes. The form of each member | |
2970 | function data is: | |
2971 | ||
c5aa993b | 2972 | NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ; |
c906108c SS |
2973 | |
2974 | An example with two member functions is: | |
2975 | ||
c5aa993b | 2976 | afunc1::20=##15;:i;2A.;afunc2::20:i;2A.; |
c906108c SS |
2977 | |
2978 | For the case of overloaded operators, the format is op$::*.funcs, where | |
2979 | $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator | |
2980 | name (such as `+=') and `.' marks the end of the operator name. | |
2981 | ||
2982 | Returns 1 for success, 0 for failure. */ | |
2983 | ||
2984 | static int | |
2985 | read_member_functions (fip, pp, type, objfile) | |
2986 | struct field_info *fip; | |
2987 | char **pp; | |
2988 | struct type *type; | |
2989 | struct objfile *objfile; | |
2990 | { | |
2991 | int nfn_fields = 0; | |
2992 | int length = 0; | |
2993 | /* Total number of member functions defined in this class. If the class | |
2994 | defines two `f' functions, and one `g' function, then this will have | |
2995 | the value 3. */ | |
2996 | int total_length = 0; | |
2997 | int i; | |
2998 | struct next_fnfield | |
2999 | { | |
3000 | struct next_fnfield *next; | |
3001 | struct fn_field fn_field; | |
c5aa993b JM |
3002 | } |
3003 | *sublist; | |
c906108c SS |
3004 | struct type *look_ahead_type; |
3005 | struct next_fnfieldlist *new_fnlist; | |
3006 | struct next_fnfield *new_sublist; | |
3007 | char *main_fn_name; | |
3008 | register char *p; | |
c5aa993b | 3009 | |
c906108c SS |
3010 | /* Process each list until we find something that is not a member function |
3011 | or find the end of the functions. */ | |
3012 | ||
3013 | while (**pp != ';') | |
3014 | { | |
3015 | /* We should be positioned at the start of the function name. | |
c5aa993b JM |
3016 | Scan forward to find the first ':' and if it is not the |
3017 | first of a "::" delimiter, then this is not a member function. */ | |
c906108c SS |
3018 | p = *pp; |
3019 | while (*p != ':') | |
3020 | { | |
3021 | p++; | |
3022 | } | |
3023 | if (p[1] != ':') | |
3024 | { | |
3025 | break; | |
3026 | } | |
3027 | ||
3028 | sublist = NULL; | |
3029 | look_ahead_type = NULL; | |
3030 | length = 0; | |
c5aa993b | 3031 | |
c906108c SS |
3032 | new_fnlist = (struct next_fnfieldlist *) |
3033 | xmalloc (sizeof (struct next_fnfieldlist)); | |
3034 | make_cleanup (free, new_fnlist); | |
3035 | memset (new_fnlist, 0, sizeof (struct next_fnfieldlist)); | |
c5aa993b | 3036 | |
c906108c SS |
3037 | if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2])) |
3038 | { | |
3039 | /* This is a completely wierd case. In order to stuff in the | |
3040 | names that might contain colons (the usual name delimiter), | |
3041 | Mike Tiemann defined a different name format which is | |
3042 | signalled if the identifier is "op$". In that case, the | |
3043 | format is "op$::XXXX." where XXXX is the name. This is | |
3044 | used for names like "+" or "=". YUUUUUUUK! FIXME! */ | |
3045 | /* This lets the user type "break operator+". | |
3046 | We could just put in "+" as the name, but that wouldn't | |
3047 | work for "*". */ | |
c5aa993b JM |
3048 | static char opname[32] = |
3049 | {'o', 'p', CPLUS_MARKER}; | |
c906108c | 3050 | char *o = opname + 3; |
c5aa993b | 3051 | |
c906108c SS |
3052 | /* Skip past '::'. */ |
3053 | *pp = p + 2; | |
3054 | ||
3055 | STABS_CONTINUE (pp, objfile); | |
3056 | p = *pp; | |
3057 | while (*p != '.') | |
3058 | { | |
3059 | *o++ = *p++; | |
3060 | } | |
3061 | main_fn_name = savestring (opname, o - opname); | |
3062 | /* Skip past '.' */ | |
3063 | *pp = p + 1; | |
3064 | } | |
3065 | else | |
3066 | { | |
3067 | main_fn_name = savestring (*pp, p - *pp); | |
3068 | /* Skip past '::'. */ | |
3069 | *pp = p + 2; | |
3070 | } | |
c5aa993b JM |
3071 | new_fnlist->fn_fieldlist.name = main_fn_name; |
3072 | ||
c906108c SS |
3073 | do |
3074 | { | |
3075 | new_sublist = | |
3076 | (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield)); | |
3077 | make_cleanup (free, new_sublist); | |
3078 | memset (new_sublist, 0, sizeof (struct next_fnfield)); | |
c5aa993b | 3079 | |
c906108c SS |
3080 | /* Check for and handle cretinous dbx symbol name continuation! */ |
3081 | if (look_ahead_type == NULL) | |
3082 | { | |
3083 | /* Normal case. */ | |
3084 | STABS_CONTINUE (pp, objfile); | |
c5aa993b JM |
3085 | |
3086 | new_sublist->fn_field.type = read_type (pp, objfile); | |
c906108c SS |
3087 | if (**pp != ':') |
3088 | { | |
3089 | /* Invalid symtab info for member function. */ | |
3090 | return 0; | |
3091 | } | |
3092 | } | |
3093 | else | |
3094 | { | |
3095 | /* g++ version 1 kludge */ | |
c5aa993b | 3096 | new_sublist->fn_field.type = look_ahead_type; |
c906108c SS |
3097 | look_ahead_type = NULL; |
3098 | } | |
c5aa993b | 3099 | |
c906108c SS |
3100 | (*pp)++; |
3101 | p = *pp; | |
3102 | while (*p != ';') | |
3103 | { | |
3104 | p++; | |
3105 | } | |
c5aa993b | 3106 | |
c906108c SS |
3107 | /* If this is just a stub, then we don't have the real name here. */ |
3108 | ||
c5aa993b | 3109 | if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB) |
c906108c | 3110 | { |
c5aa993b JM |
3111 | if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type)) |
3112 | TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type; | |
3113 | new_sublist->fn_field.is_stub = 1; | |
c906108c | 3114 | } |
c5aa993b | 3115 | new_sublist->fn_field.physname = savestring (*pp, p - *pp); |
c906108c | 3116 | *pp = p + 1; |
c5aa993b | 3117 | |
c906108c SS |
3118 | /* Set this member function's visibility fields. */ |
3119 | switch (*(*pp)++) | |
3120 | { | |
c5aa993b JM |
3121 | case VISIBILITY_PRIVATE: |
3122 | new_sublist->fn_field.is_private = 1; | |
3123 | break; | |
3124 | case VISIBILITY_PROTECTED: | |
3125 | new_sublist->fn_field.is_protected = 1; | |
3126 | break; | |
c906108c | 3127 | } |
c5aa993b | 3128 | |
c906108c SS |
3129 | STABS_CONTINUE (pp, objfile); |
3130 | switch (**pp) | |
3131 | { | |
c5aa993b JM |
3132 | case 'A': /* Normal functions. */ |
3133 | new_sublist->fn_field.is_const = 0; | |
3134 | new_sublist->fn_field.is_volatile = 0; | |
3135 | (*pp)++; | |
3136 | break; | |
3137 | case 'B': /* `const' member functions. */ | |
3138 | new_sublist->fn_field.is_const = 1; | |
3139 | new_sublist->fn_field.is_volatile = 0; | |
3140 | (*pp)++; | |
3141 | break; | |
3142 | case 'C': /* `volatile' member function. */ | |
3143 | new_sublist->fn_field.is_const = 0; | |
3144 | new_sublist->fn_field.is_volatile = 1; | |
3145 | (*pp)++; | |
3146 | break; | |
3147 | case 'D': /* `const volatile' member function. */ | |
3148 | new_sublist->fn_field.is_const = 1; | |
3149 | new_sublist->fn_field.is_volatile = 1; | |
3150 | (*pp)++; | |
3151 | break; | |
3152 | case '*': /* File compiled with g++ version 1 -- no info */ | |
3153 | case '?': | |
3154 | case '.': | |
3155 | break; | |
3156 | default: | |
3157 | complain (&const_vol_complaint, **pp); | |
3158 | break; | |
c906108c | 3159 | } |
c5aa993b | 3160 | |
c906108c SS |
3161 | switch (*(*pp)++) |
3162 | { | |
c5aa993b | 3163 | case '*': |
c906108c SS |
3164 | { |
3165 | int nbits; | |
c5aa993b | 3166 | /* virtual member function, followed by index. |
c906108c SS |
3167 | The sign bit is set to distinguish pointers-to-methods |
3168 | from virtual function indicies. Since the array is | |
3169 | in words, the quantity must be shifted left by 1 | |
3170 | on 16 bit machine, and by 2 on 32 bit machine, forcing | |
3171 | the sign bit out, and usable as a valid index into | |
3172 | the array. Remove the sign bit here. */ | |
c5aa993b | 3173 | new_sublist->fn_field.voffset = |
c906108c SS |
3174 | (0x7fffffff & read_huge_number (pp, ';', &nbits)) + 2; |
3175 | if (nbits != 0) | |
3176 | return 0; | |
c5aa993b | 3177 | |
c906108c SS |
3178 | STABS_CONTINUE (pp, objfile); |
3179 | if (**pp == ';' || **pp == '\0') | |
3180 | { | |
3181 | /* Must be g++ version 1. */ | |
c5aa993b | 3182 | new_sublist->fn_field.fcontext = 0; |
c906108c SS |
3183 | } |
3184 | else | |
3185 | { | |
3186 | /* Figure out from whence this virtual function came. | |
3187 | It may belong to virtual function table of | |
3188 | one of its baseclasses. */ | |
3189 | look_ahead_type = read_type (pp, objfile); | |
3190 | if (**pp == ':') | |
3191 | { | |
3192 | /* g++ version 1 overloaded methods. */ | |
3193 | } | |
3194 | else | |
3195 | { | |
c5aa993b | 3196 | new_sublist->fn_field.fcontext = look_ahead_type; |
c906108c SS |
3197 | if (**pp != ';') |
3198 | { | |
3199 | return 0; | |
3200 | } | |
3201 | else | |
3202 | { | |
3203 | ++*pp; | |
3204 | } | |
3205 | look_ahead_type = NULL; | |
3206 | } | |
3207 | } | |
3208 | break; | |
3209 | } | |
c5aa993b JM |
3210 | case '?': |
3211 | /* static member function. */ | |
3212 | new_sublist->fn_field.voffset = VOFFSET_STATIC; | |
3213 | if (strncmp (new_sublist->fn_field.physname, | |
3214 | main_fn_name, strlen (main_fn_name))) | |
3215 | { | |
3216 | new_sublist->fn_field.is_stub = 1; | |
3217 | } | |
3218 | break; | |
3219 | ||
3220 | default: | |
3221 | /* error */ | |
3222 | complain (&member_fn_complaint, (*pp)[-1]); | |
3223 | /* Fall through into normal member function. */ | |
3224 | ||
3225 | case '.': | |
3226 | /* normal member function. */ | |
3227 | new_sublist->fn_field.voffset = 0; | |
3228 | new_sublist->fn_field.fcontext = 0; | |
3229 | break; | |
c906108c | 3230 | } |
c5aa993b JM |
3231 | |
3232 | new_sublist->next = sublist; | |
c906108c SS |
3233 | sublist = new_sublist; |
3234 | length++; | |
3235 | STABS_CONTINUE (pp, objfile); | |
3236 | } | |
3237 | while (**pp != ';' && **pp != '\0'); | |
c5aa993b | 3238 | |
c906108c | 3239 | (*pp)++; |
c5aa993b JM |
3240 | |
3241 | new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *) | |
3242 | obstack_alloc (&objfile->type_obstack, | |
c906108c | 3243 | sizeof (struct fn_field) * length); |
c5aa993b | 3244 | memset (new_fnlist->fn_fieldlist.fn_fields, 0, |
c906108c | 3245 | sizeof (struct fn_field) * length); |
c5aa993b | 3246 | for (i = length; (i--, sublist); sublist = sublist->next) |
c906108c | 3247 | { |
c5aa993b | 3248 | new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field; |
c906108c | 3249 | } |
c5aa993b JM |
3250 | |
3251 | new_fnlist->fn_fieldlist.length = length; | |
3252 | new_fnlist->next = fip->fnlist; | |
3253 | fip->fnlist = new_fnlist; | |
c906108c SS |
3254 | nfn_fields++; |
3255 | total_length += length; | |
3256 | STABS_CONTINUE (pp, objfile); | |
3257 | } | |
3258 | ||
3259 | if (nfn_fields) | |
3260 | { | |
3261 | ALLOCATE_CPLUS_STRUCT_TYPE (type); | |
3262 | TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *) | |
3263 | TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields); | |
3264 | memset (TYPE_FN_FIELDLISTS (type), 0, | |
3265 | sizeof (struct fn_fieldlist) * nfn_fields); | |
3266 | TYPE_NFN_FIELDS (type) = nfn_fields; | |
3267 | TYPE_NFN_FIELDS_TOTAL (type) = total_length; | |
3268 | } | |
3269 | ||
3270 | return 1; | |
3271 | } | |
3272 | ||
3273 | /* Special GNU C++ name. | |
3274 | ||
3275 | Returns 1 for success, 0 for failure. "failure" means that we can't | |
3276 | keep parsing and it's time for error_type(). */ | |
3277 | ||
3278 | static int | |
3279 | read_cpp_abbrev (fip, pp, type, objfile) | |
3280 | struct field_info *fip; | |
3281 | char **pp; | |
3282 | struct type *type; | |
3283 | struct objfile *objfile; | |
3284 | { | |
3285 | register char *p; | |
3286 | char *name; | |
3287 | char cpp_abbrev; | |
3288 | struct type *context; | |
3289 | ||
3290 | p = *pp; | |
3291 | if (*++p == 'v') | |
3292 | { | |
3293 | name = NULL; | |
3294 | cpp_abbrev = *++p; | |
3295 | ||
3296 | *pp = p + 1; | |
3297 | ||
3298 | /* At this point, *pp points to something like "22:23=*22...", | |
c5aa993b JM |
3299 | where the type number before the ':' is the "context" and |
3300 | everything after is a regular type definition. Lookup the | |
3301 | type, find it's name, and construct the field name. */ | |
c906108c SS |
3302 | |
3303 | context = read_type (pp, objfile); | |
3304 | ||
3305 | switch (cpp_abbrev) | |
3306 | { | |
c5aa993b JM |
3307 | case 'f': /* $vf -- a virtual function table pointer */ |
3308 | fip->list->field.name = | |
3309 | obconcat (&objfile->type_obstack, vptr_name, "", ""); | |
3310 | break; | |
c906108c | 3311 | |
c5aa993b JM |
3312 | case 'b': /* $vb -- a virtual bsomethingorother */ |
3313 | name = type_name_no_tag (context); | |
3314 | if (name == NULL) | |
3315 | { | |
3316 | complain (&invalid_cpp_type_complaint, symnum); | |
3317 | name = "FOO"; | |
3318 | } | |
3319 | fip->list->field.name = | |
3320 | obconcat (&objfile->type_obstack, vb_name, name, ""); | |
3321 | break; | |
c906108c | 3322 | |
c5aa993b JM |
3323 | default: |
3324 | complain (&invalid_cpp_abbrev_complaint, *pp); | |
3325 | fip->list->field.name = | |
3326 | obconcat (&objfile->type_obstack, | |
3327 | "INVALID_CPLUSPLUS_ABBREV", "", ""); | |
3328 | break; | |
c906108c SS |
3329 | } |
3330 | ||
3331 | /* At this point, *pp points to the ':'. Skip it and read the | |
c5aa993b | 3332 | field type. */ |
c906108c SS |
3333 | |
3334 | p = ++(*pp); | |
3335 | if (p[-1] != ':') | |
3336 | { | |
3337 | complain (&invalid_cpp_abbrev_complaint, *pp); | |
3338 | return 0; | |
3339 | } | |
3340 | fip->list->field.type = read_type (pp, objfile); | |
3341 | if (**pp == ',') | |
c5aa993b | 3342 | (*pp)++; /* Skip the comma. */ |
c906108c SS |
3343 | else |
3344 | return 0; | |
3345 | ||
3346 | { | |
3347 | int nbits; | |
3348 | FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ';', &nbits); | |
3349 | if (nbits != 0) | |
3350 | return 0; | |
3351 | } | |
3352 | /* This field is unpacked. */ | |
3353 | FIELD_BITSIZE (fip->list->field) = 0; | |
3354 | fip->list->visibility = VISIBILITY_PRIVATE; | |
3355 | } | |
3356 | else | |
3357 | { | |
3358 | complain (&invalid_cpp_abbrev_complaint, *pp); | |
3359 | /* We have no idea what syntax an unrecognized abbrev would have, so | |
c5aa993b JM |
3360 | better return 0. If we returned 1, we would need to at least advance |
3361 | *pp to avoid an infinite loop. */ | |
c906108c SS |
3362 | return 0; |
3363 | } | |
3364 | return 1; | |
3365 | } | |
3366 | ||
3367 | static void | |
3368 | read_one_struct_field (fip, pp, p, type, objfile) | |
3369 | struct field_info *fip; | |
3370 | char **pp; | |
3371 | char *p; | |
3372 | struct type *type; | |
3373 | struct objfile *objfile; | |
3374 | { | |
3375 | /* The following is code to work around cfront generated stabs. | |
3376 | The stabs contains full mangled name for each field. | |
3377 | We try to demangle the name and extract the field name out of it. | |
c5aa993b | 3378 | */ |
c906108c SS |
3379 | if (ARM_DEMANGLING && current_subfile->language == language_cplus) |
3380 | { | |
3381 | char save_p; | |
3382 | char *dem, *dem_p; | |
3383 | save_p = *p; | |
3384 | *p = '\0'; | |
3385 | dem = cplus_demangle (*pp, DMGL_ANSI | DMGL_PARAMS); | |
3386 | if (dem != NULL) | |
c5aa993b JM |
3387 | { |
3388 | dem_p = strrchr (dem, ':'); | |
3389 | if (dem_p != 0 && *(dem_p - 1) == ':') | |
3390 | dem_p++; | |
3391 | FIELD_NAME (fip->list->field) = | |
3392 | obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack); | |
3393 | } | |
c906108c | 3394 | else |
c5aa993b JM |
3395 | { |
3396 | FIELD_NAME (fip->list->field) = | |
3397 | obsavestring (*pp, p - *pp, &objfile->type_obstack); | |
3398 | } | |
c906108c SS |
3399 | *p = save_p; |
3400 | } | |
3401 | /* end of code for cfront work around */ | |
3402 | ||
3403 | else | |
c5aa993b JM |
3404 | fip->list->field.name = |
3405 | obsavestring (*pp, p - *pp, &objfile->type_obstack); | |
c906108c SS |
3406 | *pp = p + 1; |
3407 | ||
3408 | /* This means we have a visibility for a field coming. */ | |
3409 | if (**pp == '/') | |
3410 | { | |
3411 | (*pp)++; | |
c5aa993b | 3412 | fip->list->visibility = *(*pp)++; |
c906108c SS |
3413 | } |
3414 | else | |
3415 | { | |
3416 | /* normal dbx-style format, no explicit visibility */ | |
c5aa993b | 3417 | fip->list->visibility = VISIBILITY_PUBLIC; |
c906108c SS |
3418 | } |
3419 | ||
c5aa993b | 3420 | fip->list->field.type = read_type (pp, objfile); |
c906108c SS |
3421 | if (**pp == ':') |
3422 | { | |
3423 | p = ++(*pp); | |
3424 | #if 0 | |
3425 | /* Possible future hook for nested types. */ | |
3426 | if (**pp == '!') | |
3427 | { | |
c5aa993b | 3428 | fip->list->field.bitpos = (long) -2; /* nested type */ |
c906108c SS |
3429 | p = ++(*pp); |
3430 | } | |
c5aa993b JM |
3431 | else |
3432 | ...; | |
c906108c | 3433 | #endif |
c5aa993b | 3434 | while (*p != ';') |
c906108c SS |
3435 | { |
3436 | p++; | |
3437 | } | |
3438 | /* Static class member. */ | |
3439 | SET_FIELD_PHYSNAME (fip->list->field, savestring (*pp, p - *pp)); | |
3440 | *pp = p + 1; | |
3441 | return; | |
3442 | } | |
3443 | else if (**pp != ',') | |
3444 | { | |
3445 | /* Bad structure-type format. */ | |
3446 | complain (&stabs_general_complaint, "bad structure-type format"); | |
3447 | return; | |
3448 | } | |
3449 | ||
3450 | (*pp)++; /* Skip the comma. */ | |
3451 | ||
3452 | { | |
3453 | int nbits; | |
3454 | FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits); | |
3455 | if (nbits != 0) | |
3456 | { | |
3457 | complain (&stabs_general_complaint, "bad structure-type format"); | |
3458 | return; | |
3459 | } | |
3460 | FIELD_BITSIZE (fip->list->field) = read_huge_number (pp, ';', &nbits); | |
3461 | if (nbits != 0) | |
3462 | { | |
3463 | complain (&stabs_general_complaint, "bad structure-type format"); | |
3464 | return; | |
3465 | } | |
3466 | } | |
3467 | ||
3468 | if (FIELD_BITPOS (fip->list->field) == 0 | |
3469 | && FIELD_BITSIZE (fip->list->field) == 0) | |
3470 | { | |
3471 | /* This can happen in two cases: (1) at least for gcc 2.4.5 or so, | |
c5aa993b JM |
3472 | it is a field which has been optimized out. The correct stab for |
3473 | this case is to use VISIBILITY_IGNORE, but that is a recent | |
3474 | invention. (2) It is a 0-size array. For example | |
3475 | union { int num; char str[0]; } foo. Printing "<no value>" for | |
3476 | str in "p foo" is OK, since foo.str (and thus foo.str[3]) | |
3477 | will continue to work, and a 0-size array as a whole doesn't | |
3478 | have any contents to print. | |
3479 | ||
3480 | I suspect this probably could also happen with gcc -gstabs (not | |
3481 | -gstabs+) for static fields, and perhaps other C++ extensions. | |
3482 | Hopefully few people use -gstabs with gdb, since it is intended | |
3483 | for dbx compatibility. */ | |
c906108c SS |
3484 | |
3485 | /* Ignore this field. */ | |
c5aa993b | 3486 | fip->list->visibility = VISIBILITY_IGNORE; |
c906108c SS |
3487 | } |
3488 | else | |
3489 | { | |
3490 | /* Detect an unpacked field and mark it as such. | |
c5aa993b JM |
3491 | dbx gives a bit size for all fields. |
3492 | Note that forward refs cannot be packed, | |
3493 | and treat enums as if they had the width of ints. */ | |
c906108c SS |
3494 | |
3495 | struct type *field_type = check_typedef (FIELD_TYPE (fip->list->field)); | |
3496 | ||
3497 | if (TYPE_CODE (field_type) != TYPE_CODE_INT | |
3498 | && TYPE_CODE (field_type) != TYPE_CODE_RANGE | |
3499 | && TYPE_CODE (field_type) != TYPE_CODE_BOOL | |
3500 | && TYPE_CODE (field_type) != TYPE_CODE_ENUM) | |
3501 | { | |
3502 | FIELD_BITSIZE (fip->list->field) = 0; | |
3503 | } | |
c5aa993b | 3504 | if ((FIELD_BITSIZE (fip->list->field) |
c906108c SS |
3505 | == TARGET_CHAR_BIT * TYPE_LENGTH (field_type) |
3506 | || (TYPE_CODE (field_type) == TYPE_CODE_ENUM | |
c5aa993b JM |
3507 | && FIELD_BITSIZE (fip->list->field) == TARGET_INT_BIT) |
3508 | ) | |
c906108c SS |
3509 | && |
3510 | FIELD_BITPOS (fip->list->field) % 8 == 0) | |
3511 | { | |
3512 | FIELD_BITSIZE (fip->list->field) = 0; | |
3513 | } | |
3514 | } | |
3515 | } | |
3516 | ||
3517 | ||
3518 | /* Read struct or class data fields. They have the form: | |
3519 | ||
c5aa993b | 3520 | NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ; |
c906108c SS |
3521 | |
3522 | At the end, we see a semicolon instead of a field. | |
3523 | ||
3524 | In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for | |
3525 | a static field. | |
3526 | ||
3527 | The optional VISIBILITY is one of: | |
3528 | ||
c5aa993b JM |
3529 | '/0' (VISIBILITY_PRIVATE) |
3530 | '/1' (VISIBILITY_PROTECTED) | |
3531 | '/2' (VISIBILITY_PUBLIC) | |
3532 | '/9' (VISIBILITY_IGNORE) | |
c906108c SS |
3533 | |
3534 | or nothing, for C style fields with public visibility. | |
3535 | ||
3536 | Returns 1 for success, 0 for failure. */ | |
3537 | ||
3538 | static int | |
3539 | read_struct_fields (fip, pp, type, objfile) | |
3540 | struct field_info *fip; | |
3541 | char **pp; | |
3542 | struct type *type; | |
3543 | struct objfile *objfile; | |
3544 | { | |
3545 | register char *p; | |
3546 | struct nextfield *new; | |
3547 | ||
3548 | /* We better set p right now, in case there are no fields at all... */ | |
3549 | ||
3550 | p = *pp; | |
3551 | ||
3552 | /* Read each data member type until we find the terminating ';' at the end of | |
3553 | the data member list, or break for some other reason such as finding the | |
3554 | start of the member function list. */ | |
3555 | ||
3556 | while (**pp != ';') | |
3557 | { | |
c5aa993b JM |
3558 | if (os9k_stabs && **pp == ',') |
3559 | break; | |
c906108c SS |
3560 | STABS_CONTINUE (pp, objfile); |
3561 | /* Get space to record the next field's data. */ | |
3562 | new = (struct nextfield *) xmalloc (sizeof (struct nextfield)); | |
3563 | make_cleanup (free, new); | |
3564 | memset (new, 0, sizeof (struct nextfield)); | |
c5aa993b JM |
3565 | new->next = fip->list; |
3566 | fip->list = new; | |
c906108c SS |
3567 | |
3568 | /* Get the field name. */ | |
3569 | p = *pp; | |
3570 | ||
3571 | /* If is starts with CPLUS_MARKER it is a special abbreviation, | |
c5aa993b JM |
3572 | unless the CPLUS_MARKER is followed by an underscore, in |
3573 | which case it is just the name of an anonymous type, which we | |
3574 | should handle like any other type name. */ | |
c906108c SS |
3575 | |
3576 | if (is_cplus_marker (p[0]) && p[1] != '_') | |
3577 | { | |
3578 | if (!read_cpp_abbrev (fip, pp, type, objfile)) | |
3579 | return 0; | |
3580 | continue; | |
3581 | } | |
3582 | ||
3583 | /* Look for the ':' that separates the field name from the field | |
c5aa993b JM |
3584 | values. Data members are delimited by a single ':', while member |
3585 | functions are delimited by a pair of ':'s. When we hit the member | |
3586 | functions (if any), terminate scan loop and return. */ | |
c906108c | 3587 | |
c5aa993b | 3588 | while (*p != ':' && *p != '\0') |
c906108c SS |
3589 | { |
3590 | p++; | |
3591 | } | |
3592 | if (*p == '\0') | |
3593 | return 0; | |
3594 | ||
3595 | /* Check to see if we have hit the member functions yet. */ | |
3596 | if (p[1] == ':') | |
3597 | { | |
3598 | break; | |
3599 | } | |
3600 | read_one_struct_field (fip, pp, p, type, objfile); | |
3601 | } | |
3602 | if (p[0] == ':' && p[1] == ':') | |
3603 | { | |
3604 | /* chill the list of fields: the last entry (at the head) is a | |
c5aa993b JM |
3605 | partially constructed entry which we now scrub. */ |
3606 | fip->list = fip->list->next; | |
c906108c SS |
3607 | } |
3608 | return 1; | |
3609 | } | |
9846de1b | 3610 | /* *INDENT-OFF* */ |
c906108c SS |
3611 | /* The stabs for C++ derived classes contain baseclass information which |
3612 | is marked by a '!' character after the total size. This function is | |
3613 | called when we encounter the baseclass marker, and slurps up all the | |
3614 | baseclass information. | |
3615 | ||
3616 | Immediately following the '!' marker is the number of base classes that | |
3617 | the class is derived from, followed by information for each base class. | |
3618 | For each base class, there are two visibility specifiers, a bit offset | |
3619 | to the base class information within the derived class, a reference to | |
3620 | the type for the base class, and a terminating semicolon. | |
3621 | ||
3622 | A typical example, with two base classes, would be "!2,020,19;0264,21;". | |
3623 | ^^ ^ ^ ^ ^ ^ ^ | |
3624 | Baseclass information marker __________________|| | | | | | | | |
3625 | Number of baseclasses __________________________| | | | | | | | |
3626 | Visibility specifiers (2) ________________________| | | | | | | |
3627 | Offset in bits from start of class _________________| | | | | | |
3628 | Type number for base class ___________________________| | | | | |
3629 | Visibility specifiers (2) _______________________________| | | | |
3630 | Offset in bits from start of class ________________________| | | |
3631 | Type number of base class ____________________________________| | |
3632 | ||
3633 | Return 1 for success, 0 for (error-type-inducing) failure. */ | |
9846de1b | 3634 | /* *INDENT-ON* */ |
c906108c | 3635 | |
c5aa993b JM |
3636 | |
3637 | ||
c906108c SS |
3638 | static int |
3639 | read_baseclasses (fip, pp, type, objfile) | |
3640 | struct field_info *fip; | |
3641 | char **pp; | |
3642 | struct type *type; | |
3643 | struct objfile *objfile; | |
3644 | { | |
3645 | int i; | |
3646 | struct nextfield *new; | |
3647 | ||
3648 | if (**pp != '!') | |
3649 | { | |
3650 | return 1; | |
3651 | } | |
3652 | else | |
3653 | { | |
3654 | /* Skip the '!' baseclass information marker. */ | |
3655 | (*pp)++; | |
3656 | } | |
3657 | ||
3658 | ALLOCATE_CPLUS_STRUCT_TYPE (type); | |
3659 | { | |
3660 | int nbits; | |
3661 | TYPE_N_BASECLASSES (type) = read_huge_number (pp, ',', &nbits); | |
3662 | if (nbits != 0) | |
3663 | return 0; | |
3664 | } | |
3665 | ||
3666 | #if 0 | |
3667 | /* Some stupid compilers have trouble with the following, so break | |
3668 | it up into simpler expressions. */ | |
3669 | TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) | |
3670 | TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type))); | |
3671 | #else | |
3672 | { | |
3673 | int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type)); | |
3674 | char *pointer; | |
3675 | ||
3676 | pointer = (char *) TYPE_ALLOC (type, num_bytes); | |
3677 | TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer; | |
3678 | } | |
3679 | #endif /* 0 */ | |
3680 | ||
3681 | B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type)); | |
3682 | ||
3683 | for (i = 0; i < TYPE_N_BASECLASSES (type); i++) | |
3684 | { | |
3685 | new = (struct nextfield *) xmalloc (sizeof (struct nextfield)); | |
3686 | make_cleanup (free, new); | |
3687 | memset (new, 0, sizeof (struct nextfield)); | |
c5aa993b JM |
3688 | new->next = fip->list; |
3689 | fip->list = new; | |
c906108c SS |
3690 | FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */ |
3691 | ||
3692 | STABS_CONTINUE (pp, objfile); | |
3693 | switch (**pp) | |
3694 | { | |
c5aa993b JM |
3695 | case '0': |
3696 | /* Nothing to do. */ | |
3697 | break; | |
3698 | case '1': | |
3699 | SET_TYPE_FIELD_VIRTUAL (type, i); | |
3700 | break; | |
3701 | default: | |
3702 | /* Unknown character. Complain and treat it as non-virtual. */ | |
3703 | { | |
3704 | static struct complaint msg = | |
c906108c | 3705 | { |
c5aa993b JM |
3706 | "Unknown virtual character `%c' for baseclass", 0, 0}; |
3707 | complain (&msg, **pp); | |
3708 | } | |
c906108c SS |
3709 | } |
3710 | ++(*pp); | |
3711 | ||
c5aa993b JM |
3712 | new->visibility = *(*pp)++; |
3713 | switch (new->visibility) | |
c906108c | 3714 | { |
c5aa993b JM |
3715 | case VISIBILITY_PRIVATE: |
3716 | case VISIBILITY_PROTECTED: | |
3717 | case VISIBILITY_PUBLIC: | |
3718 | break; | |
3719 | default: | |
3720 | /* Bad visibility format. Complain and treat it as | |
3721 | public. */ | |
3722 | { | |
3723 | static struct complaint msg = | |
c906108c | 3724 | { |
53a5351d JM |
3725 | "Unknown visibility `%c' for baseclass", 0, 0 |
3726 | }; | |
c5aa993b JM |
3727 | complain (&msg, new->visibility); |
3728 | new->visibility = VISIBILITY_PUBLIC; | |
3729 | } | |
c906108c SS |
3730 | } |
3731 | ||
3732 | { | |
3733 | int nbits; | |
c5aa993b | 3734 | |
c906108c SS |
3735 | /* The remaining value is the bit offset of the portion of the object |
3736 | corresponding to this baseclass. Always zero in the absence of | |
3737 | multiple inheritance. */ | |
3738 | ||
3739 | FIELD_BITPOS (new->field) = read_huge_number (pp, ',', &nbits); | |
3740 | if (nbits != 0) | |
3741 | return 0; | |
3742 | } | |
3743 | ||
3744 | /* The last piece of baseclass information is the type of the | |
c5aa993b JM |
3745 | base class. Read it, and remember it's type name as this |
3746 | field's name. */ | |
c906108c | 3747 | |
c5aa993b JM |
3748 | new->field.type = read_type (pp, objfile); |
3749 | new->field.name = type_name_no_tag (new->field.type); | |
c906108c SS |
3750 | |
3751 | /* skip trailing ';' and bump count of number of fields seen */ | |
3752 | if (**pp == ';') | |
3753 | (*pp)++; | |
3754 | else | |
3755 | return 0; | |
3756 | } | |
3757 | return 1; | |
3758 | } | |
3759 | ||
3760 | /* The tail end of stabs for C++ classes that contain a virtual function | |
3761 | pointer contains a tilde, a %, and a type number. | |
3762 | The type number refers to the base class (possibly this class itself) which | |
3763 | contains the vtable pointer for the current class. | |
3764 | ||
3765 | This function is called when we have parsed all the method declarations, | |
3766 | so we can look for the vptr base class info. */ | |
3767 | ||
3768 | static int | |
3769 | read_tilde_fields (fip, pp, type, objfile) | |
3770 | struct field_info *fip; | |
3771 | char **pp; | |
3772 | struct type *type; | |
3773 | struct objfile *objfile; | |
3774 | { | |
3775 | register char *p; | |
3776 | ||
3777 | STABS_CONTINUE (pp, objfile); | |
3778 | ||
3779 | /* If we are positioned at a ';', then skip it. */ | |
3780 | if (**pp == ';') | |
3781 | { | |
3782 | (*pp)++; | |
3783 | } | |
3784 | ||
3785 | if (**pp == '~') | |
3786 | { | |
3787 | (*pp)++; | |
3788 | ||
3789 | if (**pp == '=' || **pp == '+' || **pp == '-') | |
3790 | { | |
3791 | /* Obsolete flags that used to indicate the presence | |
3792 | of constructors and/or destructors. */ | |
3793 | (*pp)++; | |
3794 | } | |
3795 | ||
3796 | /* Read either a '%' or the final ';'. */ | |
3797 | if (*(*pp)++ == '%') | |
3798 | { | |
3799 | /* The next number is the type number of the base class | |
3800 | (possibly our own class) which supplies the vtable for | |
3801 | this class. Parse it out, and search that class to find | |
3802 | its vtable pointer, and install those into TYPE_VPTR_BASETYPE | |
3803 | and TYPE_VPTR_FIELDNO. */ | |
3804 | ||
3805 | struct type *t; | |
3806 | int i; | |
3807 | ||
3808 | t = read_type (pp, objfile); | |
3809 | p = (*pp)++; | |
3810 | while (*p != '\0' && *p != ';') | |
3811 | { | |
3812 | p++; | |
3813 | } | |
3814 | if (*p == '\0') | |
3815 | { | |
3816 | /* Premature end of symbol. */ | |
3817 | return 0; | |
3818 | } | |
c5aa993b | 3819 | |
c906108c | 3820 | TYPE_VPTR_BASETYPE (type) = t; |
c5aa993b | 3821 | if (type == t) /* Our own class provides vtbl ptr */ |
c906108c SS |
3822 | { |
3823 | for (i = TYPE_NFIELDS (t) - 1; | |
3824 | i >= TYPE_N_BASECLASSES (t); | |
3825 | --i) | |
3826 | { | |
c5aa993b JM |
3827 | if (!strncmp (TYPE_FIELD_NAME (t, i), vptr_name, |
3828 | sizeof (vptr_name) - 1)) | |
c906108c SS |
3829 | { |
3830 | TYPE_VPTR_FIELDNO (type) = i; | |
3831 | goto gotit; | |
3832 | } | |
3833 | } | |
3834 | /* Virtual function table field not found. */ | |
3835 | complain (&vtbl_notfound_complaint, TYPE_NAME (type)); | |
3836 | return 0; | |
3837 | } | |
3838 | else | |
3839 | { | |
3840 | TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t); | |
3841 | } | |
3842 | ||
c5aa993b | 3843 | gotit: |
c906108c SS |
3844 | *pp = p + 1; |
3845 | } | |
3846 | } | |
3847 | return 1; | |
3848 | } | |
3849 | ||
3850 | static int | |
3851 | attach_fn_fields_to_type (fip, type) | |
3852 | struct field_info *fip; | |
3853 | register struct type *type; | |
3854 | { | |
3855 | register int n; | |
3856 | ||
3857 | for (n = TYPE_NFN_FIELDS (type); | |
c5aa993b JM |
3858 | fip->fnlist != NULL; |
3859 | fip->fnlist = fip->fnlist->next) | |
c906108c | 3860 | { |
c5aa993b JM |
3861 | --n; /* Circumvent Sun3 compiler bug */ |
3862 | TYPE_FN_FIELDLISTS (type)[n] = fip->fnlist->fn_fieldlist; | |
c906108c SS |
3863 | } |
3864 | return 1; | |
3865 | } | |
3866 | ||
3867 | /* read cfront class static data. | |
3868 | pp points to string starting with the list of static data | |
3869 | eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;; | |
c5aa993b | 3870 | ^^^^^^^^ |
c906108c | 3871 | |
c5aa993b JM |
3872 | A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;; |
3873 | ^ | |
3874 | */ | |
c906108c SS |
3875 | |
3876 | static int | |
3877 | read_cfront_static_fields (fip, pp, type, objfile) | |
3878 | struct field_info *fip; | |
3879 | char **pp; | |
3880 | struct type *type; | |
3881 | struct objfile *objfile; | |
3882 | { | |
c5aa993b | 3883 | struct nextfield *new; |
c906108c | 3884 | struct type *stype; |
c5aa993b JM |
3885 | char *sname; |
3886 | struct symbol *ref_static = 0; | |
3887 | ||
3888 | if (**pp == ';') /* no static data; return */ | |
c906108c SS |
3889 | { |
3890 | ++(*pp); | |
3891 | return 1; | |
3892 | } | |
3893 | ||
3894 | /* Process each field in the list until we find the terminating ";" */ | |
3895 | ||
3896 | /* eg: p = "as__1A ;;;" */ | |
c5aa993b JM |
3897 | STABS_CONTINUE (pp, objfile); /* handle \\ */ |
3898 | while (**pp != ';' && (sname = get_substring (pp, ' '), sname)) | |
c906108c | 3899 | { |
c5aa993b JM |
3900 | ref_static = lookup_symbol (sname, 0, VAR_NAMESPACE, 0, 0); /*demangled_name */ |
3901 | if (!ref_static) | |
3902 | { | |
3903 | static struct complaint msg = | |
3904 | {"\ | |
c906108c | 3905 | Unable to find symbol for static data field %s\n", |
c5aa993b | 3906 | 0, 0}; |
c906108c SS |
3907 | complain (&msg, sname); |
3908 | continue; | |
3909 | } | |
c5aa993b | 3910 | stype = SYMBOL_TYPE (ref_static); |
c906108c SS |
3911 | |
3912 | /* allocate a new fip */ | |
3913 | new = (struct nextfield *) xmalloc (sizeof (struct nextfield)); | |
3914 | make_cleanup (free, new); | |
3915 | memset (new, 0, sizeof (struct nextfield)); | |
c5aa993b JM |
3916 | new->next = fip->list; |
3917 | fip->list = new; | |
c906108c SS |
3918 | |
3919 | /* set visibility */ | |
3920 | /* FIXME! no way to tell visibility from stabs??? */ | |
c5aa993b | 3921 | new->visibility = VISIBILITY_PUBLIC; |
c906108c SS |
3922 | |
3923 | /* set field info into fip */ | |
c5aa993b | 3924 | fip->list->field.type = stype; |
c906108c SS |
3925 | |
3926 | /* set bitpos & bitsize */ | |
3927 | SET_FIELD_PHYSNAME (fip->list->field, savestring (sname, strlen (sname))); | |
3928 | ||
3929 | /* set name field */ | |
3930 | /* The following is code to work around cfront generated stabs. | |
3931 | The stabs contains full mangled name for each field. | |
3932 | We try to demangle the name and extract the field name out of it. | |
c5aa993b | 3933 | */ |
c906108c | 3934 | if (ARM_DEMANGLING) |
c5aa993b JM |
3935 | { |
3936 | char *dem, *dem_p; | |
3937 | dem = cplus_demangle (sname, DMGL_ANSI | DMGL_PARAMS); | |
3938 | if (dem != NULL) | |
3939 | { | |
3940 | dem_p = strrchr (dem, ':'); | |
3941 | if (dem_p != 0 && *(dem_p - 1) == ':') | |
3942 | dem_p++; | |
3943 | fip->list->field.name = | |
3944 | obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack); | |
c906108c | 3945 | } |
c5aa993b JM |
3946 | else |
3947 | { | |
3948 | fip->list->field.name = | |
3949 | obsavestring (sname, strlen (sname), &objfile->type_obstack); | |
3950 | } | |
3951 | } /* end of code for cfront work around */ | |
3952 | } /* loop again for next static field */ | |
c906108c SS |
3953 | return 1; |
3954 | } | |
3955 | ||
3956 | /* Copy structure fields to fip so attach_fields_to_type will work. | |
3957 | type has already been created with the initial instance data fields. | |
3958 | Now we want to be able to add the other members to the class, | |
3959 | so we want to add them back to the fip and reattach them again | |
3960 | once we have collected all the class members. */ | |
3961 | ||
3962 | static int | |
3963 | copy_cfront_struct_fields (fip, type, objfile) | |
3964 | struct field_info *fip; | |
3965 | struct type *type; | |
3966 | struct objfile *objfile; | |
3967 | { | |
c5aa993b | 3968 | int nfields = TYPE_NFIELDS (type); |
c906108c | 3969 | int i; |
c5aa993b | 3970 | struct nextfield *new; |
c906108c SS |
3971 | |
3972 | /* Copy the fields into the list of fips and reset the types | |
3973 | to remove the old fields */ | |
3974 | ||
c5aa993b | 3975 | for (i = 0; i < nfields; i++) |
c906108c SS |
3976 | { |
3977 | /* allocate a new fip */ | |
3978 | new = (struct nextfield *) xmalloc (sizeof (struct nextfield)); | |
3979 | make_cleanup (free, new); | |
3980 | memset (new, 0, sizeof (struct nextfield)); | |
c5aa993b JM |
3981 | new->next = fip->list; |
3982 | fip->list = new; | |
c906108c SS |
3983 | |
3984 | /* copy field info into fip */ | |
c5aa993b | 3985 | new->field = TYPE_FIELD (type, i); |
c906108c SS |
3986 | /* set visibility */ |
3987 | if (TYPE_FIELD_PROTECTED (type, i)) | |
c5aa993b | 3988 | new->visibility = VISIBILITY_PROTECTED; |
c906108c | 3989 | else if (TYPE_FIELD_PRIVATE (type, i)) |
c5aa993b | 3990 | new->visibility = VISIBILITY_PRIVATE; |
c906108c | 3991 | else |
c5aa993b | 3992 | new->visibility = VISIBILITY_PUBLIC; |
c906108c SS |
3993 | } |
3994 | /* Now delete the fields from the type since we will be | |
3995 | allocing new space once we get the rest of the fields | |
3996 | in attach_fields_to_type. | |
3997 | The pointer TYPE_FIELDS(type) is left dangling but should | |
3998 | be freed later by objstack_free */ | |
c5aa993b | 3999 | TYPE_FIELDS (type) = 0; |
c906108c SS |
4000 | TYPE_NFIELDS (type) = 0; |
4001 | ||
4002 | return 1; | |
4003 | } | |
4004 | ||
4005 | /* Create the vector of fields, and record how big it is. | |
4006 | We need this info to record proper virtual function table information | |
4007 | for this class's virtual functions. */ | |
4008 | ||
4009 | static int | |
4010 | attach_fields_to_type (fip, type, objfile) | |
4011 | struct field_info *fip; | |
4012 | register struct type *type; | |
4013 | struct objfile *objfile; | |
4014 | { | |
4015 | register int nfields = 0; | |
4016 | register int non_public_fields = 0; | |
4017 | register struct nextfield *scan; | |
4018 | ||
4019 | /* Count up the number of fields that we have, as well as taking note of | |
4020 | whether or not there are any non-public fields, which requires us to | |
4021 | allocate and build the private_field_bits and protected_field_bits | |
4022 | bitfields. */ | |
4023 | ||
c5aa993b | 4024 | for (scan = fip->list; scan != NULL; scan = scan->next) |
c906108c SS |
4025 | { |
4026 | nfields++; | |
c5aa993b | 4027 | if (scan->visibility != VISIBILITY_PUBLIC) |
c906108c SS |
4028 | { |
4029 | non_public_fields++; | |
4030 | } | |
4031 | } | |
4032 | ||
4033 | /* Now we know how many fields there are, and whether or not there are any | |
4034 | non-public fields. Record the field count, allocate space for the | |
4035 | array of fields, and create blank visibility bitfields if necessary. */ | |
4036 | ||
4037 | TYPE_NFIELDS (type) = nfields; | |
4038 | TYPE_FIELDS (type) = (struct field *) | |
4039 | TYPE_ALLOC (type, sizeof (struct field) * nfields); | |
4040 | memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields); | |
4041 | ||
4042 | if (non_public_fields) | |
4043 | { | |
4044 | ALLOCATE_CPLUS_STRUCT_TYPE (type); | |
4045 | ||
4046 | TYPE_FIELD_PRIVATE_BITS (type) = | |
4047 | (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); | |
4048 | B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields); | |
4049 | ||
4050 | TYPE_FIELD_PROTECTED_BITS (type) = | |
4051 | (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); | |
4052 | B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields); | |
4053 | ||
4054 | TYPE_FIELD_IGNORE_BITS (type) = | |
4055 | (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields)); | |
4056 | B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields); | |
4057 | } | |
4058 | ||
4059 | /* Copy the saved-up fields into the field vector. Start from the head | |
4060 | of the list, adding to the tail of the field array, so that they end | |
4061 | up in the same order in the array in which they were added to the list. */ | |
4062 | ||
4063 | while (nfields-- > 0) | |
4064 | { | |
c5aa993b JM |
4065 | TYPE_FIELD (type, nfields) = fip->list->field; |
4066 | switch (fip->list->visibility) | |
c906108c | 4067 | { |
c5aa993b JM |
4068 | case VISIBILITY_PRIVATE: |
4069 | SET_TYPE_FIELD_PRIVATE (type, nfields); | |
4070 | break; | |
c906108c | 4071 | |
c5aa993b JM |
4072 | case VISIBILITY_PROTECTED: |
4073 | SET_TYPE_FIELD_PROTECTED (type, nfields); | |
4074 | break; | |
c906108c | 4075 | |
c5aa993b JM |
4076 | case VISIBILITY_IGNORE: |
4077 | SET_TYPE_FIELD_IGNORE (type, nfields); | |
4078 | break; | |
c906108c | 4079 | |
c5aa993b JM |
4080 | case VISIBILITY_PUBLIC: |
4081 | break; | |
c906108c | 4082 | |
c5aa993b JM |
4083 | default: |
4084 | /* Unknown visibility. Complain and treat it as public. */ | |
4085 | { | |
4086 | static struct complaint msg = | |
c906108c | 4087 | { |
c5aa993b JM |
4088 | "Unknown visibility `%c' for field", 0, 0}; |
4089 | complain (&msg, fip->list->visibility); | |
4090 | } | |
4091 | break; | |
c906108c | 4092 | } |
c5aa993b | 4093 | fip->list = fip->list->next; |
c906108c SS |
4094 | } |
4095 | return 1; | |
4096 | } | |
4097 | ||
4098 | /* Read the description of a structure (or union type) and return an object | |
4099 | describing the type. | |
4100 | ||
4101 | PP points to a character pointer that points to the next unconsumed token | |
4102 | in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;", | |
4103 | *PP will point to "4a:1,0,32;;". | |
4104 | ||
4105 | TYPE points to an incomplete type that needs to be filled in. | |
4106 | ||
4107 | OBJFILE points to the current objfile from which the stabs information is | |
4108 | being read. (Note that it is redundant in that TYPE also contains a pointer | |
4109 | to this same objfile, so it might be a good idea to eliminate it. FIXME). | |
c5aa993b | 4110 | */ |
c906108c SS |
4111 | |
4112 | static struct type * | |
4113 | read_struct_type (pp, type, objfile) | |
4114 | char **pp; | |
4115 | struct type *type; | |
4116 | struct objfile *objfile; | |
4117 | { | |
4118 | struct cleanup *back_to; | |
4119 | struct field_info fi; | |
4120 | ||
4121 | fi.list = NULL; | |
4122 | fi.fnlist = NULL; | |
4123 | ||
4124 | back_to = make_cleanup (null_cleanup, 0); | |
4125 | ||
4126 | INIT_CPLUS_SPECIFIC (type); | |
4127 | TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB; | |
4128 | ||
4129 | /* First comes the total size in bytes. */ | |
4130 | ||
4131 | { | |
4132 | int nbits; | |
4133 | TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits); | |
4134 | if (nbits != 0) | |
4135 | return error_type (pp, objfile); | |
4136 | } | |
4137 | ||
4138 | /* Now read the baseclasses, if any, read the regular C struct or C++ | |
4139 | class member fields, attach the fields to the type, read the C++ | |
4140 | member functions, attach them to the type, and then read any tilde | |
4141 | field (baseclass specifier for the class holding the main vtable). */ | |
4142 | ||
4143 | if (!read_baseclasses (&fi, pp, type, objfile) | |
4144 | || !read_struct_fields (&fi, pp, type, objfile) | |
4145 | || !attach_fields_to_type (&fi, type, objfile) | |
4146 | || !read_member_functions (&fi, pp, type, objfile) | |
4147 | || !attach_fn_fields_to_type (&fi, type) | |
4148 | || !read_tilde_fields (&fi, pp, type, objfile)) | |
4149 | { | |
4150 | type = error_type (pp, objfile); | |
4151 | } | |
4152 | ||
4153 | do_cleanups (back_to); | |
4154 | return (type); | |
4155 | } | |
4156 | ||
4157 | /* Read a definition of an array type, | |
4158 | and create and return a suitable type object. | |
4159 | Also creates a range type which represents the bounds of that | |
4160 | array. */ | |
4161 | ||
4162 | static struct type * | |
4163 | read_array_type (pp, type, objfile) | |
4164 | register char **pp; | |
4165 | register struct type *type; | |
4166 | struct objfile *objfile; | |
4167 | { | |
4168 | struct type *index_type, *element_type, *range_type; | |
4169 | int lower, upper; | |
4170 | int adjustable = 0; | |
4171 | int nbits; | |
4172 | ||
4173 | /* Format of an array type: | |
4174 | "ar<index type>;lower;upper;<array_contents_type>". | |
4175 | OS9000: "arlower,upper;<array_contents_type>". | |
4176 | ||
4177 | Fortran adjustable arrays use Adigits or Tdigits for lower or upper; | |
4178 | for these, produce a type like float[][]. */ | |
4179 | ||
4180 | if (os9k_stabs) | |
4181 | index_type = builtin_type_int; | |
4182 | else | |
4183 | { | |
4184 | index_type = read_type (pp, objfile); | |
4185 | if (**pp != ';') | |
4186 | /* Improper format of array type decl. */ | |
4187 | return error_type (pp, objfile); | |
4188 | ++*pp; | |
4189 | } | |
4190 | ||
4191 | if (!(**pp >= '0' && **pp <= '9') && **pp != '-') | |
4192 | { | |
4193 | (*pp)++; | |
4194 | adjustable = 1; | |
4195 | } | |
4196 | lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits); | |
4197 | if (nbits != 0) | |
4198 | return error_type (pp, objfile); | |
4199 | ||
4200 | if (!(**pp >= '0' && **pp <= '9') && **pp != '-') | |
4201 | { | |
4202 | (*pp)++; | |
4203 | adjustable = 1; | |
4204 | } | |
4205 | upper = read_huge_number (pp, ';', &nbits); | |
4206 | if (nbits != 0) | |
4207 | return error_type (pp, objfile); | |
c5aa993b | 4208 | |
c906108c SS |
4209 | element_type = read_type (pp, objfile); |
4210 | ||
4211 | if (adjustable) | |
4212 | { | |
4213 | lower = 0; | |
4214 | upper = -1; | |
4215 | } | |
4216 | ||
4217 | range_type = | |
4218 | create_range_type ((struct type *) NULL, index_type, lower, upper); | |
4219 | type = create_array_type (type, element_type, range_type); | |
4220 | ||
4221 | return type; | |
4222 | } | |
4223 | ||
4224 | ||
4225 | /* Read a definition of an enumeration type, | |
4226 | and create and return a suitable type object. | |
4227 | Also defines the symbols that represent the values of the type. */ | |
4228 | ||
4229 | static struct type * | |
4230 | read_enum_type (pp, type, objfile) | |
4231 | register char **pp; | |
4232 | register struct type *type; | |
4233 | struct objfile *objfile; | |
4234 | { | |
4235 | register char *p; | |
4236 | char *name; | |
4237 | register long n; | |
4238 | register struct symbol *sym; | |
4239 | int nsyms = 0; | |
4240 | struct pending **symlist; | |
4241 | struct pending *osyms, *syms; | |
4242 | int o_nsyms; | |
4243 | int nbits; | |
4244 | int unsigned_enum = 1; | |
4245 | ||
4246 | #if 0 | |
4247 | /* FIXME! The stabs produced by Sun CC merrily define things that ought | |
4248 | to be file-scope, between N_FN entries, using N_LSYM. What's a mother | |
4249 | to do? For now, force all enum values to file scope. */ | |
4250 | if (within_function) | |
4251 | symlist = &local_symbols; | |
4252 | else | |
4253 | #endif | |
4254 | symlist = &file_symbols; | |
4255 | osyms = *symlist; | |
4256 | o_nsyms = osyms ? osyms->nsyms : 0; | |
4257 | ||
4258 | if (os9k_stabs) | |
4259 | { | |
4260 | /* Size. Perhaps this does not have to be conditionalized on | |
c5aa993b JM |
4261 | os9k_stabs (assuming the name of an enum constant can't start |
4262 | with a digit). */ | |
c906108c SS |
4263 | read_huge_number (pp, 0, &nbits); |
4264 | if (nbits != 0) | |
4265 | return error_type (pp, objfile); | |
4266 | } | |
4267 | ||
4268 | /* The aix4 compiler emits an extra field before the enum members; | |
4269 | my guess is it's a type of some sort. Just ignore it. */ | |
4270 | if (**pp == '-') | |
4271 | { | |
4272 | /* Skip over the type. */ | |
4273 | while (**pp != ':') | |
c5aa993b | 4274 | (*pp)++; |
c906108c SS |
4275 | |
4276 | /* Skip over the colon. */ | |
4277 | (*pp)++; | |
4278 | } | |
4279 | ||
4280 | /* Read the value-names and their values. | |
4281 | The input syntax is NAME:VALUE,NAME:VALUE, and so on. | |
4282 | A semicolon or comma instead of a NAME means the end. */ | |
4283 | while (**pp && **pp != ';' && **pp != ',') | |
4284 | { | |
4285 | STABS_CONTINUE (pp, objfile); | |
4286 | p = *pp; | |
c5aa993b JM |
4287 | while (*p != ':') |
4288 | p++; | |
4289 | name = obsavestring (*pp, p - *pp, &objfile->symbol_obstack); | |
c906108c SS |
4290 | *pp = p + 1; |
4291 | n = read_huge_number (pp, ',', &nbits); | |
4292 | if (nbits != 0) | |
4293 | return error_type (pp, objfile); | |
4294 | ||
4295 | sym = (struct symbol *) | |
c5aa993b | 4296 | obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); |
c906108c SS |
4297 | memset (sym, 0, sizeof (struct symbol)); |
4298 | SYMBOL_NAME (sym) = name; | |
c5aa993b | 4299 | SYMBOL_LANGUAGE (sym) = current_subfile->language; |
c906108c SS |
4300 | SYMBOL_CLASS (sym) = LOC_CONST; |
4301 | SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE; | |
4302 | SYMBOL_VALUE (sym) = n; | |
4303 | if (n < 0) | |
4304 | unsigned_enum = 0; | |
4305 | add_symbol_to_list (sym, symlist); | |
4306 | nsyms++; | |
4307 | } | |
4308 | ||
4309 | if (**pp == ';') | |
4310 | (*pp)++; /* Skip the semicolon. */ | |
4311 | ||
4312 | /* Now fill in the fields of the type-structure. */ | |
4313 | ||
4314 | TYPE_LENGTH (type) = TARGET_INT_BIT / HOST_CHAR_BIT; | |
4315 | TYPE_CODE (type) = TYPE_CODE_ENUM; | |
4316 | TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB; | |
4317 | if (unsigned_enum) | |
4318 | TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED; | |
4319 | TYPE_NFIELDS (type) = nsyms; | |
4320 | TYPE_FIELDS (type) = (struct field *) | |
4321 | TYPE_ALLOC (type, sizeof (struct field) * nsyms); | |
4322 | memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms); | |
4323 | ||
4324 | /* Find the symbols for the values and put them into the type. | |
4325 | The symbols can be found in the symlist that we put them on | |
4326 | to cause them to be defined. osyms contains the old value | |
4327 | of that symlist; everything up to there was defined by us. */ | |
4328 | /* Note that we preserve the order of the enum constants, so | |
4329 | that in something like "enum {FOO, LAST_THING=FOO}" we print | |
4330 | FOO, not LAST_THING. */ | |
4331 | ||
4332 | for (syms = *symlist, n = nsyms - 1; syms; syms = syms->next) | |
4333 | { | |
4334 | int last = syms == osyms ? o_nsyms : 0; | |
4335 | int j = syms->nsyms; | |
4336 | for (; --j >= last; --n) | |
4337 | { | |
4338 | struct symbol *xsym = syms->symbol[j]; | |
4339 | SYMBOL_TYPE (xsym) = type; | |
4340 | TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym); | |
4341 | TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym); | |
4342 | TYPE_FIELD_BITSIZE (type, n) = 0; | |
4343 | } | |
4344 | if (syms == osyms) | |
4345 | break; | |
4346 | } | |
4347 | ||
4348 | return type; | |
4349 | } | |
4350 | ||
4351 | /* Sun's ACC uses a somewhat saner method for specifying the builtin | |
4352 | typedefs in every file (for int, long, etc): | |
4353 | ||
c5aa993b JM |
4354 | type = b <signed> <width> <format type>; <offset>; <nbits> |
4355 | signed = u or s. | |
4356 | optional format type = c or b for char or boolean. | |
4357 | offset = offset from high order bit to start bit of type. | |
4358 | width is # bytes in object of this type, nbits is # bits in type. | |
c906108c SS |
4359 | |
4360 | The width/offset stuff appears to be for small objects stored in | |
4361 | larger ones (e.g. `shorts' in `int' registers). We ignore it for now, | |
4362 | FIXME. */ | |
4363 | ||
4364 | static struct type * | |
4365 | read_sun_builtin_type (pp, typenums, objfile) | |
4366 | char **pp; | |
4367 | int typenums[2]; | |
4368 | struct objfile *objfile; | |
4369 | { | |
4370 | int type_bits; | |
4371 | int nbits; | |
4372 | int signed_type; | |
4373 | enum type_code code = TYPE_CODE_INT; | |
4374 | ||
4375 | switch (**pp) | |
4376 | { | |
c5aa993b JM |
4377 | case 's': |
4378 | signed_type = 1; | |
4379 | break; | |
4380 | case 'u': | |
4381 | signed_type = 0; | |
4382 | break; | |
4383 | default: | |
4384 | return error_type (pp, objfile); | |
c906108c SS |
4385 | } |
4386 | (*pp)++; | |
4387 | ||
4388 | /* For some odd reason, all forms of char put a c here. This is strange | |
4389 | because no other type has this honor. We can safely ignore this because | |
4390 | we actually determine 'char'acterness by the number of bits specified in | |
4391 | the descriptor. | |
4392 | Boolean forms, e.g Fortran logical*X, put a b here. */ | |
4393 | ||
4394 | if (**pp == 'c') | |
4395 | (*pp)++; | |
4396 | else if (**pp == 'b') | |
4397 | { | |
4398 | code = TYPE_CODE_BOOL; | |
4399 | (*pp)++; | |
4400 | } | |
4401 | ||
4402 | /* The first number appears to be the number of bytes occupied | |
4403 | by this type, except that unsigned short is 4 instead of 2. | |
4404 | Since this information is redundant with the third number, | |
4405 | we will ignore it. */ | |
4406 | read_huge_number (pp, ';', &nbits); | |
4407 | if (nbits != 0) | |
4408 | return error_type (pp, objfile); | |
4409 | ||
4410 | /* The second number is always 0, so ignore it too. */ | |
4411 | read_huge_number (pp, ';', &nbits); | |
4412 | if (nbits != 0) | |
4413 | return error_type (pp, objfile); | |
4414 | ||
4415 | /* The third number is the number of bits for this type. */ | |
4416 | type_bits = read_huge_number (pp, 0, &nbits); | |
4417 | if (nbits != 0) | |
4418 | return error_type (pp, objfile); | |
4419 | /* The type *should* end with a semicolon. If it are embedded | |
4420 | in a larger type the semicolon may be the only way to know where | |
4421 | the type ends. If this type is at the end of the stabstring we | |
4422 | can deal with the omitted semicolon (but we don't have to like | |
4423 | it). Don't bother to complain(), Sun's compiler omits the semicolon | |
4424 | for "void". */ | |
4425 | if (**pp == ';') | |
4426 | ++(*pp); | |
4427 | ||
4428 | if (type_bits == 0) | |
4429 | return init_type (TYPE_CODE_VOID, 1, | |
c5aa993b | 4430 | signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL, |
c906108c SS |
4431 | objfile); |
4432 | else | |
4433 | return init_type (code, | |
4434 | type_bits / TARGET_CHAR_BIT, | |
c5aa993b | 4435 | signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL, |
c906108c SS |
4436 | objfile); |
4437 | } | |
4438 | ||
4439 | static struct type * | |
4440 | read_sun_floating_type (pp, typenums, objfile) | |
4441 | char **pp; | |
4442 | int typenums[2]; | |
4443 | struct objfile *objfile; | |
4444 | { | |
4445 | int nbits; | |
4446 | int details; | |
4447 | int nbytes; | |
4448 | ||
4449 | /* The first number has more details about the type, for example | |
4450 | FN_COMPLEX. */ | |
4451 | details = read_huge_number (pp, ';', &nbits); | |
4452 | if (nbits != 0) | |
4453 | return error_type (pp, objfile); | |
4454 | ||
4455 | /* The second number is the number of bytes occupied by this type */ | |
4456 | nbytes = read_huge_number (pp, ';', &nbits); | |
4457 | if (nbits != 0) | |
4458 | return error_type (pp, objfile); | |
4459 | ||
4460 | if (details == NF_COMPLEX || details == NF_COMPLEX16 | |
4461 | || details == NF_COMPLEX32) | |
4462 | /* This is a type we can't handle, but we do know the size. | |
4463 | We also will be able to give it a name. */ | |
4464 | return init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile); | |
4465 | ||
4466 | return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile); | |
4467 | } | |
4468 | ||
4469 | /* Read a number from the string pointed to by *PP. | |
4470 | The value of *PP is advanced over the number. | |
4471 | If END is nonzero, the character that ends the | |
4472 | number must match END, or an error happens; | |
4473 | and that character is skipped if it does match. | |
4474 | If END is zero, *PP is left pointing to that character. | |
4475 | ||
4476 | If the number fits in a long, set *BITS to 0 and return the value. | |
4477 | If not, set *BITS to be the number of bits in the number and return 0. | |
4478 | ||
4479 | If encounter garbage, set *BITS to -1 and return 0. */ | |
4480 | ||
c2d11a7d | 4481 | static long |
c906108c SS |
4482 | read_huge_number (pp, end, bits) |
4483 | char **pp; | |
4484 | int end; | |
4485 | int *bits; | |
4486 | { | |
4487 | char *p = *pp; | |
4488 | int sign = 1; | |
c2d11a7d | 4489 | long n = 0; |
c906108c SS |
4490 | int radix = 10; |
4491 | char overflow = 0; | |
4492 | int nbits = 0; | |
4493 | int c; | |
c2d11a7d | 4494 | long upper_limit; |
c5aa993b | 4495 | |
c906108c SS |
4496 | if (*p == '-') |
4497 | { | |
4498 | sign = -1; | |
4499 | p++; | |
4500 | } | |
4501 | ||
4502 | /* Leading zero means octal. GCC uses this to output values larger | |
4503 | than an int (because that would be hard in decimal). */ | |
4504 | if (*p == '0') | |
4505 | { | |
4506 | radix = 8; | |
4507 | p++; | |
4508 | } | |
4509 | ||
4510 | if (os9k_stabs) | |
c2d11a7d | 4511 | upper_limit = ULONG_MAX / radix; |
c906108c | 4512 | else |
c2d11a7d | 4513 | upper_limit = LONG_MAX / radix; |
c906108c SS |
4514 | |
4515 | while ((c = *p++) >= '0' && c < ('0' + radix)) | |
4516 | { | |
4517 | if (n <= upper_limit) | |
4518 | { | |
4519 | n *= radix; | |
4520 | n += c - '0'; /* FIXME this overflows anyway */ | |
4521 | } | |
4522 | else | |
4523 | overflow = 1; | |
c5aa993b | 4524 | |
c906108c | 4525 | /* This depends on large values being output in octal, which is |
c5aa993b | 4526 | what GCC does. */ |
c906108c SS |
4527 | if (radix == 8) |
4528 | { | |
4529 | if (nbits == 0) | |
4530 | { | |
4531 | if (c == '0') | |
4532 | /* Ignore leading zeroes. */ | |
4533 | ; | |
4534 | else if (c == '1') | |
4535 | nbits = 1; | |
4536 | else if (c == '2' || c == '3') | |
4537 | nbits = 2; | |
4538 | else | |
4539 | nbits = 3; | |
4540 | } | |
4541 | else | |
4542 | nbits += 3; | |
4543 | } | |
4544 | } | |
4545 | if (end) | |
4546 | { | |
4547 | if (c && c != end) | |
4548 | { | |
4549 | if (bits != NULL) | |
4550 | *bits = -1; | |
4551 | return 0; | |
4552 | } | |
4553 | } | |
4554 | else | |
4555 | --p; | |
4556 | ||
4557 | *pp = p; | |
4558 | if (overflow) | |
4559 | { | |
4560 | if (nbits == 0) | |
4561 | { | |
4562 | /* Large decimal constants are an error (because it is hard to | |
4563 | count how many bits are in them). */ | |
4564 | if (bits != NULL) | |
4565 | *bits = -1; | |
4566 | return 0; | |
4567 | } | |
c5aa993b | 4568 | |
c906108c | 4569 | /* -0x7f is the same as 0x80. So deal with it by adding one to |
c5aa993b | 4570 | the number of bits. */ |
c906108c SS |
4571 | if (sign == -1) |
4572 | ++nbits; | |
4573 | if (bits) | |
4574 | *bits = nbits; | |
4575 | } | |
4576 | else | |
4577 | { | |
4578 | if (bits) | |
4579 | *bits = 0; | |
4580 | return n * sign; | |
4581 | } | |
4582 | /* It's *BITS which has the interesting information. */ | |
4583 | return 0; | |
4584 | } | |
4585 | ||
4586 | static struct type * | |
4587 | read_range_type (pp, typenums, objfile) | |
4588 | char **pp; | |
4589 | int typenums[2]; | |
4590 | struct objfile *objfile; | |
4591 | { | |
4592 | char *orig_pp = *pp; | |
4593 | int rangenums[2]; | |
c2d11a7d | 4594 | long n2, n3; |
c906108c SS |
4595 | int n2bits, n3bits; |
4596 | int self_subrange; | |
4597 | struct type *result_type; | |
4598 | struct type *index_type = NULL; | |
4599 | ||
4600 | /* First comes a type we are a subrange of. | |
4601 | In C it is usually 0, 1 or the type being defined. */ | |
4602 | if (read_type_number (pp, rangenums) != 0) | |
4603 | return error_type (pp, objfile); | |
4604 | self_subrange = (rangenums[0] == typenums[0] && | |
4605 | rangenums[1] == typenums[1]); | |
4606 | ||
4607 | if (**pp == '=') | |
4608 | { | |
4609 | *pp = orig_pp; | |
4610 | index_type = read_type (pp, objfile); | |
4611 | } | |
4612 | ||
4613 | /* A semicolon should now follow; skip it. */ | |
4614 | if (**pp == ';') | |
4615 | (*pp)++; | |
4616 | ||
4617 | /* The remaining two operands are usually lower and upper bounds | |
4618 | of the range. But in some special cases they mean something else. */ | |
4619 | n2 = read_huge_number (pp, ';', &n2bits); | |
4620 | n3 = read_huge_number (pp, ';', &n3bits); | |
4621 | ||
4622 | if (n2bits == -1 || n3bits == -1) | |
4623 | return error_type (pp, objfile); | |
4624 | ||
4625 | if (index_type) | |
4626 | goto handle_true_range; | |
4627 | ||
4628 | /* If limits are huge, must be large integral type. */ | |
4629 | if (n2bits != 0 || n3bits != 0) | |
4630 | { | |
4631 | char got_signed = 0; | |
4632 | char got_unsigned = 0; | |
4633 | /* Number of bits in the type. */ | |
4634 | int nbits = 0; | |
4635 | ||
4636 | /* Range from 0 to <large number> is an unsigned large integral type. */ | |
4637 | if ((n2bits == 0 && n2 == 0) && n3bits != 0) | |
4638 | { | |
4639 | got_unsigned = 1; | |
4640 | nbits = n3bits; | |
4641 | } | |
4642 | /* Range from <large number> to <large number>-1 is a large signed | |
c5aa993b JM |
4643 | integral type. Take care of the case where <large number> doesn't |
4644 | fit in a long but <large number>-1 does. */ | |
c906108c SS |
4645 | else if ((n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1) |
4646 | || (n2bits != 0 && n3bits == 0 | |
c2d11a7d JM |
4647 | && (n2bits == sizeof (long) * HOST_CHAR_BIT) |
4648 | && n3 == LONG_MAX)) | |
c906108c SS |
4649 | { |
4650 | got_signed = 1; | |
4651 | nbits = n2bits; | |
4652 | } | |
4653 | ||
4654 | if (got_signed || got_unsigned) | |
4655 | { | |
4656 | return init_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT, | |
4657 | got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL, | |
4658 | objfile); | |
4659 | } | |
4660 | else | |
4661 | return error_type (pp, objfile); | |
4662 | } | |
4663 | ||
4664 | /* A type defined as a subrange of itself, with bounds both 0, is void. */ | |
4665 | if (self_subrange && n2 == 0 && n3 == 0) | |
4666 | return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile); | |
4667 | ||
4668 | /* If n3 is zero and n2 is positive, we want a floating type, and n2 | |
4669 | is the width in bytes. | |
4670 | ||
4671 | Fortran programs appear to use this for complex types also. To | |
4672 | distinguish between floats and complex, g77 (and others?) seem | |
4673 | to use self-subranges for the complexes, and subranges of int for | |
4674 | the floats. | |
4675 | ||
4676 | Also note that for complexes, g77 sets n2 to the size of one of | |
4677 | the member floats, not the whole complex beast. My guess is that | |
4678 | this was to work well with pre-COMPLEX versions of gdb. */ | |
4679 | ||
4680 | if (n3 == 0 && n2 > 0) | |
4681 | { | |
4682 | if (self_subrange) | |
4683 | { | |
4684 | return init_type (TYPE_CODE_COMPLEX, 2 * n2, 0, NULL, objfile); | |
4685 | } | |
4686 | else | |
4687 | { | |
4688 | return init_type (TYPE_CODE_FLT, n2, 0, NULL, objfile); | |
4689 | } | |
4690 | } | |
4691 | ||
4692 | /* If the upper bound is -1, it must really be an unsigned int. */ | |
4693 | ||
4694 | else if (n2 == 0 && n3 == -1) | |
4695 | { | |
4696 | /* It is unsigned int or unsigned long. */ | |
4697 | /* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5 | |
c5aa993b | 4698 | compatibility hack. */ |
c906108c SS |
4699 | return init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, |
4700 | TYPE_FLAG_UNSIGNED, NULL, objfile); | |
4701 | } | |
4702 | ||
4703 | /* Special case: char is defined (Who knows why) as a subrange of | |
4704 | itself with range 0-127. */ | |
4705 | else if (self_subrange && n2 == 0 && n3 == 127) | |
4706 | return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile); | |
4707 | ||
4708 | else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill | |
4709 | && !self_subrange) | |
4710 | goto handle_true_range; | |
4711 | ||
4712 | /* We used to do this only for subrange of self or subrange of int. */ | |
4713 | else if (n2 == 0) | |
4714 | { | |
a0b3c4fd JM |
4715 | /* -1 is used for the upper bound of (4 byte) "unsigned int" and |
4716 | "unsigned long", and we already checked for that, | |
4717 | so don't need to test for it here. */ | |
4718 | ||
c906108c SS |
4719 | if (n3 < 0) |
4720 | /* n3 actually gives the size. */ | |
c5aa993b | 4721 | return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED, |
c906108c | 4722 | NULL, objfile); |
c906108c | 4723 | |
7be570e7 | 4724 | /* Is n3 == 2**(8n)-1 for some integer n? Then it's an |
a0b3c4fd JM |
4725 | unsigned n-byte integer. But do require n to be a power of |
4726 | two; we don't want 3- and 5-byte integers flying around. */ | |
4727 | { | |
4728 | int bytes; | |
4729 | unsigned long bits; | |
4730 | ||
4731 | bits = n3; | |
4732 | for (bytes = 0; (bits & 0xff) == 0xff; bytes++) | |
4733 | bits >>= 8; | |
4734 | if (bits == 0 | |
4735 | && ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */ | |
4736 | return init_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL, | |
4737 | objfile); | |
4738 | } | |
c906108c SS |
4739 | } |
4740 | /* I think this is for Convex "long long". Since I don't know whether | |
4741 | Convex sets self_subrange, I also accept that particular size regardless | |
4742 | of self_subrange. */ | |
4743 | else if (n3 == 0 && n2 < 0 | |
4744 | && (self_subrange | |
c5aa993b JM |
4745 | || n2 == -TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT)) |
4746 | return init_type (TYPE_CODE_INT, -n2, 0, NULL, objfile); | |
4747 | else if (n2 == -n3 - 1) | |
c906108c SS |
4748 | { |
4749 | if (n3 == 0x7f) | |
4750 | return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile); | |
4751 | if (n3 == 0x7fff) | |
4752 | return init_type (TYPE_CODE_INT, 2, 0, NULL, objfile); | |
4753 | if (n3 == 0x7fffffff) | |
4754 | return init_type (TYPE_CODE_INT, 4, 0, NULL, objfile); | |
4755 | } | |
4756 | ||
4757 | /* We have a real range type on our hands. Allocate space and | |
4758 | return a real pointer. */ | |
c5aa993b | 4759 | handle_true_range: |
c906108c SS |
4760 | |
4761 | if (self_subrange) | |
4762 | index_type = builtin_type_int; | |
4763 | else | |
4764 | index_type = *dbx_lookup_type (rangenums); | |
4765 | if (index_type == NULL) | |
4766 | { | |
4767 | /* Does this actually ever happen? Is that why we are worrying | |
4768 | about dealing with it rather than just calling error_type? */ | |
4769 | ||
4770 | static struct type *range_type_index; | |
4771 | ||
4772 | complain (&range_type_base_complaint, rangenums[1]); | |
4773 | if (range_type_index == NULL) | |
4774 | range_type_index = | |
4775 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
4776 | 0, "range type index type", NULL); | |
4777 | index_type = range_type_index; | |
4778 | } | |
4779 | ||
4780 | result_type = create_range_type ((struct type *) NULL, index_type, n2, n3); | |
4781 | return (result_type); | |
4782 | } | |
4783 | ||
4784 | /* Read in an argument list. This is a list of types, separated by commas | |
4785 | and terminated with END. Return the list of types read in, or (struct type | |
4786 | **)-1 if there is an error. */ | |
4787 | ||
4788 | static struct type ** | |
4789 | read_args (pp, end, objfile) | |
4790 | char **pp; | |
4791 | int end; | |
4792 | struct objfile *objfile; | |
4793 | { | |
4794 | /* FIXME! Remove this arbitrary limit! */ | |
c5aa993b | 4795 | struct type *types[1024], **rval; /* allow for fns of 1023 parameters */ |
c906108c SS |
4796 | int n = 0; |
4797 | ||
4798 | while (**pp != end) | |
4799 | { | |
4800 | if (**pp != ',') | |
4801 | /* Invalid argument list: no ','. */ | |
c5aa993b | 4802 | return (struct type **) -1; |
c906108c SS |
4803 | (*pp)++; |
4804 | STABS_CONTINUE (pp, objfile); | |
4805 | types[n++] = read_type (pp, objfile); | |
4806 | } | |
4807 | (*pp)++; /* get past `end' (the ':' character) */ | |
4808 | ||
4809 | if (n == 1) | |
4810 | { | |
4811 | rval = (struct type **) xmalloc (2 * sizeof (struct type *)); | |
4812 | } | |
c5aa993b | 4813 | else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID) |
c906108c SS |
4814 | { |
4815 | rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *)); | |
4816 | memset (rval + n, 0, sizeof (struct type *)); | |
4817 | } | |
4818 | else | |
4819 | { | |
4820 | rval = (struct type **) xmalloc (n * sizeof (struct type *)); | |
4821 | } | |
4822 | memcpy (rval, types, n * sizeof (struct type *)); | |
4823 | return rval; | |
4824 | } | |
4825 | \f | |
4826 | /* Common block handling. */ | |
4827 | ||
4828 | /* List of symbols declared since the last BCOMM. This list is a tail | |
4829 | of local_symbols. When ECOMM is seen, the symbols on the list | |
4830 | are noted so their proper addresses can be filled in later, | |
4831 | using the common block base address gotten from the assembler | |
4832 | stabs. */ | |
4833 | ||
4834 | static struct pending *common_block; | |
4835 | static int common_block_i; | |
4836 | ||
4837 | /* Name of the current common block. We get it from the BCOMM instead of the | |
4838 | ECOMM to match IBM documentation (even though IBM puts the name both places | |
4839 | like everyone else). */ | |
4840 | static char *common_block_name; | |
4841 | ||
4842 | /* Process a N_BCOMM symbol. The storage for NAME is not guaranteed | |
4843 | to remain after this function returns. */ | |
4844 | ||
4845 | void | |
4846 | common_block_start (name, objfile) | |
4847 | char *name; | |
4848 | struct objfile *objfile; | |
4849 | { | |
4850 | if (common_block_name != NULL) | |
4851 | { | |
c5aa993b JM |
4852 | static struct complaint msg = |
4853 | { | |
c906108c SS |
4854 | "Invalid symbol data: common block within common block", |
4855 | 0, 0}; | |
4856 | complain (&msg); | |
4857 | } | |
4858 | common_block = local_symbols; | |
4859 | common_block_i = local_symbols ? local_symbols->nsyms : 0; | |
4860 | common_block_name = obsavestring (name, strlen (name), | |
c5aa993b | 4861 | &objfile->symbol_obstack); |
c906108c SS |
4862 | } |
4863 | ||
4864 | /* Process a N_ECOMM symbol. */ | |
4865 | ||
4866 | void | |
4867 | common_block_end (objfile) | |
4868 | struct objfile *objfile; | |
4869 | { | |
4870 | /* Symbols declared since the BCOMM are to have the common block | |
4871 | start address added in when we know it. common_block and | |
4872 | common_block_i point to the first symbol after the BCOMM in | |
4873 | the local_symbols list; copy the list and hang it off the | |
4874 | symbol for the common block name for later fixup. */ | |
4875 | int i; | |
4876 | struct symbol *sym; | |
4877 | struct pending *new = 0; | |
4878 | struct pending *next; | |
4879 | int j; | |
4880 | ||
4881 | if (common_block_name == NULL) | |
4882 | { | |
c5aa993b JM |
4883 | static struct complaint msg = |
4884 | {"ECOMM symbol unmatched by BCOMM", 0, 0}; | |
c906108c SS |
4885 | complain (&msg); |
4886 | return; | |
4887 | } | |
4888 | ||
c5aa993b JM |
4889 | sym = (struct symbol *) |
4890 | obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol)); | |
c906108c SS |
4891 | memset (sym, 0, sizeof (struct symbol)); |
4892 | /* Note: common_block_name already saved on symbol_obstack */ | |
4893 | SYMBOL_NAME (sym) = common_block_name; | |
4894 | SYMBOL_CLASS (sym) = LOC_BLOCK; | |
4895 | ||
4896 | /* Now we copy all the symbols which have been defined since the BCOMM. */ | |
4897 | ||
4898 | /* Copy all the struct pendings before common_block. */ | |
4899 | for (next = local_symbols; | |
4900 | next != NULL && next != common_block; | |
4901 | next = next->next) | |
4902 | { | |
4903 | for (j = 0; j < next->nsyms; j++) | |
4904 | add_symbol_to_list (next->symbol[j], &new); | |
4905 | } | |
4906 | ||
4907 | /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is | |
4908 | NULL, it means copy all the local symbols (which we already did | |
4909 | above). */ | |
4910 | ||
4911 | if (common_block != NULL) | |
4912 | for (j = common_block_i; j < common_block->nsyms; j++) | |
4913 | add_symbol_to_list (common_block->symbol[j], &new); | |
4914 | ||
4915 | SYMBOL_TYPE (sym) = (struct type *) new; | |
4916 | ||
4917 | /* Should we be putting local_symbols back to what it was? | |
4918 | Does it matter? */ | |
4919 | ||
4920 | i = hashname (SYMBOL_NAME (sym)); | |
4921 | SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i]; | |
4922 | global_sym_chain[i] = sym; | |
4923 | common_block_name = NULL; | |
4924 | } | |
4925 | ||
4926 | /* Add a common block's start address to the offset of each symbol | |
4927 | declared to be in it (by being between a BCOMM/ECOMM pair that uses | |
4928 | the common block name). */ | |
4929 | ||
4930 | static void | |
4931 | fix_common_block (sym, valu) | |
c5aa993b JM |
4932 | struct symbol *sym; |
4933 | int valu; | |
c906108c SS |
4934 | { |
4935 | struct pending *next = (struct pending *) SYMBOL_TYPE (sym); | |
c5aa993b | 4936 | for (; next; next = next->next) |
c906108c SS |
4937 | { |
4938 | register int j; | |
4939 | for (j = next->nsyms - 1; j >= 0; j--) | |
4940 | SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu; | |
4941 | } | |
4942 | } | |
c5aa993b | 4943 | \f |
c906108c SS |
4944 | |
4945 | ||
c906108c SS |
4946 | /* What about types defined as forward references inside of a small lexical |
4947 | scope? */ | |
4948 | /* Add a type to the list of undefined types to be checked through | |
4949 | once this file has been read in. */ | |
4950 | ||
4951 | void | |
4952 | add_undefined_type (type) | |
4953 | struct type *type; | |
4954 | { | |
4955 | if (undef_types_length == undef_types_allocated) | |
4956 | { | |
4957 | undef_types_allocated *= 2; | |
4958 | undef_types = (struct type **) | |
4959 | xrealloc ((char *) undef_types, | |
4960 | undef_types_allocated * sizeof (struct type *)); | |
4961 | } | |
4962 | undef_types[undef_types_length++] = type; | |
4963 | } | |
4964 | ||
4965 | /* Go through each undefined type, see if it's still undefined, and fix it | |
4966 | up if possible. We have two kinds of undefined types: | |
4967 | ||
4968 | TYPE_CODE_ARRAY: Array whose target type wasn't defined yet. | |
c5aa993b JM |
4969 | Fix: update array length using the element bounds |
4970 | and the target type's length. | |
c906108c | 4971 | TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not |
c5aa993b JM |
4972 | yet defined at the time a pointer to it was made. |
4973 | Fix: Do a full lookup on the struct/union tag. */ | |
c906108c SS |
4974 | void |
4975 | cleanup_undefined_types () | |
4976 | { | |
4977 | struct type **type; | |
4978 | ||
4979 | for (type = undef_types; type < undef_types + undef_types_length; type++) | |
4980 | { | |
4981 | switch (TYPE_CODE (*type)) | |
4982 | { | |
4983 | ||
c5aa993b JM |
4984 | case TYPE_CODE_STRUCT: |
4985 | case TYPE_CODE_UNION: | |
4986 | case TYPE_CODE_ENUM: | |
c906108c SS |
4987 | { |
4988 | /* Check if it has been defined since. Need to do this here | |
4989 | as well as in check_typedef to deal with the (legitimate in | |
4990 | C though not C++) case of several types with the same name | |
4991 | in different source files. */ | |
4992 | if (TYPE_FLAGS (*type) & TYPE_FLAG_STUB) | |
4993 | { | |
4994 | struct pending *ppt; | |
4995 | int i; | |
4996 | /* Name of the type, without "struct" or "union" */ | |
4997 | char *typename = TYPE_TAG_NAME (*type); | |
4998 | ||
4999 | if (typename == NULL) | |
5000 | { | |
c5aa993b JM |
5001 | static struct complaint msg = |
5002 | {"need a type name", 0, 0}; | |
c906108c SS |
5003 | complain (&msg); |
5004 | break; | |
5005 | } | |
5006 | for (ppt = file_symbols; ppt; ppt = ppt->next) | |
5007 | { | |
5008 | for (i = 0; i < ppt->nsyms; i++) | |
5009 | { | |
5010 | struct symbol *sym = ppt->symbol[i]; | |
c5aa993b | 5011 | |
c906108c SS |
5012 | if (SYMBOL_CLASS (sym) == LOC_TYPEDEF |
5013 | && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE | |
5014 | && (TYPE_CODE (SYMBOL_TYPE (sym)) == | |
5015 | TYPE_CODE (*type)) | |
5016 | && STREQ (SYMBOL_NAME (sym), typename)) | |
5017 | { | |
5018 | memcpy (*type, SYMBOL_TYPE (sym), | |
5019 | sizeof (struct type)); | |
5020 | } | |
5021 | } | |
5022 | } | |
5023 | } | |
5024 | } | |
5025 | break; | |
5026 | ||
5027 | default: | |
5028 | { | |
c5aa993b JM |
5029 | static struct complaint msg = |
5030 | {"\ | |
c906108c SS |
5031 | GDB internal error. cleanup_undefined_types with bad type %d.", 0, 0}; |
5032 | complain (&msg, TYPE_CODE (*type)); | |
5033 | } | |
5034 | break; | |
5035 | } | |
5036 | } | |
5037 | ||
5038 | undef_types_length = 0; | |
5039 | } | |
5040 | ||
5041 | /* Scan through all of the global symbols defined in the object file, | |
5042 | assigning values to the debugging symbols that need to be assigned | |
5043 | to. Get these symbols from the minimal symbol table. */ | |
5044 | ||
5045 | void | |
5046 | scan_file_globals (objfile) | |
5047 | struct objfile *objfile; | |
5048 | { | |
5049 | int hash; | |
5050 | struct minimal_symbol *msymbol; | |
5051 | struct symbol *sym, *prev, *rsym; | |
5052 | struct objfile *resolve_objfile; | |
5053 | ||
5054 | /* SVR4 based linkers copy referenced global symbols from shared | |
5055 | libraries to the main executable. | |
5056 | If we are scanning the symbols for a shared library, try to resolve | |
5057 | them from the minimal symbols of the main executable first. */ | |
5058 | ||
5059 | if (symfile_objfile && objfile != symfile_objfile) | |
5060 | resolve_objfile = symfile_objfile; | |
5061 | else | |
5062 | resolve_objfile = objfile; | |
5063 | ||
5064 | while (1) | |
5065 | { | |
5066 | /* Avoid expensive loop through all minimal symbols if there are | |
c5aa993b | 5067 | no unresolved symbols. */ |
c906108c SS |
5068 | for (hash = 0; hash < HASHSIZE; hash++) |
5069 | { | |
5070 | if (global_sym_chain[hash]) | |
5071 | break; | |
5072 | } | |
5073 | if (hash >= HASHSIZE) | |
5074 | return; | |
5075 | ||
c5aa993b | 5076 | for (msymbol = resolve_objfile->msymbols; |
c906108c SS |
5077 | msymbol && SYMBOL_NAME (msymbol) != NULL; |
5078 | msymbol++) | |
5079 | { | |
5080 | QUIT; | |
5081 | ||
5082 | /* Skip static symbols. */ | |
5083 | switch (MSYMBOL_TYPE (msymbol)) | |
5084 | { | |
5085 | case mst_file_text: | |
5086 | case mst_file_data: | |
5087 | case mst_file_bss: | |
5088 | continue; | |
5089 | default: | |
5090 | break; | |
5091 | } | |
5092 | ||
5093 | prev = NULL; | |
5094 | ||
5095 | /* Get the hash index and check all the symbols | |
5096 | under that hash index. */ | |
5097 | ||
5098 | hash = hashname (SYMBOL_NAME (msymbol)); | |
5099 | ||
5100 | for (sym = global_sym_chain[hash]; sym;) | |
5101 | { | |
5102 | if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] && | |
c5aa993b | 5103 | STREQ (SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1)) |
c906108c SS |
5104 | { |
5105 | ||
5106 | struct alias_list *aliases; | |
5107 | ||
5108 | /* Splice this symbol out of the hash chain and | |
5109 | assign the value we have to it. */ | |
5110 | if (prev) | |
5111 | { | |
5112 | SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym); | |
5113 | } | |
5114 | else | |
5115 | { | |
5116 | global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym); | |
5117 | } | |
c5aa993b | 5118 | |
c906108c SS |
5119 | /* Check to see whether we need to fix up a common block. */ |
5120 | /* Note: this code might be executed several times for | |
5121 | the same symbol if there are multiple references. */ | |
5122 | ||
5123 | /* If symbol has aliases, do minimal symbol fixups for each. | |
5124 | These live aliases/references weren't added to | |
5125 | global_sym_chain hash but may also need to be fixed up. */ | |
c5aa993b | 5126 | /* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal |
c906108c SS |
5127 | symbols? Still, we wouldn't want to add_to_list. */ |
5128 | /* Now do the same for each alias of this symbol */ | |
5129 | rsym = sym; | |
5130 | aliases = SYMBOL_ALIASES (sym); | |
5131 | while (rsym) | |
5132 | { | |
5133 | if (SYMBOL_CLASS (rsym) == LOC_BLOCK) | |
5134 | { | |
5135 | fix_common_block (rsym, | |
5136 | SYMBOL_VALUE_ADDRESS (msymbol)); | |
5137 | } | |
5138 | else | |
5139 | { | |
5140 | SYMBOL_VALUE_ADDRESS (rsym) | |
5141 | = SYMBOL_VALUE_ADDRESS (msymbol); | |
5142 | } | |
5143 | SYMBOL_SECTION (rsym) = SYMBOL_SECTION (msymbol); | |
5144 | if (aliases) | |
5145 | { | |
5146 | rsym = aliases->sym; | |
5147 | aliases = aliases->next; | |
5148 | } | |
5149 | else | |
5150 | rsym = NULL; | |
5151 | } | |
5152 | ||
c5aa993b | 5153 | |
c906108c SS |
5154 | if (prev) |
5155 | { | |
5156 | sym = SYMBOL_VALUE_CHAIN (prev); | |
5157 | } | |
5158 | else | |
5159 | { | |
5160 | sym = global_sym_chain[hash]; | |
5161 | } | |
5162 | } | |
5163 | else | |
5164 | { | |
5165 | prev = sym; | |
5166 | sym = SYMBOL_VALUE_CHAIN (sym); | |
5167 | } | |
5168 | } | |
5169 | } | |
5170 | if (resolve_objfile == objfile) | |
5171 | break; | |
5172 | resolve_objfile = objfile; | |
5173 | } | |
5174 | ||
5175 | /* Change the storage class of any remaining unresolved globals to | |
5176 | LOC_UNRESOLVED and remove them from the chain. */ | |
5177 | for (hash = 0; hash < HASHSIZE; hash++) | |
5178 | { | |
5179 | sym = global_sym_chain[hash]; | |
5180 | while (sym) | |
5181 | { | |
5182 | prev = sym; | |
5183 | sym = SYMBOL_VALUE_CHAIN (sym); | |
5184 | ||
5185 | /* Change the symbol address from the misleading chain value | |
5186 | to address zero. */ | |
5187 | SYMBOL_VALUE_ADDRESS (prev) = 0; | |
5188 | ||
5189 | /* Complain about unresolved common block symbols. */ | |
5190 | if (SYMBOL_CLASS (prev) == LOC_STATIC) | |
5191 | SYMBOL_CLASS (prev) = LOC_UNRESOLVED; | |
5192 | else | |
5193 | complain (&unresolved_sym_chain_complaint, | |
c5aa993b | 5194 | objfile->name, SYMBOL_NAME (prev)); |
c906108c SS |
5195 | } |
5196 | } | |
5197 | memset (global_sym_chain, 0, sizeof (global_sym_chain)); | |
5198 | } | |
5199 | ||
5200 | /* Initialize anything that needs initializing when starting to read | |
5201 | a fresh piece of a symbol file, e.g. reading in the stuff corresponding | |
5202 | to a psymtab. */ | |
5203 | ||
5204 | void | |
5205 | stabsread_init () | |
5206 | { | |
5207 | } | |
5208 | ||
5209 | /* Initialize anything that needs initializing when a completely new | |
5210 | symbol file is specified (not just adding some symbols from another | |
5211 | file, e.g. a shared library). */ | |
5212 | ||
5213 | void | |
5214 | stabsread_new_init () | |
5215 | { | |
5216 | /* Empty the hash table of global syms looking for values. */ | |
5217 | memset (global_sym_chain, 0, sizeof (global_sym_chain)); | |
5218 | } | |
5219 | ||
5220 | /* Initialize anything that needs initializing at the same time as | |
5221 | start_symtab() is called. */ | |
5222 | ||
c5aa993b JM |
5223 | void |
5224 | start_stabs () | |
c906108c SS |
5225 | { |
5226 | global_stabs = NULL; /* AIX COFF */ | |
5227 | /* Leave FILENUM of 0 free for builtin types and this file's types. */ | |
5228 | n_this_object_header_files = 1; | |
5229 | type_vector_length = 0; | |
5230 | type_vector = (struct type **) 0; | |
5231 | ||
5232 | /* FIXME: If common_block_name is not already NULL, we should complain(). */ | |
5233 | common_block_name = NULL; | |
5234 | ||
5235 | os9k_stabs = 0; | |
5236 | } | |
5237 | ||
5238 | /* Call after end_symtab() */ | |
5239 | ||
c5aa993b JM |
5240 | void |
5241 | end_stabs () | |
c906108c SS |
5242 | { |
5243 | if (type_vector) | |
5244 | { | |
5245 | free ((char *) type_vector); | |
5246 | } | |
5247 | type_vector = 0; | |
5248 | type_vector_length = 0; | |
5249 | previous_stab_code = 0; | |
5250 | } | |
5251 | ||
5252 | void | |
5253 | finish_global_stabs (objfile) | |
5254 | struct objfile *objfile; | |
5255 | { | |
5256 | if (global_stabs) | |
5257 | { | |
5258 | patch_block_stabs (global_symbols, global_stabs, objfile); | |
5259 | free ((PTR) global_stabs); | |
5260 | global_stabs = NULL; | |
5261 | } | |
5262 | } | |
5263 | ||
5264 | /* Initializer for this module */ | |
5265 | ||
5266 | void | |
5267 | _initialize_stabsread () | |
5268 | { | |
5269 | undef_types_allocated = 20; | |
5270 | undef_types_length = 0; | |
5271 | undef_types = (struct type **) | |
5272 | xmalloc (undef_types_allocated * sizeof (struct type *)); | |
5273 | } |