1 /* Support routines for decoding "stabs" debugging information format.
2 Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 1998
3 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* Support routines for reading and decoding debugging information in
23 the "stabs" format. This format is used with many systems that use
24 the a.out object file format, as well as some systems that use
25 COFF or ELF where the stabs data is placed in a special section.
26 Avoid placing any object file format specific code in this file. */
29 #include "gdb_string.h"
34 #include "expression.h"
37 #include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
39 #include "aout/aout64.h"
40 #include "gdb-stabs.h"
42 #include "complaints.h"
48 /* Ask stabsread.h to define the vars it normally declares `extern'. */
51 #include "stabsread.h" /* Our own declarations */
54 extern void _initialize_stabsread (void);
56 /* The routines that read and process a complete stabs for a C struct or
57 C++ class pass lists of data member fields and lists of member function
58 fields in an instance of a field_info structure, as defined below.
59 This is part of some reorganization of low level C++ support and is
60 expected to eventually go away... (FIXME) */
66 struct nextfield *next;
68 /* This is the raw visibility from the stab. It is not checked
69 for being one of the visibilities we recognize, so code which
70 examines this field better be able to deal. */
76 struct next_fnfieldlist
78 struct next_fnfieldlist *next;
79 struct fn_fieldlist fn_fieldlist;
85 read_one_struct_field (struct field_info *, char **, char *,
86 struct type *, struct objfile *);
88 static char *get_substring (char **, int);
90 static struct type *dbx_alloc_type (int[2], struct objfile *);
92 static long read_huge_number (char **, int, int *);
94 static struct type *error_type (char **, struct objfile *);
97 patch_block_stabs (struct pending *, struct pending_stabs *,
100 static void fix_common_block (struct symbol *, int);
102 static int read_type_number (char **, int *);
104 static struct type *read_range_type (char **, int[2], struct objfile *);
106 static struct type *read_sun_builtin_type (char **, int[2], struct objfile *);
108 static struct type *read_sun_floating_type (char **, int[2],
111 static struct type *read_enum_type (char **, struct type *, struct objfile *);
113 static struct type *rs6000_builtin_type (int);
116 read_member_functions (struct field_info *, char **, struct type *,
120 read_struct_fields (struct field_info *, char **, struct type *,
124 read_baseclasses (struct field_info *, char **, struct type *,
128 read_tilde_fields (struct field_info *, char **, struct type *,
131 static int attach_fn_fields_to_type (struct field_info *, struct type *);
134 attach_fields_to_type (struct field_info *, struct type *, struct objfile *);
136 static struct type *read_struct_type (char **, struct type *,
139 static struct type *read_array_type (char **, struct type *,
142 static struct type **read_args (char **, int, struct objfile *);
145 read_cpp_abbrev (struct field_info *, char **, struct type *,
148 /* new functions added for cfront support */
151 copy_cfront_struct_fields (struct field_info *, struct type *,
154 static char *get_cfront_method_physname (char *);
157 read_cfront_baseclasses (struct field_info *, char **,
158 struct type *, struct objfile *);
161 read_cfront_static_fields (struct field_info *, char **,
162 struct type *, struct objfile *);
164 read_cfront_member_functions (struct field_info *, char **,
165 struct type *, struct objfile *);
167 /* end new functions added for cfront support */
170 add_live_range (struct objfile *, struct symbol *, CORE_ADDR, CORE_ADDR);
172 static int resolve_live_range (struct objfile *, struct symbol *, char *);
174 static int process_reference (char **string);
176 static CORE_ADDR ref_search_value (int refnum);
179 resolve_symbol_reference (struct objfile *, struct symbol *, char *);
181 void stabsread_clear_cache (void);
183 static const char vptr_name[] =
184 {'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
185 static const char vb_name[] =
186 {'_', 'v', 'b', CPLUS_MARKER, '\0'};
188 /* Define this as 1 if a pcc declaration of a char or short argument
189 gives the correct address. Otherwise assume pcc gives the
190 address of the corresponding int, which is not the same on a
191 big-endian machine. */
193 #if !defined (BELIEVE_PCC_PROMOTION)
194 #define BELIEVE_PCC_PROMOTION 0
196 #if !defined (BELIEVE_PCC_PROMOTION_TYPE)
197 #define BELIEVE_PCC_PROMOTION_TYPE 0
200 static struct complaint invalid_cpp_abbrev_complaint =
201 {"invalid C++ abbreviation `%s'", 0, 0};
203 static struct complaint invalid_cpp_type_complaint =
204 {"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
206 static struct complaint member_fn_complaint =
207 {"member function type missing, got '%c'", 0, 0};
209 static struct complaint const_vol_complaint =
210 {"const/volatile indicator missing, got '%c'", 0, 0};
212 static struct complaint error_type_complaint =
213 {"debug info mismatch between compiler and debugger", 0, 0};
215 static struct complaint invalid_member_complaint =
216 {"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
218 static struct complaint range_type_base_complaint =
219 {"base type %d of range type is not defined", 0, 0};
221 static struct complaint reg_value_complaint =
222 {"register number %d too large (max %d) in symbol %s", 0, 0};
224 static struct complaint vtbl_notfound_complaint =
225 {"virtual function table pointer not found when defining class `%s'", 0, 0};
227 static struct complaint unrecognized_cplus_name_complaint =
228 {"Unknown C++ symbol name `%s'", 0, 0};
230 static struct complaint rs6000_builtin_complaint =
231 {"Unknown builtin type %d", 0, 0};
233 static struct complaint unresolved_sym_chain_complaint =
234 {"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
236 static struct complaint stabs_general_complaint =
239 static struct complaint lrs_general_complaint =
242 /* Make a list of forward references which haven't been defined. */
244 static struct type **undef_types;
245 static int undef_types_allocated;
246 static int undef_types_length;
247 static struct symbol *current_symbol = NULL;
249 /* Check for and handle cretinous stabs symbol name continuation! */
250 #define STABS_CONTINUE(pp,objfile) \
252 if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
253 *(pp) = next_symbol_text (objfile); \
256 /* FIXME: These probably should be our own types (like rs6000_builtin_type
257 has its own types) rather than builtin_type_*. */
258 static struct type **os9k_type_vector[] =
265 &builtin_type_unsigned_char,
266 &builtin_type_unsigned_short,
267 &builtin_type_unsigned_long,
268 &builtin_type_unsigned_int,
270 &builtin_type_double,
272 &builtin_type_long_double
275 static void os9k_init_type_vector (struct type **);
278 os9k_init_type_vector (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 (typenums)
297 register int filenum = typenums[0];
298 register int index = typenums[1];
300 register int real_filenum;
301 register struct header_file *f;
304 if (filenum == -1) /* -1,-1 is for temporary types. */
307 if (filenum < 0 || filenum >= n_this_object_header_files)
309 static struct complaint msg =
311 Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
313 complain (&msg, filenum, index, symnum);
321 /* Caller wants address of address of type. We think
322 that negative (rs6k builtin) types will never appear as
323 "lvalues", (nor should they), so we stuff the real type
324 pointer into a temp, and return its address. If referenced,
325 this will do the right thing. */
326 static struct type *temp_type;
328 temp_type = rs6000_builtin_type (index);
332 /* Type is defined outside of header files.
333 Find it in this object file's type vector. */
334 if (index >= type_vector_length)
336 old_len = type_vector_length;
339 type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
340 type_vector = (struct type **)
341 xmalloc (type_vector_length * sizeof (struct type *));
343 while (index >= type_vector_length)
345 type_vector_length *= 2;
347 type_vector = (struct type **)
348 xrealloc ((char *) type_vector,
349 (type_vector_length * sizeof (struct type *)));
350 memset (&type_vector[old_len], 0,
351 (type_vector_length - old_len) * sizeof (struct type *));
354 /* Deal with OS9000 fundamental types. */
355 os9k_init_type_vector (type_vector);
357 return (&type_vector[index]);
361 real_filenum = this_object_header_files[filenum];
363 if (real_filenum >= N_HEADER_FILES (current_objfile))
365 struct type *temp_type;
366 struct type **temp_type_p;
368 warning ("GDB internal error: bad real_filenum");
371 temp_type = init_type (TYPE_CODE_ERROR, 0, 0, NULL, NULL);
372 temp_type_p = (struct type **) xmalloc (sizeof (struct type *));
373 *temp_type_p = temp_type;
377 f = HEADER_FILES (current_objfile) + real_filenum;
379 f_orig_length = f->length;
380 if (index >= f_orig_length)
382 while (index >= f->length)
386 f->vector = (struct type **)
387 xrealloc ((char *) f->vector, f->length * sizeof (struct type *));
388 memset (&f->vector[f_orig_length], 0,
389 (f->length - f_orig_length) * sizeof (struct type *));
391 return (&f->vector[index]);
395 /* Make sure there is a type allocated for type numbers TYPENUMS
396 and return the type object.
397 This can create an empty (zeroed) type object.
398 TYPENUMS may be (-1, -1) to return a new type object that is not
399 put into the type vector, and so may not be referred to by number. */
402 dbx_alloc_type (typenums, objfile)
404 struct objfile *objfile;
406 register struct type **type_addr;
408 if (typenums[0] == -1)
410 return (alloc_type (objfile));
413 type_addr = dbx_lookup_type (typenums);
415 /* If we are referring to a type not known at all yet,
416 allocate an empty type for it.
417 We will fill it in later if we find out how. */
420 *type_addr = alloc_type (objfile);
426 /* for all the stabs in a given stab vector, build appropriate types
427 and fix their symbols in given symbol vector. */
430 patch_block_stabs (symbols, stabs, objfile)
431 struct pending *symbols;
432 struct pending_stabs *stabs;
433 struct objfile *objfile;
443 /* for all the stab entries, find their corresponding symbols and
444 patch their types! */
446 for (ii = 0; ii < stabs->count; ++ii)
448 name = stabs->stab[ii];
449 pp = (char *) strchr (name, ':');
453 pp = (char *) strchr (pp, ':');
455 sym = find_symbol_in_list (symbols, name, pp - name);
458 /* FIXME-maybe: it would be nice if we noticed whether
459 the variable was defined *anywhere*, not just whether
460 it is defined in this compilation unit. But neither
461 xlc or GCC seem to need such a definition, and until
462 we do psymtabs (so that the minimal symbols from all
463 compilation units are available now), I'm not sure
464 how to get the information. */
466 /* On xcoff, if a global is defined and never referenced,
467 ld will remove it from the executable. There is then
468 a N_GSYM stab for it, but no regular (C_EXT) symbol. */
469 sym = (struct symbol *)
470 obstack_alloc (&objfile->symbol_obstack,
471 sizeof (struct symbol));
473 memset (sym, 0, sizeof (struct symbol));
474 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
475 SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
477 obsavestring (name, pp - name, &objfile->symbol_obstack);
479 if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
481 /* I don't think the linker does this with functions,
482 so as far as I know this is never executed.
483 But it doesn't hurt to check. */
485 lookup_function_type (read_type (&pp, objfile));
489 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
491 add_symbol_to_list (sym, &global_symbols);
496 if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
499 lookup_function_type (read_type (&pp, objfile));
503 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
511 /* Read a number by which a type is referred to in dbx data,
512 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
513 Just a single number N is equivalent to (0,N).
514 Return the two numbers by storing them in the vector TYPENUMS.
515 TYPENUMS will then be used as an argument to dbx_lookup_type.
517 Returns 0 for success, -1 for error. */
520 read_type_number (pp, typenums)
522 register int *typenums;
528 typenums[0] = read_huge_number (pp, ',', &nbits);
531 typenums[1] = read_huge_number (pp, ')', &nbits);
538 typenums[1] = read_huge_number (pp, 0, &nbits);
546 #define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
547 #define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
548 #define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
549 #define VISIBILITY_IGNORE '9' /* Optimized out or zero length */
551 #define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */
552 #define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */
554 /* This code added to support parsing of ARM/Cfront stabs strings */
556 /* Get substring from string up to char c, advance string pointer past
577 /* Physname gets strcat'd onto sname in order to recreate the mangled
578 name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
579 the physname look like that of g++ - take out the initial mangling
580 eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
583 get_cfront_method_physname (fname)
587 /* FIXME would like to make this generic for g++ too, but
588 that is already handled in read_member_funcctions */
591 /* search ahead to find the start of the mangled suffix */
592 if (*p == '_' && *(p + 1) == '_') /* compiler generated; probably a ctor/dtor */
594 while (p && (unsigned) ((p + 1) - fname) < strlen (fname) && *(p + 1) != '_')
596 if (!(p && *p == '_' && *(p + 1) == '_'))
597 error ("Invalid mangled function name %s", fname);
598 p += 2; /* advance past '__' */
600 /* struct name length and name of type should come next; advance past it */
603 len = len * 10 + (*p - '0');
611 /* Read base classes within cfront class definition.
612 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
615 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
620 read_cfront_baseclasses (fip, pp, type, objfile)
621 struct field_info *fip;
622 struct objfile *objfile;
626 static struct complaint msg_unknown =
628 Unsupported token in stabs string %s.\n",
630 static struct complaint msg_notfound =
632 Unable to find base type for %s.\n",
637 struct nextfield *new;
639 if (**pp == ';') /* no base classes; return */
645 /* first count base classes so we can allocate space before parsing */
646 for (p = *pp; p && *p && *p != ';'; p++)
651 bnum++; /* add one more for last one */
653 /* now parse the base classes until we get to the start of the methods
654 (code extracted and munged from read_baseclasses) */
655 ALLOCATE_CPLUS_STRUCT_TYPE (type);
656 TYPE_N_BASECLASSES (type) = bnum;
660 int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
663 pointer = (char *) TYPE_ALLOC (type, num_bytes);
664 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
666 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
668 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
670 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
671 make_cleanup (free, new);
672 memset (new, 0, sizeof (struct nextfield));
673 new->next = fip->list;
675 FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
677 STABS_CONTINUE (pp, objfile);
679 /* virtual? eg: v2@Bvir */
682 SET_TYPE_FIELD_VIRTUAL (type, i);
686 /* access? eg: 2@Bvir */
687 /* Note: protected inheritance not supported in cfront */
690 case CFRONT_VISIBILITY_PRIVATE:
691 new->visibility = VISIBILITY_PRIVATE;
693 case CFRONT_VISIBILITY_PUBLIC:
694 new->visibility = VISIBILITY_PUBLIC;
697 /* Bad visibility format. Complain and treat it as
700 static struct complaint msg =
702 "Unknown visibility `%c' for baseclass", 0, 0};
703 complain (&msg, new->visibility);
704 new->visibility = VISIBILITY_PUBLIC;
708 /* "@" comes next - eg: @Bvir */
711 complain (&msg_unknown, *pp);
717 /* Set the bit offset of the portion of the object corresponding
718 to this baseclass. Always zero in the absence of
719 multiple inheritance. */
720 /* Unable to read bit position from stabs;
721 Assuming no multiple inheritance for now FIXME! */
722 /* We may have read this in the structure definition;
723 now we should fixup the members to be the actual base classes */
724 FIELD_BITPOS (new->field) = 0;
726 /* Get the base class name and type */
728 char *bname; /* base class name */
729 struct symbol *bsym; /* base class */
731 p1 = strchr (*pp, ' ');
732 p2 = strchr (*pp, ';');
734 bname = get_substring (pp, ' ');
736 bname = get_substring (pp, ';');
737 if (!bname || !*bname)
739 complain (&msg_unknown, *pp);
742 /* FIXME! attach base info to type */
743 bsym = lookup_symbol (bname, 0, STRUCT_NAMESPACE, 0, 0); /*demangled_name */
746 new->field.type = SYMBOL_TYPE (bsym);
747 new->field.name = type_name_no_tag (new->field.type);
751 complain (&msg_notfound, *pp);
756 /* If more base classes to parse, loop again.
757 We ate the last ' ' or ';' in get_substring,
758 so on exit we will have skipped the trailing ';' */
759 /* if invalid, return 0; add code to detect - FIXME! */
764 /* read cfront member functions.
765 pp points to string starting with list of functions
766 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
767 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
768 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
769 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
773 read_cfront_member_functions (fip, pp, type, objfile)
774 struct field_info *fip;
777 struct objfile *objfile;
779 /* This code extracted from read_member_functions
780 so as to do the similar thing for our funcs */
784 /* Total number of member functions defined in this class. If the class
785 defines two `f' functions, and one `g' function, then this will have
787 int total_length = 0;
791 struct next_fnfield *next;
792 struct fn_field fn_field;
795 struct type *look_ahead_type;
796 struct next_fnfieldlist *new_fnlist;
797 struct next_fnfield *new_sublist;
800 struct symbol *ref_func = 0;
802 /* Process each list until we find the end of the member functions.
803 eg: p = "__ct__1AFv foo__1AFv ;;;" */
805 STABS_CONTINUE (pp, objfile); /* handle \\ */
807 while (**pp != ';' && (fname = get_substring (pp, ' '), fname))
810 int sublist_count = 0;
812 if (fname[0] == '*') /* static member */
818 ref_func = lookup_symbol (fname, 0, VAR_NAMESPACE, 0, 0); /* demangled name */
821 static struct complaint msg =
823 Unable to find function symbol for %s\n",
825 complain (&msg, fname);
829 look_ahead_type = NULL;
832 new_fnlist = (struct next_fnfieldlist *)
833 xmalloc (sizeof (struct next_fnfieldlist));
834 make_cleanup (free, new_fnlist);
835 memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
837 /* The following is code to work around cfront generated stabs.
838 The stabs contains full mangled name for each field.
839 We try to demangle the name and extract the field name out of it. */
841 char *dem, *dem_p, *dem_args;
843 dem = cplus_demangle (fname, DMGL_ANSI | DMGL_PARAMS);
846 dem_p = strrchr (dem, ':');
847 if (dem_p != 0 && *(dem_p - 1) == ':')
849 /* get rid of args */
850 dem_args = strchr (dem_p, '(');
851 if (dem_args == NULL)
852 dem_len = strlen (dem_p);
854 dem_len = dem_args - dem_p;
856 obsavestring (dem_p, dem_len, &objfile->type_obstack);
861 obsavestring (fname, strlen (fname), &objfile->type_obstack);
863 } /* end of code for cfront work around */
865 new_fnlist->fn_fieldlist.name = main_fn_name;
867 /*-------------------------------------------------*/
868 /* Set up the sublists
869 Sublists are stuff like args, static, visibility, etc.
870 so in ARM, we have to set that info some other way.
871 Multiple sublists happen if overloading
872 eg: foo::26=##1;:;2A.;
873 In g++, we'd loop here thru all the sublists... */
876 (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
877 make_cleanup (free, new_sublist);
878 memset (new_sublist, 0, sizeof (struct next_fnfield));
880 /* eat 1; from :;2A.; */
881 new_sublist->fn_field.type = SYMBOL_TYPE (ref_func); /* normally takes a read_type */
882 /* Make this type look like a method stub for gdb */
883 TYPE_FLAGS (new_sublist->fn_field.type) |= TYPE_FLAG_STUB;
884 TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD;
886 /* If this is just a stub, then we don't have the real name here. */
887 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
889 if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
890 TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
891 new_sublist->fn_field.is_stub = 1;
894 /* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i
895 physname gets strcat'd in order to recreate the onto mangled name */
896 pname = get_cfront_method_physname (fname);
897 new_sublist->fn_field.physname = savestring (pname, strlen (pname));
900 /* Set this member function's visibility fields.
901 Unable to distinguish access from stabs definition!
902 Assuming public for now. FIXME!
903 (for private, set new_sublist->fn_field.is_private = 1,
904 for public, set new_sublist->fn_field.is_protected = 1) */
906 /* Unable to distinguish const/volatile from stabs definition!
907 Assuming normal for now. FIXME! */
909 new_sublist->fn_field.is_const = 0;
910 new_sublist->fn_field.is_volatile = 0; /* volatile not implemented in cfront */
912 /* Set virtual/static function info
913 How to get vtable offsets ?
914 Assuming normal for now FIXME!!
915 For vtables, figure out from whence this virtual function came.
916 It may belong to virtual function table of
917 one of its baseclasses.
919 new_sublist -> fn_field.voffset = vtable offset,
920 new_sublist -> fn_field.fcontext = look_ahead_type;
921 where look_ahead_type is type of baseclass */
923 new_sublist->fn_field.voffset = VOFFSET_STATIC;
924 else /* normal member function. */
925 new_sublist->fn_field.voffset = 0;
926 new_sublist->fn_field.fcontext = 0;
929 /* Prepare new sublist */
930 new_sublist->next = sublist;
931 sublist = new_sublist;
934 /* In g++, we loop thu sublists - now we set from functions. */
935 new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
936 obstack_alloc (&objfile->type_obstack,
937 sizeof (struct fn_field) * length);
938 memset (new_fnlist->fn_fieldlist.fn_fields, 0,
939 sizeof (struct fn_field) * length);
940 for (i = length; (i--, sublist); sublist = sublist->next)
942 new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
945 new_fnlist->fn_fieldlist.length = length;
946 new_fnlist->next = fip->fnlist;
947 fip->fnlist = new_fnlist;
949 total_length += length;
950 STABS_CONTINUE (pp, objfile); /* handle \\ */
955 /* type should already have space */
956 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
957 TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
958 memset (TYPE_FN_FIELDLISTS (type), 0,
959 sizeof (struct fn_fieldlist) * nfn_fields);
960 TYPE_NFN_FIELDS (type) = nfn_fields;
961 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
964 /* end of scope for reading member func */
968 /* Skip trailing ';' and bump count of number of fields seen */
976 /* This routine fixes up partial cfront types that were created
977 while parsing the stabs. The main need for this function is
978 to add information such as methods to classes.
979 Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */
981 resolve_cfront_continuation (objfile, sym, p)
982 struct objfile *objfile;
986 struct symbol *ref_sym = 0;
988 /* snarfed from read_struct_type */
989 struct field_info fi;
991 struct cleanup *back_to;
993 /* Need to make sure that fi isn't gunna conflict with struct
994 in case struct already had some fnfs */
997 back_to = make_cleanup (null_cleanup, 0);
999 /* We only accept structs, classes and unions at the moment.
1000 Other continuation types include t (typedef), r (long dbl), ...
1001 We may want to add support for them as well;
1002 right now they are handled by duplicating the symbol information
1003 into the type information (see define_symbol) */
1004 if (*p != 's' /* structs */
1005 && *p != 'c' /* class */
1006 && *p != 'u') /* union */
1007 return 0; /* only handle C++ types */
1010 /* Get symbol typs name and validate
1011 eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */
1012 sname = get_substring (&p, ';');
1013 if (!sname || strcmp (sname, SYMBOL_NAME (sym)))
1014 error ("Internal error: base symbol type name does not match\n");
1016 /* Find symbol's internal gdb reference using demangled_name.
1017 This is the real sym that we want;
1018 sym was a temp hack to make debugger happy */
1019 ref_sym = lookup_symbol (SYMBOL_NAME (sym), 0, STRUCT_NAMESPACE, 0, 0);
1020 type = SYMBOL_TYPE (ref_sym);
1023 /* Now read the baseclasses, if any, read the regular C struct or C++
1024 class member fields, attach the fields to the type, read the C++
1025 member functions, attach them to the type, and then read any tilde
1026 field (baseclass specifier for the class holding the main vtable). */
1028 if (!read_cfront_baseclasses (&fi, &p, type, objfile)
1029 /* g++ does this next, but cfront already did this:
1030 || !read_struct_fields (&fi, &p, type, objfile) */
1031 || !copy_cfront_struct_fields (&fi, type, objfile)
1032 || !read_cfront_member_functions (&fi, &p, type, objfile)
1033 || !read_cfront_static_fields (&fi, &p, type, objfile)
1034 || !attach_fields_to_type (&fi, type, objfile)
1035 || !attach_fn_fields_to_type (&fi, type)
1036 /* g++ does this next, but cfront doesn't seem to have this:
1037 || !read_tilde_fields (&fi, &p, type, objfile) */
1040 type = error_type (&p, objfile);
1043 do_cleanups (back_to);
1046 /* End of code added to support parsing of ARM/Cfront stabs strings */
1049 /* This routine fixes up symbol references/aliases to point to the original
1050 symbol definition. Returns 0 on failure, non-zero on success. */
1053 resolve_symbol_reference (objfile, sym, p)
1054 struct objfile *objfile;
1059 struct symbol *ref_sym = 0;
1060 struct alias_list *alias;
1062 /* If this is not a symbol reference return now. */
1066 /* Use "#<num>" as the name; we'll fix the name later.
1067 We stored the original symbol name as "#<id>=<name>"
1068 so we can now search for "#<id>" to resolving the reference.
1069 We'll fix the names later by removing the "#<id>" or "#<id>=" */
1071 /*---------------------------------------------------------*/
1072 /* Get the reference id number, and
1073 advance p past the names so we can parse the rest.
1074 eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */
1075 /*---------------------------------------------------------*/
1077 /* This gets reference name from string. sym may not have a name. */
1079 /* Get the reference number associated with the reference id in the
1080 gdb stab string. From that reference number, get the main/primary
1081 symbol for this alias. */
1082 refnum = process_reference (&p);
1083 ref_sym = ref_search (refnum);
1086 complain (&lrs_general_complaint, "symbol for reference not found");
1090 /* Parse the stab of the referencing symbol
1091 now that we have the referenced symbol.
1092 Add it as a new symbol and a link back to the referenced symbol.
1093 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1096 /* If the stab symbol table and string contain:
1097 RSYM 0 5 00000000 868 #15=z:r(0,1)
1098 LBRAC 0 0 00000000 899 #5=
1099 SLINE 0 16 00000003 923 #6=
1100 Then the same symbols can be later referenced by:
1101 RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6)
1102 This is used in live range splitting to:
1103 1) specify that a symbol (#15) is actually just a new storage
1104 class for a symbol (#15=z) which was previously defined.
1105 2) specify that the beginning and ending ranges for a symbol
1106 (#15) are the values of the beginning (#5) and ending (#6)
1109 /* Read number as reference id.
1110 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1111 /* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
1112 in case of "l(0,0)"? */
1114 /*--------------------------------------------------*/
1115 /* Add this symbol to the reference list. */
1116 /*--------------------------------------------------*/
1118 alias = (struct alias_list *) obstack_alloc (&objfile->type_obstack,
1119 sizeof (struct alias_list));
1122 complain (&lrs_general_complaint, "Unable to allocate alias list memory");
1129 if (!SYMBOL_ALIASES (ref_sym))
1131 SYMBOL_ALIASES (ref_sym) = alias;
1135 struct alias_list *temp;
1137 /* Get to the end of the list. */
1138 for (temp = SYMBOL_ALIASES (ref_sym);
1145 /* Want to fix up name so that other functions (eg. valops)
1146 will correctly print the name.
1147 Don't add_symbol_to_list so that lookup_symbol won't find it.
1148 nope... needed for fixups. */
1149 SYMBOL_NAME (sym) = SYMBOL_NAME (ref_sym);
1155 /* Structure for storing pointers to reference definitions for fast lookup
1156 during "process_later". */
1165 #define MAX_CHUNK_REFS 100
1166 #define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map))
1167 #define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE)
1169 static struct ref_map *ref_map;
1171 /* Ptr to free cell in chunk's linked list. */
1172 static int ref_count = 0;
1174 /* Number of chunks malloced. */
1175 static int ref_chunk = 0;
1177 /* This file maintains a cache of stabs aliases found in the symbol
1178 table. If the symbol table changes, this cache must be cleared
1179 or we are left holding onto data in invalid obstacks. */
1181 stabsread_clear_cache ()
1187 /* Create array of pointers mapping refids to symbols and stab strings.
1188 Add pointers to reference definition symbols and/or their values as we
1189 find them, using their reference numbers as our index.
1190 These will be used later when we resolve references. */
1192 ref_add (refnum, sym, stabs, value)
1200 if (refnum >= ref_count)
1201 ref_count = refnum + 1;
1202 if (ref_count > ref_chunk * MAX_CHUNK_REFS)
1204 int new_slots = ref_count - ref_chunk * MAX_CHUNK_REFS;
1205 int new_chunks = new_slots / MAX_CHUNK_REFS + 1;
1206 ref_map = (struct ref_map *)
1207 xrealloc (ref_map, REF_MAP_SIZE (ref_chunk + new_chunks));
1208 memset (ref_map + ref_chunk * MAX_CHUNK_REFS, 0, new_chunks * REF_CHUNK_SIZE);
1209 ref_chunk += new_chunks;
1211 ref_map[refnum].stabs = stabs;
1212 ref_map[refnum].sym = sym;
1213 ref_map[refnum].value = value;
1216 /* Return defined sym for the reference REFNUM. */
1221 if (refnum < 0 || refnum > ref_count)
1223 return ref_map[refnum].sym;
1226 /* Return value for the reference REFNUM. */
1229 ref_search_value (refnum)
1232 if (refnum < 0 || refnum > ref_count)
1234 return ref_map[refnum].value;
1237 /* Parse a reference id in STRING and return the resulting
1238 reference number. Move STRING beyond the reference id. */
1241 process_reference (string)
1247 if (**string != '#')
1250 /* Advance beyond the initial '#'. */
1253 /* Read number as reference id. */
1254 while (*p && isdigit (*p))
1256 refnum = refnum * 10 + *p - '0';
1263 /* If STRING defines a reference, store away a pointer to the reference
1264 definition for later use. Return the reference number. */
1267 symbol_reference_defined (string)
1273 refnum = process_reference (&p);
1275 /* Defining symbols end in '=' */
1278 /* Symbol is being defined here. */
1284 /* Must be a reference. Either the symbol has already been defined,
1285 or this is a forward reference to it. */
1293 define_symbol (valu, string, desc, type, objfile)
1298 struct objfile *objfile;
1300 register struct symbol *sym;
1301 char *p = (char *) strchr (string, ':');
1306 /* We would like to eliminate nameless symbols, but keep their types.
1307 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1308 to type 2, but, should not create a symbol to address that type. Since
1309 the symbol will be nameless, there is no way any user can refer to it. */
1313 /* Ignore syms with empty names. */
1317 /* Ignore old-style symbols from cc -go */
1324 p = strchr (p, ':');
1327 /* If a nameless stab entry, all we need is the type, not the symbol.
1328 e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
1329 nameless = (p == string || ((string[0] == ' ') && (string[1] == ':')));
1331 current_symbol = sym = (struct symbol *)
1332 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
1333 memset (sym, 0, sizeof (struct symbol));
1335 switch (type & N_TYPE)
1338 SYMBOL_SECTION (sym) = SECT_OFF_TEXT (objfile);
1341 SYMBOL_SECTION (sym) = SECT_OFF_DATA (objfile);
1344 SYMBOL_SECTION (sym) = SECT_OFF_BSS (objfile);
1348 if (processing_gcc_compilation)
1350 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1351 number of bytes occupied by a type or object, which we ignore. */
1352 SYMBOL_LINE (sym) = desc;
1356 SYMBOL_LINE (sym) = 0; /* unknown */
1359 if (is_cplus_marker (string[0]))
1361 /* Special GNU C++ names. */
1365 SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
1366 &objfile->symbol_obstack);
1369 case 'v': /* $vtbl_ptr_type */
1370 /* Was: SYMBOL_NAME (sym) = "vptr"; */
1374 SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"),
1375 &objfile->symbol_obstack);
1379 /* This was an anonymous type that was never fixed up. */
1382 #ifdef STATIC_TRANSFORM_NAME
1384 /* SunPRO (3.0 at least) static variable encoding. */
1389 complain (&unrecognized_cplus_name_complaint, string);
1390 goto normal; /* Do *something* with it */
1393 else if (string[0] == '#')
1395 /* Special GNU C extension for referencing symbols. */
1399 /* If STRING defines a new reference id, then add it to the
1400 reference map. Else it must be referring to a previously
1401 defined symbol, so add it to the alias list of the previously
1404 refnum = symbol_reference_defined (&s);
1406 ref_add (refnum, sym, string, SYMBOL_VALUE (sym));
1407 else if (!resolve_symbol_reference (objfile, sym, string))
1410 /* S..P contains the name of the symbol. We need to store
1411 the correct name into SYMBOL_NAME. */
1417 SYMBOL_NAME (sym) = (char *)
1418 obstack_alloc (&objfile->symbol_obstack, nlen);
1419 strncpy (SYMBOL_NAME (sym), s, nlen);
1420 SYMBOL_NAME (sym)[nlen] = '\0';
1421 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1424 /* FIXME! Want SYMBOL_NAME (sym) = 0;
1425 Get error if leave name 0. So give it something. */
1428 SYMBOL_NAME (sym) = (char *)
1429 obstack_alloc (&objfile->symbol_obstack, nlen);
1430 strncpy (SYMBOL_NAME (sym), string, nlen);
1431 SYMBOL_NAME (sym)[nlen] = '\0';
1432 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1435 /* Advance STRING beyond the reference id. */
1441 SYMBOL_LANGUAGE (sym) = current_subfile->language;
1442 SYMBOL_NAME (sym) = (char *)
1443 obstack_alloc (&objfile->symbol_obstack, ((p - string) + 1));
1444 /* Open-coded memcpy--saves function call time. */
1445 /* FIXME: Does it really? Try replacing with simple strcpy and
1446 try it on an executable with a large symbol table. */
1447 /* FIXME: considering that gcc can open code memcpy anyway, I
1448 doubt it. xoxorich. */
1450 register char *p1 = string;
1451 register char *p2 = SYMBOL_NAME (sym);
1459 /* If this symbol is from a C++ compilation, then attempt to cache the
1460 demangled form for future reference. This is a typical time versus
1461 space tradeoff, that was decided in favor of time because it sped up
1462 C++ symbol lookups by a factor of about 20. */
1464 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1468 /* Determine the type of name being defined. */
1470 /* Getting GDB to correctly skip the symbol on an undefined symbol
1471 descriptor and not ever dump core is a very dodgy proposition if
1472 we do things this way. I say the acorn RISC machine can just
1473 fix their compiler. */
1474 /* The Acorn RISC machine's compiler can put out locals that don't
1475 start with "234=" or "(3,4)=", so assume anything other than the
1476 deftypes we know how to handle is a local. */
1477 if (!strchr ("cfFGpPrStTvVXCR", *p))
1479 if (isdigit (*p) || *p == '(' || *p == '-')
1488 /* c is a special case, not followed by a type-number.
1489 SYMBOL:c=iVALUE for an integer constant symbol.
1490 SYMBOL:c=rVALUE for a floating constant symbol.
1491 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1492 e.g. "b:c=e6,0" for "const b = blob1"
1493 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1496 SYMBOL_CLASS (sym) = LOC_CONST;
1497 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1498 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1499 add_symbol_to_list (sym, &file_symbols);
1507 double d = atof (p);
1510 /* FIXME-if-picky-about-floating-accuracy: Should be using
1511 target arithmetic to get the value. real.c in GCC
1512 probably has the necessary code. */
1514 /* FIXME: lookup_fundamental_type is a hack. We should be
1515 creating a type especially for the type of float constants.
1516 Problem is, what type should it be?
1518 Also, what should the name of this type be? Should we
1519 be using 'S' constants (see stabs.texinfo) instead? */
1521 SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
1524 obstack_alloc (&objfile->symbol_obstack,
1525 TYPE_LENGTH (SYMBOL_TYPE (sym)));
1526 store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)), d);
1527 SYMBOL_VALUE_BYTES (sym) = dbl_valu;
1528 SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
1533 /* Defining integer constants this way is kind of silly,
1534 since 'e' constants allows the compiler to give not
1535 only the value, but the type as well. C has at least
1536 int, long, unsigned int, and long long as constant
1537 types; other languages probably should have at least
1538 unsigned as well as signed constants. */
1540 /* We just need one int constant type for all objfiles.
1541 It doesn't depend on languages or anything (arguably its
1542 name should be a language-specific name for a type of
1543 that size, but I'm inclined to say that if the compiler
1544 wants a nice name for the type, it can use 'e'). */
1545 static struct type *int_const_type;
1547 /* Yes, this is as long as a *host* int. That is because we
1549 if (int_const_type == NULL)
1551 init_type (TYPE_CODE_INT,
1552 sizeof (int) * HOST_CHAR_BIT / TARGET_CHAR_BIT, 0,
1554 (struct objfile *) NULL);
1555 SYMBOL_TYPE (sym) = int_const_type;
1556 SYMBOL_VALUE (sym) = atoi (p);
1557 SYMBOL_CLASS (sym) = LOC_CONST;
1561 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
1562 can be represented as integral.
1563 e.g. "b:c=e6,0" for "const b = blob1"
1564 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1566 SYMBOL_CLASS (sym) = LOC_CONST;
1567 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1571 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1576 /* If the value is too big to fit in an int (perhaps because
1577 it is unsigned), or something like that, we silently get
1578 a bogus value. The type and everything else about it is
1579 correct. Ideally, we should be using whatever we have
1580 available for parsing unsigned and long long values,
1582 SYMBOL_VALUE (sym) = atoi (p);
1587 SYMBOL_CLASS (sym) = LOC_CONST;
1588 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1591 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1592 add_symbol_to_list (sym, &file_symbols);
1596 /* The name of a caught exception. */
1597 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1598 SYMBOL_CLASS (sym) = LOC_LABEL;
1599 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1600 SYMBOL_VALUE_ADDRESS (sym) = valu;
1601 add_symbol_to_list (sym, &local_symbols);
1605 /* A static function definition. */
1606 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1607 SYMBOL_CLASS (sym) = LOC_BLOCK;
1608 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1609 add_symbol_to_list (sym, &file_symbols);
1610 /* fall into process_function_types. */
1612 process_function_types:
1613 /* Function result types are described as the result type in stabs.
1614 We need to convert this to the function-returning-type-X type
1615 in GDB. E.g. "int" is converted to "function returning int". */
1616 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
1617 SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
1619 /* All functions in C++ have prototypes. */
1620 if (SYMBOL_LANGUAGE (sym) == language_cplus)
1621 TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED;
1623 /* fall into process_prototype_types */
1625 process_prototype_types:
1626 /* Sun acc puts declared types of arguments here. */
1629 struct type *ftype = SYMBOL_TYPE (sym);
1634 /* Obtain a worst case guess for the number of arguments
1635 by counting the semicolons. */
1642 /* Allocate parameter information fields and fill them in. */
1643 TYPE_FIELDS (ftype) = (struct field *)
1644 TYPE_ALLOC (ftype, nsemi * sizeof (struct field));
1649 /* A type number of zero indicates the start of varargs.
1650 FIXME: GDB currently ignores vararg functions. */
1651 if (p[0] == '0' && p[1] == '\0')
1653 ptype = read_type (&p, objfile);
1655 /* The Sun compilers mark integer arguments, which should
1656 be promoted to the width of the calling conventions, with
1657 a type which references itself. This type is turned into
1658 a TYPE_CODE_VOID type by read_type, and we have to turn
1659 it back into builtin_type_int here.
1660 FIXME: Do we need a new builtin_type_promoted_int_arg ? */
1661 if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
1662 ptype = builtin_type_int;
1663 TYPE_FIELD_TYPE (ftype, nparams++) = ptype;
1665 TYPE_NFIELDS (ftype) = nparams;
1666 TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
1671 /* A global function definition. */
1672 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1673 SYMBOL_CLASS (sym) = LOC_BLOCK;
1674 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1675 add_symbol_to_list (sym, &global_symbols);
1676 goto process_function_types;
1679 /* For a class G (global) symbol, it appears that the
1680 value is not correct. It is necessary to search for the
1681 corresponding linker definition to find the value.
1682 These definitions appear at the end of the namelist. */
1683 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1684 SYMBOL_CLASS (sym) = LOC_STATIC;
1685 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1686 /* Don't add symbol references to global_sym_chain.
1687 Symbol references don't have valid names and wont't match up with
1688 minimal symbols when the global_sym_chain is relocated.
1689 We'll fixup symbol references when we fixup the defining symbol. */
1690 if (SYMBOL_NAME (sym) && SYMBOL_NAME (sym)[0] != '#')
1692 i = hashname (SYMBOL_NAME (sym));
1693 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
1694 global_sym_chain[i] = sym;
1696 add_symbol_to_list (sym, &global_symbols);
1699 /* This case is faked by a conditional above,
1700 when there is no code letter in the dbx data.
1701 Dbx data never actually contains 'l'. */
1704 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1705 SYMBOL_CLASS (sym) = LOC_LOCAL;
1706 SYMBOL_VALUE (sym) = valu;
1707 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1708 add_symbol_to_list (sym, &local_symbols);
1713 /* pF is a two-letter code that means a function parameter in Fortran.
1714 The type-number specifies the type of the return value.
1715 Translate it into a pointer-to-function type. */
1719 = lookup_pointer_type
1720 (lookup_function_type (read_type (&p, objfile)));
1723 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1725 /* Normally this is a parameter, a LOC_ARG. On the i960, it
1726 can also be a LOC_LOCAL_ARG depending on symbol type. */
1727 #ifndef DBX_PARM_SYMBOL_CLASS
1728 #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
1731 SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
1732 SYMBOL_VALUE (sym) = valu;
1733 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1734 add_symbol_to_list (sym, &local_symbols);
1736 if (TARGET_BYTE_ORDER != BIG_ENDIAN)
1738 /* On little-endian machines, this crud is never necessary,
1739 and, if the extra bytes contain garbage, is harmful. */
1743 /* If it's gcc-compiled, if it says `short', believe it. */
1744 if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
1747 if (!BELIEVE_PCC_PROMOTION)
1749 /* This is the signed type which arguments get promoted to. */
1750 static struct type *pcc_promotion_type;
1751 /* This is the unsigned type which arguments get promoted to. */
1752 static struct type *pcc_unsigned_promotion_type;
1754 /* Call it "int" because this is mainly C lossage. */
1755 if (pcc_promotion_type == NULL)
1756 pcc_promotion_type =
1757 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1760 if (pcc_unsigned_promotion_type == NULL)
1761 pcc_unsigned_promotion_type =
1762 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1763 TYPE_FLAG_UNSIGNED, "unsigned int", NULL);
1765 if (BELIEVE_PCC_PROMOTION_TYPE)
1767 /* This is defined on machines (e.g. sparc) where we
1768 should believe the type of a PCC 'short' argument,
1769 but shouldn't believe the address (the address is the
1770 address of the corresponding int).
1772 My guess is that this correction, as opposed to
1773 changing the parameter to an 'int' (as done below,
1774 for PCC on most machines), is the right thing to do
1775 on all machines, but I don't want to risk breaking
1776 something that already works. On most PCC machines,
1777 the sparc problem doesn't come up because the calling
1778 function has to zero the top bytes (not knowing
1779 whether the called function wants an int or a short),
1780 so there is little practical difference between an
1781 int and a short (except perhaps what happens when the
1782 GDB user types "print short_arg = 0x10000;").
1785 compiler actually produces the correct address (we
1786 don't need to fix it up). I made this code adapt so
1787 that it will offset the symbol if it was pointing at
1788 an int-aligned location and not otherwise. This way
1789 you can use the same gdb for 4.0.x and 4.1 systems.
1791 If the parameter is shorter than an int, and is
1792 integral (e.g. char, short, or unsigned equivalent),
1793 and is claimed to be passed on an integer boundary,
1794 don't believe it! Offset the parameter's address to
1795 the tail-end of that integer. */
1797 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
1798 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT
1799 && 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (pcc_promotion_type))
1801 SYMBOL_VALUE (sym) += TYPE_LENGTH (pcc_promotion_type)
1802 - TYPE_LENGTH (SYMBOL_TYPE (sym));
1808 /* If PCC says a parameter is a short or a char,
1809 it is really an int. */
1810 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
1811 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
1814 TYPE_UNSIGNED (SYMBOL_TYPE (sym))
1815 ? pcc_unsigned_promotion_type
1816 : pcc_promotion_type;
1823 /* acc seems to use P to declare the prototypes of functions that
1824 are referenced by this file. gdb is not prepared to deal
1825 with this extra information. FIXME, it ought to. */
1828 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1829 goto process_prototype_types;
1834 /* Parameter which is in a register. */
1835 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1836 SYMBOL_CLASS (sym) = LOC_REGPARM;
1837 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1838 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1840 complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
1841 SYMBOL_SOURCE_NAME (sym));
1842 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1844 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1845 add_symbol_to_list (sym, &local_symbols);
1849 /* Register variable (either global or local). */
1850 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1851 SYMBOL_CLASS (sym) = LOC_REGISTER;
1852 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1853 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1855 complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
1856 SYMBOL_SOURCE_NAME (sym));
1857 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1859 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1860 if (within_function)
1862 /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
1863 name to represent an argument passed in a register.
1864 GCC uses 'P' for the same case. So if we find such a symbol pair
1865 we combine it into one 'P' symbol. For Sun cc we need to do this
1866 regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
1867 the 'p' symbol even if it never saves the argument onto the stack.
1869 On most machines, we want to preserve both symbols, so that
1870 we can still get information about what is going on with the
1871 stack (VAX for computing args_printed, using stack slots instead
1872 of saved registers in backtraces, etc.).
1874 Note that this code illegally combines
1875 main(argc) struct foo argc; { register struct foo argc; }
1876 but this case is considered pathological and causes a warning
1877 from a decent compiler. */
1880 && local_symbols->nsyms > 0
1881 #ifndef USE_REGISTER_NOT_ARG
1882 && REG_STRUCT_HAS_ADDR_P ()
1883 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
1885 && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1886 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION
1887 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET
1888 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
1892 struct symbol *prev_sym;
1893 prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
1894 if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
1895 || SYMBOL_CLASS (prev_sym) == LOC_ARG)
1896 && STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME (sym)))
1898 SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
1899 /* Use the type from the LOC_REGISTER; that is the type
1900 that is actually in that register. */
1901 SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
1902 SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym);
1907 add_symbol_to_list (sym, &local_symbols);
1910 add_symbol_to_list (sym, &file_symbols);
1914 /* Static symbol at top level of file */
1915 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1916 SYMBOL_CLASS (sym) = LOC_STATIC;
1917 SYMBOL_VALUE_ADDRESS (sym) = valu;
1918 #ifdef STATIC_TRANSFORM_NAME
1919 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
1921 struct minimal_symbol *msym;
1922 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
1925 SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
1926 SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
1930 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1931 add_symbol_to_list (sym, &file_symbols);
1935 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1937 /* For a nameless type, we don't want a create a symbol, thus we
1938 did not use `sym'. Return without further processing. */
1942 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1943 SYMBOL_VALUE (sym) = valu;
1944 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1945 /* C++ vagaries: we may have a type which is derived from
1946 a base type which did not have its name defined when the
1947 derived class was output. We fill in the derived class's
1948 base part member's name here in that case. */
1949 if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL)
1950 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1951 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
1952 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
1955 for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
1956 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
1957 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
1958 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
1961 if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
1963 /* gcc-2.6 or later (when using -fvtable-thunks)
1964 emits a unique named type for a vtable entry.
1965 Some gdb code depends on that specific name. */
1966 extern const char vtbl_ptr_name[];
1968 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
1969 && strcmp (SYMBOL_NAME (sym), vtbl_ptr_name))
1970 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC)
1972 /* If we are giving a name to a type such as "pointer to
1973 foo" or "function returning foo", we better not set
1974 the TYPE_NAME. If the program contains "typedef char
1975 *caddr_t;", we don't want all variables of type char
1976 * to print as caddr_t. This is not just a
1977 consequence of GDB's type management; PCC and GCC (at
1978 least through version 2.4) both output variables of
1979 either type char * or caddr_t with the type number
1980 defined in the 't' symbol for caddr_t. If a future
1981 compiler cleans this up it GDB is not ready for it
1982 yet, but if it becomes ready we somehow need to
1983 disable this check (without breaking the PCC/GCC2.4
1988 Fortunately, this check seems not to be necessary
1989 for anything except pointers or functions. */
1992 TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_NAME (sym);
1995 add_symbol_to_list (sym, &file_symbols);
1999 /* Struct, union, or enum tag. For GNU C++, this can be be followed
2000 by 't' which means we are typedef'ing it as well. */
2001 synonym = *p == 't';
2005 /* The semantics of C++ state that "struct foo { ... }" also defines
2006 a typedef for "foo". Unfortunately, cfront never makes the typedef
2007 when translating C++ into C. We make the typedef here so that
2008 "ptype foo" works as expected for cfront translated code. */
2009 else if (current_subfile->language == language_cplus)
2012 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2014 /* For a nameless type, we don't want a create a symbol, thus we
2015 did not use `sym'. Return without further processing. */
2019 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
2020 SYMBOL_VALUE (sym) = valu;
2021 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
2022 if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
2023 TYPE_TAG_NAME (SYMBOL_TYPE (sym))
2024 = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
2025 add_symbol_to_list (sym, &file_symbols);
2029 /* Clone the sym and then modify it. */
2030 register struct symbol *typedef_sym = (struct symbol *)
2031 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
2032 *typedef_sym = *sym;
2033 SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
2034 SYMBOL_VALUE (typedef_sym) = valu;
2035 SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
2036 if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
2037 TYPE_NAME (SYMBOL_TYPE (sym))
2038 = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
2039 add_symbol_to_list (typedef_sym, &file_symbols);
2044 /* Static symbol of local scope */
2045 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2046 SYMBOL_CLASS (sym) = LOC_STATIC;
2047 SYMBOL_VALUE_ADDRESS (sym) = valu;
2048 #ifdef STATIC_TRANSFORM_NAME
2049 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
2051 struct minimal_symbol *msym;
2052 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
2055 SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
2056 SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
2060 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2062 add_symbol_to_list (sym, &global_symbols);
2064 add_symbol_to_list (sym, &local_symbols);
2068 /* Reference parameter */
2069 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2070 SYMBOL_CLASS (sym) = LOC_REF_ARG;
2071 SYMBOL_VALUE (sym) = valu;
2072 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2073 add_symbol_to_list (sym, &local_symbols);
2077 /* Reference parameter which is in a register. */
2078 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2079 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
2080 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
2081 if (SYMBOL_VALUE (sym) >= NUM_REGS)
2083 complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
2084 SYMBOL_SOURCE_NAME (sym));
2085 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
2087 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2088 add_symbol_to_list (sym, &local_symbols);
2092 /* This is used by Sun FORTRAN for "function result value".
2093 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
2094 that Pascal uses it too, but when I tried it Pascal used
2095 "x:3" (local symbol) instead. */
2096 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2097 SYMBOL_CLASS (sym) = LOC_LOCAL;
2098 SYMBOL_VALUE (sym) = valu;
2099 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2100 add_symbol_to_list (sym, &local_symbols);
2103 /* New code added to support cfront stabs strings.
2104 Note: case 'P' already handled above */
2106 /* Cfront type continuation coming up!
2107 Find the original definition and add to it.
2108 We'll have to do this for the typedef too,
2109 since we cloned the symbol to define a type in read_type.
2110 Stabs info examples:
2112 foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24))
2113 C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;;
2114 where C is the name of the class.
2115 Unfortunately, we can't lookup the original symbol yet 'cuz
2116 we haven't finished reading all the symbols.
2117 Instead, we save it for processing later */
2118 process_later (sym, p, resolve_cfront_continuation);
2119 SYMBOL_TYPE (sym) = error_type (&p, objfile); /* FIXME! change later */
2120 SYMBOL_CLASS (sym) = LOC_CONST;
2121 SYMBOL_VALUE (sym) = 0;
2122 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2123 /* Don't add to list - we'll delete it later when
2124 we add the continuation to the real sym */
2126 /* End of new code added to support cfront stabs strings */
2129 SYMBOL_TYPE (sym) = error_type (&p, objfile);
2130 SYMBOL_CLASS (sym) = LOC_CONST;
2131 SYMBOL_VALUE (sym) = 0;
2132 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2133 add_symbol_to_list (sym, &file_symbols);
2137 /* When passing structures to a function, some systems sometimes pass
2138 the address in a register, not the structure itself. */
2140 if (REG_STRUCT_HAS_ADDR_P ()
2141 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
2142 && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
2144 struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
2146 if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
2147 || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
2148 || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
2149 || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
2151 /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
2152 LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
2153 if (SYMBOL_CLASS (sym) == LOC_REGPARM)
2154 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
2155 /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
2156 and subsequent arguments on the sparc, for example). */
2157 else if (SYMBOL_CLASS (sym) == LOC_ARG)
2158 SYMBOL_CLASS (sym) = LOC_REF_ARG;
2162 /* Is there more to parse? For example LRS/alias information? */
2163 while (*p && *p == ';')
2166 if (*p && p[0] == 'l' && p[1] == '(')
2168 /* GNU extensions for live range splitting may be appended to
2169 the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */
2171 /* Resolve the live range and add it to SYM's live range list. */
2172 if (!resolve_live_range (objfile, sym, p))
2175 /* Find end of live range info. */
2176 p = strchr (p, ')');
2177 if (!*p || *p != ')')
2179 complain (&lrs_general_complaint, "live range format not recognized");
2188 /* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns
2189 non-zero on success, zero otherwise. */
2192 resolve_live_range (objfile, sym, p)
2193 struct objfile *objfile;
2198 CORE_ADDR start, end;
2200 /* Sanity check the beginning of the stabs string. */
2201 if (!*p || *p != 'l')
2203 complain (&lrs_general_complaint, "live range string 1");
2208 if (!*p || *p != '(')
2210 complain (&lrs_general_complaint, "live range string 2");
2215 /* Get starting value of range and advance P past the reference id.
2217 ?!? In theory, the process_reference should never fail, but we should
2218 catch that case just in case the compiler scrogged the stabs. */
2219 refnum = process_reference (&p);
2220 start = ref_search_value (refnum);
2223 complain (&lrs_general_complaint, "Live range symbol not found 1");
2227 if (!*p || *p != ',')
2229 complain (&lrs_general_complaint, "live range string 3");
2234 /* Get ending value of range and advance P past the reference id.
2236 ?!? In theory, the process_reference should never fail, but we should
2237 catch that case just in case the compiler scrogged the stabs. */
2238 refnum = process_reference (&p);
2239 end = ref_search_value (refnum);
2242 complain (&lrs_general_complaint, "Live range symbol not found 2");
2246 if (!*p || *p != ')')
2248 complain (&lrs_general_complaint, "live range string 4");
2252 /* Now that we know the bounds of the range, add it to the
2254 add_live_range (objfile, sym, start, end);
2259 /* Add a new live range defined by START and END to the symbol SYM
2260 in objfile OBJFILE. */
2263 add_live_range (objfile, sym, start, end)
2264 struct objfile *objfile;
2266 CORE_ADDR start, end;
2268 struct range_list *r, *rs;
2272 complain (&lrs_general_complaint, "end of live range follows start");
2276 /* Alloc new live range structure. */
2277 r = (struct range_list *)
2278 obstack_alloc (&objfile->type_obstack,
2279 sizeof (struct range_list));
2284 /* Append this range to the symbol's range list. */
2285 if (!SYMBOL_RANGES (sym))
2286 SYMBOL_RANGES (sym) = r;
2289 /* Get the last range for the symbol. */
2290 for (rs = SYMBOL_RANGES (sym); rs->next; rs = rs->next)
2297 /* Skip rest of this symbol and return an error type.
2299 General notes on error recovery: error_type always skips to the
2300 end of the symbol (modulo cretinous dbx symbol name continuation).
2301 Thus code like this:
2303 if (*(*pp)++ != ';')
2304 return error_type (pp, objfile);
2306 is wrong because if *pp starts out pointing at '\0' (typically as the
2307 result of an earlier error), it will be incremented to point to the
2308 start of the next symbol, which might produce strange results, at least
2309 if you run off the end of the string table. Instead use
2312 return error_type (pp, objfile);
2318 foo = error_type (pp, objfile);
2322 And in case it isn't obvious, the point of all this hair is so the compiler
2323 can define new types and new syntaxes, and old versions of the
2324 debugger will be able to read the new symbol tables. */
2326 static struct type *
2327 error_type (pp, objfile)
2329 struct objfile *objfile;
2331 complain (&error_type_complaint);
2334 /* Skip to end of symbol. */
2335 while (**pp != '\0')
2340 /* Check for and handle cretinous dbx symbol name continuation! */
2341 if ((*pp)[-1] == '\\' || (*pp)[-1] == '?')
2343 *pp = next_symbol_text (objfile);
2350 return (builtin_type_error);
2354 /* Read type information or a type definition; return the type. Even
2355 though this routine accepts either type information or a type
2356 definition, the distinction is relevant--some parts of stabsread.c
2357 assume that type information starts with a digit, '-', or '(' in
2358 deciding whether to call read_type. */
2361 read_type (pp, objfile)
2363 struct objfile *objfile;
2365 register struct type *type = 0;
2368 char type_descriptor;
2370 /* Size in bits of type if specified by a type attribute, or -1 if
2371 there is no size attribute. */
2374 /* Used to distinguish string and bitstring from char-array and set. */
2377 /* Read type number if present. The type number may be omitted.
2378 for instance in a two-dimensional array declared with type
2379 "ar1;1;10;ar1;1;10;4". */
2380 if ((**pp >= '0' && **pp <= '9')
2384 if (read_type_number (pp, typenums) != 0)
2385 return error_type (pp, objfile);
2387 /* Type is not being defined here. Either it already exists,
2388 or this is a forward reference to it. dbx_alloc_type handles
2391 return dbx_alloc_type (typenums, objfile);
2393 /* Type is being defined here. */
2395 Also skip the type descriptor - we get it below with (*pp)[-1]. */
2400 /* 'typenums=' not present, type is anonymous. Read and return
2401 the definition, but don't put it in the type vector. */
2402 typenums[0] = typenums[1] = -1;
2407 type_descriptor = (*pp)[-1];
2408 switch (type_descriptor)
2412 enum type_code code;
2414 /* Used to index through file_symbols. */
2415 struct pending *ppt;
2418 /* Name including "struct", etc. */
2422 char *from, *to, *p, *q1, *q2;
2424 /* Set the type code according to the following letter. */
2428 code = TYPE_CODE_STRUCT;
2431 code = TYPE_CODE_UNION;
2434 code = TYPE_CODE_ENUM;
2438 /* Complain and keep going, so compilers can invent new
2439 cross-reference types. */
2440 static struct complaint msg =
2441 {"Unrecognized cross-reference type `%c'", 0, 0};
2442 complain (&msg, (*pp)[0]);
2443 code = TYPE_CODE_STRUCT;
2448 q1 = strchr (*pp, '<');
2449 p = strchr (*pp, ':');
2451 return error_type (pp, objfile);
2452 if (q1 && p > q1 && p[1] == ':')
2454 int nesting_level = 0;
2455 for (q2 = q1; *q2; q2++)
2459 else if (*q2 == '>')
2461 else if (*q2 == ':' && nesting_level == 0)
2466 return error_type (pp, objfile);
2469 (char *) obstack_alloc (&objfile->type_obstack, p - *pp + 1);
2471 /* Copy the name. */
2477 /* Set the pointer ahead of the name which we just read, and
2482 /* Now check to see whether the type has already been
2483 declared. This was written for arrays of cross-referenced
2484 types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty
2485 sure it is not necessary anymore. But it might be a good
2486 idea, to save a little memory. */
2488 for (ppt = file_symbols; ppt; ppt = ppt->next)
2489 for (i = 0; i < ppt->nsyms; i++)
2491 struct symbol *sym = ppt->symbol[i];
2493 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
2494 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
2495 && (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
2496 && STREQ (SYMBOL_NAME (sym), type_name))
2498 obstack_free (&objfile->type_obstack, type_name);
2499 type = SYMBOL_TYPE (sym);
2504 /* Didn't find the type to which this refers, so we must
2505 be dealing with a forward reference. Allocate a type
2506 structure for it, and keep track of it so we can
2507 fill in the rest of the fields when we get the full
2509 type = dbx_alloc_type (typenums, objfile);
2510 TYPE_CODE (type) = code;
2511 TYPE_TAG_NAME (type) = type_name;
2512 INIT_CPLUS_SPECIFIC (type);
2513 TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
2515 add_undefined_type (type);
2519 case '-': /* RS/6000 built-in type */
2533 /* We deal with something like t(1,2)=(3,4)=... which
2534 the Lucid compiler and recent gcc versions (post 2.7.3) use. */
2536 /* Allocate and enter the typedef type first.
2537 This handles recursive types. */
2538 type = dbx_alloc_type (typenums, objfile);
2539 TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
2541 struct type *xtype = read_type (pp, objfile);
2544 /* It's being defined as itself. That means it is "void". */
2545 TYPE_CODE (type) = TYPE_CODE_VOID;
2546 TYPE_LENGTH (type) = 1;
2548 else if (type_size >= 0 || is_string)
2551 TYPE_NAME (type) = NULL;
2552 TYPE_TAG_NAME (type) = NULL;
2556 TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
2557 TYPE_TARGET_TYPE (type) = xtype;
2562 /* In the following types, we must be sure to overwrite any existing
2563 type that the typenums refer to, rather than allocating a new one
2564 and making the typenums point to the new one. This is because there
2565 may already be pointers to the existing type (if it had been
2566 forward-referenced), and we must change it to a pointer, function,
2567 reference, or whatever, *in-place*. */
2570 type1 = read_type (pp, objfile);
2571 type = make_pointer_type (type1, dbx_lookup_type (typenums));
2574 case '&': /* Reference to another type */
2575 type1 = read_type (pp, objfile);
2576 type = make_reference_type (type1, dbx_lookup_type (typenums));
2579 case 'f': /* Function returning another type */
2580 if (os9k_stabs && **pp == '(')
2582 /* Function prototype; parse it.
2583 We must conditionalize this on os9k_stabs because otherwise
2584 it could be confused with a Sun-style (1,3) typenumber
2590 t = read_type (pp, objfile);
2595 type1 = read_type (pp, objfile);
2596 type = make_function_type (type1, dbx_lookup_type (typenums));
2599 case 'k': /* Const qualifier on some type (Sun) */
2600 case 'c': /* Const qualifier on some type (OS9000) */
2601 /* Because 'c' means other things to AIX and 'k' is perfectly good,
2602 only accept 'c' in the os9k_stabs case. */
2603 if (type_descriptor == 'c' && !os9k_stabs)
2604 return error_type (pp, objfile);
2605 type = read_type (pp, objfile);
2606 /* FIXME! For now, we ignore const and volatile qualifiers. */
2609 case 'B': /* Volatile qual on some type (Sun) */
2610 case 'i': /* Volatile qual on some type (OS9000) */
2611 /* Because 'i' means other things to AIX and 'B' is perfectly good,
2612 only accept 'i' in the os9k_stabs case. */
2613 if (type_descriptor == 'i' && !os9k_stabs)
2614 return error_type (pp, objfile);
2615 type = read_type (pp, objfile);
2616 /* FIXME! For now, we ignore const and volatile qualifiers. */
2620 if (isdigit (**pp) || **pp == '(' || **pp == '-')
2621 { /* Member (class & variable) type */
2622 /* FIXME -- we should be doing smash_to_XXX types here. */
2624 struct type *domain = read_type (pp, objfile);
2625 struct type *memtype;
2628 /* Invalid member type data format. */
2629 return error_type (pp, objfile);
2632 memtype = read_type (pp, objfile);
2633 type = dbx_alloc_type (typenums, objfile);
2634 smash_to_member_type (type, domain, memtype);
2637 /* type attribute */
2640 /* Skip to the semicolon. */
2641 while (**pp != ';' && **pp != '\0')
2644 return error_type (pp, objfile);
2646 ++ * pp; /* Skip the semicolon. */
2651 type_size = atoi (attr + 1);
2661 /* Ignore unrecognized type attributes, so future compilers
2662 can invent new ones. */
2670 case '#': /* Method (class & fn) type */
2671 if ((*pp)[0] == '#')
2673 /* We'll get the parameter types from the name. */
2674 struct type *return_type;
2677 return_type = read_type (pp, objfile);
2678 if (*(*pp)++ != ';')
2679 complain (&invalid_member_complaint, symnum);
2680 type = allocate_stub_method (return_type);
2681 if (typenums[0] != -1)
2682 *dbx_lookup_type (typenums) = type;
2686 struct type *domain = read_type (pp, objfile);
2687 struct type *return_type;
2691 /* Invalid member type data format. */
2692 return error_type (pp, objfile);
2696 return_type = read_type (pp, objfile);
2697 args = read_args (pp, ';', objfile);
2698 type = dbx_alloc_type (typenums, objfile);
2699 smash_to_method_type (type, domain, return_type, args);
2703 case 'r': /* Range type */
2704 type = read_range_type (pp, typenums, objfile);
2705 if (typenums[0] != -1)
2706 *dbx_lookup_type (typenums) = type;
2711 /* Const and volatile qualified type. */
2712 type = read_type (pp, objfile);
2715 /* Sun ACC builtin int type */
2716 type = read_sun_builtin_type (pp, typenums, objfile);
2717 if (typenums[0] != -1)
2718 *dbx_lookup_type (typenums) = type;
2722 case 'R': /* Sun ACC builtin float type */
2723 type = read_sun_floating_type (pp, typenums, objfile);
2724 if (typenums[0] != -1)
2725 *dbx_lookup_type (typenums) = type;
2728 case 'e': /* Enumeration type */
2729 type = dbx_alloc_type (typenums, objfile);
2730 type = read_enum_type (pp, type, objfile);
2731 if (typenums[0] != -1)
2732 *dbx_lookup_type (typenums) = type;
2735 case 's': /* Struct type */
2736 case 'u': /* Union type */
2737 type = dbx_alloc_type (typenums, objfile);
2738 switch (type_descriptor)
2741 TYPE_CODE (type) = TYPE_CODE_STRUCT;
2744 TYPE_CODE (type) = TYPE_CODE_UNION;
2747 type = read_struct_type (pp, type, objfile);
2750 case 'a': /* Array type */
2752 return error_type (pp, objfile);
2755 type = dbx_alloc_type (typenums, objfile);
2756 type = read_array_type (pp, type, objfile);
2758 TYPE_CODE (type) = TYPE_CODE_STRING;
2762 type1 = read_type (pp, objfile);
2763 type = create_set_type ((struct type *) NULL, type1);
2765 TYPE_CODE (type) = TYPE_CODE_BITSTRING;
2766 if (typenums[0] != -1)
2767 *dbx_lookup_type (typenums) = type;
2771 --*pp; /* Go back to the symbol in error */
2772 /* Particularly important if it was \0! */
2773 return error_type (pp, objfile);
2778 warning ("GDB internal error, type is NULL in stabsread.c\n");
2779 return error_type (pp, objfile);
2782 /* Size specified in a type attribute overrides any other size. */
2783 if (type_size != -1)
2784 TYPE_LENGTH (type) = (type_size + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
2789 /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
2790 Return the proper type node for a given builtin type number. */
2792 static struct type *
2793 rs6000_builtin_type (typenum)
2796 /* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
2797 #define NUMBER_RECOGNIZED 34
2798 /* This includes an empty slot for type number -0. */
2799 static struct type *negative_types[NUMBER_RECOGNIZED + 1];
2800 struct type *rettype = NULL;
2802 if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED)
2804 complain (&rs6000_builtin_complaint, typenum);
2805 return builtin_type_error;
2807 if (negative_types[-typenum] != NULL)
2808 return negative_types[-typenum];
2810 #if TARGET_CHAR_BIT != 8
2811 #error This code wrong for TARGET_CHAR_BIT not 8
2812 /* These definitions all assume that TARGET_CHAR_BIT is 8. I think
2813 that if that ever becomes not true, the correct fix will be to
2814 make the size in the struct type to be in bits, not in units of
2821 /* The size of this and all the other types are fixed, defined
2822 by the debugging format. If there is a type called "int" which
2823 is other than 32 bits, then it should use a new negative type
2824 number (or avoid negative type numbers for that case).
2825 See stabs.texinfo. */
2826 rettype = init_type (TYPE_CODE_INT, 4, 0, "int", NULL);
2829 rettype = init_type (TYPE_CODE_INT, 1, 0, "char", NULL);
2832 rettype = init_type (TYPE_CODE_INT, 2, 0, "short", NULL);
2835 rettype = init_type (TYPE_CODE_INT, 4, 0, "long", NULL);
2838 rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
2839 "unsigned char", NULL);
2842 rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", NULL);
2845 rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
2846 "unsigned short", NULL);
2849 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2850 "unsigned int", NULL);
2853 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2856 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2857 "unsigned long", NULL);
2860 rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
2863 /* IEEE single precision (32 bit). */
2864 rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL);
2867 /* IEEE double precision (64 bit). */
2868 rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL);
2871 /* This is an IEEE double on the RS/6000, and different machines with
2872 different sizes for "long double" should use different negative
2873 type numbers. See stabs.texinfo. */
2874 rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", NULL);
2877 rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", NULL);
2880 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2884 rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", NULL);
2887 rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", NULL);
2890 rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", NULL);
2893 rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED,
2897 rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED,
2901 rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED,
2905 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2909 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2913 /* Complex type consisting of two IEEE single precision values. */
2914 rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL);
2917 /* Complex type consisting of two IEEE double precision values. */
2918 rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL);
2921 rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL);
2924 rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", NULL);
2927 rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", NULL);
2930 rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL);
2933 rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL);
2936 rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
2937 "unsigned long long", NULL);
2940 rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
2944 rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL);
2947 negative_types[-typenum] = rettype;
2951 /* This page contains subroutines of read_type. */
2953 /* Read member function stabs info for C++ classes. The form of each member
2956 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
2958 An example with two member functions is:
2960 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
2962 For the case of overloaded operators, the format is op$::*.funcs, where
2963 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
2964 name (such as `+=') and `.' marks the end of the operator name.
2966 Returns 1 for success, 0 for failure. */
2969 read_member_functions (fip, pp, type, objfile)
2970 struct field_info *fip;
2973 struct objfile *objfile;
2977 /* Total number of member functions defined in this class. If the class
2978 defines two `f' functions, and one `g' function, then this will have
2980 int total_length = 0;
2984 struct next_fnfield *next;
2985 struct fn_field fn_field;
2988 struct type *look_ahead_type;
2989 struct next_fnfieldlist *new_fnlist;
2990 struct next_fnfield *new_sublist;
2994 /* Process each list until we find something that is not a member function
2995 or find the end of the functions. */
2999 /* We should be positioned at the start of the function name.
3000 Scan forward to find the first ':' and if it is not the
3001 first of a "::" delimiter, then this is not a member function. */
3013 look_ahead_type = NULL;
3016 new_fnlist = (struct next_fnfieldlist *)
3017 xmalloc (sizeof (struct next_fnfieldlist));
3018 make_cleanup (free, new_fnlist);
3019 memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
3021 if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
3023 /* This is a completely wierd case. In order to stuff in the
3024 names that might contain colons (the usual name delimiter),
3025 Mike Tiemann defined a different name format which is
3026 signalled if the identifier is "op$". In that case, the
3027 format is "op$::XXXX." where XXXX is the name. This is
3028 used for names like "+" or "=". YUUUUUUUK! FIXME! */
3029 /* This lets the user type "break operator+".
3030 We could just put in "+" as the name, but that wouldn't
3032 static char opname[32] =
3033 {'o', 'p', CPLUS_MARKER};
3034 char *o = opname + 3;
3036 /* Skip past '::'. */
3039 STABS_CONTINUE (pp, objfile);
3045 main_fn_name = savestring (opname, o - opname);
3051 main_fn_name = savestring (*pp, p - *pp);
3052 /* Skip past '::'. */
3055 new_fnlist->fn_fieldlist.name = main_fn_name;
3060 (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
3061 make_cleanup (free, new_sublist);
3062 memset (new_sublist, 0, sizeof (struct next_fnfield));
3064 /* Check for and handle cretinous dbx symbol name continuation! */
3065 if (look_ahead_type == NULL)
3068 STABS_CONTINUE (pp, objfile);
3070 new_sublist->fn_field.type = read_type (pp, objfile);
3073 /* Invalid symtab info for member function. */
3079 /* g++ version 1 kludge */
3080 new_sublist->fn_field.type = look_ahead_type;
3081 look_ahead_type = NULL;
3091 /* If this is just a stub, then we don't have the real name here. */
3093 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
3095 if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
3096 TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
3097 new_sublist->fn_field.is_stub = 1;
3099 new_sublist->fn_field.physname = savestring (*pp, p - *pp);
3102 /* Set this member function's visibility fields. */
3105 case VISIBILITY_PRIVATE:
3106 new_sublist->fn_field.is_private = 1;
3108 case VISIBILITY_PROTECTED:
3109 new_sublist->fn_field.is_protected = 1;
3113 STABS_CONTINUE (pp, objfile);
3116 case 'A': /* Normal functions. */
3117 new_sublist->fn_field.is_const = 0;
3118 new_sublist->fn_field.is_volatile = 0;
3121 case 'B': /* `const' member functions. */
3122 new_sublist->fn_field.is_const = 1;
3123 new_sublist->fn_field.is_volatile = 0;
3126 case 'C': /* `volatile' member function. */
3127 new_sublist->fn_field.is_const = 0;
3128 new_sublist->fn_field.is_volatile = 1;
3131 case 'D': /* `const volatile' member function. */
3132 new_sublist->fn_field.is_const = 1;
3133 new_sublist->fn_field.is_volatile = 1;
3136 case '*': /* File compiled with g++ version 1 -- no info */
3141 complain (&const_vol_complaint, **pp);
3150 /* virtual member function, followed by index.
3151 The sign bit is set to distinguish pointers-to-methods
3152 from virtual function indicies. Since the array is
3153 in words, the quantity must be shifted left by 1
3154 on 16 bit machine, and by 2 on 32 bit machine, forcing
3155 the sign bit out, and usable as a valid index into
3156 the array. Remove the sign bit here. */
3157 new_sublist->fn_field.voffset =
3158 (0x7fffffff & read_huge_number (pp, ';', &nbits)) + 2;
3162 STABS_CONTINUE (pp, objfile);
3163 if (**pp == ';' || **pp == '\0')
3165 /* Must be g++ version 1. */
3166 new_sublist->fn_field.fcontext = 0;
3170 /* Figure out from whence this virtual function came.
3171 It may belong to virtual function table of
3172 one of its baseclasses. */
3173 look_ahead_type = read_type (pp, objfile);
3176 /* g++ version 1 overloaded methods. */
3180 new_sublist->fn_field.fcontext = look_ahead_type;
3189 look_ahead_type = NULL;
3195 /* static member function. */
3196 new_sublist->fn_field.voffset = VOFFSET_STATIC;
3197 if (strncmp (new_sublist->fn_field.physname,
3198 main_fn_name, strlen (main_fn_name)))
3200 new_sublist->fn_field.is_stub = 1;
3206 complain (&member_fn_complaint, (*pp)[-1]);
3207 /* Fall through into normal member function. */
3210 /* normal member function. */
3211 new_sublist->fn_field.voffset = 0;
3212 new_sublist->fn_field.fcontext = 0;
3216 new_sublist->next = sublist;
3217 sublist = new_sublist;
3219 STABS_CONTINUE (pp, objfile);
3221 while (**pp != ';' && **pp != '\0');
3225 new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
3226 obstack_alloc (&objfile->type_obstack,
3227 sizeof (struct fn_field) * length);
3228 memset (new_fnlist->fn_fieldlist.fn_fields, 0,
3229 sizeof (struct fn_field) * length);
3230 for (i = length; (i--, sublist); sublist = sublist->next)
3232 new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
3235 new_fnlist->fn_fieldlist.length = length;
3236 new_fnlist->next = fip->fnlist;
3237 fip->fnlist = new_fnlist;
3239 total_length += length;
3240 STABS_CONTINUE (pp, objfile);
3245 ALLOCATE_CPLUS_STRUCT_TYPE (type);
3246 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
3247 TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
3248 memset (TYPE_FN_FIELDLISTS (type), 0,
3249 sizeof (struct fn_fieldlist) * nfn_fields);
3250 TYPE_NFN_FIELDS (type) = nfn_fields;
3251 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
3257 /* Special GNU C++ name.
3259 Returns 1 for success, 0 for failure. "failure" means that we can't
3260 keep parsing and it's time for error_type(). */
3263 read_cpp_abbrev (fip, pp, type, objfile)
3264 struct field_info *fip;
3267 struct objfile *objfile;
3272 struct type *context;
3282 /* At this point, *pp points to something like "22:23=*22...",
3283 where the type number before the ':' is the "context" and
3284 everything after is a regular type definition. Lookup the
3285 type, find it's name, and construct the field name. */
3287 context = read_type (pp, objfile);
3291 case 'f': /* $vf -- a virtual function table pointer */
3292 fip->list->field.name =
3293 obconcat (&objfile->type_obstack, vptr_name, "", "");
3296 case 'b': /* $vb -- a virtual bsomethingorother */
3297 name = type_name_no_tag (context);
3300 complain (&invalid_cpp_type_complaint, symnum);
3303 fip->list->field.name =
3304 obconcat (&objfile->type_obstack, vb_name, name, "");
3308 complain (&invalid_cpp_abbrev_complaint, *pp);
3309 fip->list->field.name =
3310 obconcat (&objfile->type_obstack,
3311 "INVALID_CPLUSPLUS_ABBREV", "", "");
3315 /* At this point, *pp points to the ':'. Skip it and read the
3321 complain (&invalid_cpp_abbrev_complaint, *pp);
3324 fip->list->field.type = read_type (pp, objfile);
3326 (*pp)++; /* Skip the comma. */
3332 FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ';', &nbits);
3336 /* This field is unpacked. */
3337 FIELD_BITSIZE (fip->list->field) = 0;
3338 fip->list->visibility = VISIBILITY_PRIVATE;
3342 complain (&invalid_cpp_abbrev_complaint, *pp);
3343 /* We have no idea what syntax an unrecognized abbrev would have, so
3344 better return 0. If we returned 1, we would need to at least advance
3345 *pp to avoid an infinite loop. */
3352 read_one_struct_field (fip, pp, p, type, objfile)
3353 struct field_info *fip;
3357 struct objfile *objfile;
3359 /* The following is code to work around cfront generated stabs.
3360 The stabs contains full mangled name for each field.
3361 We try to demangle the name and extract the field name out of it.
3363 if (ARM_DEMANGLING && current_subfile->language == language_cplus)
3369 dem = cplus_demangle (*pp, DMGL_ANSI | DMGL_PARAMS);
3372 dem_p = strrchr (dem, ':');
3373 if (dem_p != 0 && *(dem_p - 1) == ':')
3375 FIELD_NAME (fip->list->field) =
3376 obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
3380 FIELD_NAME (fip->list->field) =
3381 obsavestring (*pp, p - *pp, &objfile->type_obstack);
3385 /* end of code for cfront work around */
3388 fip->list->field.name =
3389 obsavestring (*pp, p - *pp, &objfile->type_obstack);
3392 /* This means we have a visibility for a field coming. */
3396 fip->list->visibility = *(*pp)++;
3400 /* normal dbx-style format, no explicit visibility */
3401 fip->list->visibility = VISIBILITY_PUBLIC;
3404 fip->list->field.type = read_type (pp, objfile);
3409 /* Possible future hook for nested types. */
3412 fip->list->field.bitpos = (long) -2; /* nested type */
3422 /* Static class member. */
3423 SET_FIELD_PHYSNAME (fip->list->field, savestring (*pp, p - *pp));
3427 else if (**pp != ',')
3429 /* Bad structure-type format. */
3430 complain (&stabs_general_complaint, "bad structure-type format");
3434 (*pp)++; /* Skip the comma. */
3438 FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits);
3441 complain (&stabs_general_complaint, "bad structure-type format");
3444 FIELD_BITSIZE (fip->list->field) = read_huge_number (pp, ';', &nbits);
3447 complain (&stabs_general_complaint, "bad structure-type format");
3452 if (FIELD_BITPOS (fip->list->field) == 0
3453 && FIELD_BITSIZE (fip->list->field) == 0)
3455 /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
3456 it is a field which has been optimized out. The correct stab for
3457 this case is to use VISIBILITY_IGNORE, but that is a recent
3458 invention. (2) It is a 0-size array. For example
3459 union { int num; char str[0]; } foo. Printing "<no value>" for
3460 str in "p foo" is OK, since foo.str (and thus foo.str[3])
3461 will continue to work, and a 0-size array as a whole doesn't
3462 have any contents to print.
3464 I suspect this probably could also happen with gcc -gstabs (not
3465 -gstabs+) for static fields, and perhaps other C++ extensions.
3466 Hopefully few people use -gstabs with gdb, since it is intended
3467 for dbx compatibility. */
3469 /* Ignore this field. */
3470 fip->list->visibility = VISIBILITY_IGNORE;
3474 /* Detect an unpacked field and mark it as such.
3475 dbx gives a bit size for all fields.
3476 Note that forward refs cannot be packed,
3477 and treat enums as if they had the width of ints. */
3479 struct type *field_type = check_typedef (FIELD_TYPE (fip->list->field));
3481 if (TYPE_CODE (field_type) != TYPE_CODE_INT
3482 && TYPE_CODE (field_type) != TYPE_CODE_RANGE
3483 && TYPE_CODE (field_type) != TYPE_CODE_BOOL
3484 && TYPE_CODE (field_type) != TYPE_CODE_ENUM)
3486 FIELD_BITSIZE (fip->list->field) = 0;
3488 if ((FIELD_BITSIZE (fip->list->field)
3489 == TARGET_CHAR_BIT * TYPE_LENGTH (field_type)
3490 || (TYPE_CODE (field_type) == TYPE_CODE_ENUM
3491 && FIELD_BITSIZE (fip->list->field) == TARGET_INT_BIT)
3494 FIELD_BITPOS (fip->list->field) % 8 == 0)
3496 FIELD_BITSIZE (fip->list->field) = 0;
3502 /* Read struct or class data fields. They have the form:
3504 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
3506 At the end, we see a semicolon instead of a field.
3508 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
3511 The optional VISIBILITY is one of:
3513 '/0' (VISIBILITY_PRIVATE)
3514 '/1' (VISIBILITY_PROTECTED)
3515 '/2' (VISIBILITY_PUBLIC)
3516 '/9' (VISIBILITY_IGNORE)
3518 or nothing, for C style fields with public visibility.
3520 Returns 1 for success, 0 for failure. */
3523 read_struct_fields (fip, pp, type, objfile)
3524 struct field_info *fip;
3527 struct objfile *objfile;
3530 struct nextfield *new;
3532 /* We better set p right now, in case there are no fields at all... */
3536 /* Read each data member type until we find the terminating ';' at the end of
3537 the data member list, or break for some other reason such as finding the
3538 start of the member function list. */
3542 if (os9k_stabs && **pp == ',')
3544 STABS_CONTINUE (pp, objfile);
3545 /* Get space to record the next field's data. */
3546 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3547 make_cleanup (free, new);
3548 memset (new, 0, sizeof (struct nextfield));
3549 new->next = fip->list;
3552 /* Get the field name. */
3555 /* If is starts with CPLUS_MARKER it is a special abbreviation,
3556 unless the CPLUS_MARKER is followed by an underscore, in
3557 which case it is just the name of an anonymous type, which we
3558 should handle like any other type name. */
3560 if (is_cplus_marker (p[0]) && p[1] != '_')
3562 if (!read_cpp_abbrev (fip, pp, type, objfile))
3567 /* Look for the ':' that separates the field name from the field
3568 values. Data members are delimited by a single ':', while member
3569 functions are delimited by a pair of ':'s. When we hit the member
3570 functions (if any), terminate scan loop and return. */
3572 while (*p != ':' && *p != '\0')
3579 /* Check to see if we have hit the member functions yet. */
3584 read_one_struct_field (fip, pp, p, type, objfile);
3586 if (p[0] == ':' && p[1] == ':')
3588 /* chill the list of fields: the last entry (at the head) is a
3589 partially constructed entry which we now scrub. */
3590 fip->list = fip->list->next;
3595 /* The stabs for C++ derived classes contain baseclass information which
3596 is marked by a '!' character after the total size. This function is
3597 called when we encounter the baseclass marker, and slurps up all the
3598 baseclass information.
3600 Immediately following the '!' marker is the number of base classes that
3601 the class is derived from, followed by information for each base class.
3602 For each base class, there are two visibility specifiers, a bit offset
3603 to the base class information within the derived class, a reference to
3604 the type for the base class, and a terminating semicolon.
3606 A typical example, with two base classes, would be "!2,020,19;0264,21;".
3608 Baseclass information marker __________________|| | | | | | |
3609 Number of baseclasses __________________________| | | | | | |
3610 Visibility specifiers (2) ________________________| | | | | |
3611 Offset in bits from start of class _________________| | | | |
3612 Type number for base class ___________________________| | | |
3613 Visibility specifiers (2) _______________________________| | |
3614 Offset in bits from start of class ________________________| |
3615 Type number of base class ____________________________________|
3617 Return 1 for success, 0 for (error-type-inducing) failure. */
3623 read_baseclasses (fip, pp, type, objfile)
3624 struct field_info *fip;
3627 struct objfile *objfile;
3630 struct nextfield *new;
3638 /* Skip the '!' baseclass information marker. */
3642 ALLOCATE_CPLUS_STRUCT_TYPE (type);
3645 TYPE_N_BASECLASSES (type) = read_huge_number (pp, ',', &nbits);
3651 /* Some stupid compilers have trouble with the following, so break
3652 it up into simpler expressions. */
3653 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
3654 TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
3657 int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
3660 pointer = (char *) TYPE_ALLOC (type, num_bytes);
3661 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
3665 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
3667 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
3669 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3670 make_cleanup (free, new);
3671 memset (new, 0, sizeof (struct nextfield));
3672 new->next = fip->list;
3674 FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
3676 STABS_CONTINUE (pp, objfile);
3680 /* Nothing to do. */
3683 SET_TYPE_FIELD_VIRTUAL (type, i);
3686 /* Unknown character. Complain and treat it as non-virtual. */
3688 static struct complaint msg =
3690 "Unknown virtual character `%c' for baseclass", 0, 0};
3691 complain (&msg, **pp);
3696 new->visibility = *(*pp)++;
3697 switch (new->visibility)
3699 case VISIBILITY_PRIVATE:
3700 case VISIBILITY_PROTECTED:
3701 case VISIBILITY_PUBLIC:
3704 /* Bad visibility format. Complain and treat it as
3707 static struct complaint msg =
3709 "Unknown visibility `%c' for baseclass", 0, 0
3711 complain (&msg, new->visibility);
3712 new->visibility = VISIBILITY_PUBLIC;
3719 /* The remaining value is the bit offset of the portion of the object
3720 corresponding to this baseclass. Always zero in the absence of
3721 multiple inheritance. */
3723 FIELD_BITPOS (new->field) = read_huge_number (pp, ',', &nbits);
3728 /* The last piece of baseclass information is the type of the
3729 base class. Read it, and remember it's type name as this
3732 new->field.type = read_type (pp, objfile);
3733 new->field.name = type_name_no_tag (new->field.type);
3735 /* skip trailing ';' and bump count of number of fields seen */
3744 /* The tail end of stabs for C++ classes that contain a virtual function
3745 pointer contains a tilde, a %, and a type number.
3746 The type number refers to the base class (possibly this class itself) which
3747 contains the vtable pointer for the current class.
3749 This function is called when we have parsed all the method declarations,
3750 so we can look for the vptr base class info. */
3753 read_tilde_fields (fip, pp, type, objfile)
3754 struct field_info *fip;
3757 struct objfile *objfile;
3761 STABS_CONTINUE (pp, objfile);
3763 /* If we are positioned at a ';', then skip it. */
3773 if (**pp == '=' || **pp == '+' || **pp == '-')
3775 /* Obsolete flags that used to indicate the presence
3776 of constructors and/or destructors. */
3780 /* Read either a '%' or the final ';'. */
3781 if (*(*pp)++ == '%')
3783 /* The next number is the type number of the base class
3784 (possibly our own class) which supplies the vtable for
3785 this class. Parse it out, and search that class to find
3786 its vtable pointer, and install those into TYPE_VPTR_BASETYPE
3787 and TYPE_VPTR_FIELDNO. */
3792 t = read_type (pp, objfile);
3794 while (*p != '\0' && *p != ';')
3800 /* Premature end of symbol. */
3804 TYPE_VPTR_BASETYPE (type) = t;
3805 if (type == t) /* Our own class provides vtbl ptr */
3807 for (i = TYPE_NFIELDS (t) - 1;
3808 i >= TYPE_N_BASECLASSES (t);
3811 if (!strncmp (TYPE_FIELD_NAME (t, i), vptr_name,
3812 sizeof (vptr_name) - 1))
3814 TYPE_VPTR_FIELDNO (type) = i;
3818 /* Virtual function table field not found. */
3819 complain (&vtbl_notfound_complaint, TYPE_NAME (type));
3824 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
3835 attach_fn_fields_to_type (fip, type)
3836 struct field_info *fip;
3837 register struct type *type;
3841 for (n = TYPE_NFN_FIELDS (type);
3842 fip->fnlist != NULL;
3843 fip->fnlist = fip->fnlist->next)
3845 --n; /* Circumvent Sun3 compiler bug */
3846 TYPE_FN_FIELDLISTS (type)[n] = fip->fnlist->fn_fieldlist;
3851 /* read cfront class static data.
3852 pp points to string starting with the list of static data
3853 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
3856 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
3861 read_cfront_static_fields (fip, pp, type, objfile)
3862 struct field_info *fip;
3865 struct objfile *objfile;
3867 struct nextfield *new;
3870 struct symbol *ref_static = 0;
3872 if (**pp == ';') /* no static data; return */
3878 /* Process each field in the list until we find the terminating ";" */
3880 /* eg: p = "as__1A ;;;" */
3881 STABS_CONTINUE (pp, objfile); /* handle \\ */
3882 while (**pp != ';' && (sname = get_substring (pp, ' '), sname))
3884 ref_static = lookup_symbol (sname, 0, VAR_NAMESPACE, 0, 0); /*demangled_name */
3887 static struct complaint msg =
3889 Unable to find symbol for static data field %s\n",
3891 complain (&msg, sname);
3894 stype = SYMBOL_TYPE (ref_static);
3896 /* allocate a new fip */
3897 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3898 make_cleanup (free, new);
3899 memset (new, 0, sizeof (struct nextfield));
3900 new->next = fip->list;
3903 /* set visibility */
3904 /* FIXME! no way to tell visibility from stabs??? */
3905 new->visibility = VISIBILITY_PUBLIC;
3907 /* set field info into fip */
3908 fip->list->field.type = stype;
3910 /* set bitpos & bitsize */
3911 SET_FIELD_PHYSNAME (fip->list->field, savestring (sname, strlen (sname)));
3913 /* set name field */
3914 /* The following is code to work around cfront generated stabs.
3915 The stabs contains full mangled name for each field.
3916 We try to demangle the name and extract the field name out of it.
3921 dem = cplus_demangle (sname, DMGL_ANSI | DMGL_PARAMS);
3924 dem_p = strrchr (dem, ':');
3925 if (dem_p != 0 && *(dem_p - 1) == ':')
3927 fip->list->field.name =
3928 obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
3932 fip->list->field.name =
3933 obsavestring (sname, strlen (sname), &objfile->type_obstack);
3935 } /* end of code for cfront work around */
3936 } /* loop again for next static field */
3940 /* Copy structure fields to fip so attach_fields_to_type will work.
3941 type has already been created with the initial instance data fields.
3942 Now we want to be able to add the other members to the class,
3943 so we want to add them back to the fip and reattach them again
3944 once we have collected all the class members. */
3947 copy_cfront_struct_fields (fip, type, objfile)
3948 struct field_info *fip;
3950 struct objfile *objfile;
3952 int nfields = TYPE_NFIELDS (type);
3954 struct nextfield *new;
3956 /* Copy the fields into the list of fips and reset the types
3957 to remove the old fields */
3959 for (i = 0; i < nfields; i++)
3961 /* allocate a new fip */
3962 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3963 make_cleanup (free, new);
3964 memset (new, 0, sizeof (struct nextfield));
3965 new->next = fip->list;
3968 /* copy field info into fip */
3969 new->field = TYPE_FIELD (type, i);
3970 /* set visibility */
3971 if (TYPE_FIELD_PROTECTED (type, i))
3972 new->visibility = VISIBILITY_PROTECTED;
3973 else if (TYPE_FIELD_PRIVATE (type, i))
3974 new->visibility = VISIBILITY_PRIVATE;
3976 new->visibility = VISIBILITY_PUBLIC;
3978 /* Now delete the fields from the type since we will be
3979 allocing new space once we get the rest of the fields
3980 in attach_fields_to_type.
3981 The pointer TYPE_FIELDS(type) is left dangling but should
3982 be freed later by objstack_free */
3983 TYPE_FIELDS (type) = 0;
3984 TYPE_NFIELDS (type) = 0;
3989 /* Create the vector of fields, and record how big it is.
3990 We need this info to record proper virtual function table information
3991 for this class's virtual functions. */
3994 attach_fields_to_type (fip, type, objfile)
3995 struct field_info *fip;
3996 register struct type *type;
3997 struct objfile *objfile;
3999 register int nfields = 0;
4000 register int non_public_fields = 0;
4001 register struct nextfield *scan;
4003 /* Count up the number of fields that we have, as well as taking note of
4004 whether or not there are any non-public fields, which requires us to
4005 allocate and build the private_field_bits and protected_field_bits
4008 for (scan = fip->list; scan != NULL; scan = scan->next)
4011 if (scan->visibility != VISIBILITY_PUBLIC)
4013 non_public_fields++;
4017 /* Now we know how many fields there are, and whether or not there are any
4018 non-public fields. Record the field count, allocate space for the
4019 array of fields, and create blank visibility bitfields if necessary. */
4021 TYPE_NFIELDS (type) = nfields;
4022 TYPE_FIELDS (type) = (struct field *)
4023 TYPE_ALLOC (type, sizeof (struct field) * nfields);
4024 memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
4026 if (non_public_fields)
4028 ALLOCATE_CPLUS_STRUCT_TYPE (type);
4030 TYPE_FIELD_PRIVATE_BITS (type) =
4031 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
4032 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
4034 TYPE_FIELD_PROTECTED_BITS (type) =
4035 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
4036 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
4038 TYPE_FIELD_IGNORE_BITS (type) =
4039 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
4040 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
4043 /* Copy the saved-up fields into the field vector. Start from the head
4044 of the list, adding to the tail of the field array, so that they end
4045 up in the same order in the array in which they were added to the list. */
4047 while (nfields-- > 0)
4049 TYPE_FIELD (type, nfields) = fip->list->field;
4050 switch (fip->list->visibility)
4052 case VISIBILITY_PRIVATE:
4053 SET_TYPE_FIELD_PRIVATE (type, nfields);
4056 case VISIBILITY_PROTECTED:
4057 SET_TYPE_FIELD_PROTECTED (type, nfields);
4060 case VISIBILITY_IGNORE:
4061 SET_TYPE_FIELD_IGNORE (type, nfields);
4064 case VISIBILITY_PUBLIC:
4068 /* Unknown visibility. Complain and treat it as public. */
4070 static struct complaint msg =
4072 "Unknown visibility `%c' for field", 0, 0};
4073 complain (&msg, fip->list->visibility);
4077 fip->list = fip->list->next;
4082 /* Read the description of a structure (or union type) and return an object
4083 describing the type.
4085 PP points to a character pointer that points to the next unconsumed token
4086 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
4087 *PP will point to "4a:1,0,32;;".
4089 TYPE points to an incomplete type that needs to be filled in.
4091 OBJFILE points to the current objfile from which the stabs information is
4092 being read. (Note that it is redundant in that TYPE also contains a pointer
4093 to this same objfile, so it might be a good idea to eliminate it. FIXME).
4096 static struct type *
4097 read_struct_type (pp, type, objfile)
4100 struct objfile *objfile;
4102 struct cleanup *back_to;
4103 struct field_info fi;
4108 back_to = make_cleanup (null_cleanup, 0);
4110 INIT_CPLUS_SPECIFIC (type);
4111 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
4113 /* First comes the total size in bytes. */
4117 TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits);
4119 return error_type (pp, objfile);
4122 /* Now read the baseclasses, if any, read the regular C struct or C++
4123 class member fields, attach the fields to the type, read the C++
4124 member functions, attach them to the type, and then read any tilde
4125 field (baseclass specifier for the class holding the main vtable). */
4127 if (!read_baseclasses (&fi, pp, type, objfile)
4128 || !read_struct_fields (&fi, pp, type, objfile)
4129 || !attach_fields_to_type (&fi, type, objfile)
4130 || !read_member_functions (&fi, pp, type, objfile)
4131 || !attach_fn_fields_to_type (&fi, type)
4132 || !read_tilde_fields (&fi, pp, type, objfile))
4134 type = error_type (pp, objfile);
4137 do_cleanups (back_to);
4141 /* Read a definition of an array type,
4142 and create and return a suitable type object.
4143 Also creates a range type which represents the bounds of that
4146 static struct type *
4147 read_array_type (pp, type, objfile)
4149 register struct type *type;
4150 struct objfile *objfile;
4152 struct type *index_type, *element_type, *range_type;
4157 /* Format of an array type:
4158 "ar<index type>;lower;upper;<array_contents_type>".
4159 OS9000: "arlower,upper;<array_contents_type>".
4161 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
4162 for these, produce a type like float[][]. */
4165 index_type = builtin_type_int;
4168 index_type = read_type (pp, objfile);
4170 /* Improper format of array type decl. */
4171 return error_type (pp, objfile);
4175 if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
4180 lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits);
4182 return error_type (pp, objfile);
4184 if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
4189 upper = read_huge_number (pp, ';', &nbits);
4191 return error_type (pp, objfile);
4193 element_type = read_type (pp, objfile);
4202 create_range_type ((struct type *) NULL, index_type, lower, upper);
4203 type = create_array_type (type, element_type, range_type);
4209 /* Read a definition of an enumeration type,
4210 and create and return a suitable type object.
4211 Also defines the symbols that represent the values of the type. */
4213 static struct type *
4214 read_enum_type (pp, type, objfile)
4216 register struct type *type;
4217 struct objfile *objfile;
4222 register struct symbol *sym;
4224 struct pending **symlist;
4225 struct pending *osyms, *syms;
4228 int unsigned_enum = 1;
4231 /* FIXME! The stabs produced by Sun CC merrily define things that ought
4232 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
4233 to do? For now, force all enum values to file scope. */
4234 if (within_function)
4235 symlist = &local_symbols;
4238 symlist = &file_symbols;
4240 o_nsyms = osyms ? osyms->nsyms : 0;
4244 /* Size. Perhaps this does not have to be conditionalized on
4245 os9k_stabs (assuming the name of an enum constant can't start
4247 read_huge_number (pp, 0, &nbits);
4249 return error_type (pp, objfile);
4252 /* The aix4 compiler emits an extra field before the enum members;
4253 my guess is it's a type of some sort. Just ignore it. */
4256 /* Skip over the type. */
4260 /* Skip over the colon. */
4264 /* Read the value-names and their values.
4265 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
4266 A semicolon or comma instead of a NAME means the end. */
4267 while (**pp && **pp != ';' && **pp != ',')
4269 STABS_CONTINUE (pp, objfile);
4273 name = obsavestring (*pp, p - *pp, &objfile->symbol_obstack);
4275 n = read_huge_number (pp, ',', &nbits);
4277 return error_type (pp, objfile);
4279 sym = (struct symbol *)
4280 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
4281 memset (sym, 0, sizeof (struct symbol));
4282 SYMBOL_NAME (sym) = name;
4283 SYMBOL_LANGUAGE (sym) = current_subfile->language;
4284 SYMBOL_CLASS (sym) = LOC_CONST;
4285 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
4286 SYMBOL_VALUE (sym) = n;
4289 add_symbol_to_list (sym, symlist);
4294 (*pp)++; /* Skip the semicolon. */
4296 /* Now fill in the fields of the type-structure. */
4298 TYPE_LENGTH (type) = TARGET_INT_BIT / HOST_CHAR_BIT;
4299 TYPE_CODE (type) = TYPE_CODE_ENUM;
4300 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
4302 TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
4303 TYPE_NFIELDS (type) = nsyms;
4304 TYPE_FIELDS (type) = (struct field *)
4305 TYPE_ALLOC (type, sizeof (struct field) * nsyms);
4306 memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms);
4308 /* Find the symbols for the values and put them into the type.
4309 The symbols can be found in the symlist that we put them on
4310 to cause them to be defined. osyms contains the old value
4311 of that symlist; everything up to there was defined by us. */
4312 /* Note that we preserve the order of the enum constants, so
4313 that in something like "enum {FOO, LAST_THING=FOO}" we print
4314 FOO, not LAST_THING. */
4316 for (syms = *symlist, n = nsyms - 1; syms; syms = syms->next)
4318 int last = syms == osyms ? o_nsyms : 0;
4319 int j = syms->nsyms;
4320 for (; --j >= last; --n)
4322 struct symbol *xsym = syms->symbol[j];
4323 SYMBOL_TYPE (xsym) = type;
4324 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
4325 TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
4326 TYPE_FIELD_BITSIZE (type, n) = 0;
4335 /* Sun's ACC uses a somewhat saner method for specifying the builtin
4336 typedefs in every file (for int, long, etc):
4338 type = b <signed> <width> <format type>; <offset>; <nbits>
4340 optional format type = c or b for char or boolean.
4341 offset = offset from high order bit to start bit of type.
4342 width is # bytes in object of this type, nbits is # bits in type.
4344 The width/offset stuff appears to be for small objects stored in
4345 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
4348 static struct type *
4349 read_sun_builtin_type (pp, typenums, objfile)
4352 struct objfile *objfile;
4357 enum type_code code = TYPE_CODE_INT;
4368 return error_type (pp, objfile);
4372 /* For some odd reason, all forms of char put a c here. This is strange
4373 because no other type has this honor. We can safely ignore this because
4374 we actually determine 'char'acterness by the number of bits specified in
4376 Boolean forms, e.g Fortran logical*X, put a b here. */
4380 else if (**pp == 'b')
4382 code = TYPE_CODE_BOOL;
4386 /* The first number appears to be the number of bytes occupied
4387 by this type, except that unsigned short is 4 instead of 2.
4388 Since this information is redundant with the third number,
4389 we will ignore it. */
4390 read_huge_number (pp, ';', &nbits);
4392 return error_type (pp, objfile);
4394 /* The second number is always 0, so ignore it too. */
4395 read_huge_number (pp, ';', &nbits);
4397 return error_type (pp, objfile);
4399 /* The third number is the number of bits for this type. */
4400 type_bits = read_huge_number (pp, 0, &nbits);
4402 return error_type (pp, objfile);
4403 /* The type *should* end with a semicolon. If it are embedded
4404 in a larger type the semicolon may be the only way to know where
4405 the type ends. If this type is at the end of the stabstring we
4406 can deal with the omitted semicolon (but we don't have to like
4407 it). Don't bother to complain(), Sun's compiler omits the semicolon
4413 return init_type (TYPE_CODE_VOID, 1,
4414 signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
4417 return init_type (code,
4418 type_bits / TARGET_CHAR_BIT,
4419 signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
4423 static struct type *
4424 read_sun_floating_type (pp, typenums, objfile)
4427 struct objfile *objfile;
4433 /* The first number has more details about the type, for example
4435 details = read_huge_number (pp, ';', &nbits);
4437 return error_type (pp, objfile);
4439 /* The second number is the number of bytes occupied by this type */
4440 nbytes = read_huge_number (pp, ';', &nbits);
4442 return error_type (pp, objfile);
4444 if (details == NF_COMPLEX || details == NF_COMPLEX16
4445 || details == NF_COMPLEX32)
4446 /* This is a type we can't handle, but we do know the size.
4447 We also will be able to give it a name. */
4448 return init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile);
4450 return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile);
4453 /* Read a number from the string pointed to by *PP.
4454 The value of *PP is advanced over the number.
4455 If END is nonzero, the character that ends the
4456 number must match END, or an error happens;
4457 and that character is skipped if it does match.
4458 If END is zero, *PP is left pointing to that character.
4460 If the number fits in a long, set *BITS to 0 and return the value.
4461 If not, set *BITS to be the number of bits in the number and return 0.
4463 If encounter garbage, set *BITS to -1 and return 0. */
4466 read_huge_number (pp, end, bits)
4486 /* Leading zero means octal. GCC uses this to output values larger
4487 than an int (because that would be hard in decimal). */
4495 upper_limit = ULONG_MAX / radix;
4497 upper_limit = LONG_MAX / radix;
4499 while ((c = *p++) >= '0' && c < ('0' + radix))
4501 if (n <= upper_limit)
4504 n += c - '0'; /* FIXME this overflows anyway */
4509 /* This depends on large values being output in octal, which is
4516 /* Ignore leading zeroes. */
4520 else if (c == '2' || c == '3')
4546 /* Large decimal constants are an error (because it is hard to
4547 count how many bits are in them). */
4553 /* -0x7f is the same as 0x80. So deal with it by adding one to
4554 the number of bits. */
4566 /* It's *BITS which has the interesting information. */
4570 static struct type *
4571 read_range_type (pp, typenums, objfile)
4574 struct objfile *objfile;
4576 char *orig_pp = *pp;
4581 struct type *result_type;
4582 struct type *index_type = NULL;
4584 /* First comes a type we are a subrange of.
4585 In C it is usually 0, 1 or the type being defined. */
4586 if (read_type_number (pp, rangenums) != 0)
4587 return error_type (pp, objfile);
4588 self_subrange = (rangenums[0] == typenums[0] &&
4589 rangenums[1] == typenums[1]);
4594 index_type = read_type (pp, objfile);
4597 /* A semicolon should now follow; skip it. */
4601 /* The remaining two operands are usually lower and upper bounds
4602 of the range. But in some special cases they mean something else. */
4603 n2 = read_huge_number (pp, ';', &n2bits);
4604 n3 = read_huge_number (pp, ';', &n3bits);
4606 if (n2bits == -1 || n3bits == -1)
4607 return error_type (pp, objfile);
4610 goto handle_true_range;
4612 /* If limits are huge, must be large integral type. */
4613 if (n2bits != 0 || n3bits != 0)
4615 char got_signed = 0;
4616 char got_unsigned = 0;
4617 /* Number of bits in the type. */
4620 /* Range from 0 to <large number> is an unsigned large integral type. */
4621 if ((n2bits == 0 && n2 == 0) && n3bits != 0)
4626 /* Range from <large number> to <large number>-1 is a large signed
4627 integral type. Take care of the case where <large number> doesn't
4628 fit in a long but <large number>-1 does. */
4629 else if ((n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
4630 || (n2bits != 0 && n3bits == 0
4631 && (n2bits == sizeof (long) * HOST_CHAR_BIT)
4638 if (got_signed || got_unsigned)
4640 return init_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT,
4641 got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL,
4645 return error_type (pp, objfile);
4648 /* A type defined as a subrange of itself, with bounds both 0, is void. */
4649 if (self_subrange && n2 == 0 && n3 == 0)
4650 return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
4652 /* If n3 is zero and n2 is positive, we want a floating type, and n2
4653 is the width in bytes.
4655 Fortran programs appear to use this for complex types also. To
4656 distinguish between floats and complex, g77 (and others?) seem
4657 to use self-subranges for the complexes, and subranges of int for
4660 Also note that for complexes, g77 sets n2 to the size of one of
4661 the member floats, not the whole complex beast. My guess is that
4662 this was to work well with pre-COMPLEX versions of gdb. */
4664 if (n3 == 0 && n2 > 0)
4668 return init_type (TYPE_CODE_COMPLEX, 2 * n2, 0, NULL, objfile);
4672 return init_type (TYPE_CODE_FLT, n2, 0, NULL, objfile);
4676 /* If the upper bound is -1, it must really be an unsigned int. */
4678 else if (n2 == 0 && n3 == -1)
4680 /* It is unsigned int or unsigned long. */
4681 /* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
4682 compatibility hack. */
4683 return init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
4684 TYPE_FLAG_UNSIGNED, NULL, objfile);
4687 /* Special case: char is defined (Who knows why) as a subrange of
4688 itself with range 0-127. */
4689 else if (self_subrange && n2 == 0 && n3 == 127)
4690 return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
4692 else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill
4694 goto handle_true_range;
4696 /* We used to do this only for subrange of self or subrange of int. */
4699 /* -1 is used for the upper bound of (4 byte) "unsigned int" and
4700 "unsigned long", and we already checked for that,
4701 so don't need to test for it here. */
4704 /* n3 actually gives the size. */
4705 return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED,
4708 /* Is n3 == 2**(8n)-1 for some integer n? Then it's an
4709 unsigned n-byte integer. But do require n to be a power of
4710 two; we don't want 3- and 5-byte integers flying around. */
4716 for (bytes = 0; (bits & 0xff) == 0xff; bytes++)
4719 && ((bytes - 1) & bytes) == 0) /* "bytes is a power of two" */
4720 return init_type (TYPE_CODE_INT, bytes, TYPE_FLAG_UNSIGNED, NULL,
4724 /* I think this is for Convex "long long". Since I don't know whether
4725 Convex sets self_subrange, I also accept that particular size regardless
4726 of self_subrange. */
4727 else if (n3 == 0 && n2 < 0
4729 || n2 == -TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT))
4730 return init_type (TYPE_CODE_INT, -n2, 0, NULL, objfile);
4731 else if (n2 == -n3 - 1)
4734 return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
4736 return init_type (TYPE_CODE_INT, 2, 0, NULL, objfile);
4737 if (n3 == 0x7fffffff)
4738 return init_type (TYPE_CODE_INT, 4, 0, NULL, objfile);
4741 /* We have a real range type on our hands. Allocate space and
4742 return a real pointer. */
4746 index_type = builtin_type_int;
4748 index_type = *dbx_lookup_type (rangenums);
4749 if (index_type == NULL)
4751 /* Does this actually ever happen? Is that why we are worrying
4752 about dealing with it rather than just calling error_type? */
4754 static struct type *range_type_index;
4756 complain (&range_type_base_complaint, rangenums[1]);
4757 if (range_type_index == NULL)
4759 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
4760 0, "range type index type", NULL);
4761 index_type = range_type_index;
4764 result_type = create_range_type ((struct type *) NULL, index_type, n2, n3);
4765 return (result_type);
4768 /* Read in an argument list. This is a list of types, separated by commas
4769 and terminated with END. Return the list of types read in, or (struct type
4770 **)-1 if there is an error. */
4772 static struct type **
4773 read_args (pp, end, objfile)
4776 struct objfile *objfile;
4778 /* FIXME! Remove this arbitrary limit! */
4779 struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
4785 /* Invalid argument list: no ','. */
4786 return (struct type **) -1;
4788 STABS_CONTINUE (pp, objfile);
4789 types[n++] = read_type (pp, objfile);
4791 (*pp)++; /* get past `end' (the ':' character) */
4795 rval = (struct type **) xmalloc (2 * sizeof (struct type *));
4797 else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID)
4799 rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
4800 memset (rval + n, 0, sizeof (struct type *));
4804 rval = (struct type **) xmalloc (n * sizeof (struct type *));
4806 memcpy (rval, types, n * sizeof (struct type *));
4810 /* Common block handling. */
4812 /* List of symbols declared since the last BCOMM. This list is a tail
4813 of local_symbols. When ECOMM is seen, the symbols on the list
4814 are noted so their proper addresses can be filled in later,
4815 using the common block base address gotten from the assembler
4818 static struct pending *common_block;
4819 static int common_block_i;
4821 /* Name of the current common block. We get it from the BCOMM instead of the
4822 ECOMM to match IBM documentation (even though IBM puts the name both places
4823 like everyone else). */
4824 static char *common_block_name;
4826 /* Process a N_BCOMM symbol. The storage for NAME is not guaranteed
4827 to remain after this function returns. */
4830 common_block_start (name, objfile)
4832 struct objfile *objfile;
4834 if (common_block_name != NULL)
4836 static struct complaint msg =
4838 "Invalid symbol data: common block within common block",
4842 common_block = local_symbols;
4843 common_block_i = local_symbols ? local_symbols->nsyms : 0;
4844 common_block_name = obsavestring (name, strlen (name),
4845 &objfile->symbol_obstack);
4848 /* Process a N_ECOMM symbol. */
4851 common_block_end (objfile)
4852 struct objfile *objfile;
4854 /* Symbols declared since the BCOMM are to have the common block
4855 start address added in when we know it. common_block and
4856 common_block_i point to the first symbol after the BCOMM in
4857 the local_symbols list; copy the list and hang it off the
4858 symbol for the common block name for later fixup. */
4861 struct pending *new = 0;
4862 struct pending *next;
4865 if (common_block_name == NULL)
4867 static struct complaint msg =
4868 {"ECOMM symbol unmatched by BCOMM", 0, 0};
4873 sym = (struct symbol *)
4874 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
4875 memset (sym, 0, sizeof (struct symbol));
4876 /* Note: common_block_name already saved on symbol_obstack */
4877 SYMBOL_NAME (sym) = common_block_name;
4878 SYMBOL_CLASS (sym) = LOC_BLOCK;
4880 /* Now we copy all the symbols which have been defined since the BCOMM. */
4882 /* Copy all the struct pendings before common_block. */
4883 for (next = local_symbols;
4884 next != NULL && next != common_block;
4887 for (j = 0; j < next->nsyms; j++)
4888 add_symbol_to_list (next->symbol[j], &new);
4891 /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is
4892 NULL, it means copy all the local symbols (which we already did
4895 if (common_block != NULL)
4896 for (j = common_block_i; j < common_block->nsyms; j++)
4897 add_symbol_to_list (common_block->symbol[j], &new);
4899 SYMBOL_TYPE (sym) = (struct type *) new;
4901 /* Should we be putting local_symbols back to what it was?
4904 i = hashname (SYMBOL_NAME (sym));
4905 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
4906 global_sym_chain[i] = sym;
4907 common_block_name = NULL;
4910 /* Add a common block's start address to the offset of each symbol
4911 declared to be in it (by being between a BCOMM/ECOMM pair that uses
4912 the common block name). */
4915 fix_common_block (sym, valu)
4919 struct pending *next = (struct pending *) SYMBOL_TYPE (sym);
4920 for (; next; next = next->next)
4923 for (j = next->nsyms - 1; j >= 0; j--)
4924 SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu;
4930 /* What about types defined as forward references inside of a small lexical
4932 /* Add a type to the list of undefined types to be checked through
4933 once this file has been read in. */
4936 add_undefined_type (type)
4939 if (undef_types_length == undef_types_allocated)
4941 undef_types_allocated *= 2;
4942 undef_types = (struct type **)
4943 xrealloc ((char *) undef_types,
4944 undef_types_allocated * sizeof (struct type *));
4946 undef_types[undef_types_length++] = type;
4949 /* Go through each undefined type, see if it's still undefined, and fix it
4950 up if possible. We have two kinds of undefined types:
4952 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
4953 Fix: update array length using the element bounds
4954 and the target type's length.
4955 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
4956 yet defined at the time a pointer to it was made.
4957 Fix: Do a full lookup on the struct/union tag. */
4959 cleanup_undefined_types ()
4963 for (type = undef_types; type < undef_types + undef_types_length; type++)
4965 switch (TYPE_CODE (*type))
4968 case TYPE_CODE_STRUCT:
4969 case TYPE_CODE_UNION:
4970 case TYPE_CODE_ENUM:
4972 /* Check if it has been defined since. Need to do this here
4973 as well as in check_typedef to deal with the (legitimate in
4974 C though not C++) case of several types with the same name
4975 in different source files. */
4976 if (TYPE_FLAGS (*type) & TYPE_FLAG_STUB)
4978 struct pending *ppt;
4980 /* Name of the type, without "struct" or "union" */
4981 char *typename = TYPE_TAG_NAME (*type);
4983 if (typename == NULL)
4985 static struct complaint msg =
4986 {"need a type name", 0, 0};
4990 for (ppt = file_symbols; ppt; ppt = ppt->next)
4992 for (i = 0; i < ppt->nsyms; i++)
4994 struct symbol *sym = ppt->symbol[i];
4996 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
4997 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
4998 && (TYPE_CODE (SYMBOL_TYPE (sym)) ==
5000 && STREQ (SYMBOL_NAME (sym), typename))
5002 memcpy (*type, SYMBOL_TYPE (sym),
5003 sizeof (struct type));
5013 static struct complaint msg =
5015 GDB internal error. cleanup_undefined_types with bad type %d.", 0, 0};
5016 complain (&msg, TYPE_CODE (*type));
5022 undef_types_length = 0;
5025 /* Scan through all of the global symbols defined in the object file,
5026 assigning values to the debugging symbols that need to be assigned
5027 to. Get these symbols from the minimal symbol table. */
5030 scan_file_globals (objfile)
5031 struct objfile *objfile;
5034 struct minimal_symbol *msymbol;
5035 struct symbol *sym, *prev, *rsym;
5036 struct objfile *resolve_objfile;
5038 /* SVR4 based linkers copy referenced global symbols from shared
5039 libraries to the main executable.
5040 If we are scanning the symbols for a shared library, try to resolve
5041 them from the minimal symbols of the main executable first. */
5043 if (symfile_objfile && objfile != symfile_objfile)
5044 resolve_objfile = symfile_objfile;
5046 resolve_objfile = objfile;
5050 /* Avoid expensive loop through all minimal symbols if there are
5051 no unresolved symbols. */
5052 for (hash = 0; hash < HASHSIZE; hash++)
5054 if (global_sym_chain[hash])
5057 if (hash >= HASHSIZE)
5060 for (msymbol = resolve_objfile->msymbols;
5061 msymbol && SYMBOL_NAME (msymbol) != NULL;
5066 /* Skip static symbols. */
5067 switch (MSYMBOL_TYPE (msymbol))
5079 /* Get the hash index and check all the symbols
5080 under that hash index. */
5082 hash = hashname (SYMBOL_NAME (msymbol));
5084 for (sym = global_sym_chain[hash]; sym;)
5086 if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
5087 STREQ (SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
5090 struct alias_list *aliases;
5092 /* Splice this symbol out of the hash chain and
5093 assign the value we have to it. */
5096 SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
5100 global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
5103 /* Check to see whether we need to fix up a common block. */
5104 /* Note: this code might be executed several times for
5105 the same symbol if there are multiple references. */
5107 /* If symbol has aliases, do minimal symbol fixups for each.
5108 These live aliases/references weren't added to
5109 global_sym_chain hash but may also need to be fixed up. */
5110 /* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal
5111 symbols? Still, we wouldn't want to add_to_list. */
5112 /* Now do the same for each alias of this symbol */
5114 aliases = SYMBOL_ALIASES (sym);
5117 if (SYMBOL_CLASS (rsym) == LOC_BLOCK)
5119 fix_common_block (rsym,
5120 SYMBOL_VALUE_ADDRESS (msymbol));
5124 SYMBOL_VALUE_ADDRESS (rsym)
5125 = SYMBOL_VALUE_ADDRESS (msymbol);
5127 SYMBOL_SECTION (rsym) = SYMBOL_SECTION (msymbol);
5130 rsym = aliases->sym;
5131 aliases = aliases->next;
5140 sym = SYMBOL_VALUE_CHAIN (prev);
5144 sym = global_sym_chain[hash];
5150 sym = SYMBOL_VALUE_CHAIN (sym);
5154 if (resolve_objfile == objfile)
5156 resolve_objfile = objfile;
5159 /* Change the storage class of any remaining unresolved globals to
5160 LOC_UNRESOLVED and remove them from the chain. */
5161 for (hash = 0; hash < HASHSIZE; hash++)
5163 sym = global_sym_chain[hash];
5167 sym = SYMBOL_VALUE_CHAIN (sym);
5169 /* Change the symbol address from the misleading chain value
5171 SYMBOL_VALUE_ADDRESS (prev) = 0;
5173 /* Complain about unresolved common block symbols. */
5174 if (SYMBOL_CLASS (prev) == LOC_STATIC)
5175 SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
5177 complain (&unresolved_sym_chain_complaint,
5178 objfile->name, SYMBOL_NAME (prev));
5181 memset (global_sym_chain, 0, sizeof (global_sym_chain));
5184 /* Initialize anything that needs initializing when starting to read
5185 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
5193 /* Initialize anything that needs initializing when a completely new
5194 symbol file is specified (not just adding some symbols from another
5195 file, e.g. a shared library). */
5198 stabsread_new_init ()
5200 /* Empty the hash table of global syms looking for values. */
5201 memset (global_sym_chain, 0, sizeof (global_sym_chain));
5204 /* Initialize anything that needs initializing at the same time as
5205 start_symtab() is called. */
5210 global_stabs = NULL; /* AIX COFF */
5211 /* Leave FILENUM of 0 free for builtin types and this file's types. */
5212 n_this_object_header_files = 1;
5213 type_vector_length = 0;
5214 type_vector = (struct type **) 0;
5216 /* FIXME: If common_block_name is not already NULL, we should complain(). */
5217 common_block_name = NULL;
5222 /* Call after end_symtab() */
5229 free ((char *) type_vector);
5232 type_vector_length = 0;
5233 previous_stab_code = 0;
5237 finish_global_stabs (objfile)
5238 struct objfile *objfile;
5242 patch_block_stabs (global_symbols, global_stabs, objfile);
5243 free ((PTR) global_stabs);
5244 global_stabs = NULL;
5248 /* Initializer for this module */
5251 _initialize_stabsread ()
5253 undef_types_allocated = 20;
5254 undef_types_length = 0;
5255 undef_types = (struct type **)
5256 xmalloc (undef_types_allocated * sizeof (struct type *));