1 /* Support routines for decoding "stabs" debugging information format.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 1996, 1997, 1998, 1999, 2000
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* Support routines for reading and decoding debugging information in
24 the "stabs" format. This format is used with many systems that use
25 the a.out object file format, as well as some systems that use
26 COFF or ELF where the stabs data is placed in a special section.
27 Avoid placing any object file format specific code in this file. */
30 #include "gdb_string.h"
35 #include "expression.h"
38 #include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
40 #include "aout/aout64.h"
41 #include "gdb-stabs.h"
43 #include "complaints.h"
49 /* Ask stabsread.h to define the vars it normally declares `extern'. */
52 #include "stabsread.h" /* Our own declarations */
55 extern void _initialize_stabsread (void);
57 /* The routines that read and process a complete stabs for a C struct or
58 C++ class pass lists of data member fields and lists of member function
59 fields in an instance of a field_info structure, as defined below.
60 This is part of some reorganization of low level C++ support and is
61 expected to eventually go away... (FIXME) */
67 struct nextfield *next;
69 /* This is the raw visibility from the stab. It is not checked
70 for being one of the visibilities we recognize, so code which
71 examines this field better be able to deal. */
77 struct next_fnfieldlist
79 struct next_fnfieldlist *next;
80 struct fn_fieldlist fn_fieldlist;
86 read_one_struct_field (struct field_info *, char **, char *,
87 struct type *, struct objfile *);
89 static char *get_substring (char **, int);
91 static struct type *dbx_alloc_type (int[2], struct objfile *);
93 static long read_huge_number (char **, int, int *);
95 static struct type *error_type (char **, struct objfile *);
98 patch_block_stabs (struct pending *, struct pending_stabs *,
101 static void fix_common_block (struct symbol *, int);
103 static int read_type_number (char **, int *);
105 static struct type *read_range_type (char **, int[2], struct objfile *);
107 static struct type *read_sun_builtin_type (char **, int[2], struct objfile *);
109 static struct type *read_sun_floating_type (char **, int[2],
112 static struct type *read_enum_type (char **, struct type *, struct objfile *);
114 static struct type *rs6000_builtin_type (int);
117 read_member_functions (struct field_info *, char **, struct type *,
121 read_struct_fields (struct field_info *, char **, struct type *,
125 read_baseclasses (struct field_info *, char **, struct type *,
129 read_tilde_fields (struct field_info *, char **, struct type *,
132 static int attach_fn_fields_to_type (struct field_info *, struct type *);
135 attach_fields_to_type (struct field_info *, struct type *, struct objfile *);
137 static struct type *read_struct_type (char **, struct type *,
140 static struct type *read_array_type (char **, struct type *,
143 static struct type **read_args (char **, int, struct objfile *);
146 read_cpp_abbrev (struct field_info *, char **, struct type *,
149 /* new functions added for cfront support */
152 copy_cfront_struct_fields (struct field_info *, struct type *,
155 static char *get_cfront_method_physname (char *);
158 read_cfront_baseclasses (struct field_info *, char **,
159 struct type *, struct objfile *);
162 read_cfront_static_fields (struct field_info *, char **,
163 struct type *, struct objfile *);
165 read_cfront_member_functions (struct field_info *, char **,
166 struct type *, struct objfile *);
168 /* end new functions added for cfront support */
171 add_live_range (struct objfile *, struct symbol *, CORE_ADDR, CORE_ADDR);
173 static int resolve_live_range (struct objfile *, struct symbol *, char *);
175 static int process_reference (char **string);
177 static CORE_ADDR ref_search_value (int refnum);
180 resolve_symbol_reference (struct objfile *, struct symbol *, char *);
182 void stabsread_clear_cache (void);
184 static const char vptr_name[] =
185 {'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
186 static const char vb_name[] =
187 {'_', 'v', 'b', CPLUS_MARKER, '\0'};
189 /* Define this as 1 if a pcc declaration of a char or short argument
190 gives the correct address. Otherwise assume pcc gives the
191 address of the corresponding int, which is not the same on a
192 big-endian machine. */
194 #if !defined (BELIEVE_PCC_PROMOTION)
195 #define BELIEVE_PCC_PROMOTION 0
197 #if !defined (BELIEVE_PCC_PROMOTION_TYPE)
198 #define BELIEVE_PCC_PROMOTION_TYPE 0
201 static struct complaint invalid_cpp_abbrev_complaint =
202 {"invalid C++ abbreviation `%s'", 0, 0};
204 static struct complaint invalid_cpp_type_complaint =
205 {"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
207 static struct complaint member_fn_complaint =
208 {"member function type missing, got '%c'", 0, 0};
210 static struct complaint const_vol_complaint =
211 {"const/volatile indicator missing, got '%c'", 0, 0};
213 static struct complaint error_type_complaint =
214 {"debug info mismatch between compiler and debugger", 0, 0};
216 static struct complaint invalid_member_complaint =
217 {"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
219 static struct complaint range_type_base_complaint =
220 {"base type %d of range type is not defined", 0, 0};
222 static struct complaint reg_value_complaint =
223 {"register number %d too large (max %d) in symbol %s", 0, 0};
225 static struct complaint vtbl_notfound_complaint =
226 {"virtual function table pointer not found when defining class `%s'", 0, 0};
228 static struct complaint unrecognized_cplus_name_complaint =
229 {"Unknown C++ symbol name `%s'", 0, 0};
231 static struct complaint rs6000_builtin_complaint =
232 {"Unknown builtin type %d", 0, 0};
234 static struct complaint unresolved_sym_chain_complaint =
235 {"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
237 static struct complaint stabs_general_complaint =
240 static struct complaint lrs_general_complaint =
243 /* Make a list of forward references which haven't been defined. */
245 static struct type **undef_types;
246 static int undef_types_allocated;
247 static int undef_types_length;
248 static struct symbol *current_symbol = NULL;
250 /* Check for and handle cretinous stabs symbol name continuation! */
251 #define STABS_CONTINUE(pp,objfile) \
253 if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
254 *(pp) = next_symbol_text (objfile); \
257 /* FIXME: These probably should be our own types (like rs6000_builtin_type
258 has its own types) rather than builtin_type_*. */
259 static struct type **os9k_type_vector[] =
266 &builtin_type_unsigned_char,
267 &builtin_type_unsigned_short,
268 &builtin_type_unsigned_long,
269 &builtin_type_unsigned_int,
271 &builtin_type_double,
273 &builtin_type_long_double
276 static void os9k_init_type_vector (struct type **);
279 os9k_init_type_vector (struct type **tv)
282 for (i = 0; i < sizeof (os9k_type_vector) / sizeof (struct type **); i++)
283 tv[i] = (os9k_type_vector[i] == 0 ? 0 : *(os9k_type_vector[i]));
286 /* Look up a dbx type-number pair. Return the address of the slot
287 where the type for that number-pair is stored.
288 The number-pair is in TYPENUMS.
290 This can be used for finding the type associated with that pair
291 or for associating a new type with the pair. */
294 dbx_lookup_type (int typenums[2])
296 register int filenum = typenums[0];
297 register int index = typenums[1];
299 register int real_filenum;
300 register struct header_file *f;
303 if (filenum == -1) /* -1,-1 is for temporary types. */
306 if (filenum < 0 || filenum >= n_this_object_header_files)
308 static struct complaint msg =
310 Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
312 complain (&msg, filenum, index, symnum);
320 /* Caller wants address of address of type. We think
321 that negative (rs6k builtin) types will never appear as
322 "lvalues", (nor should they), so we stuff the real type
323 pointer into a temp, and return its address. If referenced,
324 this will do the right thing. */
325 static struct type *temp_type;
327 temp_type = rs6000_builtin_type (index);
331 /* Type is defined outside of header files.
332 Find it in this object file's type vector. */
333 if (index >= type_vector_length)
335 old_len = type_vector_length;
338 type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
339 type_vector = (struct type **)
340 xmalloc (type_vector_length * sizeof (struct type *));
342 while (index >= type_vector_length)
344 type_vector_length *= 2;
346 type_vector = (struct type **)
347 xrealloc ((char *) type_vector,
348 (type_vector_length * sizeof (struct type *)));
349 memset (&type_vector[old_len], 0,
350 (type_vector_length - old_len) * sizeof (struct type *));
353 /* Deal with OS9000 fundamental types. */
354 os9k_init_type_vector (type_vector);
356 return (&type_vector[index]);
360 real_filenum = this_object_header_files[filenum];
362 if (real_filenum >= N_HEADER_FILES (current_objfile))
364 struct type *temp_type;
365 struct type **temp_type_p;
367 warning ("GDB internal error: bad real_filenum");
370 temp_type = init_type (TYPE_CODE_ERROR, 0, 0, NULL, NULL);
371 temp_type_p = (struct type **) xmalloc (sizeof (struct type *));
372 *temp_type_p = temp_type;
376 f = HEADER_FILES (current_objfile) + real_filenum;
378 f_orig_length = f->length;
379 if (index >= f_orig_length)
381 while (index >= f->length)
385 f->vector = (struct type **)
386 xrealloc ((char *) f->vector, f->length * sizeof (struct type *));
387 memset (&f->vector[f_orig_length], 0,
388 (f->length - f_orig_length) * sizeof (struct type *));
390 return (&f->vector[index]);
394 /* Make sure there is a type allocated for type numbers TYPENUMS
395 and return the type object.
396 This can create an empty (zeroed) type object.
397 TYPENUMS may be (-1, -1) to return a new type object that is not
398 put into the type vector, and so may not be referred to by number. */
401 dbx_alloc_type (int typenums[2], struct objfile *objfile)
403 register struct type **type_addr;
405 if (typenums[0] == -1)
407 return (alloc_type (objfile));
410 type_addr = dbx_lookup_type (typenums);
412 /* If we are referring to a type not known at all yet,
413 allocate an empty type for it.
414 We will fill it in later if we find out how. */
417 *type_addr = alloc_type (objfile);
423 /* for all the stabs in a given stab vector, build appropriate types
424 and fix their symbols in given symbol vector. */
427 patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
428 struct objfile *objfile)
438 /* for all the stab entries, find their corresponding symbols and
439 patch their types! */
441 for (ii = 0; ii < stabs->count; ++ii)
443 name = stabs->stab[ii];
444 pp = (char *) strchr (name, ':');
448 pp = (char *) strchr (pp, ':');
450 sym = find_symbol_in_list (symbols, name, pp - name);
453 /* FIXME-maybe: it would be nice if we noticed whether
454 the variable was defined *anywhere*, not just whether
455 it is defined in this compilation unit. But neither
456 xlc or GCC seem to need such a definition, and until
457 we do psymtabs (so that the minimal symbols from all
458 compilation units are available now), I'm not sure
459 how to get the information. */
461 /* On xcoff, if a global is defined and never referenced,
462 ld will remove it from the executable. There is then
463 a N_GSYM stab for it, but no regular (C_EXT) symbol. */
464 sym = (struct symbol *)
465 obstack_alloc (&objfile->symbol_obstack,
466 sizeof (struct symbol));
468 memset (sym, 0, sizeof (struct symbol));
469 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
470 SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
472 obsavestring (name, pp - name, &objfile->symbol_obstack);
474 if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
476 /* I don't think the linker does this with functions,
477 so as far as I know this is never executed.
478 But it doesn't hurt to check. */
480 lookup_function_type (read_type (&pp, objfile));
484 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
486 add_symbol_to_list (sym, &global_symbols);
491 if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
494 lookup_function_type (read_type (&pp, objfile));
498 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
506 /* Read a number by which a type is referred to in dbx data,
507 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
508 Just a single number N is equivalent to (0,N).
509 Return the two numbers by storing them in the vector TYPENUMS.
510 TYPENUMS will then be used as an argument to dbx_lookup_type.
512 Returns 0 for success, -1 for error. */
515 read_type_number (register char **pp, register int *typenums)
521 typenums[0] = read_huge_number (pp, ',', &nbits);
524 typenums[1] = read_huge_number (pp, ')', &nbits);
531 typenums[1] = read_huge_number (pp, 0, &nbits);
539 #define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
540 #define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
541 #define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
542 #define VISIBILITY_IGNORE '9' /* Optimized out or zero length */
544 #define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */
545 #define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */
547 /* This code added to support parsing of ARM/Cfront stabs strings */
549 /* Get substring from string up to char c, advance string pointer past
553 get_substring (char **p, int c)
568 /* Physname gets strcat'd onto sname in order to recreate the mangled
569 name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
570 the physname look like that of g++ - take out the initial mangling
571 eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
574 get_cfront_method_physname (char *fname)
577 /* FIXME would like to make this generic for g++ too, but
578 that is already handled in read_member_funcctions */
581 /* search ahead to find the start of the mangled suffix */
582 if (*p == '_' && *(p + 1) == '_') /* compiler generated; probably a ctor/dtor */
584 while (p && (unsigned) ((p + 1) - fname) < strlen (fname) && *(p + 1) != '_')
586 if (!(p && *p == '_' && *(p + 1) == '_'))
587 error ("Invalid mangled function name %s", fname);
588 p += 2; /* advance past '__' */
590 /* struct name length and name of type should come next; advance past it */
593 len = len * 10 + (*p - '0');
601 /* Read base classes within cfront class definition.
602 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
605 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
610 read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
611 struct objfile *objfile)
613 static struct complaint msg_unknown =
615 Unsupported token in stabs string %s.\n",
617 static struct complaint msg_notfound =
619 Unable to find base type for %s.\n",
624 struct nextfield *new;
626 if (**pp == ';') /* no base classes; return */
632 /* first count base classes so we can allocate space before parsing */
633 for (p = *pp; p && *p && *p != ';'; p++)
638 bnum++; /* add one more for last one */
640 /* now parse the base classes until we get to the start of the methods
641 (code extracted and munged from read_baseclasses) */
642 ALLOCATE_CPLUS_STRUCT_TYPE (type);
643 TYPE_N_BASECLASSES (type) = bnum;
647 int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
650 pointer = (char *) TYPE_ALLOC (type, num_bytes);
651 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
653 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
655 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
657 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
658 make_cleanup (xfree, new);
659 memset (new, 0, sizeof (struct nextfield));
660 new->next = fip->list;
662 FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
664 STABS_CONTINUE (pp, objfile);
666 /* virtual? eg: v2@Bvir */
669 SET_TYPE_FIELD_VIRTUAL (type, i);
673 /* access? eg: 2@Bvir */
674 /* Note: protected inheritance not supported in cfront */
677 case CFRONT_VISIBILITY_PRIVATE:
678 new->visibility = VISIBILITY_PRIVATE;
680 case CFRONT_VISIBILITY_PUBLIC:
681 new->visibility = VISIBILITY_PUBLIC;
684 /* Bad visibility format. Complain and treat it as
687 static struct complaint msg =
689 "Unknown visibility `%c' for baseclass", 0, 0};
690 complain (&msg, new->visibility);
691 new->visibility = VISIBILITY_PUBLIC;
695 /* "@" comes next - eg: @Bvir */
698 complain (&msg_unknown, *pp);
704 /* Set the bit offset of the portion of the object corresponding
705 to this baseclass. Always zero in the absence of
706 multiple inheritance. */
707 /* Unable to read bit position from stabs;
708 Assuming no multiple inheritance for now FIXME! */
709 /* We may have read this in the structure definition;
710 now we should fixup the members to be the actual base classes */
711 FIELD_BITPOS (new->field) = 0;
713 /* Get the base class name and type */
715 char *bname; /* base class name */
716 struct symbol *bsym; /* base class */
718 p1 = strchr (*pp, ' ');
719 p2 = strchr (*pp, ';');
721 bname = get_substring (pp, ' ');
723 bname = get_substring (pp, ';');
724 if (!bname || !*bname)
726 complain (&msg_unknown, *pp);
729 /* FIXME! attach base info to type */
730 bsym = lookup_symbol (bname, 0, STRUCT_NAMESPACE, 0, 0); /*demangled_name */
733 new->field.type = SYMBOL_TYPE (bsym);
734 new->field.name = type_name_no_tag (new->field.type);
738 complain (&msg_notfound, *pp);
743 /* If more base classes to parse, loop again.
744 We ate the last ' ' or ';' in get_substring,
745 so on exit we will have skipped the trailing ';' */
746 /* if invalid, return 0; add code to detect - FIXME! */
751 /* read cfront member functions.
752 pp points to string starting with list of functions
753 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
754 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
755 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
756 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
760 read_cfront_member_functions (struct field_info *fip, char **pp,
761 struct type *type, struct objfile *objfile)
763 /* This code extracted from read_member_functions
764 so as to do the similar thing for our funcs */
768 /* Total number of member functions defined in this class. If the class
769 defines two `f' functions, and one `g' function, then this will have
771 int total_length = 0;
775 struct next_fnfield *next;
776 struct fn_field fn_field;
779 struct type *look_ahead_type;
780 struct next_fnfieldlist *new_fnlist;
781 struct next_fnfield *new_sublist;
784 struct symbol *ref_func = 0;
786 /* Process each list until we find the end of the member functions.
787 eg: p = "__ct__1AFv foo__1AFv ;;;" */
789 STABS_CONTINUE (pp, objfile); /* handle \\ */
791 while (**pp != ';' && (fname = get_substring (pp, ' '), fname))
794 int sublist_count = 0;
796 if (fname[0] == '*') /* static member */
802 ref_func = lookup_symbol (fname, 0, VAR_NAMESPACE, 0, 0); /* demangled name */
805 static struct complaint msg =
807 Unable to find function symbol for %s\n",
809 complain (&msg, fname);
813 look_ahead_type = NULL;
816 new_fnlist = (struct next_fnfieldlist *)
817 xmalloc (sizeof (struct next_fnfieldlist));
818 make_cleanup (xfree, new_fnlist);
819 memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
821 /* The following is code to work around cfront generated stabs.
822 The stabs contains full mangled name for each field.
823 We try to demangle the name and extract the field name out of it. */
825 char *dem, *dem_p, *dem_args;
827 dem = cplus_demangle (fname, DMGL_ANSI | DMGL_PARAMS);
830 dem_p = strrchr (dem, ':');
831 if (dem_p != 0 && *(dem_p - 1) == ':')
833 /* get rid of args */
834 dem_args = strchr (dem_p, '(');
835 if (dem_args == NULL)
836 dem_len = strlen (dem_p);
838 dem_len = dem_args - dem_p;
840 obsavestring (dem_p, dem_len, &objfile->type_obstack);
845 obsavestring (fname, strlen (fname), &objfile->type_obstack);
847 } /* end of code for cfront work around */
849 new_fnlist->fn_fieldlist.name = main_fn_name;
851 /*-------------------------------------------------*/
852 /* Set up the sublists
853 Sublists are stuff like args, static, visibility, etc.
854 so in ARM, we have to set that info some other way.
855 Multiple sublists happen if overloading
856 eg: foo::26=##1;:;2A.;
857 In g++, we'd loop here thru all the sublists... */
860 (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
861 make_cleanup (xfree, new_sublist);
862 memset (new_sublist, 0, sizeof (struct next_fnfield));
864 /* eat 1; from :;2A.; */
865 new_sublist->fn_field.type = SYMBOL_TYPE (ref_func); /* normally takes a read_type */
866 /* Make this type look like a method stub for gdb */
867 TYPE_FLAGS (new_sublist->fn_field.type) |= TYPE_FLAG_STUB;
868 TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD;
870 /* If this is just a stub, then we don't have the real name here. */
871 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
873 if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
874 TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
875 new_sublist->fn_field.is_stub = 1;
878 /* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i
879 physname gets strcat'd in order to recreate the onto mangled name */
880 pname = get_cfront_method_physname (fname);
881 new_sublist->fn_field.physname = savestring (pname, strlen (pname));
884 /* Set this member function's visibility fields.
885 Unable to distinguish access from stabs definition!
886 Assuming public for now. FIXME!
887 (for private, set new_sublist->fn_field.is_private = 1,
888 for public, set new_sublist->fn_field.is_protected = 1) */
890 /* Unable to distinguish const/volatile from stabs definition!
891 Assuming normal for now. FIXME! */
893 new_sublist->fn_field.is_const = 0;
894 new_sublist->fn_field.is_volatile = 0; /* volatile not implemented in cfront */
896 /* Set virtual/static function info
897 How to get vtable offsets ?
898 Assuming normal for now FIXME!!
899 For vtables, figure out from whence this virtual function came.
900 It may belong to virtual function table of
901 one of its baseclasses.
903 new_sublist -> fn_field.voffset = vtable offset,
904 new_sublist -> fn_field.fcontext = look_ahead_type;
905 where look_ahead_type is type of baseclass */
907 new_sublist->fn_field.voffset = VOFFSET_STATIC;
908 else /* normal member function. */
909 new_sublist->fn_field.voffset = 0;
910 new_sublist->fn_field.fcontext = 0;
913 /* Prepare new sublist */
914 new_sublist->next = sublist;
915 sublist = new_sublist;
918 /* In g++, we loop thu sublists - now we set from functions. */
919 new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
920 obstack_alloc (&objfile->type_obstack,
921 sizeof (struct fn_field) * length);
922 memset (new_fnlist->fn_fieldlist.fn_fields, 0,
923 sizeof (struct fn_field) * length);
924 for (i = length; (i--, sublist); sublist = sublist->next)
926 new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
929 new_fnlist->fn_fieldlist.length = length;
930 new_fnlist->next = fip->fnlist;
931 fip->fnlist = new_fnlist;
933 total_length += length;
934 STABS_CONTINUE (pp, objfile); /* handle \\ */
939 /* type should already have space */
940 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
941 TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
942 memset (TYPE_FN_FIELDLISTS (type), 0,
943 sizeof (struct fn_fieldlist) * nfn_fields);
944 TYPE_NFN_FIELDS (type) = nfn_fields;
945 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
948 /* end of scope for reading member func */
952 /* Skip trailing ';' and bump count of number of fields seen */
960 /* This routine fixes up partial cfront types that were created
961 while parsing the stabs. The main need for this function is
962 to add information such as methods to classes.
963 Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */
965 resolve_cfront_continuation (struct objfile *objfile, struct symbol *sym,
968 struct symbol *ref_sym = 0;
970 /* snarfed from read_struct_type */
971 struct field_info fi;
973 struct cleanup *back_to;
975 /* Need to make sure that fi isn't gunna conflict with struct
976 in case struct already had some fnfs */
979 back_to = make_cleanup (null_cleanup, 0);
981 /* We only accept structs, classes and unions at the moment.
982 Other continuation types include t (typedef), r (long dbl), ...
983 We may want to add support for them as well;
984 right now they are handled by duplicating the symbol information
985 into the type information (see define_symbol) */
986 if (*p != 's' /* structs */
987 && *p != 'c' /* class */
988 && *p != 'u') /* union */
989 return 0; /* only handle C++ types */
992 /* Get symbol typs name and validate
993 eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */
994 sname = get_substring (&p, ';');
995 if (!sname || strcmp (sname, SYMBOL_NAME (sym)))
996 error ("Internal error: base symbol type name does not match\n");
998 /* Find symbol's internal gdb reference using demangled_name.
999 This is the real sym that we want;
1000 sym was a temp hack to make debugger happy */
1001 ref_sym = lookup_symbol (SYMBOL_NAME (sym), 0, STRUCT_NAMESPACE, 0, 0);
1002 type = SYMBOL_TYPE (ref_sym);
1005 /* Now read the baseclasses, if any, read the regular C struct or C++
1006 class member fields, attach the fields to the type, read the C++
1007 member functions, attach them to the type, and then read any tilde
1008 field (baseclass specifier for the class holding the main vtable). */
1010 if (!read_cfront_baseclasses (&fi, &p, type, objfile)
1011 /* g++ does this next, but cfront already did this:
1012 || !read_struct_fields (&fi, &p, type, objfile) */
1013 || !copy_cfront_struct_fields (&fi, type, objfile)
1014 || !read_cfront_member_functions (&fi, &p, type, objfile)
1015 || !read_cfront_static_fields (&fi, &p, type, objfile)
1016 || !attach_fields_to_type (&fi, type, objfile)
1017 || !attach_fn_fields_to_type (&fi, type)
1018 /* g++ does this next, but cfront doesn't seem to have this:
1019 || !read_tilde_fields (&fi, &p, type, objfile) */
1022 type = error_type (&p, objfile);
1025 do_cleanups (back_to);
1028 /* End of code added to support parsing of ARM/Cfront stabs strings */
1031 /* This routine fixes up symbol references/aliases to point to the original
1032 symbol definition. Returns 0 on failure, non-zero on success. */
1035 resolve_symbol_reference (struct objfile *objfile, struct symbol *sym, char *p)
1038 struct symbol *ref_sym = 0;
1039 struct alias_list *alias;
1041 /* If this is not a symbol reference return now. */
1045 /* Use "#<num>" as the name; we'll fix the name later.
1046 We stored the original symbol name as "#<id>=<name>"
1047 so we can now search for "#<id>" to resolving the reference.
1048 We'll fix the names later by removing the "#<id>" or "#<id>=" */
1050 /*---------------------------------------------------------*/
1051 /* Get the reference id number, and
1052 advance p past the names so we can parse the rest.
1053 eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */
1054 /*---------------------------------------------------------*/
1056 /* This gets reference name from string. sym may not have a name. */
1058 /* Get the reference number associated with the reference id in the
1059 gdb stab string. From that reference number, get the main/primary
1060 symbol for this alias. */
1061 refnum = process_reference (&p);
1062 ref_sym = ref_search (refnum);
1065 complain (&lrs_general_complaint, "symbol for reference not found");
1069 /* Parse the stab of the referencing symbol
1070 now that we have the referenced symbol.
1071 Add it as a new symbol and a link back to the referenced symbol.
1072 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1075 /* If the stab symbol table and string contain:
1076 RSYM 0 5 00000000 868 #15=z:r(0,1)
1077 LBRAC 0 0 00000000 899 #5=
1078 SLINE 0 16 00000003 923 #6=
1079 Then the same symbols can be later referenced by:
1080 RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6)
1081 This is used in live range splitting to:
1082 1) specify that a symbol (#15) is actually just a new storage
1083 class for a symbol (#15=z) which was previously defined.
1084 2) specify that the beginning and ending ranges for a symbol
1085 (#15) are the values of the beginning (#5) and ending (#6)
1088 /* Read number as reference id.
1089 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1090 /* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
1091 in case of "l(0,0)"? */
1093 /*--------------------------------------------------*/
1094 /* Add this symbol to the reference list. */
1095 /*--------------------------------------------------*/
1097 alias = (struct alias_list *) obstack_alloc (&objfile->type_obstack,
1098 sizeof (struct alias_list));
1101 complain (&lrs_general_complaint, "Unable to allocate alias list memory");
1108 if (!SYMBOL_ALIASES (ref_sym))
1110 SYMBOL_ALIASES (ref_sym) = alias;
1114 struct alias_list *temp;
1116 /* Get to the end of the list. */
1117 for (temp = SYMBOL_ALIASES (ref_sym);
1124 /* Want to fix up name so that other functions (eg. valops)
1125 will correctly print the name.
1126 Don't add_symbol_to_list so that lookup_symbol won't find it.
1127 nope... needed for fixups. */
1128 SYMBOL_NAME (sym) = SYMBOL_NAME (ref_sym);
1134 /* Structure for storing pointers to reference definitions for fast lookup
1135 during "process_later". */
1144 #define MAX_CHUNK_REFS 100
1145 #define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map))
1146 #define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE)
1148 static struct ref_map *ref_map;
1150 /* Ptr to free cell in chunk's linked list. */
1151 static int ref_count = 0;
1153 /* Number of chunks malloced. */
1154 static int ref_chunk = 0;
1156 /* This file maintains a cache of stabs aliases found in the symbol
1157 table. If the symbol table changes, this cache must be cleared
1158 or we are left holding onto data in invalid obstacks. */
1160 stabsread_clear_cache (void)
1166 /* Create array of pointers mapping refids to symbols and stab strings.
1167 Add pointers to reference definition symbols and/or their values as we
1168 find them, using their reference numbers as our index.
1169 These will be used later when we resolve references. */
1171 ref_add (int refnum, struct symbol *sym, char *stabs, CORE_ADDR value)
1175 if (refnum >= ref_count)
1176 ref_count = refnum + 1;
1177 if (ref_count > ref_chunk * MAX_CHUNK_REFS)
1179 int new_slots = ref_count - ref_chunk * MAX_CHUNK_REFS;
1180 int new_chunks = new_slots / MAX_CHUNK_REFS + 1;
1181 ref_map = (struct ref_map *)
1182 xrealloc (ref_map, REF_MAP_SIZE (ref_chunk + new_chunks));
1183 memset (ref_map + ref_chunk * MAX_CHUNK_REFS, 0, new_chunks * REF_CHUNK_SIZE);
1184 ref_chunk += new_chunks;
1186 ref_map[refnum].stabs = stabs;
1187 ref_map[refnum].sym = sym;
1188 ref_map[refnum].value = value;
1191 /* Return defined sym for the reference REFNUM. */
1193 ref_search (int refnum)
1195 if (refnum < 0 || refnum > ref_count)
1197 return ref_map[refnum].sym;
1200 /* Return value for the reference REFNUM. */
1203 ref_search_value (int refnum)
1205 if (refnum < 0 || refnum > ref_count)
1207 return ref_map[refnum].value;
1210 /* Parse a reference id in STRING and return the resulting
1211 reference number. Move STRING beyond the reference id. */
1214 process_reference (char **string)
1219 if (**string != '#')
1222 /* Advance beyond the initial '#'. */
1225 /* Read number as reference id. */
1226 while (*p && isdigit (*p))
1228 refnum = refnum * 10 + *p - '0';
1235 /* If STRING defines a reference, store away a pointer to the reference
1236 definition for later use. Return the reference number. */
1239 symbol_reference_defined (char **string)
1244 refnum = process_reference (&p);
1246 /* Defining symbols end in '=' */
1249 /* Symbol is being defined here. */
1255 /* Must be a reference. Either the symbol has already been defined,
1256 or this is a forward reference to it. */
1264 define_symbol (CORE_ADDR valu, char *string, int desc, int type,
1265 struct objfile *objfile)
1267 register struct symbol *sym;
1268 char *p = (char *) strchr (string, ':');
1273 /* We would like to eliminate nameless symbols, but keep their types.
1274 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1275 to type 2, but, should not create a symbol to address that type. Since
1276 the symbol will be nameless, there is no way any user can refer to it. */
1280 /* Ignore syms with empty names. */
1284 /* Ignore old-style symbols from cc -go */
1291 p = strchr (p, ':');
1294 /* If a nameless stab entry, all we need is the type, not the symbol.
1295 e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
1296 nameless = (p == string || ((string[0] == ' ') && (string[1] == ':')));
1298 current_symbol = sym = (struct symbol *)
1299 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
1300 memset (sym, 0, sizeof (struct symbol));
1302 switch (type & N_TYPE)
1305 SYMBOL_SECTION (sym) = SECT_OFF_TEXT (objfile);
1308 SYMBOL_SECTION (sym) = SECT_OFF_DATA (objfile);
1311 SYMBOL_SECTION (sym) = SECT_OFF_BSS (objfile);
1315 if (processing_gcc_compilation)
1317 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1318 number of bytes occupied by a type or object, which we ignore. */
1319 SYMBOL_LINE (sym) = desc;
1323 SYMBOL_LINE (sym) = 0; /* unknown */
1326 if (is_cplus_marker (string[0]))
1328 /* Special GNU C++ names. */
1332 SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
1333 &objfile->symbol_obstack);
1336 case 'v': /* $vtbl_ptr_type */
1337 /* Was: SYMBOL_NAME (sym) = "vptr"; */
1341 SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"),
1342 &objfile->symbol_obstack);
1346 /* This was an anonymous type that was never fixed up. */
1349 #ifdef STATIC_TRANSFORM_NAME
1351 /* SunPRO (3.0 at least) static variable encoding. */
1356 complain (&unrecognized_cplus_name_complaint, string);
1357 goto normal; /* Do *something* with it */
1360 else if (string[0] == '#')
1362 /* Special GNU C extension for referencing symbols. */
1366 /* If STRING defines a new reference id, then add it to the
1367 reference map. Else it must be referring to a previously
1368 defined symbol, so add it to the alias list of the previously
1371 refnum = symbol_reference_defined (&s);
1373 ref_add (refnum, sym, string, SYMBOL_VALUE (sym));
1374 else if (!resolve_symbol_reference (objfile, sym, string))
1377 /* S..P contains the name of the symbol. We need to store
1378 the correct name into SYMBOL_NAME. */
1384 SYMBOL_NAME (sym) = (char *)
1385 obstack_alloc (&objfile->symbol_obstack, nlen);
1386 strncpy (SYMBOL_NAME (sym), s, nlen);
1387 SYMBOL_NAME (sym)[nlen] = '\0';
1388 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1391 /* FIXME! Want SYMBOL_NAME (sym) = 0;
1392 Get error if leave name 0. So give it something. */
1395 SYMBOL_NAME (sym) = (char *)
1396 obstack_alloc (&objfile->symbol_obstack, nlen);
1397 strncpy (SYMBOL_NAME (sym), string, nlen);
1398 SYMBOL_NAME (sym)[nlen] = '\0';
1399 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1402 /* Advance STRING beyond the reference id. */
1408 SYMBOL_LANGUAGE (sym) = current_subfile->language;
1409 SYMBOL_NAME (sym) = (char *)
1410 obstack_alloc (&objfile->symbol_obstack, ((p - string) + 1));
1411 /* Open-coded memcpy--saves function call time. */
1412 /* FIXME: Does it really? Try replacing with simple strcpy and
1413 try it on an executable with a large symbol table. */
1414 /* FIXME: considering that gcc can open code memcpy anyway, I
1415 doubt it. xoxorich. */
1417 register char *p1 = string;
1418 register char *p2 = SYMBOL_NAME (sym);
1426 /* If this symbol is from a C++ compilation, then attempt to cache the
1427 demangled form for future reference. This is a typical time versus
1428 space tradeoff, that was decided in favor of time because it sped up
1429 C++ symbol lookups by a factor of about 20. */
1431 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1435 /* Determine the type of name being defined. */
1437 /* Getting GDB to correctly skip the symbol on an undefined symbol
1438 descriptor and not ever dump core is a very dodgy proposition if
1439 we do things this way. I say the acorn RISC machine can just
1440 fix their compiler. */
1441 /* The Acorn RISC machine's compiler can put out locals that don't
1442 start with "234=" or "(3,4)=", so assume anything other than the
1443 deftypes we know how to handle is a local. */
1444 if (!strchr ("cfFGpPrStTvVXCR", *p))
1446 if (isdigit (*p) || *p == '(' || *p == '-')
1455 /* c is a special case, not followed by a type-number.
1456 SYMBOL:c=iVALUE for an integer constant symbol.
1457 SYMBOL:c=rVALUE for a floating constant symbol.
1458 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1459 e.g. "b:c=e6,0" for "const b = blob1"
1460 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1463 SYMBOL_CLASS (sym) = LOC_CONST;
1464 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1465 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1466 add_symbol_to_list (sym, &file_symbols);
1474 double d = atof (p);
1477 /* FIXME-if-picky-about-floating-accuracy: Should be using
1478 target arithmetic to get the value. real.c in GCC
1479 probably has the necessary code. */
1481 /* FIXME: lookup_fundamental_type is a hack. We should be
1482 creating a type especially for the type of float constants.
1483 Problem is, what type should it be?
1485 Also, what should the name of this type be? Should we
1486 be using 'S' constants (see stabs.texinfo) instead? */
1488 SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
1491 obstack_alloc (&objfile->symbol_obstack,
1492 TYPE_LENGTH (SYMBOL_TYPE (sym)));
1493 store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)), d);
1494 SYMBOL_VALUE_BYTES (sym) = dbl_valu;
1495 SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
1500 /* Defining integer constants this way is kind of silly,
1501 since 'e' constants allows the compiler to give not
1502 only the value, but the type as well. C has at least
1503 int, long, unsigned int, and long long as constant
1504 types; other languages probably should have at least
1505 unsigned as well as signed constants. */
1507 /* We just need one int constant type for all objfiles.
1508 It doesn't depend on languages or anything (arguably its
1509 name should be a language-specific name for a type of
1510 that size, but I'm inclined to say that if the compiler
1511 wants a nice name for the type, it can use 'e'). */
1512 static struct type *int_const_type;
1514 /* Yes, this is as long as a *host* int. That is because we
1516 if (int_const_type == NULL)
1518 init_type (TYPE_CODE_INT,
1519 sizeof (int) * HOST_CHAR_BIT / TARGET_CHAR_BIT, 0,
1521 (struct objfile *) NULL);
1522 SYMBOL_TYPE (sym) = int_const_type;
1523 SYMBOL_VALUE (sym) = atoi (p);
1524 SYMBOL_CLASS (sym) = LOC_CONST;
1528 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
1529 can be represented as integral.
1530 e.g. "b:c=e6,0" for "const b = blob1"
1531 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1533 SYMBOL_CLASS (sym) = LOC_CONST;
1534 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1538 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1543 /* If the value is too big to fit in an int (perhaps because
1544 it is unsigned), or something like that, we silently get
1545 a bogus value. The type and everything else about it is
1546 correct. Ideally, we should be using whatever we have
1547 available for parsing unsigned and long long values,
1549 SYMBOL_VALUE (sym) = atoi (p);
1554 SYMBOL_CLASS (sym) = LOC_CONST;
1555 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1558 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1559 add_symbol_to_list (sym, &file_symbols);
1563 /* The name of a caught exception. */
1564 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1565 SYMBOL_CLASS (sym) = LOC_LABEL;
1566 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1567 SYMBOL_VALUE_ADDRESS (sym) = valu;
1568 add_symbol_to_list (sym, &local_symbols);
1572 /* A static function definition. */
1573 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1574 SYMBOL_CLASS (sym) = LOC_BLOCK;
1575 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1576 add_symbol_to_list (sym, &file_symbols);
1577 /* fall into process_function_types. */
1579 process_function_types:
1580 /* Function result types are described as the result type in stabs.
1581 We need to convert this to the function-returning-type-X type
1582 in GDB. E.g. "int" is converted to "function returning int". */
1583 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
1584 SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
1586 /* All functions in C++ have prototypes. */
1587 if (SYMBOL_LANGUAGE (sym) == language_cplus)
1588 TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED;
1590 /* fall into process_prototype_types */
1592 process_prototype_types:
1593 /* Sun acc puts declared types of arguments here. */
1596 struct type *ftype = SYMBOL_TYPE (sym);
1601 /* Obtain a worst case guess for the number of arguments
1602 by counting the semicolons. */
1609 /* Allocate parameter information fields and fill them in. */
1610 TYPE_FIELDS (ftype) = (struct field *)
1611 TYPE_ALLOC (ftype, nsemi * sizeof (struct field));
1616 /* A type number of zero indicates the start of varargs.
1617 FIXME: GDB currently ignores vararg functions. */
1618 if (p[0] == '0' && p[1] == '\0')
1620 ptype = read_type (&p, objfile);
1622 /* The Sun compilers mark integer arguments, which should
1623 be promoted to the width of the calling conventions, with
1624 a type which references itself. This type is turned into
1625 a TYPE_CODE_VOID type by read_type, and we have to turn
1626 it back into builtin_type_int here.
1627 FIXME: Do we need a new builtin_type_promoted_int_arg ? */
1628 if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
1629 ptype = builtin_type_int;
1630 TYPE_FIELD_TYPE (ftype, nparams++) = ptype;
1632 TYPE_NFIELDS (ftype) = nparams;
1633 TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
1638 /* A global function definition. */
1639 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1640 SYMBOL_CLASS (sym) = LOC_BLOCK;
1641 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1642 add_symbol_to_list (sym, &global_symbols);
1643 goto process_function_types;
1646 /* For a class G (global) symbol, it appears that the
1647 value is not correct. It is necessary to search for the
1648 corresponding linker definition to find the value.
1649 These definitions appear at the end of the namelist. */
1650 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1651 SYMBOL_CLASS (sym) = LOC_STATIC;
1652 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1653 /* Don't add symbol references to global_sym_chain.
1654 Symbol references don't have valid names and wont't match up with
1655 minimal symbols when the global_sym_chain is relocated.
1656 We'll fixup symbol references when we fixup the defining symbol. */
1657 if (SYMBOL_NAME (sym) && SYMBOL_NAME (sym)[0] != '#')
1659 i = hashname (SYMBOL_NAME (sym));
1660 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
1661 global_sym_chain[i] = sym;
1663 add_symbol_to_list (sym, &global_symbols);
1666 /* This case is faked by a conditional above,
1667 when there is no code letter in the dbx data.
1668 Dbx data never actually contains 'l'. */
1671 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1672 SYMBOL_CLASS (sym) = LOC_LOCAL;
1673 SYMBOL_VALUE (sym) = valu;
1674 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1675 add_symbol_to_list (sym, &local_symbols);
1680 /* pF is a two-letter code that means a function parameter in Fortran.
1681 The type-number specifies the type of the return value.
1682 Translate it into a pointer-to-function type. */
1686 = lookup_pointer_type
1687 (lookup_function_type (read_type (&p, objfile)));
1690 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1692 /* Normally this is a parameter, a LOC_ARG. On the i960, it
1693 can also be a LOC_LOCAL_ARG depending on symbol type. */
1694 #ifndef DBX_PARM_SYMBOL_CLASS
1695 #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
1698 SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
1699 SYMBOL_VALUE (sym) = valu;
1700 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1701 add_symbol_to_list (sym, &local_symbols);
1703 if (TARGET_BYTE_ORDER != BIG_ENDIAN)
1705 /* On little-endian machines, this crud is never necessary,
1706 and, if the extra bytes contain garbage, is harmful. */
1710 /* If it's gcc-compiled, if it says `short', believe it. */
1711 if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
1714 if (!BELIEVE_PCC_PROMOTION)
1716 /* This is the signed type which arguments get promoted to. */
1717 static struct type *pcc_promotion_type;
1718 /* This is the unsigned type which arguments get promoted to. */
1719 static struct type *pcc_unsigned_promotion_type;
1721 /* Call it "int" because this is mainly C lossage. */
1722 if (pcc_promotion_type == NULL)
1723 pcc_promotion_type =
1724 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1727 if (pcc_unsigned_promotion_type == NULL)
1728 pcc_unsigned_promotion_type =
1729 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1730 TYPE_FLAG_UNSIGNED, "unsigned int", NULL);
1732 if (BELIEVE_PCC_PROMOTION_TYPE)
1734 /* This is defined on machines (e.g. sparc) where we
1735 should believe the type of a PCC 'short' argument,
1736 but shouldn't believe the address (the address is the
1737 address of the corresponding int).
1739 My guess is that this correction, as opposed to
1740 changing the parameter to an 'int' (as done below,
1741 for PCC on most machines), is the right thing to do
1742 on all machines, but I don't want to risk breaking
1743 something that already works. On most PCC machines,
1744 the sparc problem doesn't come up because the calling
1745 function has to zero the top bytes (not knowing
1746 whether the called function wants an int or a short),
1747 so there is little practical difference between an
1748 int and a short (except perhaps what happens when the
1749 GDB user types "print short_arg = 0x10000;").
1752 compiler actually produces the correct address (we
1753 don't need to fix it up). I made this code adapt so
1754 that it will offset the symbol if it was pointing at
1755 an int-aligned location and not otherwise. This way
1756 you can use the same gdb for 4.0.x and 4.1 systems.
1758 If the parameter is shorter than an int, and is
1759 integral (e.g. char, short, or unsigned equivalent),
1760 and is claimed to be passed on an integer boundary,
1761 don't believe it! Offset the parameter's address to
1762 the tail-end of that integer. */
1764 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
1765 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT
1766 && 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (pcc_promotion_type))
1768 SYMBOL_VALUE (sym) += TYPE_LENGTH (pcc_promotion_type)
1769 - TYPE_LENGTH (SYMBOL_TYPE (sym));
1775 /* If PCC says a parameter is a short or a char,
1776 it is really an int. */
1777 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
1778 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
1781 TYPE_UNSIGNED (SYMBOL_TYPE (sym))
1782 ? pcc_unsigned_promotion_type
1783 : pcc_promotion_type;
1790 /* acc seems to use P to declare the prototypes of functions that
1791 are referenced by this file. gdb is not prepared to deal
1792 with this extra information. FIXME, it ought to. */
1795 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1796 goto process_prototype_types;
1801 /* Parameter which is in a register. */
1802 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1803 SYMBOL_CLASS (sym) = LOC_REGPARM;
1804 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1805 if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
1807 complain (®_value_complaint, SYMBOL_VALUE (sym),
1808 NUM_REGS + NUM_PSEUDO_REGS,
1809 SYMBOL_SOURCE_NAME (sym));
1810 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1812 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1813 add_symbol_to_list (sym, &local_symbols);
1817 /* Register variable (either global or local). */
1818 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1819 SYMBOL_CLASS (sym) = LOC_REGISTER;
1820 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1821 if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
1823 complain (®_value_complaint, SYMBOL_VALUE (sym),
1824 NUM_REGS + NUM_PSEUDO_REGS,
1825 SYMBOL_SOURCE_NAME (sym));
1826 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1828 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1829 if (within_function)
1831 /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
1832 name to represent an argument passed in a register.
1833 GCC uses 'P' for the same case. So if we find such a symbol pair
1834 we combine it into one 'P' symbol. For Sun cc we need to do this
1835 regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
1836 the 'p' symbol even if it never saves the argument onto the stack.
1838 On most machines, we want to preserve both symbols, so that
1839 we can still get information about what is going on with the
1840 stack (VAX for computing args_printed, using stack slots instead
1841 of saved registers in backtraces, etc.).
1843 Note that this code illegally combines
1844 main(argc) struct foo argc; { register struct foo argc; }
1845 but this case is considered pathological and causes a warning
1846 from a decent compiler. */
1849 && local_symbols->nsyms > 0
1850 #ifndef USE_REGISTER_NOT_ARG
1851 && REG_STRUCT_HAS_ADDR_P ()
1852 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
1854 && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1855 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION
1856 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET
1857 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
1861 struct symbol *prev_sym;
1862 prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
1863 if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
1864 || SYMBOL_CLASS (prev_sym) == LOC_ARG)
1865 && STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME (sym)))
1867 SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
1868 /* Use the type from the LOC_REGISTER; that is the type
1869 that is actually in that register. */
1870 SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
1871 SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym);
1876 add_symbol_to_list (sym, &local_symbols);
1879 add_symbol_to_list (sym, &file_symbols);
1883 /* Static symbol at top level of file */
1884 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1885 SYMBOL_CLASS (sym) = LOC_STATIC;
1886 SYMBOL_VALUE_ADDRESS (sym) = valu;
1887 #ifdef STATIC_TRANSFORM_NAME
1888 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
1890 struct minimal_symbol *msym;
1891 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
1894 SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
1895 SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
1899 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1900 add_symbol_to_list (sym, &file_symbols);
1904 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1906 /* For a nameless type, we don't want a create a symbol, thus we
1907 did not use `sym'. Return without further processing. */
1911 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1912 SYMBOL_VALUE (sym) = valu;
1913 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1914 /* C++ vagaries: we may have a type which is derived from
1915 a base type which did not have its name defined when the
1916 derived class was output. We fill in the derived class's
1917 base part member's name here in that case. */
1918 if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL)
1919 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1920 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
1921 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
1924 for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
1925 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
1926 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
1927 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
1930 if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
1932 /* gcc-2.6 or later (when using -fvtable-thunks)
1933 emits a unique named type for a vtable entry.
1934 Some gdb code depends on that specific name. */
1935 extern const char vtbl_ptr_name[];
1937 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
1938 && strcmp (SYMBOL_NAME (sym), vtbl_ptr_name))
1939 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC)
1941 /* If we are giving a name to a type such as "pointer to
1942 foo" or "function returning foo", we better not set
1943 the TYPE_NAME. If the program contains "typedef char
1944 *caddr_t;", we don't want all variables of type char
1945 * to print as caddr_t. This is not just a
1946 consequence of GDB's type management; PCC and GCC (at
1947 least through version 2.4) both output variables of
1948 either type char * or caddr_t with the type number
1949 defined in the 't' symbol for caddr_t. If a future
1950 compiler cleans this up it GDB is not ready for it
1951 yet, but if it becomes ready we somehow need to
1952 disable this check (without breaking the PCC/GCC2.4
1957 Fortunately, this check seems not to be necessary
1958 for anything except pointers or functions. */
1959 /* ezannoni: 2000-10-26. This seems to apply for
1960 versions of gcc older than 2.8. This was the original
1961 problem: with the following code gdb would tell that
1962 the type for name1 is caddr_t, and func is char()
1963 typedef char *caddr_t;
1975 /* Pascal accepts names for pointer types. */
1976 if (current_subfile->language == language_pascal)
1978 TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_NAME (sym);
1982 TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_NAME (sym);
1985 add_symbol_to_list (sym, &file_symbols);
1989 /* Struct, union, or enum tag. For GNU C++, this can be be followed
1990 by 't' which means we are typedef'ing it as well. */
1991 synonym = *p == 't';
1995 /* The semantics of C++ state that "struct foo { ... }" also defines
1996 a typedef for "foo". Unfortunately, cfront never makes the typedef
1997 when translating C++ into C. We make the typedef here so that
1998 "ptype foo" works as expected for cfront translated code. */
1999 else if (current_subfile->language == language_cplus)
2002 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2004 /* For a nameless type, we don't want a create a symbol, thus we
2005 did not use `sym'. Return without further processing. */
2009 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
2010 SYMBOL_VALUE (sym) = valu;
2011 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
2012 if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
2013 TYPE_TAG_NAME (SYMBOL_TYPE (sym))
2014 = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
2015 add_symbol_to_list (sym, &file_symbols);
2019 /* Clone the sym and then modify it. */
2020 register struct symbol *typedef_sym = (struct symbol *)
2021 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
2022 *typedef_sym = *sym;
2023 SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
2024 SYMBOL_VALUE (typedef_sym) = valu;
2025 SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
2026 if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
2027 TYPE_NAME (SYMBOL_TYPE (sym))
2028 = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
2029 add_symbol_to_list (typedef_sym, &file_symbols);
2034 /* Static symbol of local scope */
2035 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2036 SYMBOL_CLASS (sym) = LOC_STATIC;
2037 SYMBOL_VALUE_ADDRESS (sym) = valu;
2038 #ifdef STATIC_TRANSFORM_NAME
2039 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
2041 struct minimal_symbol *msym;
2042 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
2045 SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
2046 SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
2050 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2052 add_symbol_to_list (sym, &global_symbols);
2054 add_symbol_to_list (sym, &local_symbols);
2058 /* Reference parameter */
2059 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2060 SYMBOL_CLASS (sym) = LOC_REF_ARG;
2061 SYMBOL_VALUE (sym) = valu;
2062 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2063 add_symbol_to_list (sym, &local_symbols);
2067 /* Reference parameter which is in a register. */
2068 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2069 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
2070 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
2071 if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
2073 complain (®_value_complaint, SYMBOL_VALUE (sym),
2074 NUM_REGS + NUM_PSEUDO_REGS,
2075 SYMBOL_SOURCE_NAME (sym));
2076 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
2078 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2079 add_symbol_to_list (sym, &local_symbols);
2083 /* This is used by Sun FORTRAN for "function result value".
2084 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
2085 that Pascal uses it too, but when I tried it Pascal used
2086 "x:3" (local symbol) instead. */
2087 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2088 SYMBOL_CLASS (sym) = LOC_LOCAL;
2089 SYMBOL_VALUE (sym) = valu;
2090 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2091 add_symbol_to_list (sym, &local_symbols);
2094 /* New code added to support cfront stabs strings.
2095 Note: case 'P' already handled above */
2097 /* Cfront type continuation coming up!
2098 Find the original definition and add to it.
2099 We'll have to do this for the typedef too,
2100 since we cloned the symbol to define a type in read_type.
2101 Stabs info examples:
2103 foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24))
2104 C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;;
2105 where C is the name of the class.
2106 Unfortunately, we can't lookup the original symbol yet 'cuz
2107 we haven't finished reading all the symbols.
2108 Instead, we save it for processing later */
2109 process_later (sym, p, resolve_cfront_continuation);
2110 SYMBOL_TYPE (sym) = error_type (&p, objfile); /* FIXME! change later */
2111 SYMBOL_CLASS (sym) = LOC_CONST;
2112 SYMBOL_VALUE (sym) = 0;
2113 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2114 /* Don't add to list - we'll delete it later when
2115 we add the continuation to the real sym */
2117 /* End of new code added to support cfront stabs strings */
2120 SYMBOL_TYPE (sym) = error_type (&p, objfile);
2121 SYMBOL_CLASS (sym) = LOC_CONST;
2122 SYMBOL_VALUE (sym) = 0;
2123 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2124 add_symbol_to_list (sym, &file_symbols);
2128 /* When passing structures to a function, some systems sometimes pass
2129 the address in a register, not the structure itself. */
2131 if (REG_STRUCT_HAS_ADDR_P ()
2132 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
2133 && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
2135 struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
2137 if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
2138 || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
2139 || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
2140 || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
2142 /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
2143 LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
2144 if (SYMBOL_CLASS (sym) == LOC_REGPARM)
2145 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
2146 /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
2147 and subsequent arguments on the sparc, for example). */
2148 else if (SYMBOL_CLASS (sym) == LOC_ARG)
2149 SYMBOL_CLASS (sym) = LOC_REF_ARG;
2153 /* Is there more to parse? For example LRS/alias information? */
2154 while (*p && *p == ';')
2157 if (*p && p[0] == 'l' && p[1] == '(')
2159 /* GNU extensions for live range splitting may be appended to
2160 the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */
2162 /* Resolve the live range and add it to SYM's live range list. */
2163 if (!resolve_live_range (objfile, sym, p))
2166 /* Find end of live range info. */
2167 p = strchr (p, ')');
2168 if (!*p || *p != ')')
2170 complain (&lrs_general_complaint, "live range format not recognized");
2179 /* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns
2180 non-zero on success, zero otherwise. */
2183 resolve_live_range (struct objfile *objfile, struct symbol *sym, char *p)
2186 CORE_ADDR start, end;
2188 /* Sanity check the beginning of the stabs string. */
2189 if (!*p || *p != 'l')
2191 complain (&lrs_general_complaint, "live range string 1");
2196 if (!*p || *p != '(')
2198 complain (&lrs_general_complaint, "live range string 2");
2203 /* Get starting value of range and advance P past the reference id.
2205 ?!? In theory, the process_reference should never fail, but we should
2206 catch that case just in case the compiler scrogged the stabs. */
2207 refnum = process_reference (&p);
2208 start = ref_search_value (refnum);
2211 complain (&lrs_general_complaint, "Live range symbol not found 1");
2215 if (!*p || *p != ',')
2217 complain (&lrs_general_complaint, "live range string 3");
2222 /* Get ending value of range and advance P past the reference id.
2224 ?!? In theory, the process_reference should never fail, but we should
2225 catch that case just in case the compiler scrogged the stabs. */
2226 refnum = process_reference (&p);
2227 end = ref_search_value (refnum);
2230 complain (&lrs_general_complaint, "Live range symbol not found 2");
2234 if (!*p || *p != ')')
2236 complain (&lrs_general_complaint, "live range string 4");
2240 /* Now that we know the bounds of the range, add it to the
2242 add_live_range (objfile, sym, start, end);
2247 /* Add a new live range defined by START and END to the symbol SYM
2248 in objfile OBJFILE. */
2251 add_live_range (struct objfile *objfile, struct symbol *sym, CORE_ADDR start,
2254 struct range_list *r, *rs;
2258 complain (&lrs_general_complaint, "end of live range follows start");
2262 /* Alloc new live range structure. */
2263 r = (struct range_list *)
2264 obstack_alloc (&objfile->type_obstack,
2265 sizeof (struct range_list));
2270 /* Append this range to the symbol's range list. */
2271 if (!SYMBOL_RANGES (sym))
2272 SYMBOL_RANGES (sym) = r;
2275 /* Get the last range for the symbol. */
2276 for (rs = SYMBOL_RANGES (sym); rs->next; rs = rs->next)
2283 /* Skip rest of this symbol and return an error type.
2285 General notes on error recovery: error_type always skips to the
2286 end of the symbol (modulo cretinous dbx symbol name continuation).
2287 Thus code like this:
2289 if (*(*pp)++ != ';')
2290 return error_type (pp, objfile);
2292 is wrong because if *pp starts out pointing at '\0' (typically as the
2293 result of an earlier error), it will be incremented to point to the
2294 start of the next symbol, which might produce strange results, at least
2295 if you run off the end of the string table. Instead use
2298 return error_type (pp, objfile);
2304 foo = error_type (pp, objfile);
2308 And in case it isn't obvious, the point of all this hair is so the compiler
2309 can define new types and new syntaxes, and old versions of the
2310 debugger will be able to read the new symbol tables. */
2312 static struct type *
2313 error_type (char **pp, struct objfile *objfile)
2315 complain (&error_type_complaint);
2318 /* Skip to end of symbol. */
2319 while (**pp != '\0')
2324 /* Check for and handle cretinous dbx symbol name continuation! */
2325 if ((*pp)[-1] == '\\' || (*pp)[-1] == '?')
2327 *pp = next_symbol_text (objfile);
2334 return (builtin_type_error);
2338 /* Read type information or a type definition; return the type. Even
2339 though this routine accepts either type information or a type
2340 definition, the distinction is relevant--some parts of stabsread.c
2341 assume that type information starts with a digit, '-', or '(' in
2342 deciding whether to call read_type. */
2345 read_type (register char **pp, struct objfile *objfile)
2347 register struct type *type = 0;
2350 char type_descriptor;
2352 /* Size in bits of type if specified by a type attribute, or -1 if
2353 there is no size attribute. */
2356 /* Used to distinguish string and bitstring from char-array and set. */
2359 /* Read type number if present. The type number may be omitted.
2360 for instance in a two-dimensional array declared with type
2361 "ar1;1;10;ar1;1;10;4". */
2362 if ((**pp >= '0' && **pp <= '9')
2366 if (read_type_number (pp, typenums) != 0)
2367 return error_type (pp, objfile);
2369 /* Type is not being defined here. Either it already exists,
2370 or this is a forward reference to it. dbx_alloc_type handles
2373 return dbx_alloc_type (typenums, objfile);
2375 /* Type is being defined here. */
2377 Also skip the type descriptor - we get it below with (*pp)[-1]. */
2382 /* 'typenums=' not present, type is anonymous. Read and return
2383 the definition, but don't put it in the type vector. */
2384 typenums[0] = typenums[1] = -1;
2389 type_descriptor = (*pp)[-1];
2390 switch (type_descriptor)
2394 enum type_code code;
2396 /* Used to index through file_symbols. */
2397 struct pending *ppt;
2400 /* Name including "struct", etc. */
2404 char *from, *to, *p, *q1, *q2;
2406 /* Set the type code according to the following letter. */
2410 code = TYPE_CODE_STRUCT;
2413 code = TYPE_CODE_UNION;
2416 code = TYPE_CODE_ENUM;
2420 /* Complain and keep going, so compilers can invent new
2421 cross-reference types. */
2422 static struct complaint msg =
2423 {"Unrecognized cross-reference type `%c'", 0, 0};
2424 complain (&msg, (*pp)[0]);
2425 code = TYPE_CODE_STRUCT;
2430 q1 = strchr (*pp, '<');
2431 p = strchr (*pp, ':');
2433 return error_type (pp, objfile);
2434 if (q1 && p > q1 && p[1] == ':')
2436 int nesting_level = 0;
2437 for (q2 = q1; *q2; q2++)
2441 else if (*q2 == '>')
2443 else if (*q2 == ':' && nesting_level == 0)
2448 return error_type (pp, objfile);
2451 (char *) obstack_alloc (&objfile->type_obstack, p - *pp + 1);
2453 /* Copy the name. */
2459 /* Set the pointer ahead of the name which we just read, and
2464 /* Now check to see whether the type has already been
2465 declared. This was written for arrays of cross-referenced
2466 types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty
2467 sure it is not necessary anymore. But it might be a good
2468 idea, to save a little memory. */
2470 for (ppt = file_symbols; ppt; ppt = ppt->next)
2471 for (i = 0; i < ppt->nsyms; i++)
2473 struct symbol *sym = ppt->symbol[i];
2475 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
2476 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
2477 && (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
2478 && STREQ (SYMBOL_NAME (sym), type_name))
2480 obstack_free (&objfile->type_obstack, type_name);
2481 type = SYMBOL_TYPE (sym);
2486 /* Didn't find the type to which this refers, so we must
2487 be dealing with a forward reference. Allocate a type
2488 structure for it, and keep track of it so we can
2489 fill in the rest of the fields when we get the full
2491 type = dbx_alloc_type (typenums, objfile);
2492 TYPE_CODE (type) = code;
2493 TYPE_TAG_NAME (type) = type_name;
2494 INIT_CPLUS_SPECIFIC (type);
2495 TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
2497 add_undefined_type (type);
2501 case '-': /* RS/6000 built-in type */
2515 /* We deal with something like t(1,2)=(3,4)=... which
2516 the Lucid compiler and recent gcc versions (post 2.7.3) use. */
2518 /* Allocate and enter the typedef type first.
2519 This handles recursive types. */
2520 type = dbx_alloc_type (typenums, objfile);
2521 TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
2523 struct type *xtype = read_type (pp, objfile);
2526 /* It's being defined as itself. That means it is "void". */
2527 TYPE_CODE (type) = TYPE_CODE_VOID;
2528 TYPE_LENGTH (type) = 1;
2530 else if (type_size >= 0 || is_string)
2533 TYPE_NAME (type) = NULL;
2534 TYPE_TAG_NAME (type) = NULL;
2538 TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
2539 TYPE_TARGET_TYPE (type) = xtype;
2544 /* In the following types, we must be sure to overwrite any existing
2545 type that the typenums refer to, rather than allocating a new one
2546 and making the typenums point to the new one. This is because there
2547 may already be pointers to the existing type (if it had been
2548 forward-referenced), and we must change it to a pointer, function,
2549 reference, or whatever, *in-place*. */
2552 type1 = read_type (pp, objfile);
2553 type = make_pointer_type (type1, dbx_lookup_type (typenums));
2556 case '&': /* Reference to another type */
2557 type1 = read_type (pp, objfile);
2558 type = make_reference_type (type1, dbx_lookup_type (typenums));
2561 case 'f': /* Function returning another type */
2562 if (os9k_stabs && **pp == '(')
2564 /* Function prototype; parse it.
2565 We must conditionalize this on os9k_stabs because otherwise
2566 it could be confused with a Sun-style (1,3) typenumber
2572 t = read_type (pp, objfile);
2577 type1 = read_type (pp, objfile);
2578 type = make_function_type (type1, dbx_lookup_type (typenums));
2581 case 'k': /* Const qualifier on some type (Sun) */
2582 case 'c': /* Const qualifier on some type (OS9000) */
2583 /* Because 'c' means other things to AIX and 'k' is perfectly good,
2584 only accept 'c' in the os9k_stabs case. */
2585 if (type_descriptor == 'c' && !os9k_stabs)
2586 return error_type (pp, objfile);
2587 type = read_type (pp, objfile);
2588 /* FIXME! For now, we ignore const and volatile qualifiers. */
2591 case 'B': /* Volatile qual on some type (Sun) */
2592 case 'i': /* Volatile qual on some type (OS9000) */
2593 /* Because 'i' means other things to AIX and 'B' is perfectly good,
2594 only accept 'i' in the os9k_stabs case. */
2595 if (type_descriptor == 'i' && !os9k_stabs)
2596 return error_type (pp, objfile);
2597 type = read_type (pp, objfile);
2598 /* FIXME! For now, we ignore const and volatile qualifiers. */
2602 if (isdigit (**pp) || **pp == '(' || **pp == '-')
2603 { /* Member (class & variable) type */
2604 /* FIXME -- we should be doing smash_to_XXX types here. */
2606 struct type *domain = read_type (pp, objfile);
2607 struct type *memtype;
2610 /* Invalid member type data format. */
2611 return error_type (pp, objfile);
2614 memtype = read_type (pp, objfile);
2615 type = dbx_alloc_type (typenums, objfile);
2616 smash_to_member_type (type, domain, memtype);
2619 /* type attribute */
2622 /* Skip to the semicolon. */
2623 while (**pp != ';' && **pp != '\0')
2626 return error_type (pp, objfile);
2628 ++ * pp; /* Skip the semicolon. */
2633 type_size = atoi (attr + 1);
2643 /* Ignore unrecognized type attributes, so future compilers
2644 can invent new ones. */
2652 case '#': /* Method (class & fn) type */
2653 if ((*pp)[0] == '#')
2655 /* We'll get the parameter types from the name. */
2656 struct type *return_type;
2659 return_type = read_type (pp, objfile);
2660 if (*(*pp)++ != ';')
2661 complain (&invalid_member_complaint, symnum);
2662 type = allocate_stub_method (return_type);
2663 if (typenums[0] != -1)
2664 *dbx_lookup_type (typenums) = type;
2668 struct type *domain = read_type (pp, objfile);
2669 struct type *return_type;
2673 /* Invalid member type data format. */
2674 return error_type (pp, objfile);
2678 return_type = read_type (pp, objfile);
2679 args = read_args (pp, ';', objfile);
2680 type = dbx_alloc_type (typenums, objfile);
2681 smash_to_method_type (type, domain, return_type, args);
2685 case 'r': /* Range type */
2686 type = read_range_type (pp, typenums, objfile);
2687 if (typenums[0] != -1)
2688 *dbx_lookup_type (typenums) = type;
2693 /* Const and volatile qualified type. */
2694 type = read_type (pp, objfile);
2697 /* Sun ACC builtin int type */
2698 type = read_sun_builtin_type (pp, typenums, objfile);
2699 if (typenums[0] != -1)
2700 *dbx_lookup_type (typenums) = type;
2704 case 'R': /* Sun ACC builtin float type */
2705 type = read_sun_floating_type (pp, typenums, objfile);
2706 if (typenums[0] != -1)
2707 *dbx_lookup_type (typenums) = type;
2710 case 'e': /* Enumeration type */
2711 type = dbx_alloc_type (typenums, objfile);
2712 type = read_enum_type (pp, type, objfile);
2713 if (typenums[0] != -1)
2714 *dbx_lookup_type (typenums) = type;
2717 case 's': /* Struct type */
2718 case 'u': /* Union type */
2719 type = dbx_alloc_type (typenums, objfile);
2720 switch (type_descriptor)
2723 TYPE_CODE (type) = TYPE_CODE_STRUCT;
2726 TYPE_CODE (type) = TYPE_CODE_UNION;
2729 type = read_struct_type (pp, type, objfile);
2732 case 'a': /* Array type */
2734 return error_type (pp, objfile);
2737 type = dbx_alloc_type (typenums, objfile);
2738 type = read_array_type (pp, type, objfile);
2740 TYPE_CODE (type) = TYPE_CODE_STRING;
2744 type1 = read_type (pp, objfile);
2745 type = create_set_type ((struct type *) NULL, type1);
2747 TYPE_CODE (type) = TYPE_CODE_BITSTRING;
2748 if (typenums[0] != -1)
2749 *dbx_lookup_type (typenums) = type;
2753 --*pp; /* Go back to the symbol in error */
2754 /* Particularly important if it was \0! */
2755 return error_type (pp, objfile);
2760 warning ("GDB internal error, type is NULL in stabsread.c\n");
2761 return error_type (pp, objfile);
2764 /* Size specified in a type attribute overrides any other size. */
2765 if (type_size != -1)
2766 TYPE_LENGTH (type) = (type_size + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
2771 /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
2772 Return the proper type node for a given builtin type number. */
2774 static struct type *
2775 rs6000_builtin_type (int typenum)
2777 /* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
2778 #define NUMBER_RECOGNIZED 34
2779 /* This includes an empty slot for type number -0. */
2780 static struct type *negative_types[NUMBER_RECOGNIZED + 1];
2781 struct type *rettype = NULL;
2783 if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED)
2785 complain (&rs6000_builtin_complaint, typenum);
2786 return builtin_type_error;
2788 if (negative_types[-typenum] != NULL)
2789 return negative_types[-typenum];
2791 #if TARGET_CHAR_BIT != 8
2792 #error This code wrong for TARGET_CHAR_BIT not 8
2793 /* These definitions all assume that TARGET_CHAR_BIT is 8. I think
2794 that if that ever becomes not true, the correct fix will be to
2795 make the size in the struct type to be in bits, not in units of
2802 /* The size of this and all the other types are fixed, defined
2803 by the debugging format. If there is a type called "int" which
2804 is other than 32 bits, then it should use a new negative type
2805 number (or avoid negative type numbers for that case).
2806 See stabs.texinfo. */
2807 rettype = init_type (TYPE_CODE_INT, 4, 0, "int", NULL);
2810 rettype = init_type (TYPE_CODE_INT, 1, 0, "char", NULL);
2813 rettype = init_type (TYPE_CODE_INT, 2, 0, "short", NULL);
2816 rettype = init_type (TYPE_CODE_INT, 4, 0, "long", NULL);
2819 rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
2820 "unsigned char", NULL);
2823 rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", NULL);
2826 rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
2827 "unsigned short", NULL);
2830 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2831 "unsigned int", NULL);
2834 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2837 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2838 "unsigned long", NULL);
2841 rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
2844 /* IEEE single precision (32 bit). */
2845 rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL);
2848 /* IEEE double precision (64 bit). */
2849 rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL);
2852 /* This is an IEEE double on the RS/6000, and different machines with
2853 different sizes for "long double" should use different negative
2854 type numbers. See stabs.texinfo. */
2855 rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", NULL);
2858 rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", NULL);
2861 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2865 rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", NULL);
2868 rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", NULL);
2871 rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", NULL);
2874 rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED,
2878 rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED,
2882 rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED,
2886 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2890 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2894 /* Complex type consisting of two IEEE single precision values. */
2895 rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL);
2898 /* Complex type consisting of two IEEE double precision values. */
2899 rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL);
2902 rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL);
2905 rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", NULL);
2908 rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", NULL);
2911 rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL);
2914 rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL);
2917 rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
2918 "unsigned long long", NULL);
2921 rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
2925 rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL);
2928 negative_types[-typenum] = rettype;
2932 /* This page contains subroutines of read_type. */
2934 /* Read member function stabs info for C++ classes. The form of each member
2937 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
2939 An example with two member functions is:
2941 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
2943 For the case of overloaded operators, the format is op$::*.funcs, where
2944 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
2945 name (such as `+=') and `.' marks the end of the operator name.
2947 Returns 1 for success, 0 for failure. */
2950 read_member_functions (struct field_info *fip, char **pp, struct type *type,
2951 struct objfile *objfile)
2955 /* Total number of member functions defined in this class. If the class
2956 defines two `f' functions, and one `g' function, then this will have
2958 int total_length = 0;
2962 struct next_fnfield *next;
2963 struct fn_field fn_field;
2966 struct type *look_ahead_type;
2967 struct next_fnfieldlist *new_fnlist;
2968 struct next_fnfield *new_sublist;
2972 /* Process each list until we find something that is not a member function
2973 or find the end of the functions. */
2977 /* We should be positioned at the start of the function name.
2978 Scan forward to find the first ':' and if it is not the
2979 first of a "::" delimiter, then this is not a member function. */
2991 look_ahead_type = NULL;
2994 new_fnlist = (struct next_fnfieldlist *)
2995 xmalloc (sizeof (struct next_fnfieldlist));
2996 make_cleanup (xfree, new_fnlist);
2997 memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
2999 if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
3001 /* This is a completely wierd case. In order to stuff in the
3002 names that might contain colons (the usual name delimiter),
3003 Mike Tiemann defined a different name format which is
3004 signalled if the identifier is "op$". In that case, the
3005 format is "op$::XXXX." where XXXX is the name. This is
3006 used for names like "+" or "=". YUUUUUUUK! FIXME! */
3007 /* This lets the user type "break operator+".
3008 We could just put in "+" as the name, but that wouldn't
3010 static char opname[32] =
3011 {'o', 'p', CPLUS_MARKER};
3012 char *o = opname + 3;
3014 /* Skip past '::'. */
3017 STABS_CONTINUE (pp, objfile);
3023 main_fn_name = savestring (opname, o - opname);
3029 main_fn_name = savestring (*pp, p - *pp);
3030 /* Skip past '::'. */
3033 new_fnlist->fn_fieldlist.name = main_fn_name;
3038 (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
3039 make_cleanup (xfree, new_sublist);
3040 memset (new_sublist, 0, sizeof (struct next_fnfield));
3042 /* Check for and handle cretinous dbx symbol name continuation! */
3043 if (look_ahead_type == NULL)
3046 STABS_CONTINUE (pp, objfile);
3048 new_sublist->fn_field.type = read_type (pp, objfile);
3051 /* Invalid symtab info for member function. */
3057 /* g++ version 1 kludge */
3058 new_sublist->fn_field.type = look_ahead_type;
3059 look_ahead_type = NULL;
3069 /* If this is just a stub, then we don't have the real name here. */
3071 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
3073 if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
3074 TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
3075 new_sublist->fn_field.is_stub = 1;
3077 new_sublist->fn_field.physname = savestring (*pp, p - *pp);
3080 /* Set this member function's visibility fields. */
3083 case VISIBILITY_PRIVATE:
3084 new_sublist->fn_field.is_private = 1;
3086 case VISIBILITY_PROTECTED:
3087 new_sublist->fn_field.is_protected = 1;
3091 STABS_CONTINUE (pp, objfile);
3094 case 'A': /* Normal functions. */
3095 new_sublist->fn_field.is_const = 0;
3096 new_sublist->fn_field.is_volatile = 0;
3099 case 'B': /* `const' member functions. */
3100 new_sublist->fn_field.is_const = 1;
3101 new_sublist->fn_field.is_volatile = 0;
3104 case 'C': /* `volatile' member function. */
3105 new_sublist->fn_field.is_const = 0;
3106 new_sublist->fn_field.is_volatile = 1;
3109 case 'D': /* `const volatile' member function. */
3110 new_sublist->fn_field.is_const = 1;
3111 new_sublist->fn_field.is_volatile = 1;
3114 case '*': /* File compiled with g++ version 1 -- no info */
3119 complain (&const_vol_complaint, **pp);
3128 /* virtual member function, followed by index.
3129 The sign bit is set to distinguish pointers-to-methods
3130 from virtual function indicies. Since the array is
3131 in words, the quantity must be shifted left by 1
3132 on 16 bit machine, and by 2 on 32 bit machine, forcing
3133 the sign bit out, and usable as a valid index into
3134 the array. Remove the sign bit here. */
3135 new_sublist->fn_field.voffset =
3136 (0x7fffffff & read_huge_number (pp, ';', &nbits)) + 2;
3140 STABS_CONTINUE (pp, objfile);
3141 if (**pp == ';' || **pp == '\0')
3143 /* Must be g++ version 1. */
3144 new_sublist->fn_field.fcontext = 0;
3148 /* Figure out from whence this virtual function came.
3149 It may belong to virtual function table of
3150 one of its baseclasses. */
3151 look_ahead_type = read_type (pp, objfile);
3154 /* g++ version 1 overloaded methods. */
3158 new_sublist->fn_field.fcontext = look_ahead_type;
3167 look_ahead_type = NULL;
3173 /* static member function. */
3174 new_sublist->fn_field.voffset = VOFFSET_STATIC;
3175 if (strncmp (new_sublist->fn_field.physname,
3176 main_fn_name, strlen (main_fn_name)))
3178 new_sublist->fn_field.is_stub = 1;
3184 complain (&member_fn_complaint, (*pp)[-1]);
3185 /* Fall through into normal member function. */
3188 /* normal member function. */
3189 new_sublist->fn_field.voffset = 0;
3190 new_sublist->fn_field.fcontext = 0;
3194 new_sublist->next = sublist;
3195 sublist = new_sublist;
3197 STABS_CONTINUE (pp, objfile);
3199 while (**pp != ';' && **pp != '\0');
3203 new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
3204 obstack_alloc (&objfile->type_obstack,
3205 sizeof (struct fn_field) * length);
3206 memset (new_fnlist->fn_fieldlist.fn_fields, 0,
3207 sizeof (struct fn_field) * length);
3208 for (i = length; (i--, sublist); sublist = sublist->next)
3210 new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
3213 new_fnlist->fn_fieldlist.length = length;
3214 new_fnlist->next = fip->fnlist;
3215 fip->fnlist = new_fnlist;
3217 total_length += length;
3218 STABS_CONTINUE (pp, objfile);
3223 ALLOCATE_CPLUS_STRUCT_TYPE (type);
3224 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
3225 TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
3226 memset (TYPE_FN_FIELDLISTS (type), 0,
3227 sizeof (struct fn_fieldlist) * nfn_fields);
3228 TYPE_NFN_FIELDS (type) = nfn_fields;
3229 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
3235 /* Special GNU C++ name.
3237 Returns 1 for success, 0 for failure. "failure" means that we can't
3238 keep parsing and it's time for error_type(). */
3241 read_cpp_abbrev (struct field_info *fip, char **pp, struct type *type,
3242 struct objfile *objfile)
3247 struct type *context;
3257 /* At this point, *pp points to something like "22:23=*22...",
3258 where the type number before the ':' is the "context" and
3259 everything after is a regular type definition. Lookup the
3260 type, find it's name, and construct the field name. */
3262 context = read_type (pp, objfile);
3266 case 'f': /* $vf -- a virtual function table pointer */
3267 name = type_name_no_tag (context);
3272 fip->list->field.name =
3273 obconcat (&objfile->type_obstack, vptr_name, name, "");
3276 case 'b': /* $vb -- a virtual bsomethingorother */
3277 name = type_name_no_tag (context);
3280 complain (&invalid_cpp_type_complaint, symnum);
3283 fip->list->field.name =
3284 obconcat (&objfile->type_obstack, vb_name, name, "");
3288 complain (&invalid_cpp_abbrev_complaint, *pp);
3289 fip->list->field.name =
3290 obconcat (&objfile->type_obstack,
3291 "INVALID_CPLUSPLUS_ABBREV", "", "");
3295 /* At this point, *pp points to the ':'. Skip it and read the
3301 complain (&invalid_cpp_abbrev_complaint, *pp);
3304 fip->list->field.type = read_type (pp, objfile);
3306 (*pp)++; /* Skip the comma. */
3312 FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ';', &nbits);
3316 /* This field is unpacked. */
3317 FIELD_BITSIZE (fip->list->field) = 0;
3318 fip->list->visibility = VISIBILITY_PRIVATE;
3322 complain (&invalid_cpp_abbrev_complaint, *pp);
3323 /* We have no idea what syntax an unrecognized abbrev would have, so
3324 better return 0. If we returned 1, we would need to at least advance
3325 *pp to avoid an infinite loop. */
3332 read_one_struct_field (struct field_info *fip, char **pp, char *p,
3333 struct type *type, struct objfile *objfile)
3335 /* The following is code to work around cfront generated stabs.
3336 The stabs contains full mangled name for each field.
3337 We try to demangle the name and extract the field name out of it.
3339 if (ARM_DEMANGLING && current_subfile->language == language_cplus)
3345 dem = cplus_demangle (*pp, DMGL_ANSI | DMGL_PARAMS);
3348 dem_p = strrchr (dem, ':');
3349 if (dem_p != 0 && *(dem_p - 1) == ':')
3351 FIELD_NAME (fip->list->field) =
3352 obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
3356 FIELD_NAME (fip->list->field) =
3357 obsavestring (*pp, p - *pp, &objfile->type_obstack);
3361 /* end of code for cfront work around */
3364 fip->list->field.name =
3365 obsavestring (*pp, p - *pp, &objfile->type_obstack);
3368 /* This means we have a visibility for a field coming. */
3372 fip->list->visibility = *(*pp)++;
3376 /* normal dbx-style format, no explicit visibility */
3377 fip->list->visibility = VISIBILITY_PUBLIC;
3380 fip->list->field.type = read_type (pp, objfile);
3385 /* Possible future hook for nested types. */
3388 fip->list->field.bitpos = (long) -2; /* nested type */
3398 /* Static class member. */
3399 SET_FIELD_PHYSNAME (fip->list->field, savestring (*pp, p - *pp));
3403 else if (**pp != ',')
3405 /* Bad structure-type format. */
3406 complain (&stabs_general_complaint, "bad structure-type format");
3410 (*pp)++; /* Skip the comma. */
3414 FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits);
3417 complain (&stabs_general_complaint, "bad structure-type format");
3420 FIELD_BITSIZE (fip->list->field) = read_huge_number (pp, ';', &nbits);
3423 complain (&stabs_general_complaint, "bad structure-type format");
3428 if (FIELD_BITPOS (fip->list->field) == 0
3429 && FIELD_BITSIZE (fip->list->field) == 0)
3431 /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
3432 it is a field which has been optimized out. The correct stab for
3433 this case is to use VISIBILITY_IGNORE, but that is a recent
3434 invention. (2) It is a 0-size array. For example
3435 union { int num; char str[0]; } foo. Printing "<no value>" for
3436 str in "p foo" is OK, since foo.str (and thus foo.str[3])
3437 will continue to work, and a 0-size array as a whole doesn't
3438 have any contents to print.
3440 I suspect this probably could also happen with gcc -gstabs (not
3441 -gstabs+) for static fields, and perhaps other C++ extensions.
3442 Hopefully few people use -gstabs with gdb, since it is intended
3443 for dbx compatibility. */
3445 /* Ignore this field. */
3446 fip->list->visibility = VISIBILITY_IGNORE;
3450 /* Detect an unpacked field and mark it as such.
3451 dbx gives a bit size for all fields.
3452 Note that forward refs cannot be packed,
3453 and treat enums as if they had the width of ints. */
3455 struct type *field_type = check_typedef (FIELD_TYPE (fip->list->field));
3457 if (TYPE_CODE (field_type) != TYPE_CODE_INT
3458 && TYPE_CODE (field_type) != TYPE_CODE_RANGE
3459 && TYPE_CODE (field_type) != TYPE_CODE_BOOL
3460 && TYPE_CODE (field_type) != TYPE_CODE_ENUM)
3462 FIELD_BITSIZE (fip->list->field) = 0;
3464 if ((FIELD_BITSIZE (fip->list->field)
3465 == TARGET_CHAR_BIT * TYPE_LENGTH (field_type)
3466 || (TYPE_CODE (field_type) == TYPE_CODE_ENUM
3467 && FIELD_BITSIZE (fip->list->field) == TARGET_INT_BIT)
3470 FIELD_BITPOS (fip->list->field) % 8 == 0)
3472 FIELD_BITSIZE (fip->list->field) = 0;
3478 /* Read struct or class data fields. They have the form:
3480 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
3482 At the end, we see a semicolon instead of a field.
3484 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
3487 The optional VISIBILITY is one of:
3489 '/0' (VISIBILITY_PRIVATE)
3490 '/1' (VISIBILITY_PROTECTED)
3491 '/2' (VISIBILITY_PUBLIC)
3492 '/9' (VISIBILITY_IGNORE)
3494 or nothing, for C style fields with public visibility.
3496 Returns 1 for success, 0 for failure. */
3499 read_struct_fields (struct field_info *fip, char **pp, struct type *type,
3500 struct objfile *objfile)
3503 struct nextfield *new;
3505 /* We better set p right now, in case there are no fields at all... */
3509 /* Read each data member type until we find the terminating ';' at the end of
3510 the data member list, or break for some other reason such as finding the
3511 start of the member function list. */
3515 if (os9k_stabs && **pp == ',')
3517 STABS_CONTINUE (pp, objfile);
3518 /* Get space to record the next field's data. */
3519 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3520 make_cleanup (xfree, new);
3521 memset (new, 0, sizeof (struct nextfield));
3522 new->next = fip->list;
3525 /* Get the field name. */
3528 /* If is starts with CPLUS_MARKER it is a special abbreviation,
3529 unless the CPLUS_MARKER is followed by an underscore, in
3530 which case it is just the name of an anonymous type, which we
3531 should handle like any other type name. */
3533 if (is_cplus_marker (p[0]) && p[1] != '_')
3535 if (!read_cpp_abbrev (fip, pp, type, objfile))
3540 /* Look for the ':' that separates the field name from the field
3541 values. Data members are delimited by a single ':', while member
3542 functions are delimited by a pair of ':'s. When we hit the member
3543 functions (if any), terminate scan loop and return. */
3545 while (*p != ':' && *p != '\0')
3552 /* Check to see if we have hit the member functions yet. */
3557 read_one_struct_field (fip, pp, p, type, objfile);
3559 if (p[0] == ':' && p[1] == ':')
3561 /* chill the list of fields: the last entry (at the head) is a
3562 partially constructed entry which we now scrub. */
3563 fip->list = fip->list->next;
3568 /* The stabs for C++ derived classes contain baseclass information which
3569 is marked by a '!' character after the total size. This function is
3570 called when we encounter the baseclass marker, and slurps up all the
3571 baseclass information.
3573 Immediately following the '!' marker is the number of base classes that
3574 the class is derived from, followed by information for each base class.
3575 For each base class, there are two visibility specifiers, a bit offset
3576 to the base class information within the derived class, a reference to
3577 the type for the base class, and a terminating semicolon.
3579 A typical example, with two base classes, would be "!2,020,19;0264,21;".
3581 Baseclass information marker __________________|| | | | | | |
3582 Number of baseclasses __________________________| | | | | | |
3583 Visibility specifiers (2) ________________________| | | | | |
3584 Offset in bits from start of class _________________| | | | |
3585 Type number for base class ___________________________| | | |
3586 Visibility specifiers (2) _______________________________| | |
3587 Offset in bits from start of class ________________________| |
3588 Type number of base class ____________________________________|
3590 Return 1 for success, 0 for (error-type-inducing) failure. */
3596 read_baseclasses (struct field_info *fip, char **pp, struct type *type,
3597 struct objfile *objfile)
3600 struct nextfield *new;
3608 /* Skip the '!' baseclass information marker. */
3612 ALLOCATE_CPLUS_STRUCT_TYPE (type);
3615 TYPE_N_BASECLASSES (type) = read_huge_number (pp, ',', &nbits);
3621 /* Some stupid compilers have trouble with the following, so break
3622 it up into simpler expressions. */
3623 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
3624 TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
3627 int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
3630 pointer = (char *) TYPE_ALLOC (type, num_bytes);
3631 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
3635 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
3637 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
3639 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3640 make_cleanup (xfree, new);
3641 memset (new, 0, sizeof (struct nextfield));
3642 new->next = fip->list;
3644 FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
3646 STABS_CONTINUE (pp, objfile);
3650 /* Nothing to do. */
3653 SET_TYPE_FIELD_VIRTUAL (type, i);
3656 /* Unknown character. Complain and treat it as non-virtual. */
3658 static struct complaint msg =
3660 "Unknown virtual character `%c' for baseclass", 0, 0};
3661 complain (&msg, **pp);
3666 new->visibility = *(*pp)++;
3667 switch (new->visibility)
3669 case VISIBILITY_PRIVATE:
3670 case VISIBILITY_PROTECTED:
3671 case VISIBILITY_PUBLIC:
3674 /* Bad visibility format. Complain and treat it as
3677 static struct complaint msg =
3679 "Unknown visibility `%c' for baseclass", 0, 0
3681 complain (&msg, new->visibility);
3682 new->visibility = VISIBILITY_PUBLIC;
3689 /* The remaining value is the bit offset of the portion of the object
3690 corresponding to this baseclass. Always zero in the absence of
3691 multiple inheritance. */
3693 FIELD_BITPOS (new->field) = read_huge_number (pp, ',', &nbits);
3698 /* The last piece of baseclass information is the type of the
3699 base class. Read it, and remember it's type name as this
3702 new->field.type = read_type (pp, objfile);
3703 new->field.name = type_name_no_tag (new->field.type);
3705 /* skip trailing ';' and bump count of number of fields seen */
3714 /* The tail end of stabs for C++ classes that contain a virtual function
3715 pointer contains a tilde, a %, and a type number.
3716 The type number refers to the base class (possibly this class itself) which
3717 contains the vtable pointer for the current class.
3719 This function is called when we have parsed all the method declarations,
3720 so we can look for the vptr base class info. */
3723 read_tilde_fields (struct field_info *fip, char **pp, struct type *type,
3724 struct objfile *objfile)
3728 STABS_CONTINUE (pp, objfile);
3730 /* If we are positioned at a ';', then skip it. */
3740 if (**pp == '=' || **pp == '+' || **pp == '-')
3742 /* Obsolete flags that used to indicate the presence
3743 of constructors and/or destructors. */
3747 /* Read either a '%' or the final ';'. */
3748 if (*(*pp)++ == '%')
3750 /* The next number is the type number of the base class
3751 (possibly our own class) which supplies the vtable for
3752 this class. Parse it out, and search that class to find
3753 its vtable pointer, and install those into TYPE_VPTR_BASETYPE
3754 and TYPE_VPTR_FIELDNO. */
3759 t = read_type (pp, objfile);
3761 while (*p != '\0' && *p != ';')
3767 /* Premature end of symbol. */
3771 TYPE_VPTR_BASETYPE (type) = t;
3772 if (type == t) /* Our own class provides vtbl ptr */
3774 for (i = TYPE_NFIELDS (t) - 1;
3775 i >= TYPE_N_BASECLASSES (t);
3778 if (!strncmp (TYPE_FIELD_NAME (t, i), vptr_name,
3779 sizeof (vptr_name) - 1))
3781 TYPE_VPTR_FIELDNO (type) = i;
3785 /* Virtual function table field not found. */
3786 complain (&vtbl_notfound_complaint, TYPE_NAME (type));
3791 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
3802 attach_fn_fields_to_type (struct field_info *fip, register struct type *type)
3806 for (n = TYPE_NFN_FIELDS (type);
3807 fip->fnlist != NULL;
3808 fip->fnlist = fip->fnlist->next)
3810 --n; /* Circumvent Sun3 compiler bug */
3811 TYPE_FN_FIELDLISTS (type)[n] = fip->fnlist->fn_fieldlist;
3816 /* read cfront class static data.
3817 pp points to string starting with the list of static data
3818 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
3821 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
3826 read_cfront_static_fields (struct field_info *fip, char **pp, struct type *type,
3827 struct objfile *objfile)
3829 struct nextfield *new;
3832 struct symbol *ref_static = 0;
3834 if (**pp == ';') /* no static data; return */
3840 /* Process each field in the list until we find the terminating ";" */
3842 /* eg: p = "as__1A ;;;" */
3843 STABS_CONTINUE (pp, objfile); /* handle \\ */
3844 while (**pp != ';' && (sname = get_substring (pp, ' '), sname))
3846 ref_static = lookup_symbol (sname, 0, VAR_NAMESPACE, 0, 0); /*demangled_name */
3849 static struct complaint msg =
3851 Unable to find symbol for static data field %s\n",
3853 complain (&msg, sname);
3856 stype = SYMBOL_TYPE (ref_static);
3858 /* allocate a new fip */
3859 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3860 make_cleanup (xfree, new);
3861 memset (new, 0, sizeof (struct nextfield));
3862 new->next = fip->list;
3865 /* set visibility */
3866 /* FIXME! no way to tell visibility from stabs??? */
3867 new->visibility = VISIBILITY_PUBLIC;
3869 /* set field info into fip */
3870 fip->list->field.type = stype;
3872 /* set bitpos & bitsize */
3873 SET_FIELD_PHYSNAME (fip->list->field, savestring (sname, strlen (sname)));
3875 /* set name field */
3876 /* The following is code to work around cfront generated stabs.
3877 The stabs contains full mangled name for each field.
3878 We try to demangle the name and extract the field name out of it.
3883 dem = cplus_demangle (sname, DMGL_ANSI | DMGL_PARAMS);
3886 dem_p = strrchr (dem, ':');
3887 if (dem_p != 0 && *(dem_p - 1) == ':')
3889 fip->list->field.name =
3890 obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
3894 fip->list->field.name =
3895 obsavestring (sname, strlen (sname), &objfile->type_obstack);
3897 } /* end of code for cfront work around */
3898 } /* loop again for next static field */
3902 /* Copy structure fields to fip so attach_fields_to_type will work.
3903 type has already been created with the initial instance data fields.
3904 Now we want to be able to add the other members to the class,
3905 so we want to add them back to the fip and reattach them again
3906 once we have collected all the class members. */
3909 copy_cfront_struct_fields (struct field_info *fip, struct type *type,
3910 struct objfile *objfile)
3912 int nfields = TYPE_NFIELDS (type);
3914 struct nextfield *new;
3916 /* Copy the fields into the list of fips and reset the types
3917 to remove the old fields */
3919 for (i = 0; i < nfields; i++)
3921 /* allocate a new fip */
3922 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3923 make_cleanup (xfree, new);
3924 memset (new, 0, sizeof (struct nextfield));
3925 new->next = fip->list;
3928 /* copy field info into fip */
3929 new->field = TYPE_FIELD (type, i);
3930 /* set visibility */
3931 if (TYPE_FIELD_PROTECTED (type, i))
3932 new->visibility = VISIBILITY_PROTECTED;
3933 else if (TYPE_FIELD_PRIVATE (type, i))
3934 new->visibility = VISIBILITY_PRIVATE;
3936 new->visibility = VISIBILITY_PUBLIC;
3938 /* Now delete the fields from the type since we will be
3939 allocing new space once we get the rest of the fields
3940 in attach_fields_to_type.
3941 The pointer TYPE_FIELDS(type) is left dangling but should
3942 be freed later by objstack_free */
3943 TYPE_FIELDS (type) = 0;
3944 TYPE_NFIELDS (type) = 0;
3949 /* Create the vector of fields, and record how big it is.
3950 We need this info to record proper virtual function table information
3951 for this class's virtual functions. */
3954 attach_fields_to_type (struct field_info *fip, register struct type *type,
3955 struct objfile *objfile)
3957 register int nfields = 0;
3958 register int non_public_fields = 0;
3959 register struct nextfield *scan;
3961 /* Count up the number of fields that we have, as well as taking note of
3962 whether or not there are any non-public fields, which requires us to
3963 allocate and build the private_field_bits and protected_field_bits
3966 for (scan = fip->list; scan != NULL; scan = scan->next)
3969 if (scan->visibility != VISIBILITY_PUBLIC)
3971 non_public_fields++;
3975 /* Now we know how many fields there are, and whether or not there are any
3976 non-public fields. Record the field count, allocate space for the
3977 array of fields, and create blank visibility bitfields if necessary. */
3979 TYPE_NFIELDS (type) = nfields;
3980 TYPE_FIELDS (type) = (struct field *)
3981 TYPE_ALLOC (type, sizeof (struct field) * nfields);
3982 memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
3984 if (non_public_fields)
3986 ALLOCATE_CPLUS_STRUCT_TYPE (type);
3988 TYPE_FIELD_PRIVATE_BITS (type) =
3989 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
3990 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
3992 TYPE_FIELD_PROTECTED_BITS (type) =
3993 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
3994 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
3996 TYPE_FIELD_IGNORE_BITS (type) =
3997 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
3998 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
4001 /* Copy the saved-up fields into the field vector. Start from the head
4002 of the list, adding to the tail of the field array, so that they end
4003 up in the same order in the array in which they were added to the list. */
4005 while (nfields-- > 0)
4007 TYPE_FIELD (type, nfields) = fip->list->field;
4008 switch (fip->list->visibility)
4010 case VISIBILITY_PRIVATE:
4011 SET_TYPE_FIELD_PRIVATE (type, nfields);
4014 case VISIBILITY_PROTECTED:
4015 SET_TYPE_FIELD_PROTECTED (type, nfields);
4018 case VISIBILITY_IGNORE:
4019 SET_TYPE_FIELD_IGNORE (type, nfields);
4022 case VISIBILITY_PUBLIC:
4026 /* Unknown visibility. Complain and treat it as public. */
4028 static struct complaint msg =
4030 "Unknown visibility `%c' for field", 0, 0};
4031 complain (&msg, fip->list->visibility);
4035 fip->list = fip->list->next;
4040 /* Read the description of a structure (or union type) and return an object
4041 describing the type.
4043 PP points to a character pointer that points to the next unconsumed token
4044 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
4045 *PP will point to "4a:1,0,32;;".
4047 TYPE points to an incomplete type that needs to be filled in.
4049 OBJFILE points to the current objfile from which the stabs information is
4050 being read. (Note that it is redundant in that TYPE also contains a pointer
4051 to this same objfile, so it might be a good idea to eliminate it. FIXME).
4054 static struct type *
4055 read_struct_type (char **pp, struct type *type, struct objfile *objfile)
4057 struct cleanup *back_to;
4058 struct field_info fi;
4063 back_to = make_cleanup (null_cleanup, 0);
4065 INIT_CPLUS_SPECIFIC (type);
4066 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
4068 /* First comes the total size in bytes. */
4072 TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits);
4074 return error_type (pp, objfile);
4077 /* Now read the baseclasses, if any, read the regular C struct or C++
4078 class member fields, attach the fields to the type, read the C++
4079 member functions, attach them to the type, and then read any tilde
4080 field (baseclass specifier for the class holding the main vtable). */
4082 if (!read_baseclasses (&fi, pp, type, objfile)
4083 || !read_struct_fields (&fi, pp, type, objfile)
4084 || !attach_fields_to_type (&fi, type, objfile)
4085 || !read_member_functions (&fi, pp, type, objfile)
4086 || !attach_fn_fields_to_type (&fi, type)
4087 || !read_tilde_fields (&fi, pp, type, objfile))
4089 type = error_type (pp, objfile);
4092 do_cleanups (back_to);
4096 /* Read a definition of an array type,
4097 and create and return a suitable type object.
4098 Also creates a range type which represents the bounds of that
4101 static struct type *
4102 read_array_type (register char **pp, register struct type *type,
4103 struct objfile *objfile)
4105 struct type *index_type, *element_type, *range_type;
4110 /* Format of an array type:
4111 "ar<index type>;lower;upper;<array_contents_type>".
4112 OS9000: "arlower,upper;<array_contents_type>".
4114 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
4115 for these, produce a type like float[][]. */
4118 index_type = builtin_type_int;
4121 index_type = read_type (pp, objfile);
4123 /* Improper format of array type decl. */
4124 return error_type (pp, objfile);
4128 if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
4133 lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits);
4135 return error_type (pp, objfile);
4137 if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
4142 upper = read_huge_number (pp, ';', &nbits);
4144 return error_type (pp, objfile);
4146 element_type = read_type (pp, objfile);
4155 create_range_type ((struct type *) NULL, index_type, lower, upper);
4156 type = create_array_type (type, element_type, range_type);
4162 /* Read a definition of an enumeration type,
4163 and create and return a suitable type object.
4164 Also defines the symbols that represent the values of the type. */
4166 static struct type *
4167 read_enum_type (register char **pp, register struct type *type,
4168 struct objfile *objfile)
4173 register struct symbol *sym;
4175 struct pending **symlist;
4176 struct pending *osyms, *syms;
4179 int unsigned_enum = 1;
4182 /* FIXME! The stabs produced by Sun CC merrily define things that ought
4183 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
4184 to do? For now, force all enum values to file scope. */
4185 if (within_function)
4186 symlist = &local_symbols;
4189 symlist = &file_symbols;
4191 o_nsyms = osyms ? osyms->nsyms : 0;
4195 /* Size. Perhaps this does not have to be conditionalized on
4196 os9k_stabs (assuming the name of an enum constant can't start
4198 read_huge_number (pp, 0, &nbits);
4200 return error_type (pp, objfile);
4203 /* The aix4 compiler emits an extra field before the enum members;
4204 my guess is it's a type of some sort. Just ignore it. */
4207 /* Skip over the type. */
4211 /* Skip over the colon. */
4215 /* Read the value-names and their values.
4216 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
4217 A semicolon or comma instead of a NAME means the end. */
4218 while (**pp && **pp != ';' && **pp != ',')
4220 STABS_CONTINUE (pp, objfile);
4224 name = obsavestring (*pp, p - *pp, &objfile->symbol_obstack);
4226 n = read_huge_number (pp, ',', &nbits);
4228 return error_type (pp, objfile);
4230 sym = (struct symbol *)
4231 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
4232 memset (sym, 0, sizeof (struct symbol));
4233 SYMBOL_NAME (sym) = name;
4234 SYMBOL_LANGUAGE (sym) = current_subfile->language;
4235 SYMBOL_CLASS (sym) = LOC_CONST;
4236 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
4237 SYMBOL_VALUE (sym) = n;
4240 add_symbol_to_list (sym, symlist);
4245 (*pp)++; /* Skip the semicolon. */
4247 /* Now fill in the fields of the type-structure. */
4249 TYPE_LENGTH (type) = TARGET_INT_BIT / HOST_CHAR_BIT;
4250 TYPE_CODE (type) = TYPE_CODE_ENUM;
4251 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
4253 TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
4254 TYPE_NFIELDS (type) = nsyms;
4255 TYPE_FIELDS (type) = (struct field *)
4256 TYPE_ALLOC (type, sizeof (struct field) * nsyms);
4257 memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms);
4259 /* Find the symbols for the values and put them into the type.
4260 The symbols can be found in the symlist that we put them on
4261 to cause them to be defined. osyms contains the old value
4262 of that symlist; everything up to there was defined by us. */
4263 /* Note that we preserve the order of the enum constants, so
4264 that in something like "enum {FOO, LAST_THING=FOO}" we print
4265 FOO, not LAST_THING. */
4267 for (syms = *symlist, n = nsyms - 1; syms; syms = syms->next)
4269 int last = syms == osyms ? o_nsyms : 0;
4270 int j = syms->nsyms;
4271 for (; --j >= last; --n)
4273 struct symbol *xsym = syms->symbol[j];
4274 SYMBOL_TYPE (xsym) = type;
4275 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
4276 TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
4277 TYPE_FIELD_BITSIZE (type, n) = 0;
4286 /* Sun's ACC uses a somewhat saner method for specifying the builtin
4287 typedefs in every file (for int, long, etc):
4289 type = b <signed> <width> <format type>; <offset>; <nbits>
4291 optional format type = c or b for char or boolean.
4292 offset = offset from high order bit to start bit of type.
4293 width is # bytes in object of this type, nbits is # bits in type.
4295 The width/offset stuff appears to be for small objects stored in
4296 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
4299 static struct type *
4300 read_sun_builtin_type (char **pp, int typenums[2], struct objfile *objfile)
4305 enum type_code code = TYPE_CODE_INT;
4316 return error_type (pp, objfile);
4320 /* For some odd reason, all forms of char put a c here. This is strange
4321 because no other type has this honor. We can safely ignore this because
4322 we actually determine 'char'acterness by the number of bits specified in
4324 Boolean forms, e.g Fortran logical*X, put a b here. */
4328 else if (**pp == 'b')
4330 code = TYPE_CODE_BOOL;
4334 /* The first number appears to be the number of bytes occupied
4335 by this type, except that unsigned short is 4 instead of 2.
4336 Since this information is redundant with the third number,
4337 we will ignore it. */
4338 read_huge_number (pp, ';', &nbits);
4340 return error_type (pp, objfile);
4342 /* The second number is always 0, so ignore it too. */
4343 read_huge_number (pp, ';', &nbits);
4345 return error_type (pp, objfile);
4347 /* The third number is the number of bits for this type. */
4348 type_bits = read_huge_number (pp, 0, &nbits);
4350 return error_type (pp, objfile);
4351 /* The type *should* end with a semicolon. If it are embedded
4352 in a larger type the semicolon may be the only way to know where
4353 the type ends. If this type is at the end of the stabstring we
4354 can deal with the omitted semicolon (but we don't have to like
4355 it). Don't bother to complain(), Sun's compiler omits the semicolon
4361 return init_type (TYPE_CODE_VOID, 1,
4362 signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
4365 return init_type (code,
4366 type_bits / TARGET_CHAR_BIT,
4367 signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
4371 static struct type *
4372 read_sun_floating_type (char **pp, int typenums[2], struct objfile *objfile)
4378 /* The first number has more details about the type, for example
4380 details = read_huge_number (pp, ';', &nbits);
4382 return error_type (pp, objfile);
4384 /* The second number is the number of bytes occupied by this type */
4385 nbytes = read_huge_number (pp, ';', &nbits);
4387 return error_type (pp, objfile);
4389 if (details == NF_COMPLEX || details == NF_COMPLEX16
4390 || details == NF_COMPLEX32)
4391 /* This is a type we can't handle, but we do know the size.
4392 We also will be able to give it a name. */
4393 return init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile);
4395 return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile);
4398 /* Read a number from the string pointed to by *PP.
4399 The value of *PP is advanced over the number.
4400 If END is nonzero, the character that ends the
4401 number must match END, or an error happens;
4402 and that character is skipped if it does match.
4403 If END is zero, *PP is left pointing to that character.
4405 If the number fits in a long, set *BITS to 0 and return the value.
4406 If not, set *BITS to be the number of bits in the number and return 0.
4408 If encounter garbage, set *BITS to -1 and return 0. */
4411 read_huge_number (char **pp, int end, int *bits)
4428 /* Leading zero means octal. GCC uses this to output values larger
4429 than an int (because that would be hard in decimal). */
4437 upper_limit = ULONG_MAX / radix;
4439 upper_limit = LONG_MAX / radix;
4441 while ((c = *p++) >= '0' && c < ('0' + radix))
4443 if (n <= upper_limit)
4446 n += c - '0'; /* FIXME this overflows anyway */
4451 /* This depends on large values being output in octal, which is
4458 /* Ignore leading zeroes. */
4462 else if (c == '2' || c == '3')
4488 /* Large decimal constants are an error (because it is hard to
4489 count how many bits are in them). */
4495 /* -0x7f is the same as 0x80. So deal with it by adding one to
4496 the number of bits. */
4508 /* It's *BITS which has the interesting information. */
4512 static struct type *
4513 read_range_type (char **pp, int typenums[2], struct objfile *objfile)
4515 char *orig_pp = *pp;
4520 struct type *result_type;
4521 struct type *index_type = NULL;
4523 /* First comes a type we are a subrange of.
4524 In C it is usually 0, 1 or the type being defined. */
4525 if (read_type_number (pp, rangenums) != 0)
4526 return error_type (pp, objfile);
4527 self_subrange = (rangenums[0] == typenums[0] &&
4528 rangenums[1] == typenums[1]);
4533 index_type = read_type (pp, objfile);
4536 /* A semicolon should now follow; skip it. */
4540 /* The remaining two operands are usually lower and upper bounds
4541 of the range. But in some special cases they mean something else. */
4542 n2 = read_huge_number (pp, ';', &n2bits);
4543 n3 = read_huge_number (pp, ';', &n3bits);
4545 if (n2bits == -1 || n3bits == -1)
4546 return error_type (pp, objfile);
4549 goto handle_true_range;
4551 /* If limits are huge, must be large integral type. */
4552 if (n2bits != 0 || n3bits != 0)
4554 char got_signed = 0;
4555 char got_unsigned = 0;
4556 /* Number of bits in the type. */
4559 /* Range from 0 to <large number> is an unsigned large integral type. */
4560 if ((n2bits == 0 && n2 == 0) && n3bits != 0)
4565 /* Range from <large number> to <large number>-1 is a large signed
4566 integral type. Take care of the case where <large number> doesn't
4567 fit in a long but <large number>-1 does. */
4568 else if ((n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
4569 || (n2bits != 0 && n3bits == 0
4570 && (n2bits == sizeof (long) * HOST_CHAR_BIT)
4577 if (got_signed || got_unsigned)
4579 return init_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT,
4580 got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL,
4584 return error_type (pp, objfile);
4587 /* A type defined as a subrange of itself, with bounds both 0, is void. */
4588 if (self_subrange && n2 == 0 && n3 == 0)
4589 return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
4591 /* If n3 is zero and n2 is positive, we want a floating type, and n2
4592 is the width in bytes.
4594 Fortran programs appear to use this for complex types also. To
4595 distinguish between floats and complex, g77 (and others?) seem
4596 to use self-subranges for the complexes, and subranges of int for
4599 Also note that for complexes, g77 sets n2 to the size of one of
4600 the member floats, not the whole complex beast. My guess is that
4601 this was to work well with pre-COMPLEX versions of gdb. */
4603 if (n3 == 0 && n2 > 0)
4605 struct type *float_type
4606 = init_type (TYPE_CODE_FLT, n2, 0, NULL, objfile);
4610 struct type *complex_type =
4611 init_type (TYPE_CODE_COMPLEX, 2 * n2, 0, NULL, objfile);
4612 TYPE_TARGET_TYPE (complex_type) = float_type;
4613 return complex_type;
4619 /* If the upper bound is -1, it must really be an unsigned int. */
4621 else if (n2 == 0 && n3 == -1)
4623 /* It is unsigned int or unsigned long. */
4624 /* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
4625 compatibility hack. */
4626 return init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
4627 TYPE_FLAG_UNSIGNED, NULL, objfile);
4630 /* Special case: char is defined (Who knows why) as a subrange of
4631 itself with range 0-127. */
4632 else if (self_subrange && n2 == 0 && n3 == 127)
4633 return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
4635 else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill
4637 goto handle_true_range;
4639 /* We used to do this only for subrange of self or subrange of int. */
4642 /* -1 is used for the upper bound of (4 byte) "unsigned int" and
4643 "unsigned long", and we already checked for that,
4644 so don't need to test for it here. */
4647 /* n3 actually gives the size. */
4648 return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED,
4651 /* Is n3 == 2**(8n)-1 for some integer n? Then it's an
4652 unsigned n-byte integer. But do require n to be a power of
4653 two; we don't want 3- and 5-byte integers flying around. */
4659 for (bytes = 0; (bits & 0xff) == 0xff; bytes++)
4662 && ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */
4663 return init_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL,
4667 /* I think this is for Convex "long long". Since I don't know whether
4668 Convex sets self_subrange, I also accept that particular size regardless
4669 of self_subrange. */
4670 else if (n3 == 0 && n2 < 0
4672 || n2 == -TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT))
4673 return init_type (TYPE_CODE_INT, -n2, 0, NULL, objfile);
4674 else if (n2 == -n3 - 1)
4677 return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
4679 return init_type (TYPE_CODE_INT, 2, 0, NULL, objfile);
4680 if (n3 == 0x7fffffff)
4681 return init_type (TYPE_CODE_INT, 4, 0, NULL, objfile);
4684 /* We have a real range type on our hands. Allocate space and
4685 return a real pointer. */
4689 index_type = builtin_type_int;
4691 index_type = *dbx_lookup_type (rangenums);
4692 if (index_type == NULL)
4694 /* Does this actually ever happen? Is that why we are worrying
4695 about dealing with it rather than just calling error_type? */
4697 static struct type *range_type_index;
4699 complain (&range_type_base_complaint, rangenums[1]);
4700 if (range_type_index == NULL)
4702 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
4703 0, "range type index type", NULL);
4704 index_type = range_type_index;
4707 result_type = create_range_type ((struct type *) NULL, index_type, n2, n3);
4708 return (result_type);
4711 /* Read in an argument list. This is a list of types, separated by commas
4712 and terminated with END. Return the list of types read in, or (struct type
4713 **)-1 if there is an error. */
4715 static struct type **
4716 read_args (char **pp, int end, struct objfile *objfile)
4718 /* FIXME! Remove this arbitrary limit! */
4719 struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
4725 /* Invalid argument list: no ','. */
4726 return (struct type **) -1;
4728 STABS_CONTINUE (pp, objfile);
4729 types[n++] = read_type (pp, objfile);
4731 (*pp)++; /* get past `end' (the ':' character) */
4735 rval = (struct type **) xmalloc (2 * sizeof (struct type *));
4737 else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID)
4739 rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
4740 memset (rval + n, 0, sizeof (struct type *));
4744 rval = (struct type **) xmalloc (n * sizeof (struct type *));
4746 memcpy (rval, types, n * sizeof (struct type *));
4750 /* Common block handling. */
4752 /* List of symbols declared since the last BCOMM. This list is a tail
4753 of local_symbols. When ECOMM is seen, the symbols on the list
4754 are noted so their proper addresses can be filled in later,
4755 using the common block base address gotten from the assembler
4758 static struct pending *common_block;
4759 static int common_block_i;
4761 /* Name of the current common block. We get it from the BCOMM instead of the
4762 ECOMM to match IBM documentation (even though IBM puts the name both places
4763 like everyone else). */
4764 static char *common_block_name;
4766 /* Process a N_BCOMM symbol. The storage for NAME is not guaranteed
4767 to remain after this function returns. */
4770 common_block_start (char *name, struct objfile *objfile)
4772 if (common_block_name != NULL)
4774 static struct complaint msg =
4776 "Invalid symbol data: common block within common block",
4780 common_block = local_symbols;
4781 common_block_i = local_symbols ? local_symbols->nsyms : 0;
4782 common_block_name = obsavestring (name, strlen (name),
4783 &objfile->symbol_obstack);
4786 /* Process a N_ECOMM symbol. */
4789 common_block_end (struct objfile *objfile)
4791 /* Symbols declared since the BCOMM are to have the common block
4792 start address added in when we know it. common_block and
4793 common_block_i point to the first symbol after the BCOMM in
4794 the local_symbols list; copy the list and hang it off the
4795 symbol for the common block name for later fixup. */
4798 struct pending *new = 0;
4799 struct pending *next;
4802 if (common_block_name == NULL)
4804 static struct complaint msg =
4805 {"ECOMM symbol unmatched by BCOMM", 0, 0};
4810 sym = (struct symbol *)
4811 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
4812 memset (sym, 0, sizeof (struct symbol));
4813 /* Note: common_block_name already saved on symbol_obstack */
4814 SYMBOL_NAME (sym) = common_block_name;
4815 SYMBOL_CLASS (sym) = LOC_BLOCK;
4817 /* Now we copy all the symbols which have been defined since the BCOMM. */
4819 /* Copy all the struct pendings before common_block. */
4820 for (next = local_symbols;
4821 next != NULL && next != common_block;
4824 for (j = 0; j < next->nsyms; j++)
4825 add_symbol_to_list (next->symbol[j], &new);
4828 /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is
4829 NULL, it means copy all the local symbols (which we already did
4832 if (common_block != NULL)
4833 for (j = common_block_i; j < common_block->nsyms; j++)
4834 add_symbol_to_list (common_block->symbol[j], &new);
4836 SYMBOL_TYPE (sym) = (struct type *) new;
4838 /* Should we be putting local_symbols back to what it was?
4841 i = hashname (SYMBOL_NAME (sym));
4842 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
4843 global_sym_chain[i] = sym;
4844 common_block_name = NULL;
4847 /* Add a common block's start address to the offset of each symbol
4848 declared to be in it (by being between a BCOMM/ECOMM pair that uses
4849 the common block name). */
4852 fix_common_block (struct symbol *sym, int valu)
4854 struct pending *next = (struct pending *) SYMBOL_TYPE (sym);
4855 for (; next; next = next->next)
4858 for (j = next->nsyms - 1; j >= 0; j--)
4859 SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu;
4865 /* What about types defined as forward references inside of a small lexical
4867 /* Add a type to the list of undefined types to be checked through
4868 once this file has been read in. */
4871 add_undefined_type (struct type *type)
4873 if (undef_types_length == undef_types_allocated)
4875 undef_types_allocated *= 2;
4876 undef_types = (struct type **)
4877 xrealloc ((char *) undef_types,
4878 undef_types_allocated * sizeof (struct type *));
4880 undef_types[undef_types_length++] = type;
4883 /* Go through each undefined type, see if it's still undefined, and fix it
4884 up if possible. We have two kinds of undefined types:
4886 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
4887 Fix: update array length using the element bounds
4888 and the target type's length.
4889 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
4890 yet defined at the time a pointer to it was made.
4891 Fix: Do a full lookup on the struct/union tag. */
4893 cleanup_undefined_types (void)
4897 for (type = undef_types; type < undef_types + undef_types_length; type++)
4899 switch (TYPE_CODE (*type))
4902 case TYPE_CODE_STRUCT:
4903 case TYPE_CODE_UNION:
4904 case TYPE_CODE_ENUM:
4906 /* Check if it has been defined since. Need to do this here
4907 as well as in check_typedef to deal with the (legitimate in
4908 C though not C++) case of several types with the same name
4909 in different source files. */
4910 if (TYPE_FLAGS (*type) & TYPE_FLAG_STUB)
4912 struct pending *ppt;
4914 /* Name of the type, without "struct" or "union" */
4915 char *typename = TYPE_TAG_NAME (*type);
4917 if (typename == NULL)
4919 static struct complaint msg =
4920 {"need a type name", 0, 0};
4924 for (ppt = file_symbols; ppt; ppt = ppt->next)
4926 for (i = 0; i < ppt->nsyms; i++)
4928 struct symbol *sym = ppt->symbol[i];
4930 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
4931 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
4932 && (TYPE_CODE (SYMBOL_TYPE (sym)) ==
4934 && STREQ (SYMBOL_NAME (sym), typename))
4936 memcpy (*type, SYMBOL_TYPE (sym),
4937 sizeof (struct type));
4947 static struct complaint msg =
4949 GDB internal error. cleanup_undefined_types with bad type %d.", 0, 0};
4950 complain (&msg, TYPE_CODE (*type));
4956 undef_types_length = 0;
4959 /* Scan through all of the global symbols defined in the object file,
4960 assigning values to the debugging symbols that need to be assigned
4961 to. Get these symbols from the minimal symbol table. */
4964 scan_file_globals (struct objfile *objfile)
4967 struct minimal_symbol *msymbol;
4968 struct symbol *sym, *prev, *rsym;
4969 struct objfile *resolve_objfile;
4971 /* SVR4 based linkers copy referenced global symbols from shared
4972 libraries to the main executable.
4973 If we are scanning the symbols for a shared library, try to resolve
4974 them from the minimal symbols of the main executable first. */
4976 if (symfile_objfile && objfile != symfile_objfile)
4977 resolve_objfile = symfile_objfile;
4979 resolve_objfile = objfile;
4983 /* Avoid expensive loop through all minimal symbols if there are
4984 no unresolved symbols. */
4985 for (hash = 0; hash < HASHSIZE; hash++)
4987 if (global_sym_chain[hash])
4990 if (hash >= HASHSIZE)
4993 for (msymbol = resolve_objfile->msymbols;
4994 msymbol && SYMBOL_NAME (msymbol) != NULL;
4999 /* Skip static symbols. */
5000 switch (MSYMBOL_TYPE (msymbol))
5012 /* Get the hash index and check all the symbols
5013 under that hash index. */
5015 hash = hashname (SYMBOL_NAME (msymbol));
5017 for (sym = global_sym_chain[hash]; sym;)
5019 if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
5020 STREQ (SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
5023 struct alias_list *aliases;
5025 /* Splice this symbol out of the hash chain and
5026 assign the value we have to it. */
5029 SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
5033 global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
5036 /* Check to see whether we need to fix up a common block. */
5037 /* Note: this code might be executed several times for
5038 the same symbol if there are multiple references. */
5040 /* If symbol has aliases, do minimal symbol fixups for each.
5041 These live aliases/references weren't added to
5042 global_sym_chain hash but may also need to be fixed up. */
5043 /* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal
5044 symbols? Still, we wouldn't want to add_to_list. */
5045 /* Now do the same for each alias of this symbol */
5047 aliases = SYMBOL_ALIASES (sym);
5050 if (SYMBOL_CLASS (rsym) == LOC_BLOCK)
5052 fix_common_block (rsym,
5053 SYMBOL_VALUE_ADDRESS (msymbol));
5057 SYMBOL_VALUE_ADDRESS (rsym)
5058 = SYMBOL_VALUE_ADDRESS (msymbol);
5060 SYMBOL_SECTION (rsym) = SYMBOL_SECTION (msymbol);
5063 rsym = aliases->sym;
5064 aliases = aliases->next;
5073 sym = SYMBOL_VALUE_CHAIN (prev);
5077 sym = global_sym_chain[hash];
5083 sym = SYMBOL_VALUE_CHAIN (sym);
5087 if (resolve_objfile == objfile)
5089 resolve_objfile = objfile;
5092 /* Change the storage class of any remaining unresolved globals to
5093 LOC_UNRESOLVED and remove them from the chain. */
5094 for (hash = 0; hash < HASHSIZE; hash++)
5096 sym = global_sym_chain[hash];
5100 sym = SYMBOL_VALUE_CHAIN (sym);
5102 /* Change the symbol address from the misleading chain value
5104 SYMBOL_VALUE_ADDRESS (prev) = 0;
5106 /* Complain about unresolved common block symbols. */
5107 if (SYMBOL_CLASS (prev) == LOC_STATIC)
5108 SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
5110 complain (&unresolved_sym_chain_complaint,
5111 objfile->name, SYMBOL_NAME (prev));
5114 memset (global_sym_chain, 0, sizeof (global_sym_chain));
5117 /* Initialize anything that needs initializing when starting to read
5118 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
5122 stabsread_init (void)
5126 /* Initialize anything that needs initializing when a completely new
5127 symbol file is specified (not just adding some symbols from another
5128 file, e.g. a shared library). */
5131 stabsread_new_init (void)
5133 /* Empty the hash table of global syms looking for values. */
5134 memset (global_sym_chain, 0, sizeof (global_sym_chain));
5137 /* Initialize anything that needs initializing at the same time as
5138 start_symtab() is called. */
5143 global_stabs = NULL; /* AIX COFF */
5144 /* Leave FILENUM of 0 free for builtin types and this file's types. */
5145 n_this_object_header_files = 1;
5146 type_vector_length = 0;
5147 type_vector = (struct type **) 0;
5149 /* FIXME: If common_block_name is not already NULL, we should complain(). */
5150 common_block_name = NULL;
5155 /* Call after end_symtab() */
5162 xfree (type_vector);
5165 type_vector_length = 0;
5166 previous_stab_code = 0;
5170 finish_global_stabs (struct objfile *objfile)
5174 patch_block_stabs (global_symbols, global_stabs, objfile);
5175 xfree (global_stabs);
5176 global_stabs = NULL;
5180 /* Initializer for this module */
5183 _initialize_stabsread (void)
5185 undef_types_allocated = 20;
5186 undef_types_length = 0;
5187 undef_types = (struct type **)
5188 xmalloc (undef_types_allocated * sizeof (struct type *));