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 PARAMS ((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 PARAMS ((struct field_info *, char **, char *,
86 struct type *, struct objfile *));
89 get_substring PARAMS ((char **, int));
92 dbx_alloc_type PARAMS ((int[2], struct objfile *));
94 static long read_huge_number PARAMS ((char **, int, int *));
96 static struct type *error_type PARAMS ((char **, struct objfile *));
99 patch_block_stabs PARAMS ((struct pending *, struct pending_stabs *,
103 fix_common_block PARAMS ((struct symbol *, int));
106 read_type_number PARAMS ((char **, int *));
109 read_range_type PARAMS ((char **, int[2], struct objfile *));
112 read_sun_builtin_type PARAMS ((char **, int[2], struct objfile *));
115 read_sun_floating_type PARAMS ((char **, int[2], struct objfile *));
118 read_enum_type PARAMS ((char **, struct type *, struct objfile *));
121 rs6000_builtin_type PARAMS ((int));
124 read_member_functions PARAMS ((struct field_info *, char **, struct type *,
128 read_struct_fields PARAMS ((struct field_info *, char **, struct type *,
132 read_baseclasses PARAMS ((struct field_info *, char **, struct type *,
136 read_tilde_fields PARAMS ((struct field_info *, char **, struct type *,
140 attach_fn_fields_to_type PARAMS ((struct field_info *, struct type *));
143 attach_fields_to_type PARAMS ((struct field_info *, struct type *,
147 read_struct_type PARAMS ((char **, struct type *, struct objfile *));
150 read_array_type PARAMS ((char **, struct type *, struct objfile *));
152 static struct type **
153 read_args PARAMS ((char **, int, struct objfile *));
156 read_cpp_abbrev PARAMS ((struct field_info *, char **, struct type *,
159 /* new functions added for cfront support */
162 copy_cfront_struct_fields PARAMS ((struct field_info *, struct type *,
166 get_cfront_method_physname PARAMS ((char *));
169 read_cfront_baseclasses PARAMS ((struct field_info *, char **,
170 struct type *, struct objfile *));
173 read_cfront_static_fields PARAMS ((struct field_info *, char **,
174 struct type *, struct objfile *));
176 read_cfront_member_functions PARAMS ((struct field_info *, char **,
177 struct type *, struct objfile *));
179 /* end new functions added for cfront support */
182 add_live_range PARAMS ((struct objfile *, struct symbol *,
183 CORE_ADDR, CORE_ADDR));
186 resolve_live_range PARAMS ((struct objfile *, struct symbol *, char *));
189 process_reference PARAMS ((char **string));
192 ref_search_value PARAMS ((int refnum));
195 resolve_symbol_reference PARAMS ((struct objfile *, struct symbol *, char *));
197 static const char vptr_name[] =
198 {'_', 'v', 'p', 't', 'r', CPLUS_MARKER, '\0'};
199 static const char vb_name[] =
200 {'_', 'v', 'b', CPLUS_MARKER, '\0'};
202 /* Define this as 1 if a pcc declaration of a char or short argument
203 gives the correct address. Otherwise assume pcc gives the
204 address of the corresponding int, which is not the same on a
205 big-endian machine. */
207 #if !defined (BELIEVE_PCC_PROMOTION)
208 #define BELIEVE_PCC_PROMOTION 0
210 #if !defined (BELIEVE_PCC_PROMOTION_TYPE)
211 #define BELIEVE_PCC_PROMOTION_TYPE 0
214 static struct complaint invalid_cpp_abbrev_complaint =
215 {"invalid C++ abbreviation `%s'", 0, 0};
217 static struct complaint invalid_cpp_type_complaint =
218 {"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
220 static struct complaint member_fn_complaint =
221 {"member function type missing, got '%c'", 0, 0};
223 static struct complaint const_vol_complaint =
224 {"const/volatile indicator missing, got '%c'", 0, 0};
226 static struct complaint error_type_complaint =
227 {"debug info mismatch between compiler and debugger", 0, 0};
229 static struct complaint invalid_member_complaint =
230 {"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
232 static struct complaint range_type_base_complaint =
233 {"base type %d of range type is not defined", 0, 0};
235 static struct complaint reg_value_complaint =
236 {"register number %d too large (max %d) in symbol %s", 0, 0};
238 static struct complaint vtbl_notfound_complaint =
239 {"virtual function table pointer not found when defining class `%s'", 0, 0};
241 static struct complaint unrecognized_cplus_name_complaint =
242 {"Unknown C++ symbol name `%s'", 0, 0};
244 static struct complaint rs6000_builtin_complaint =
245 {"Unknown builtin type %d", 0, 0};
247 static struct complaint unresolved_sym_chain_complaint =
248 {"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
250 static struct complaint stabs_general_complaint =
253 static struct complaint lrs_general_complaint =
256 /* Make a list of forward references which haven't been defined. */
258 static struct type **undef_types;
259 static int undef_types_allocated;
260 static int undef_types_length;
261 static struct symbol *current_symbol = NULL;
263 /* Check for and handle cretinous stabs symbol name continuation! */
264 #define STABS_CONTINUE(pp,objfile) \
266 if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
267 *(pp) = next_symbol_text (objfile); \
270 /* FIXME: These probably should be our own types (like rs6000_builtin_type
271 has its own types) rather than builtin_type_*. */
272 static struct type **os9k_type_vector[] =
279 &builtin_type_unsigned_char,
280 &builtin_type_unsigned_short,
281 &builtin_type_unsigned_long,
282 &builtin_type_unsigned_int,
284 &builtin_type_double,
286 &builtin_type_long_double
289 static void os9k_init_type_vector PARAMS ((struct type **));
292 os9k_init_type_vector (tv)
296 for (i = 0; i < sizeof (os9k_type_vector) / sizeof (struct type **); i++)
297 tv[i] = (os9k_type_vector[i] == 0 ? 0 : *(os9k_type_vector[i]));
300 /* Look up a dbx type-number pair. Return the address of the slot
301 where the type for that number-pair is stored.
302 The number-pair is in TYPENUMS.
304 This can be used for finding the type associated with that pair
305 or for associating a new type with the pair. */
308 dbx_lookup_type (typenums)
311 register int filenum = typenums[0];
312 register int index = typenums[1];
314 register int real_filenum;
315 register struct header_file *f;
318 if (filenum == -1) /* -1,-1 is for temporary types. */
321 if (filenum < 0 || filenum >= n_this_object_header_files)
323 static struct complaint msg =
325 Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
327 complain (&msg, filenum, index, symnum);
335 /* Caller wants address of address of type. We think
336 that negative (rs6k builtin) types will never appear as
337 "lvalues", (nor should they), so we stuff the real type
338 pointer into a temp, and return its address. If referenced,
339 this will do the right thing. */
340 static struct type *temp_type;
342 temp_type = rs6000_builtin_type (index);
346 /* Type is defined outside of header files.
347 Find it in this object file's type vector. */
348 if (index >= type_vector_length)
350 old_len = type_vector_length;
353 type_vector_length = INITIAL_TYPE_VECTOR_LENGTH;
354 type_vector = (struct type **)
355 xmalloc (type_vector_length * sizeof (struct type *));
357 while (index >= type_vector_length)
359 type_vector_length *= 2;
361 type_vector = (struct type **)
362 xrealloc ((char *) type_vector,
363 (type_vector_length * sizeof (struct type *)));
364 memset (&type_vector[old_len], 0,
365 (type_vector_length - old_len) * sizeof (struct type *));
368 /* Deal with OS9000 fundamental types. */
369 os9k_init_type_vector (type_vector);
371 return (&type_vector[index]);
375 real_filenum = this_object_header_files[filenum];
377 if (real_filenum >= N_HEADER_FILES (current_objfile))
379 struct type *temp_type;
380 struct type **temp_type_p;
382 warning ("GDB internal error: bad real_filenum");
385 temp_type = init_type (TYPE_CODE_ERROR, 0, 0, NULL, NULL);
386 temp_type_p = (struct type **) xmalloc (sizeof (struct type *));
387 *temp_type_p = temp_type;
391 f = HEADER_FILES (current_objfile) + real_filenum;
393 f_orig_length = f->length;
394 if (index >= f_orig_length)
396 while (index >= f->length)
400 f->vector = (struct type **)
401 xrealloc ((char *) f->vector, f->length * sizeof (struct type *));
402 memset (&f->vector[f_orig_length], 0,
403 (f->length - f_orig_length) * sizeof (struct type *));
405 return (&f->vector[index]);
409 /* Make sure there is a type allocated for type numbers TYPENUMS
410 and return the type object.
411 This can create an empty (zeroed) type object.
412 TYPENUMS may be (-1, -1) to return a new type object that is not
413 put into the type vector, and so may not be referred to by number. */
416 dbx_alloc_type (typenums, objfile)
418 struct objfile *objfile;
420 register struct type **type_addr;
422 if (typenums[0] == -1)
424 return (alloc_type (objfile));
427 type_addr = dbx_lookup_type (typenums);
429 /* If we are referring to a type not known at all yet,
430 allocate an empty type for it.
431 We will fill it in later if we find out how. */
434 *type_addr = alloc_type (objfile);
440 /* for all the stabs in a given stab vector, build appropriate types
441 and fix their symbols in given symbol vector. */
444 patch_block_stabs (symbols, stabs, objfile)
445 struct pending *symbols;
446 struct pending_stabs *stabs;
447 struct objfile *objfile;
457 /* for all the stab entries, find their corresponding symbols and
458 patch their types! */
460 for (ii = 0; ii < stabs->count; ++ii)
462 name = stabs->stab[ii];
463 pp = (char *) strchr (name, ':');
467 pp = (char *) strchr (pp, ':');
469 sym = find_symbol_in_list (symbols, name, pp - name);
472 /* FIXME-maybe: it would be nice if we noticed whether
473 the variable was defined *anywhere*, not just whether
474 it is defined in this compilation unit. But neither
475 xlc or GCC seem to need such a definition, and until
476 we do psymtabs (so that the minimal symbols from all
477 compilation units are available now), I'm not sure
478 how to get the information. */
480 /* On xcoff, if a global is defined and never referenced,
481 ld will remove it from the executable. There is then
482 a N_GSYM stab for it, but no regular (C_EXT) symbol. */
483 sym = (struct symbol *)
484 obstack_alloc (&objfile->symbol_obstack,
485 sizeof (struct symbol));
487 memset (sym, 0, sizeof (struct symbol));
488 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
489 SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
491 obsavestring (name, pp - name, &objfile->symbol_obstack);
493 if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
495 /* I don't think the linker does this with functions,
496 so as far as I know this is never executed.
497 But it doesn't hurt to check. */
499 lookup_function_type (read_type (&pp, objfile));
503 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
505 add_symbol_to_list (sym, &global_symbols);
510 if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
513 lookup_function_type (read_type (&pp, objfile));
517 SYMBOL_TYPE (sym) = read_type (&pp, objfile);
525 /* Read a number by which a type is referred to in dbx data,
526 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
527 Just a single number N is equivalent to (0,N).
528 Return the two numbers by storing them in the vector TYPENUMS.
529 TYPENUMS will then be used as an argument to dbx_lookup_type.
531 Returns 0 for success, -1 for error. */
534 read_type_number (pp, typenums)
536 register int *typenums;
542 typenums[0] = read_huge_number (pp, ',', &nbits);
545 typenums[1] = read_huge_number (pp, ')', &nbits);
552 typenums[1] = read_huge_number (pp, 0, &nbits);
560 #if !defined (REG_STRUCT_HAS_ADDR)
561 #define REG_STRUCT_HAS_ADDR(gcc_p,type) 0
564 #define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
565 #define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
566 #define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
567 #define VISIBILITY_IGNORE '9' /* Optimized out or zero length */
569 #define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */
570 #define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */
572 /* This code added to support parsing of ARM/Cfront stabs strings */
574 /* Get substring from string up to char c, advance string pointer past
595 /* Physname gets strcat'd onto sname in order to recreate the mangled
596 name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
597 the physname look like that of g++ - take out the initial mangling
598 eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
601 get_cfront_method_physname (fname)
605 /* FIXME would like to make this generic for g++ too, but
606 that is already handled in read_member_funcctions */
609 /* search ahead to find the start of the mangled suffix */
610 if (*p == '_' && *(p + 1) == '_') /* compiler generated; probably a ctor/dtor */
612 while (p && (unsigned) ((p + 1) - fname) < strlen (fname) && *(p + 1) != '_')
614 if (!(p && *p == '_' && *(p + 1) == '_'))
615 error ("Invalid mangled function name %s", fname);
616 p += 2; /* advance past '__' */
618 /* struct name length and name of type should come next; advance past it */
621 len = len * 10 + (*p - '0');
629 /* Read base classes within cfront class definition.
630 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
633 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
638 read_cfront_baseclasses (fip, pp, type, objfile)
639 struct field_info *fip;
640 struct objfile *objfile;
644 static struct complaint msg_unknown =
646 Unsupported token in stabs string %s.\n",
648 static struct complaint msg_notfound =
650 Unable to find base type for %s.\n",
655 struct nextfield *new;
657 if (**pp == ';') /* no base classes; return */
663 /* first count base classes so we can allocate space before parsing */
664 for (p = *pp; p && *p && *p != ';'; p++)
669 bnum++; /* add one more for last one */
671 /* now parse the base classes until we get to the start of the methods
672 (code extracted and munged from read_baseclasses) */
673 ALLOCATE_CPLUS_STRUCT_TYPE (type);
674 TYPE_N_BASECLASSES (type) = bnum;
678 int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
681 pointer = (char *) TYPE_ALLOC (type, num_bytes);
682 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
684 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
686 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
688 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
689 make_cleanup (free, new);
690 memset (new, 0, sizeof (struct nextfield));
691 new->next = fip->list;
693 FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
695 STABS_CONTINUE (pp, objfile);
697 /* virtual? eg: v2@Bvir */
700 SET_TYPE_FIELD_VIRTUAL (type, i);
704 /* access? eg: 2@Bvir */
705 /* Note: protected inheritance not supported in cfront */
708 case CFRONT_VISIBILITY_PRIVATE:
709 new->visibility = VISIBILITY_PRIVATE;
711 case CFRONT_VISIBILITY_PUBLIC:
712 new->visibility = VISIBILITY_PUBLIC;
715 /* Bad visibility format. Complain and treat it as
718 static struct complaint msg =
720 "Unknown visibility `%c' for baseclass", 0, 0};
721 complain (&msg, new->visibility);
722 new->visibility = VISIBILITY_PUBLIC;
726 /* "@" comes next - eg: @Bvir */
729 complain (&msg_unknown, *pp);
735 /* Set the bit offset of the portion of the object corresponding
736 to this baseclass. Always zero in the absence of
737 multiple inheritance. */
738 /* Unable to read bit position from stabs;
739 Assuming no multiple inheritance for now FIXME! */
740 /* We may have read this in the structure definition;
741 now we should fixup the members to be the actual base classes */
742 FIELD_BITPOS (new->field) = 0;
744 /* Get the base class name and type */
746 char *bname; /* base class name */
747 struct symbol *bsym; /* base class */
749 p1 = strchr (*pp, ' ');
750 p2 = strchr (*pp, ';');
752 bname = get_substring (pp, ' ');
754 bname = get_substring (pp, ';');
755 if (!bname || !*bname)
757 complain (&msg_unknown, *pp);
760 /* FIXME! attach base info to type */
761 bsym = lookup_symbol (bname, 0, STRUCT_NAMESPACE, 0, 0); /*demangled_name */
764 new->field.type = SYMBOL_TYPE (bsym);
765 new->field.name = type_name_no_tag (new->field.type);
769 complain (&msg_notfound, *pp);
774 /* If more base classes to parse, loop again.
775 We ate the last ' ' or ';' in get_substring,
776 so on exit we will have skipped the trailing ';' */
777 /* if invalid, return 0; add code to detect - FIXME! */
782 /* read cfront member functions.
783 pp points to string starting with list of functions
784 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
785 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
786 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
787 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
791 read_cfront_member_functions (fip, pp, type, objfile)
792 struct field_info *fip;
795 struct objfile *objfile;
797 /* This code extracted from read_member_functions
798 so as to do the similar thing for our funcs */
802 /* Total number of member functions defined in this class. If the class
803 defines two `f' functions, and one `g' function, then this will have
805 int total_length = 0;
809 struct next_fnfield *next;
810 struct fn_field fn_field;
813 struct type *look_ahead_type;
814 struct next_fnfieldlist *new_fnlist;
815 struct next_fnfield *new_sublist;
818 struct symbol *ref_func = 0;
820 /* Process each list until we find the end of the member functions.
821 eg: p = "__ct__1AFv foo__1AFv ;;;" */
823 STABS_CONTINUE (pp, objfile); /* handle \\ */
825 while (**pp != ';' && (fname = get_substring (pp, ' '), fname))
828 int sublist_count = 0;
830 if (fname[0] == '*') /* static member */
836 ref_func = lookup_symbol (fname, 0, VAR_NAMESPACE, 0, 0); /* demangled name */
839 static struct complaint msg =
841 Unable to find function symbol for %s\n",
843 complain (&msg, fname);
847 look_ahead_type = NULL;
850 new_fnlist = (struct next_fnfieldlist *)
851 xmalloc (sizeof (struct next_fnfieldlist));
852 make_cleanup (free, new_fnlist);
853 memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
855 /* The following is code to work around cfront generated stabs.
856 The stabs contains full mangled name for each field.
857 We try to demangle the name and extract the field name out of it. */
859 char *dem, *dem_p, *dem_args;
861 dem = cplus_demangle (fname, DMGL_ANSI | DMGL_PARAMS);
864 dem_p = strrchr (dem, ':');
865 if (dem_p != 0 && *(dem_p - 1) == ':')
867 /* get rid of args */
868 dem_args = strchr (dem_p, '(');
869 if (dem_args == NULL)
870 dem_len = strlen (dem_p);
872 dem_len = dem_args - dem_p;
874 obsavestring (dem_p, dem_len, &objfile->type_obstack);
879 obsavestring (fname, strlen (fname), &objfile->type_obstack);
881 } /* end of code for cfront work around */
883 new_fnlist->fn_fieldlist.name = main_fn_name;
885 /*-------------------------------------------------*/
886 /* Set up the sublists
887 Sublists are stuff like args, static, visibility, etc.
888 so in ARM, we have to set that info some other way.
889 Multiple sublists happen if overloading
890 eg: foo::26=##1;:;2A.;
891 In g++, we'd loop here thru all the sublists... */
894 (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
895 make_cleanup (free, new_sublist);
896 memset (new_sublist, 0, sizeof (struct next_fnfield));
898 /* eat 1; from :;2A.; */
899 new_sublist->fn_field.type = SYMBOL_TYPE (ref_func); /* normally takes a read_type */
900 /* Make this type look like a method stub for gdb */
901 TYPE_FLAGS (new_sublist->fn_field.type) |= TYPE_FLAG_STUB;
902 TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD;
904 /* If this is just a stub, then we don't have the real name here. */
905 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
907 if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
908 TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
909 new_sublist->fn_field.is_stub = 1;
912 /* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i
913 physname gets strcat'd in order to recreate the onto mangled name */
914 pname = get_cfront_method_physname (fname);
915 new_sublist->fn_field.physname = savestring (pname, strlen (pname));
918 /* Set this member function's visibility fields.
919 Unable to distinguish access from stabs definition!
920 Assuming public for now. FIXME!
921 (for private, set new_sublist->fn_field.is_private = 1,
922 for public, set new_sublist->fn_field.is_protected = 1) */
924 /* Unable to distinguish const/volatile from stabs definition!
925 Assuming normal for now. FIXME! */
927 new_sublist->fn_field.is_const = 0;
928 new_sublist->fn_field.is_volatile = 0; /* volatile not implemented in cfront */
930 /* Set virtual/static function info
931 How to get vtable offsets ?
932 Assuming normal for now FIXME!!
933 For vtables, figure out from whence this virtual function came.
934 It may belong to virtual function table of
935 one of its baseclasses.
937 new_sublist -> fn_field.voffset = vtable offset,
938 new_sublist -> fn_field.fcontext = look_ahead_type;
939 where look_ahead_type is type of baseclass */
941 new_sublist->fn_field.voffset = VOFFSET_STATIC;
942 else /* normal member function. */
943 new_sublist->fn_field.voffset = 0;
944 new_sublist->fn_field.fcontext = 0;
947 /* Prepare new sublist */
948 new_sublist->next = sublist;
949 sublist = new_sublist;
952 /* In g++, we loop thu sublists - now we set from functions. */
953 new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
954 obstack_alloc (&objfile->type_obstack,
955 sizeof (struct fn_field) * length);
956 memset (new_fnlist->fn_fieldlist.fn_fields, 0,
957 sizeof (struct fn_field) * length);
958 for (i = length; (i--, sublist); sublist = sublist->next)
960 new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
963 new_fnlist->fn_fieldlist.length = length;
964 new_fnlist->next = fip->fnlist;
965 fip->fnlist = new_fnlist;
967 total_length += length;
968 STABS_CONTINUE (pp, objfile); /* handle \\ */
973 /* type should already have space */
974 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
975 TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
976 memset (TYPE_FN_FIELDLISTS (type), 0,
977 sizeof (struct fn_fieldlist) * nfn_fields);
978 TYPE_NFN_FIELDS (type) = nfn_fields;
979 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
982 /* end of scope for reading member func */
986 /* Skip trailing ';' and bump count of number of fields seen */
994 /* This routine fixes up partial cfront types that were created
995 while parsing the stabs. The main need for this function is
996 to add information such as methods to classes.
997 Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */
999 resolve_cfront_continuation (objfile, sym, p)
1000 struct objfile *objfile;
1004 struct symbol *ref_sym = 0;
1006 /* snarfed from read_struct_type */
1007 struct field_info fi;
1009 struct cleanup *back_to;
1011 /* Need to make sure that fi isn't gunna conflict with struct
1012 in case struct already had some fnfs */
1015 back_to = make_cleanup (null_cleanup, 0);
1017 /* We only accept structs, classes and unions at the moment.
1018 Other continuation types include t (typedef), r (long dbl), ...
1019 We may want to add support for them as well;
1020 right now they are handled by duplicating the symbol information
1021 into the type information (see define_symbol) */
1022 if (*p != 's' /* structs */
1023 && *p != 'c' /* class */
1024 && *p != 'u') /* union */
1025 return 0; /* only handle C++ types */
1028 /* Get symbol typs name and validate
1029 eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */
1030 sname = get_substring (&p, ';');
1031 if (!sname || strcmp (sname, SYMBOL_NAME (sym)))
1032 error ("Internal error: base symbol type name does not match\n");
1034 /* Find symbol's internal gdb reference using demangled_name.
1035 This is the real sym that we want;
1036 sym was a temp hack to make debugger happy */
1037 ref_sym = lookup_symbol (SYMBOL_NAME (sym), 0, STRUCT_NAMESPACE, 0, 0);
1038 type = SYMBOL_TYPE (ref_sym);
1041 /* Now read the baseclasses, if any, read the regular C struct or C++
1042 class member fields, attach the fields to the type, read the C++
1043 member functions, attach them to the type, and then read any tilde
1044 field (baseclass specifier for the class holding the main vtable). */
1046 if (!read_cfront_baseclasses (&fi, &p, type, objfile)
1047 /* g++ does this next, but cfront already did this:
1048 || !read_struct_fields (&fi, &p, type, objfile) */
1049 || !copy_cfront_struct_fields (&fi, type, objfile)
1050 || !read_cfront_member_functions (&fi, &p, type, objfile)
1051 || !read_cfront_static_fields (&fi, &p, type, objfile)
1052 || !attach_fields_to_type (&fi, type, objfile)
1053 || !attach_fn_fields_to_type (&fi, type)
1054 /* g++ does this next, but cfront doesn't seem to have this:
1055 || !read_tilde_fields (&fi, &p, type, objfile) */
1058 type = error_type (&p, objfile);
1061 do_cleanups (back_to);
1064 /* End of code added to support parsing of ARM/Cfront stabs strings */
1067 /* This routine fixes up symbol references/aliases to point to the original
1068 symbol definition. Returns 0 on failure, non-zero on success. */
1071 resolve_symbol_reference (objfile, sym, p)
1072 struct objfile *objfile;
1077 struct symbol *ref_sym = 0;
1078 struct alias_list *alias;
1080 /* If this is not a symbol reference return now. */
1084 /* Use "#<num>" as the name; we'll fix the name later.
1085 We stored the original symbol name as "#<id>=<name>"
1086 so we can now search for "#<id>" to resolving the reference.
1087 We'll fix the names later by removing the "#<id>" or "#<id>=" */
1089 /*---------------------------------------------------------*/
1090 /* Get the reference id number, and
1091 advance p past the names so we can parse the rest.
1092 eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */
1093 /*---------------------------------------------------------*/
1095 /* This gets reference name from string. sym may not have a name. */
1097 /* Get the reference number associated with the reference id in the
1098 gdb stab string. From that reference number, get the main/primary
1099 symbol for this alias. */
1100 refnum = process_reference (&p);
1101 ref_sym = ref_search (refnum);
1104 complain (&lrs_general_complaint, "symbol for reference not found");
1108 /* Parse the stab of the referencing symbol
1109 now that we have the referenced symbol.
1110 Add it as a new symbol and a link back to the referenced symbol.
1111 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1114 /* If the stab symbol table and string contain:
1115 RSYM 0 5 00000000 868 #15=z:r(0,1)
1116 LBRAC 0 0 00000000 899 #5=
1117 SLINE 0 16 00000003 923 #6=
1118 Then the same symbols can be later referenced by:
1119 RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6)
1120 This is used in live range splitting to:
1121 1) specify that a symbol (#15) is actually just a new storage
1122 class for a symbol (#15=z) which was previously defined.
1123 2) specify that the beginning and ending ranges for a symbol
1124 (#15) are the values of the beginning (#5) and ending (#6)
1127 /* Read number as reference id.
1128 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1129 /* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
1130 in case of "l(0,0)"? */
1132 /*--------------------------------------------------*/
1133 /* Add this symbol to the reference list. */
1134 /*--------------------------------------------------*/
1136 alias = (struct alias_list *) obstack_alloc (&objfile->type_obstack,
1137 sizeof (struct alias_list));
1140 complain (&lrs_general_complaint, "Unable to allocate alias list memory");
1147 if (!SYMBOL_ALIASES (ref_sym))
1149 SYMBOL_ALIASES (ref_sym) = alias;
1153 struct alias_list *temp;
1155 /* Get to the end of the list. */
1156 for (temp = SYMBOL_ALIASES (ref_sym);
1163 /* Want to fix up name so that other functions (eg. valops)
1164 will correctly print the name.
1165 Don't add_symbol_to_list so that lookup_symbol won't find it.
1166 nope... needed for fixups. */
1167 SYMBOL_NAME (sym) = SYMBOL_NAME (ref_sym);
1173 /* Structure for storing pointers to reference definitions for fast lookup
1174 during "process_later". */
1183 #define MAX_CHUNK_REFS 100
1184 #define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map))
1185 #define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE)
1187 static struct ref_map *ref_map;
1189 /* Ptr to free cell in chunk's linked list. */
1190 static int ref_count = 0;
1192 /* Number of chunks malloced. */
1193 static int ref_chunk = 0;
1195 /* Create array of pointers mapping refids to symbols and stab strings.
1196 Add pointers to reference definition symbols and/or their values as we
1197 find them, using their reference numbers as our index.
1198 These will be used later when we resolve references. */
1200 ref_add (refnum, sym, stabs, value)
1208 if (refnum >= ref_count)
1209 ref_count = refnum + 1;
1210 if (ref_count > ref_chunk * MAX_CHUNK_REFS)
1212 int new_slots = ref_count - ref_chunk * MAX_CHUNK_REFS;
1213 int new_chunks = new_slots / MAX_CHUNK_REFS + 1;
1214 ref_map = (struct ref_map *)
1215 xrealloc (ref_map, REF_MAP_SIZE (ref_chunk + new_chunks));
1216 memset (ref_map + ref_chunk * MAX_CHUNK_REFS, 0, new_chunks * REF_CHUNK_SIZE);
1217 ref_chunk += new_chunks;
1219 ref_map[refnum].stabs = stabs;
1220 ref_map[refnum].sym = sym;
1221 ref_map[refnum].value = value;
1224 /* Return defined sym for the reference REFNUM. */
1229 if (refnum < 0 || refnum > ref_count)
1231 return ref_map[refnum].sym;
1234 /* Return value for the reference REFNUM. */
1237 ref_search_value (refnum)
1240 if (refnum < 0 || refnum > ref_count)
1242 return ref_map[refnum].value;
1245 /* Parse a reference id in STRING and return the resulting
1246 reference number. Move STRING beyond the reference id. */
1249 process_reference (string)
1255 if (**string != '#')
1258 /* Advance beyond the initial '#'. */
1261 /* Read number as reference id. */
1262 while (*p && isdigit (*p))
1264 refnum = refnum * 10 + *p - '0';
1271 /* If STRING defines a reference, store away a pointer to the reference
1272 definition for later use. Return the reference number. */
1275 symbol_reference_defined (string)
1281 refnum = process_reference (&p);
1283 /* Defining symbols end in '=' */
1286 /* Symbol is being defined here. */
1292 /* Must be a reference. Either the symbol has already been defined,
1293 or this is a forward reference to it. */
1301 define_symbol (valu, string, desc, type, objfile)
1306 struct objfile *objfile;
1308 register struct symbol *sym;
1309 char *p = (char *) strchr (string, ':');
1314 /* We would like to eliminate nameless symbols, but keep their types.
1315 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1316 to type 2, but, should not create a symbol to address that type. Since
1317 the symbol will be nameless, there is no way any user can refer to it. */
1321 /* Ignore syms with empty names. */
1325 /* Ignore old-style symbols from cc -go */
1332 p = strchr (p, ':');
1335 /* If a nameless stab entry, all we need is the type, not the symbol.
1336 e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
1337 nameless = (p == string || ((string[0] == ' ') && (string[1] == ':')));
1339 current_symbol = sym = (struct symbol *)
1340 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
1341 memset (sym, 0, sizeof (struct symbol));
1343 switch (type & N_TYPE)
1346 SYMBOL_SECTION (sym) = SECT_OFF_TEXT;
1349 SYMBOL_SECTION (sym) = SECT_OFF_DATA;
1352 SYMBOL_SECTION (sym) = SECT_OFF_BSS;
1356 if (processing_gcc_compilation)
1358 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1359 number of bytes occupied by a type or object, which we ignore. */
1360 SYMBOL_LINE (sym) = desc;
1364 SYMBOL_LINE (sym) = 0; /* unknown */
1367 if (is_cplus_marker (string[0]))
1369 /* Special GNU C++ names. */
1373 SYMBOL_NAME (sym) = obsavestring ("this", strlen ("this"),
1374 &objfile->symbol_obstack);
1377 case 'v': /* $vtbl_ptr_type */
1378 /* Was: SYMBOL_NAME (sym) = "vptr"; */
1382 SYMBOL_NAME (sym) = obsavestring ("eh_throw", strlen ("eh_throw"),
1383 &objfile->symbol_obstack);
1387 /* This was an anonymous type that was never fixed up. */
1390 #ifdef STATIC_TRANSFORM_NAME
1392 /* SunPRO (3.0 at least) static variable encoding. */
1397 complain (&unrecognized_cplus_name_complaint, string);
1398 goto normal; /* Do *something* with it */
1401 else if (string[0] == '#')
1403 /* Special GNU C extension for referencing symbols. */
1407 /* If STRING defines a new reference id, then add it to the
1408 reference map. Else it must be referring to a previously
1409 defined symbol, so add it to the alias list of the previously
1412 refnum = symbol_reference_defined (&s);
1414 ref_add (refnum, sym, string, SYMBOL_VALUE (sym));
1415 else if (!resolve_symbol_reference (objfile, sym, string))
1418 /* S..P contains the name of the symbol. We need to store
1419 the correct name into SYMBOL_NAME. */
1425 SYMBOL_NAME (sym) = (char *)
1426 obstack_alloc (&objfile->symbol_obstack, nlen);
1427 strncpy (SYMBOL_NAME (sym), s, nlen);
1428 SYMBOL_NAME (sym)[nlen] = '\0';
1429 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1432 /* FIXME! Want SYMBOL_NAME (sym) = 0;
1433 Get error if leave name 0. So give it something. */
1436 SYMBOL_NAME (sym) = (char *)
1437 obstack_alloc (&objfile->symbol_obstack, nlen);
1438 strncpy (SYMBOL_NAME (sym), string, nlen);
1439 SYMBOL_NAME (sym)[nlen] = '\0';
1440 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1443 /* Advance STRING beyond the reference id. */
1449 SYMBOL_LANGUAGE (sym) = current_subfile->language;
1450 SYMBOL_NAME (sym) = (char *)
1451 obstack_alloc (&objfile->symbol_obstack, ((p - string) + 1));
1452 /* Open-coded memcpy--saves function call time. */
1453 /* FIXME: Does it really? Try replacing with simple strcpy and
1454 try it on an executable with a large symbol table. */
1455 /* FIXME: considering that gcc can open code memcpy anyway, I
1456 doubt it. xoxorich. */
1458 register char *p1 = string;
1459 register char *p2 = SYMBOL_NAME (sym);
1467 /* If this symbol is from a C++ compilation, then attempt to cache the
1468 demangled form for future reference. This is a typical time versus
1469 space tradeoff, that was decided in favor of time because it sped up
1470 C++ symbol lookups by a factor of about 20. */
1472 SYMBOL_INIT_DEMANGLED_NAME (sym, &objfile->symbol_obstack);
1476 /* Determine the type of name being defined. */
1478 /* Getting GDB to correctly skip the symbol on an undefined symbol
1479 descriptor and not ever dump core is a very dodgy proposition if
1480 we do things this way. I say the acorn RISC machine can just
1481 fix their compiler. */
1482 /* The Acorn RISC machine's compiler can put out locals that don't
1483 start with "234=" or "(3,4)=", so assume anything other than the
1484 deftypes we know how to handle is a local. */
1485 if (!strchr ("cfFGpPrStTvVXCR", *p))
1487 if (isdigit (*p) || *p == '(' || *p == '-')
1496 /* c is a special case, not followed by a type-number.
1497 SYMBOL:c=iVALUE for an integer constant symbol.
1498 SYMBOL:c=rVALUE for a floating constant symbol.
1499 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1500 e.g. "b:c=e6,0" for "const b = blob1"
1501 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1504 SYMBOL_CLASS (sym) = LOC_CONST;
1505 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1506 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1507 add_symbol_to_list (sym, &file_symbols);
1515 double d = atof (p);
1518 /* FIXME-if-picky-about-floating-accuracy: Should be using
1519 target arithmetic to get the value. real.c in GCC
1520 probably has the necessary code. */
1522 /* FIXME: lookup_fundamental_type is a hack. We should be
1523 creating a type especially for the type of float constants.
1524 Problem is, what type should it be?
1526 Also, what should the name of this type be? Should we
1527 be using 'S' constants (see stabs.texinfo) instead? */
1529 SYMBOL_TYPE (sym) = lookup_fundamental_type (objfile,
1532 obstack_alloc (&objfile->symbol_obstack,
1533 TYPE_LENGTH (SYMBOL_TYPE (sym)));
1534 store_floating (dbl_valu, TYPE_LENGTH (SYMBOL_TYPE (sym)), d);
1535 SYMBOL_VALUE_BYTES (sym) = dbl_valu;
1536 SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
1541 /* Defining integer constants this way is kind of silly,
1542 since 'e' constants allows the compiler to give not
1543 only the value, but the type as well. C has at least
1544 int, long, unsigned int, and long long as constant
1545 types; other languages probably should have at least
1546 unsigned as well as signed constants. */
1548 /* We just need one int constant type for all objfiles.
1549 It doesn't depend on languages or anything (arguably its
1550 name should be a language-specific name for a type of
1551 that size, but I'm inclined to say that if the compiler
1552 wants a nice name for the type, it can use 'e'). */
1553 static struct type *int_const_type;
1555 /* Yes, this is as long as a *host* int. That is because we
1557 if (int_const_type == NULL)
1559 init_type (TYPE_CODE_INT,
1560 sizeof (int) * HOST_CHAR_BIT / TARGET_CHAR_BIT, 0,
1562 (struct objfile *) NULL);
1563 SYMBOL_TYPE (sym) = int_const_type;
1564 SYMBOL_VALUE (sym) = atoi (p);
1565 SYMBOL_CLASS (sym) = LOC_CONST;
1569 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
1570 can be represented as integral.
1571 e.g. "b:c=e6,0" for "const b = blob1"
1572 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1574 SYMBOL_CLASS (sym) = LOC_CONST;
1575 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1579 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1584 /* If the value is too big to fit in an int (perhaps because
1585 it is unsigned), or something like that, we silently get
1586 a bogus value. The type and everything else about it is
1587 correct. Ideally, we should be using whatever we have
1588 available for parsing unsigned and long long values,
1590 SYMBOL_VALUE (sym) = atoi (p);
1595 SYMBOL_CLASS (sym) = LOC_CONST;
1596 SYMBOL_TYPE (sym) = error_type (&p, objfile);
1599 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1600 add_symbol_to_list (sym, &file_symbols);
1604 /* The name of a caught exception. */
1605 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1606 SYMBOL_CLASS (sym) = LOC_LABEL;
1607 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1608 SYMBOL_VALUE_ADDRESS (sym) = valu;
1609 add_symbol_to_list (sym, &local_symbols);
1613 /* A static function definition. */
1614 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1615 SYMBOL_CLASS (sym) = LOC_BLOCK;
1616 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1617 add_symbol_to_list (sym, &file_symbols);
1618 /* fall into process_function_types. */
1620 process_function_types:
1621 /* Function result types are described as the result type in stabs.
1622 We need to convert this to the function-returning-type-X type
1623 in GDB. E.g. "int" is converted to "function returning int". */
1624 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
1625 SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
1627 /* All functions in C++ have prototypes. */
1628 if (SYMBOL_LANGUAGE (sym) == language_cplus)
1629 TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED;
1631 /* fall into process_prototype_types */
1633 process_prototype_types:
1634 /* Sun acc puts declared types of arguments here. */
1637 struct type *ftype = SYMBOL_TYPE (sym);
1642 /* Obtain a worst case guess for the number of arguments
1643 by counting the semicolons. */
1650 /* Allocate parameter information fields and fill them in. */
1651 TYPE_FIELDS (ftype) = (struct field *)
1652 TYPE_ALLOC (ftype, nsemi * sizeof (struct field));
1657 /* A type number of zero indicates the start of varargs.
1658 FIXME: GDB currently ignores vararg functions. */
1659 if (p[0] == '0' && p[1] == '\0')
1661 ptype = read_type (&p, objfile);
1663 /* The Sun compilers mark integer arguments, which should
1664 be promoted to the width of the calling conventions, with
1665 a type which references itself. This type is turned into
1666 a TYPE_CODE_VOID type by read_type, and we have to turn
1667 it back into builtin_type_int here.
1668 FIXME: Do we need a new builtin_type_promoted_int_arg ? */
1669 if (TYPE_CODE (ptype) == TYPE_CODE_VOID)
1670 ptype = builtin_type_int;
1671 TYPE_FIELD_TYPE (ftype, nparams++) = ptype;
1673 TYPE_NFIELDS (ftype) = nparams;
1674 TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
1679 /* A global function definition. */
1680 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1681 SYMBOL_CLASS (sym) = LOC_BLOCK;
1682 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1683 add_symbol_to_list (sym, &global_symbols);
1684 goto process_function_types;
1687 /* For a class G (global) symbol, it appears that the
1688 value is not correct. It is necessary to search for the
1689 corresponding linker definition to find the value.
1690 These definitions appear at the end of the namelist. */
1691 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1692 SYMBOL_CLASS (sym) = LOC_STATIC;
1693 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1694 /* Don't add symbol references to global_sym_chain.
1695 Symbol references don't have valid names and wont't match up with
1696 minimal symbols when the global_sym_chain is relocated.
1697 We'll fixup symbol references when we fixup the defining symbol. */
1698 if (SYMBOL_NAME (sym) && SYMBOL_NAME (sym)[0] != '#')
1700 i = hashname (SYMBOL_NAME (sym));
1701 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
1702 global_sym_chain[i] = sym;
1704 add_symbol_to_list (sym, &global_symbols);
1707 /* This case is faked by a conditional above,
1708 when there is no code letter in the dbx data.
1709 Dbx data never actually contains 'l'. */
1712 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1713 SYMBOL_CLASS (sym) = LOC_LOCAL;
1714 SYMBOL_VALUE (sym) = valu;
1715 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1716 add_symbol_to_list (sym, &local_symbols);
1721 /* pF is a two-letter code that means a function parameter in Fortran.
1722 The type-number specifies the type of the return value.
1723 Translate it into a pointer-to-function type. */
1727 = lookup_pointer_type
1728 (lookup_function_type (read_type (&p, objfile)));
1731 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1733 /* Normally this is a parameter, a LOC_ARG. On the i960, it
1734 can also be a LOC_LOCAL_ARG depending on symbol type. */
1735 #ifndef DBX_PARM_SYMBOL_CLASS
1736 #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
1739 SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
1740 SYMBOL_VALUE (sym) = valu;
1741 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1742 add_symbol_to_list (sym, &local_symbols);
1744 if (TARGET_BYTE_ORDER != BIG_ENDIAN)
1746 /* On little-endian machines, this crud is never necessary,
1747 and, if the extra bytes contain garbage, is harmful. */
1751 /* If it's gcc-compiled, if it says `short', believe it. */
1752 if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
1755 if (!BELIEVE_PCC_PROMOTION)
1757 /* This is the signed type which arguments get promoted to. */
1758 static struct type *pcc_promotion_type;
1759 /* This is the unsigned type which arguments get promoted to. */
1760 static struct type *pcc_unsigned_promotion_type;
1762 /* Call it "int" because this is mainly C lossage. */
1763 if (pcc_promotion_type == NULL)
1764 pcc_promotion_type =
1765 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1768 if (pcc_unsigned_promotion_type == NULL)
1769 pcc_unsigned_promotion_type =
1770 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1771 TYPE_FLAG_UNSIGNED, "unsigned int", NULL);
1773 if (BELIEVE_PCC_PROMOTION_TYPE)
1775 /* This is defined on machines (e.g. sparc) where we
1776 should believe the type of a PCC 'short' argument,
1777 but shouldn't believe the address (the address is the
1778 address of the corresponding int).
1780 My guess is that this correction, as opposed to
1781 changing the parameter to an 'int' (as done below,
1782 for PCC on most machines), is the right thing to do
1783 on all machines, but I don't want to risk breaking
1784 something that already works. On most PCC machines,
1785 the sparc problem doesn't come up because the calling
1786 function has to zero the top bytes (not knowing
1787 whether the called function wants an int or a short),
1788 so there is little practical difference between an
1789 int and a short (except perhaps what happens when the
1790 GDB user types "print short_arg = 0x10000;").
1793 compiler actually produces the correct address (we
1794 don't need to fix it up). I made this code adapt so
1795 that it will offset the symbol if it was pointing at
1796 an int-aligned location and not otherwise. This way
1797 you can use the same gdb for 4.0.x and 4.1 systems.
1799 If the parameter is shorter than an int, and is
1800 integral (e.g. char, short, or unsigned equivalent),
1801 and is claimed to be passed on an integer boundary,
1802 don't believe it! Offset the parameter's address to
1803 the tail-end of that integer. */
1805 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
1806 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT
1807 && 0 == SYMBOL_VALUE (sym) % TYPE_LENGTH (pcc_promotion_type))
1809 SYMBOL_VALUE (sym) += TYPE_LENGTH (pcc_promotion_type)
1810 - TYPE_LENGTH (SYMBOL_TYPE (sym));
1816 /* If PCC says a parameter is a short or a char,
1817 it is really an int. */
1818 if (TYPE_LENGTH (SYMBOL_TYPE (sym)) < TYPE_LENGTH (pcc_promotion_type)
1819 && TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_INT)
1822 TYPE_UNSIGNED (SYMBOL_TYPE (sym))
1823 ? pcc_unsigned_promotion_type
1824 : pcc_promotion_type;
1831 /* acc seems to use P to declare the prototypes of functions that
1832 are referenced by this file. gdb is not prepared to deal
1833 with this extra information. FIXME, it ought to. */
1836 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1837 goto process_prototype_types;
1842 /* Parameter which is in a register. */
1843 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1844 SYMBOL_CLASS (sym) = LOC_REGPARM;
1845 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1846 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1848 complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
1849 SYMBOL_SOURCE_NAME (sym));
1850 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1852 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1853 add_symbol_to_list (sym, &local_symbols);
1857 /* Register variable (either global or local). */
1858 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1859 SYMBOL_CLASS (sym) = LOC_REGISTER;
1860 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
1861 if (SYMBOL_VALUE (sym) >= NUM_REGS)
1863 complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
1864 SYMBOL_SOURCE_NAME (sym));
1865 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
1867 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1868 if (within_function)
1870 /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
1871 name to represent an argument passed in a register.
1872 GCC uses 'P' for the same case. So if we find such a symbol pair
1873 we combine it into one 'P' symbol. For Sun cc we need to do this
1874 regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
1875 the 'p' symbol even if it never saves the argument onto the stack.
1877 On most machines, we want to preserve both symbols, so that
1878 we can still get information about what is going on with the
1879 stack (VAX for computing args_printed, using stack slots instead
1880 of saved registers in backtraces, etc.).
1882 Note that this code illegally combines
1883 main(argc) struct foo argc; { register struct foo argc; }
1884 but this case is considered pathological and causes a warning
1885 from a decent compiler. */
1888 && local_symbols->nsyms > 0
1889 #ifndef USE_REGISTER_NOT_ARG
1890 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
1892 && (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1893 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION
1894 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET
1895 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
1899 struct symbol *prev_sym;
1900 prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
1901 if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
1902 || SYMBOL_CLASS (prev_sym) == LOC_ARG)
1903 && STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME (sym)))
1905 SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
1906 /* Use the type from the LOC_REGISTER; that is the type
1907 that is actually in that register. */
1908 SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
1909 SYMBOL_VALUE (prev_sym) = SYMBOL_VALUE (sym);
1914 add_symbol_to_list (sym, &local_symbols);
1917 add_symbol_to_list (sym, &file_symbols);
1921 /* Static symbol at top level of file */
1922 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1923 SYMBOL_CLASS (sym) = LOC_STATIC;
1924 SYMBOL_VALUE_ADDRESS (sym) = valu;
1925 #ifdef STATIC_TRANSFORM_NAME
1926 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
1928 struct minimal_symbol *msym;
1929 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
1932 SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
1933 SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
1937 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1938 add_symbol_to_list (sym, &file_symbols);
1942 SYMBOL_TYPE (sym) = read_type (&p, objfile);
1944 /* For a nameless type, we don't want a create a symbol, thus we
1945 did not use `sym'. Return without further processing. */
1949 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
1950 SYMBOL_VALUE (sym) = valu;
1951 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
1952 /* C++ vagaries: we may have a type which is derived from
1953 a base type which did not have its name defined when the
1954 derived class was output. We fill in the derived class's
1955 base part member's name here in that case. */
1956 if (TYPE_NAME (SYMBOL_TYPE (sym)) != NULL)
1957 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT
1958 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
1959 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)))
1962 for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
1963 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
1964 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
1965 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym), j));
1968 if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
1970 /* gcc-2.6 or later (when using -fvtable-thunks)
1971 emits a unique named type for a vtable entry.
1972 Some gdb code depends on that specific name. */
1973 extern const char vtbl_ptr_name[];
1975 if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
1976 && strcmp (SYMBOL_NAME (sym), vtbl_ptr_name))
1977 || TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC)
1979 /* If we are giving a name to a type such as "pointer to
1980 foo" or "function returning foo", we better not set
1981 the TYPE_NAME. If the program contains "typedef char
1982 *caddr_t;", we don't want all variables of type char
1983 * to print as caddr_t. This is not just a
1984 consequence of GDB's type management; PCC and GCC (at
1985 least through version 2.4) both output variables of
1986 either type char * or caddr_t with the type number
1987 defined in the 't' symbol for caddr_t. If a future
1988 compiler cleans this up it GDB is not ready for it
1989 yet, but if it becomes ready we somehow need to
1990 disable this check (without breaking the PCC/GCC2.4
1995 Fortunately, this check seems not to be necessary
1996 for anything except pointers or functions. */
1999 TYPE_NAME (SYMBOL_TYPE (sym)) = SYMBOL_NAME (sym);
2002 add_symbol_to_list (sym, &file_symbols);
2006 /* Struct, union, or enum tag. For GNU C++, this can be be followed
2007 by 't' which means we are typedef'ing it as well. */
2008 synonym = *p == 't';
2012 /* The semantics of C++ state that "struct foo { ... }" also defines
2013 a typedef for "foo". Unfortunately, cfront never makes the typedef
2014 when translating C++ into C. We make the typedef here so that
2015 "ptype foo" works as expected for cfront translated code. */
2016 else if (current_subfile->language == language_cplus)
2019 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2021 /* For a nameless type, we don't want a create a symbol, thus we
2022 did not use `sym'. Return without further processing. */
2026 SYMBOL_CLASS (sym) = LOC_TYPEDEF;
2027 SYMBOL_VALUE (sym) = valu;
2028 SYMBOL_NAMESPACE (sym) = STRUCT_NAMESPACE;
2029 if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
2030 TYPE_TAG_NAME (SYMBOL_TYPE (sym))
2031 = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
2032 add_symbol_to_list (sym, &file_symbols);
2036 /* Clone the sym and then modify it. */
2037 register struct symbol *typedef_sym = (struct symbol *)
2038 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
2039 *typedef_sym = *sym;
2040 SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
2041 SYMBOL_VALUE (typedef_sym) = valu;
2042 SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
2043 if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
2044 TYPE_NAME (SYMBOL_TYPE (sym))
2045 = obconcat (&objfile->type_obstack, "", "", SYMBOL_NAME (sym));
2046 add_symbol_to_list (typedef_sym, &file_symbols);
2051 /* Static symbol of local scope */
2052 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2053 SYMBOL_CLASS (sym) = LOC_STATIC;
2054 SYMBOL_VALUE_ADDRESS (sym) = valu;
2055 #ifdef STATIC_TRANSFORM_NAME
2056 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym)))
2058 struct minimal_symbol *msym;
2059 msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
2062 SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
2063 SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
2067 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2069 add_symbol_to_list (sym, &global_symbols);
2071 add_symbol_to_list (sym, &local_symbols);
2075 /* Reference parameter */
2076 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2077 SYMBOL_CLASS (sym) = LOC_REF_ARG;
2078 SYMBOL_VALUE (sym) = valu;
2079 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2080 add_symbol_to_list (sym, &local_symbols);
2084 /* Reference parameter which is in a register. */
2085 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2086 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
2087 SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
2088 if (SYMBOL_VALUE (sym) >= NUM_REGS)
2090 complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
2091 SYMBOL_SOURCE_NAME (sym));
2092 SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
2094 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2095 add_symbol_to_list (sym, &local_symbols);
2099 /* This is used by Sun FORTRAN for "function result value".
2100 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
2101 that Pascal uses it too, but when I tried it Pascal used
2102 "x:3" (local symbol) instead. */
2103 SYMBOL_TYPE (sym) = read_type (&p, objfile);
2104 SYMBOL_CLASS (sym) = LOC_LOCAL;
2105 SYMBOL_VALUE (sym) = valu;
2106 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2107 add_symbol_to_list (sym, &local_symbols);
2110 /* New code added to support cfront stabs strings.
2111 Note: case 'P' already handled above */
2113 /* Cfront type continuation coming up!
2114 Find the original definition and add to it.
2115 We'll have to do this for the typedef too,
2116 since we cloned the symbol to define a type in read_type.
2117 Stabs info examples:
2119 foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24))
2120 C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;;
2121 where C is the name of the class.
2122 Unfortunately, we can't lookup the original symbol yet 'cuz
2123 we haven't finished reading all the symbols.
2124 Instead, we save it for processing later */
2125 process_later (sym, p, resolve_cfront_continuation);
2126 SYMBOL_TYPE (sym) = error_type (&p, objfile); /* FIXME! change later */
2127 SYMBOL_CLASS (sym) = LOC_CONST;
2128 SYMBOL_VALUE (sym) = 0;
2129 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2130 /* Don't add to list - we'll delete it later when
2131 we add the continuation to the real sym */
2133 /* End of new code added to support cfront stabs strings */
2136 SYMBOL_TYPE (sym) = error_type (&p, objfile);
2137 SYMBOL_CLASS (sym) = LOC_CONST;
2138 SYMBOL_VALUE (sym) = 0;
2139 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
2140 add_symbol_to_list (sym, &file_symbols);
2144 /* When passing structures to a function, some systems sometimes pass
2145 the address in a register, not the structure itself. */
2147 if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
2148 && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
2150 struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
2152 if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
2153 || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
2154 || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
2155 || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
2157 /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
2158 LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
2159 if (SYMBOL_CLASS (sym) == LOC_REGPARM)
2160 SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
2161 /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
2162 and subsequent arguments on the sparc, for example). */
2163 else if (SYMBOL_CLASS (sym) == LOC_ARG)
2164 SYMBOL_CLASS (sym) = LOC_REF_ARG;
2168 /* Is there more to parse? For example LRS/alias information? */
2169 while (*p && *p == ';')
2172 if (*p && p[0] == 'l' && p[1] == '(')
2174 /* GNU extensions for live range splitting may be appended to
2175 the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */
2177 /* Resolve the live range and add it to SYM's live range list. */
2178 if (!resolve_live_range (objfile, sym, p))
2181 /* Find end of live range info. */
2182 p = strchr (p, ')');
2183 if (!*p || *p != ')')
2185 complain (&lrs_general_complaint, "live range format not recognized");
2194 /* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns
2195 non-zero on success, zero otherwise. */
2198 resolve_live_range (objfile, sym, p)
2199 struct objfile *objfile;
2204 CORE_ADDR start, end;
2206 /* Sanity check the beginning of the stabs string. */
2207 if (!*p || *p != 'l')
2209 complain (&lrs_general_complaint, "live range string 1");
2214 if (!*p || *p != '(')
2216 complain (&lrs_general_complaint, "live range string 2");
2221 /* Get starting value of range and advance P past the reference id.
2223 ?!? In theory, the process_reference should never fail, but we should
2224 catch that case just in case the compiler scrogged the stabs. */
2225 refnum = process_reference (&p);
2226 start = ref_search_value (refnum);
2229 complain (&lrs_general_complaint, "Live range symbol not found 1");
2233 if (!*p || *p != ',')
2235 complain (&lrs_general_complaint, "live range string 3");
2240 /* Get ending value of range and advance P past the reference id.
2242 ?!? In theory, the process_reference should never fail, but we should
2243 catch that case just in case the compiler scrogged the stabs. */
2244 refnum = process_reference (&p);
2245 end = ref_search_value (refnum);
2248 complain (&lrs_general_complaint, "Live range symbol not found 2");
2252 if (!*p || *p != ')')
2254 complain (&lrs_general_complaint, "live range string 4");
2258 /* Now that we know the bounds of the range, add it to the
2260 add_live_range (objfile, sym, start, end);
2265 /* Add a new live range defined by START and END to the symbol SYM
2266 in objfile OBJFILE. */
2269 add_live_range (objfile, sym, start, end)
2270 struct objfile *objfile;
2272 CORE_ADDR start, end;
2274 struct range_list *r, *rs;
2278 complain (&lrs_general_complaint, "end of live range follows start");
2282 /* Alloc new live range structure. */
2283 r = (struct range_list *)
2284 obstack_alloc (&objfile->type_obstack,
2285 sizeof (struct range_list));
2290 /* Append this range to the symbol's range list. */
2291 if (!SYMBOL_RANGES (sym))
2292 SYMBOL_RANGES (sym) = r;
2295 /* Get the last range for the symbol. */
2296 for (rs = SYMBOL_RANGES (sym); rs->next; rs = rs->next)
2303 /* Skip rest of this symbol and return an error type.
2305 General notes on error recovery: error_type always skips to the
2306 end of the symbol (modulo cretinous dbx symbol name continuation).
2307 Thus code like this:
2309 if (*(*pp)++ != ';')
2310 return error_type (pp, objfile);
2312 is wrong because if *pp starts out pointing at '\0' (typically as the
2313 result of an earlier error), it will be incremented to point to the
2314 start of the next symbol, which might produce strange results, at least
2315 if you run off the end of the string table. Instead use
2318 return error_type (pp, objfile);
2324 foo = error_type (pp, objfile);
2328 And in case it isn't obvious, the point of all this hair is so the compiler
2329 can define new types and new syntaxes, and old versions of the
2330 debugger will be able to read the new symbol tables. */
2332 static struct type *
2333 error_type (pp, objfile)
2335 struct objfile *objfile;
2337 complain (&error_type_complaint);
2340 /* Skip to end of symbol. */
2341 while (**pp != '\0')
2346 /* Check for and handle cretinous dbx symbol name continuation! */
2347 if ((*pp)[-1] == '\\' || (*pp)[-1] == '?')
2349 *pp = next_symbol_text (objfile);
2356 return (builtin_type_error);
2360 /* Read type information or a type definition; return the type. Even
2361 though this routine accepts either type information or a type
2362 definition, the distinction is relevant--some parts of stabsread.c
2363 assume that type information starts with a digit, '-', or '(' in
2364 deciding whether to call read_type. */
2367 read_type (pp, objfile)
2369 struct objfile *objfile;
2371 register struct type *type = 0;
2374 char type_descriptor;
2376 /* Size in bits of type if specified by a type attribute, or -1 if
2377 there is no size attribute. */
2380 /* Used to distinguish string and bitstring from char-array and set. */
2383 /* Read type number if present. The type number may be omitted.
2384 for instance in a two-dimensional array declared with type
2385 "ar1;1;10;ar1;1;10;4". */
2386 if ((**pp >= '0' && **pp <= '9')
2390 if (read_type_number (pp, typenums) != 0)
2391 return error_type (pp, objfile);
2393 /* Type is not being defined here. Either it already exists,
2394 or this is a forward reference to it. dbx_alloc_type handles
2397 return dbx_alloc_type (typenums, objfile);
2399 /* Type is being defined here. */
2401 Also skip the type descriptor - we get it below with (*pp)[-1]. */
2406 /* 'typenums=' not present, type is anonymous. Read and return
2407 the definition, but don't put it in the type vector. */
2408 typenums[0] = typenums[1] = -1;
2413 type_descriptor = (*pp)[-1];
2414 switch (type_descriptor)
2418 enum type_code code;
2420 /* Used to index through file_symbols. */
2421 struct pending *ppt;
2424 /* Name including "struct", etc. */
2428 char *from, *to, *p, *q1, *q2;
2430 /* Set the type code according to the following letter. */
2434 code = TYPE_CODE_STRUCT;
2437 code = TYPE_CODE_UNION;
2440 code = TYPE_CODE_ENUM;
2444 /* Complain and keep going, so compilers can invent new
2445 cross-reference types. */
2446 static struct complaint msg =
2447 {"Unrecognized cross-reference type `%c'", 0, 0};
2448 complain (&msg, (*pp)[0]);
2449 code = TYPE_CODE_STRUCT;
2454 q1 = strchr (*pp, '<');
2455 p = strchr (*pp, ':');
2457 return error_type (pp, objfile);
2458 if (q1 && p > q1 && p[1] == ':')
2460 int nesting_level = 0;
2461 for (q2 = q1; *q2; q2++)
2465 else if (*q2 == '>')
2467 else if (*q2 == ':' && nesting_level == 0)
2472 return error_type (pp, objfile);
2475 (char *) obstack_alloc (&objfile->type_obstack, p - *pp + 1);
2477 /* Copy the name. */
2483 /* Set the pointer ahead of the name which we just read, and
2488 /* Now check to see whether the type has already been
2489 declared. This was written for arrays of cross-referenced
2490 types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty
2491 sure it is not necessary anymore. But it might be a good
2492 idea, to save a little memory. */
2494 for (ppt = file_symbols; ppt; ppt = ppt->next)
2495 for (i = 0; i < ppt->nsyms; i++)
2497 struct symbol *sym = ppt->symbol[i];
2499 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
2500 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
2501 && (TYPE_CODE (SYMBOL_TYPE (sym)) == code)
2502 && STREQ (SYMBOL_NAME (sym), type_name))
2504 obstack_free (&objfile->type_obstack, type_name);
2505 type = SYMBOL_TYPE (sym);
2510 /* Didn't find the type to which this refers, so we must
2511 be dealing with a forward reference. Allocate a type
2512 structure for it, and keep track of it so we can
2513 fill in the rest of the fields when we get the full
2515 type = dbx_alloc_type (typenums, objfile);
2516 TYPE_CODE (type) = code;
2517 TYPE_TAG_NAME (type) = type_name;
2518 INIT_CPLUS_SPECIFIC (type);
2519 TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
2521 add_undefined_type (type);
2525 case '-': /* RS/6000 built-in type */
2539 /* We deal with something like t(1,2)=(3,4)=... which
2540 the Lucid compiler and recent gcc versions (post 2.7.3) use. */
2542 /* Allocate and enter the typedef type first.
2543 This handles recursive types. */
2544 type = dbx_alloc_type (typenums, objfile);
2545 TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
2547 struct type *xtype = read_type (pp, objfile);
2550 /* It's being defined as itself. That means it is "void". */
2551 TYPE_CODE (type) = TYPE_CODE_VOID;
2552 TYPE_LENGTH (type) = 1;
2554 else if (type_size >= 0 || is_string)
2557 TYPE_NAME (type) = NULL;
2558 TYPE_TAG_NAME (type) = NULL;
2562 TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
2563 TYPE_TARGET_TYPE (type) = xtype;
2568 /* In the following types, we must be sure to overwrite any existing
2569 type that the typenums refer to, rather than allocating a new one
2570 and making the typenums point to the new one. This is because there
2571 may already be pointers to the existing type (if it had been
2572 forward-referenced), and we must change it to a pointer, function,
2573 reference, or whatever, *in-place*. */
2576 type1 = read_type (pp, objfile);
2577 type = make_pointer_type (type1, dbx_lookup_type (typenums));
2580 case '&': /* Reference to another type */
2581 type1 = read_type (pp, objfile);
2582 type = make_reference_type (type1, dbx_lookup_type (typenums));
2585 case 'f': /* Function returning another type */
2586 if (os9k_stabs && **pp == '(')
2588 /* Function prototype; parse it.
2589 We must conditionalize this on os9k_stabs because otherwise
2590 it could be confused with a Sun-style (1,3) typenumber
2596 t = read_type (pp, objfile);
2601 type1 = read_type (pp, objfile);
2602 type = make_function_type (type1, dbx_lookup_type (typenums));
2605 case 'k': /* Const qualifier on some type (Sun) */
2606 case 'c': /* Const qualifier on some type (OS9000) */
2607 /* Because 'c' means other things to AIX and 'k' is perfectly good,
2608 only accept 'c' in the os9k_stabs case. */
2609 if (type_descriptor == 'c' && !os9k_stabs)
2610 return error_type (pp, objfile);
2611 type = read_type (pp, objfile);
2612 /* FIXME! For now, we ignore const and volatile qualifiers. */
2615 case 'B': /* Volatile qual on some type (Sun) */
2616 case 'i': /* Volatile qual on some type (OS9000) */
2617 /* Because 'i' means other things to AIX and 'B' is perfectly good,
2618 only accept 'i' in the os9k_stabs case. */
2619 if (type_descriptor == 'i' && !os9k_stabs)
2620 return error_type (pp, objfile);
2621 type = read_type (pp, objfile);
2622 /* FIXME! For now, we ignore const and volatile qualifiers. */
2626 if (isdigit (**pp) || **pp == '(' || **pp == '-')
2627 { /* Member (class & variable) type */
2628 /* FIXME -- we should be doing smash_to_XXX types here. */
2630 struct type *domain = read_type (pp, objfile);
2631 struct type *memtype;
2634 /* Invalid member type data format. */
2635 return error_type (pp, objfile);
2638 memtype = read_type (pp, objfile);
2639 type = dbx_alloc_type (typenums, objfile);
2640 smash_to_member_type (type, domain, memtype);
2643 /* type attribute */
2646 /* Skip to the semicolon. */
2647 while (**pp != ';' && **pp != '\0')
2650 return error_type (pp, objfile);
2652 ++ * pp; /* Skip the semicolon. */
2657 type_size = atoi (attr + 1);
2667 /* Ignore unrecognized type attributes, so future compilers
2668 can invent new ones. */
2676 case '#': /* Method (class & fn) type */
2677 if ((*pp)[0] == '#')
2679 /* We'll get the parameter types from the name. */
2680 struct type *return_type;
2683 return_type = read_type (pp, objfile);
2684 if (*(*pp)++ != ';')
2685 complain (&invalid_member_complaint, symnum);
2686 type = allocate_stub_method (return_type);
2687 if (typenums[0] != -1)
2688 *dbx_lookup_type (typenums) = type;
2692 struct type *domain = read_type (pp, objfile);
2693 struct type *return_type;
2697 /* Invalid member type data format. */
2698 return error_type (pp, objfile);
2702 return_type = read_type (pp, objfile);
2703 args = read_args (pp, ';', objfile);
2704 type = dbx_alloc_type (typenums, objfile);
2705 smash_to_method_type (type, domain, return_type, args);
2709 case 'r': /* Range type */
2710 type = read_range_type (pp, typenums, objfile);
2711 if (typenums[0] != -1)
2712 *dbx_lookup_type (typenums) = type;
2717 /* Const and volatile qualified type. */
2718 type = read_type (pp, objfile);
2721 /* Sun ACC builtin int type */
2722 type = read_sun_builtin_type (pp, typenums, objfile);
2723 if (typenums[0] != -1)
2724 *dbx_lookup_type (typenums) = type;
2728 case 'R': /* Sun ACC builtin float type */
2729 type = read_sun_floating_type (pp, typenums, objfile);
2730 if (typenums[0] != -1)
2731 *dbx_lookup_type (typenums) = type;
2734 case 'e': /* Enumeration type */
2735 type = dbx_alloc_type (typenums, objfile);
2736 type = read_enum_type (pp, type, objfile);
2737 if (typenums[0] != -1)
2738 *dbx_lookup_type (typenums) = type;
2741 case 's': /* Struct type */
2742 case 'u': /* Union type */
2743 type = dbx_alloc_type (typenums, objfile);
2744 switch (type_descriptor)
2747 TYPE_CODE (type) = TYPE_CODE_STRUCT;
2750 TYPE_CODE (type) = TYPE_CODE_UNION;
2753 type = read_struct_type (pp, type, objfile);
2756 case 'a': /* Array type */
2758 return error_type (pp, objfile);
2761 type = dbx_alloc_type (typenums, objfile);
2762 type = read_array_type (pp, type, objfile);
2764 TYPE_CODE (type) = TYPE_CODE_STRING;
2768 type1 = read_type (pp, objfile);
2769 type = create_set_type ((struct type *) NULL, type1);
2771 TYPE_CODE (type) = TYPE_CODE_BITSTRING;
2772 if (typenums[0] != -1)
2773 *dbx_lookup_type (typenums) = type;
2777 --*pp; /* Go back to the symbol in error */
2778 /* Particularly important if it was \0! */
2779 return error_type (pp, objfile);
2784 warning ("GDB internal error, type is NULL in stabsread.c\n");
2785 return error_type (pp, objfile);
2788 /* Size specified in a type attribute overrides any other size. */
2789 if (type_size != -1)
2790 TYPE_LENGTH (type) = (type_size + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
2795 /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
2796 Return the proper type node for a given builtin type number. */
2798 static struct type *
2799 rs6000_builtin_type (typenum)
2802 /* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
2803 #define NUMBER_RECOGNIZED 34
2804 /* This includes an empty slot for type number -0. */
2805 static struct type *negative_types[NUMBER_RECOGNIZED + 1];
2806 struct type *rettype = NULL;
2808 if (typenum >= 0 || typenum < -NUMBER_RECOGNIZED)
2810 complain (&rs6000_builtin_complaint, typenum);
2811 return builtin_type_error;
2813 if (negative_types[-typenum] != NULL)
2814 return negative_types[-typenum];
2816 #if TARGET_CHAR_BIT != 8
2817 #error This code wrong for TARGET_CHAR_BIT not 8
2818 /* These definitions all assume that TARGET_CHAR_BIT is 8. I think
2819 that if that ever becomes not true, the correct fix will be to
2820 make the size in the struct type to be in bits, not in units of
2827 /* The size of this and all the other types are fixed, defined
2828 by the debugging format. If there is a type called "int" which
2829 is other than 32 bits, then it should use a new negative type
2830 number (or avoid negative type numbers for that case).
2831 See stabs.texinfo. */
2832 rettype = init_type (TYPE_CODE_INT, 4, 0, "int", NULL);
2835 rettype = init_type (TYPE_CODE_INT, 1, 0, "char", NULL);
2838 rettype = init_type (TYPE_CODE_INT, 2, 0, "short", NULL);
2841 rettype = init_type (TYPE_CODE_INT, 4, 0, "long", NULL);
2844 rettype = init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED,
2845 "unsigned char", NULL);
2848 rettype = init_type (TYPE_CODE_INT, 1, 0, "signed char", NULL);
2851 rettype = init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED,
2852 "unsigned short", NULL);
2855 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2856 "unsigned int", NULL);
2859 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2862 rettype = init_type (TYPE_CODE_INT, 4, TYPE_FLAG_UNSIGNED,
2863 "unsigned long", NULL);
2866 rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
2869 /* IEEE single precision (32 bit). */
2870 rettype = init_type (TYPE_CODE_FLT, 4, 0, "float", NULL);
2873 /* IEEE double precision (64 bit). */
2874 rettype = init_type (TYPE_CODE_FLT, 8, 0, "double", NULL);
2877 /* This is an IEEE double on the RS/6000, and different machines with
2878 different sizes for "long double" should use different negative
2879 type numbers. See stabs.texinfo. */
2880 rettype = init_type (TYPE_CODE_FLT, 8, 0, "long double", NULL);
2883 rettype = init_type (TYPE_CODE_INT, 4, 0, "integer", NULL);
2886 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2890 rettype = init_type (TYPE_CODE_FLT, 4, 0, "short real", NULL);
2893 rettype = init_type (TYPE_CODE_FLT, 8, 0, "real", NULL);
2896 rettype = init_type (TYPE_CODE_ERROR, 0, 0, "stringptr", NULL);
2899 rettype = init_type (TYPE_CODE_CHAR, 1, TYPE_FLAG_UNSIGNED,
2903 rettype = init_type (TYPE_CODE_BOOL, 1, TYPE_FLAG_UNSIGNED,
2907 rettype = init_type (TYPE_CODE_BOOL, 2, TYPE_FLAG_UNSIGNED,
2911 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2915 rettype = init_type (TYPE_CODE_BOOL, 4, TYPE_FLAG_UNSIGNED,
2919 /* Complex type consisting of two IEEE single precision values. */
2920 rettype = init_type (TYPE_CODE_COMPLEX, 8, 0, "complex", NULL);
2923 /* Complex type consisting of two IEEE double precision values. */
2924 rettype = init_type (TYPE_CODE_COMPLEX, 16, 0, "double complex", NULL);
2927 rettype = init_type (TYPE_CODE_INT, 1, 0, "integer*1", NULL);
2930 rettype = init_type (TYPE_CODE_INT, 2, 0, "integer*2", NULL);
2933 rettype = init_type (TYPE_CODE_INT, 4, 0, "integer*4", NULL);
2936 rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL);
2939 rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL);
2942 rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
2943 "unsigned long long", NULL);
2946 rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
2950 rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL);
2953 negative_types[-typenum] = rettype;
2957 /* This page contains subroutines of read_type. */
2959 /* Read member function stabs info for C++ classes. The form of each member
2962 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
2964 An example with two member functions is:
2966 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
2968 For the case of overloaded operators, the format is op$::*.funcs, where
2969 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
2970 name (such as `+=') and `.' marks the end of the operator name.
2972 Returns 1 for success, 0 for failure. */
2975 read_member_functions (fip, pp, type, objfile)
2976 struct field_info *fip;
2979 struct objfile *objfile;
2983 /* Total number of member functions defined in this class. If the class
2984 defines two `f' functions, and one `g' function, then this will have
2986 int total_length = 0;
2990 struct next_fnfield *next;
2991 struct fn_field fn_field;
2994 struct type *look_ahead_type;
2995 struct next_fnfieldlist *new_fnlist;
2996 struct next_fnfield *new_sublist;
3000 /* Process each list until we find something that is not a member function
3001 or find the end of the functions. */
3005 /* We should be positioned at the start of the function name.
3006 Scan forward to find the first ':' and if it is not the
3007 first of a "::" delimiter, then this is not a member function. */
3019 look_ahead_type = NULL;
3022 new_fnlist = (struct next_fnfieldlist *)
3023 xmalloc (sizeof (struct next_fnfieldlist));
3024 make_cleanup (free, new_fnlist);
3025 memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
3027 if ((*pp)[0] == 'o' && (*pp)[1] == 'p' && is_cplus_marker ((*pp)[2]))
3029 /* This is a completely wierd case. In order to stuff in the
3030 names that might contain colons (the usual name delimiter),
3031 Mike Tiemann defined a different name format which is
3032 signalled if the identifier is "op$". In that case, the
3033 format is "op$::XXXX." where XXXX is the name. This is
3034 used for names like "+" or "=". YUUUUUUUK! FIXME! */
3035 /* This lets the user type "break operator+".
3036 We could just put in "+" as the name, but that wouldn't
3038 static char opname[32] =
3039 {'o', 'p', CPLUS_MARKER};
3040 char *o = opname + 3;
3042 /* Skip past '::'. */
3045 STABS_CONTINUE (pp, objfile);
3051 main_fn_name = savestring (opname, o - opname);
3057 main_fn_name = savestring (*pp, p - *pp);
3058 /* Skip past '::'. */
3061 new_fnlist->fn_fieldlist.name = main_fn_name;
3066 (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
3067 make_cleanup (free, new_sublist);
3068 memset (new_sublist, 0, sizeof (struct next_fnfield));
3070 /* Check for and handle cretinous dbx symbol name continuation! */
3071 if (look_ahead_type == NULL)
3074 STABS_CONTINUE (pp, objfile);
3076 new_sublist->fn_field.type = read_type (pp, objfile);
3079 /* Invalid symtab info for member function. */
3085 /* g++ version 1 kludge */
3086 new_sublist->fn_field.type = look_ahead_type;
3087 look_ahead_type = NULL;
3097 /* If this is just a stub, then we don't have the real name here. */
3099 if (TYPE_FLAGS (new_sublist->fn_field.type) & TYPE_FLAG_STUB)
3101 if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
3102 TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
3103 new_sublist->fn_field.is_stub = 1;
3105 new_sublist->fn_field.physname = savestring (*pp, p - *pp);
3108 /* Set this member function's visibility fields. */
3111 case VISIBILITY_PRIVATE:
3112 new_sublist->fn_field.is_private = 1;
3114 case VISIBILITY_PROTECTED:
3115 new_sublist->fn_field.is_protected = 1;
3119 STABS_CONTINUE (pp, objfile);
3122 case 'A': /* Normal functions. */
3123 new_sublist->fn_field.is_const = 0;
3124 new_sublist->fn_field.is_volatile = 0;
3127 case 'B': /* `const' member functions. */
3128 new_sublist->fn_field.is_const = 1;
3129 new_sublist->fn_field.is_volatile = 0;
3132 case 'C': /* `volatile' member function. */
3133 new_sublist->fn_field.is_const = 0;
3134 new_sublist->fn_field.is_volatile = 1;
3137 case 'D': /* `const volatile' member function. */
3138 new_sublist->fn_field.is_const = 1;
3139 new_sublist->fn_field.is_volatile = 1;
3142 case '*': /* File compiled with g++ version 1 -- no info */
3147 complain (&const_vol_complaint, **pp);
3156 /* virtual member function, followed by index.
3157 The sign bit is set to distinguish pointers-to-methods
3158 from virtual function indicies. Since the array is
3159 in words, the quantity must be shifted left by 1
3160 on 16 bit machine, and by 2 on 32 bit machine, forcing
3161 the sign bit out, and usable as a valid index into
3162 the array. Remove the sign bit here. */
3163 new_sublist->fn_field.voffset =
3164 (0x7fffffff & read_huge_number (pp, ';', &nbits)) + 2;
3168 STABS_CONTINUE (pp, objfile);
3169 if (**pp == ';' || **pp == '\0')
3171 /* Must be g++ version 1. */
3172 new_sublist->fn_field.fcontext = 0;
3176 /* Figure out from whence this virtual function came.
3177 It may belong to virtual function table of
3178 one of its baseclasses. */
3179 look_ahead_type = read_type (pp, objfile);
3182 /* g++ version 1 overloaded methods. */
3186 new_sublist->fn_field.fcontext = look_ahead_type;
3195 look_ahead_type = NULL;
3201 /* static member function. */
3202 new_sublist->fn_field.voffset = VOFFSET_STATIC;
3203 if (strncmp (new_sublist->fn_field.physname,
3204 main_fn_name, strlen (main_fn_name)))
3206 new_sublist->fn_field.is_stub = 1;
3212 complain (&member_fn_complaint, (*pp)[-1]);
3213 /* Fall through into normal member function. */
3216 /* normal member function. */
3217 new_sublist->fn_field.voffset = 0;
3218 new_sublist->fn_field.fcontext = 0;
3222 new_sublist->next = sublist;
3223 sublist = new_sublist;
3225 STABS_CONTINUE (pp, objfile);
3227 while (**pp != ';' && **pp != '\0');
3231 new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
3232 obstack_alloc (&objfile->type_obstack,
3233 sizeof (struct fn_field) * length);
3234 memset (new_fnlist->fn_fieldlist.fn_fields, 0,
3235 sizeof (struct fn_field) * length);
3236 for (i = length; (i--, sublist); sublist = sublist->next)
3238 new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
3241 new_fnlist->fn_fieldlist.length = length;
3242 new_fnlist->next = fip->fnlist;
3243 fip->fnlist = new_fnlist;
3245 total_length += length;
3246 STABS_CONTINUE (pp, objfile);
3251 ALLOCATE_CPLUS_STRUCT_TYPE (type);
3252 TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
3253 TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
3254 memset (TYPE_FN_FIELDLISTS (type), 0,
3255 sizeof (struct fn_fieldlist) * nfn_fields);
3256 TYPE_NFN_FIELDS (type) = nfn_fields;
3257 TYPE_NFN_FIELDS_TOTAL (type) = total_length;
3263 /* Special GNU C++ name.
3265 Returns 1 for success, 0 for failure. "failure" means that we can't
3266 keep parsing and it's time for error_type(). */
3269 read_cpp_abbrev (fip, pp, type, objfile)
3270 struct field_info *fip;
3273 struct objfile *objfile;
3278 struct type *context;
3288 /* At this point, *pp points to something like "22:23=*22...",
3289 where the type number before the ':' is the "context" and
3290 everything after is a regular type definition. Lookup the
3291 type, find it's name, and construct the field name. */
3293 context = read_type (pp, objfile);
3297 case 'f': /* $vf -- a virtual function table pointer */
3298 fip->list->field.name =
3299 obconcat (&objfile->type_obstack, vptr_name, "", "");
3302 case 'b': /* $vb -- a virtual bsomethingorother */
3303 name = type_name_no_tag (context);
3306 complain (&invalid_cpp_type_complaint, symnum);
3309 fip->list->field.name =
3310 obconcat (&objfile->type_obstack, vb_name, name, "");
3314 complain (&invalid_cpp_abbrev_complaint, *pp);
3315 fip->list->field.name =
3316 obconcat (&objfile->type_obstack,
3317 "INVALID_CPLUSPLUS_ABBREV", "", "");
3321 /* At this point, *pp points to the ':'. Skip it and read the
3327 complain (&invalid_cpp_abbrev_complaint, *pp);
3330 fip->list->field.type = read_type (pp, objfile);
3332 (*pp)++; /* Skip the comma. */
3338 FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ';', &nbits);
3342 /* This field is unpacked. */
3343 FIELD_BITSIZE (fip->list->field) = 0;
3344 fip->list->visibility = VISIBILITY_PRIVATE;
3348 complain (&invalid_cpp_abbrev_complaint, *pp);
3349 /* We have no idea what syntax an unrecognized abbrev would have, so
3350 better return 0. If we returned 1, we would need to at least advance
3351 *pp to avoid an infinite loop. */
3358 read_one_struct_field (fip, pp, p, type, objfile)
3359 struct field_info *fip;
3363 struct objfile *objfile;
3365 /* The following is code to work around cfront generated stabs.
3366 The stabs contains full mangled name for each field.
3367 We try to demangle the name and extract the field name out of it.
3369 if (ARM_DEMANGLING && current_subfile->language == language_cplus)
3375 dem = cplus_demangle (*pp, DMGL_ANSI | DMGL_PARAMS);
3378 dem_p = strrchr (dem, ':');
3379 if (dem_p != 0 && *(dem_p - 1) == ':')
3381 FIELD_NAME (fip->list->field) =
3382 obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
3386 FIELD_NAME (fip->list->field) =
3387 obsavestring (*pp, p - *pp, &objfile->type_obstack);
3391 /* end of code for cfront work around */
3394 fip->list->field.name =
3395 obsavestring (*pp, p - *pp, &objfile->type_obstack);
3398 /* This means we have a visibility for a field coming. */
3402 fip->list->visibility = *(*pp)++;
3406 /* normal dbx-style format, no explicit visibility */
3407 fip->list->visibility = VISIBILITY_PUBLIC;
3410 fip->list->field.type = read_type (pp, objfile);
3415 /* Possible future hook for nested types. */
3418 fip->list->field.bitpos = (long) -2; /* nested type */
3428 /* Static class member. */
3429 SET_FIELD_PHYSNAME (fip->list->field, savestring (*pp, p - *pp));
3433 else if (**pp != ',')
3435 /* Bad structure-type format. */
3436 complain (&stabs_general_complaint, "bad structure-type format");
3440 (*pp)++; /* Skip the comma. */
3444 FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits);
3447 complain (&stabs_general_complaint, "bad structure-type format");
3450 FIELD_BITSIZE (fip->list->field) = read_huge_number (pp, ';', &nbits);
3453 complain (&stabs_general_complaint, "bad structure-type format");
3458 if (FIELD_BITPOS (fip->list->field) == 0
3459 && FIELD_BITSIZE (fip->list->field) == 0)
3461 /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
3462 it is a field which has been optimized out. The correct stab for
3463 this case is to use VISIBILITY_IGNORE, but that is a recent
3464 invention. (2) It is a 0-size array. For example
3465 union { int num; char str[0]; } foo. Printing "<no value>" for
3466 str in "p foo" is OK, since foo.str (and thus foo.str[3])
3467 will continue to work, and a 0-size array as a whole doesn't
3468 have any contents to print.
3470 I suspect this probably could also happen with gcc -gstabs (not
3471 -gstabs+) for static fields, and perhaps other C++ extensions.
3472 Hopefully few people use -gstabs with gdb, since it is intended
3473 for dbx compatibility. */
3475 /* Ignore this field. */
3476 fip->list->visibility = VISIBILITY_IGNORE;
3480 /* Detect an unpacked field and mark it as such.
3481 dbx gives a bit size for all fields.
3482 Note that forward refs cannot be packed,
3483 and treat enums as if they had the width of ints. */
3485 struct type *field_type = check_typedef (FIELD_TYPE (fip->list->field));
3487 if (TYPE_CODE (field_type) != TYPE_CODE_INT
3488 && TYPE_CODE (field_type) != TYPE_CODE_RANGE
3489 && TYPE_CODE (field_type) != TYPE_CODE_BOOL
3490 && TYPE_CODE (field_type) != TYPE_CODE_ENUM)
3492 FIELD_BITSIZE (fip->list->field) = 0;
3494 if ((FIELD_BITSIZE (fip->list->field)
3495 == TARGET_CHAR_BIT * TYPE_LENGTH (field_type)
3496 || (TYPE_CODE (field_type) == TYPE_CODE_ENUM
3497 && FIELD_BITSIZE (fip->list->field) == TARGET_INT_BIT)
3500 FIELD_BITPOS (fip->list->field) % 8 == 0)
3502 FIELD_BITSIZE (fip->list->field) = 0;
3508 /* Read struct or class data fields. They have the form:
3510 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
3512 At the end, we see a semicolon instead of a field.
3514 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
3517 The optional VISIBILITY is one of:
3519 '/0' (VISIBILITY_PRIVATE)
3520 '/1' (VISIBILITY_PROTECTED)
3521 '/2' (VISIBILITY_PUBLIC)
3522 '/9' (VISIBILITY_IGNORE)
3524 or nothing, for C style fields with public visibility.
3526 Returns 1 for success, 0 for failure. */
3529 read_struct_fields (fip, pp, type, objfile)
3530 struct field_info *fip;
3533 struct objfile *objfile;
3536 struct nextfield *new;
3538 /* We better set p right now, in case there are no fields at all... */
3542 /* Read each data member type until we find the terminating ';' at the end of
3543 the data member list, or break for some other reason such as finding the
3544 start of the member function list. */
3548 if (os9k_stabs && **pp == ',')
3550 STABS_CONTINUE (pp, objfile);
3551 /* Get space to record the next field's data. */
3552 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3553 make_cleanup (free, new);
3554 memset (new, 0, sizeof (struct nextfield));
3555 new->next = fip->list;
3558 /* Get the field name. */
3561 /* If is starts with CPLUS_MARKER it is a special abbreviation,
3562 unless the CPLUS_MARKER is followed by an underscore, in
3563 which case it is just the name of an anonymous type, which we
3564 should handle like any other type name. */
3566 if (is_cplus_marker (p[0]) && p[1] != '_')
3568 if (!read_cpp_abbrev (fip, pp, type, objfile))
3573 /* Look for the ':' that separates the field name from the field
3574 values. Data members are delimited by a single ':', while member
3575 functions are delimited by a pair of ':'s. When we hit the member
3576 functions (if any), terminate scan loop and return. */
3578 while (*p != ':' && *p != '\0')
3585 /* Check to see if we have hit the member functions yet. */
3590 read_one_struct_field (fip, pp, p, type, objfile);
3592 if (p[0] == ':' && p[1] == ':')
3594 /* chill the list of fields: the last entry (at the head) is a
3595 partially constructed entry which we now scrub. */
3596 fip->list = fip->list->next;
3601 /* The stabs for C++ derived classes contain baseclass information which
3602 is marked by a '!' character after the total size. This function is
3603 called when we encounter the baseclass marker, and slurps up all the
3604 baseclass information.
3606 Immediately following the '!' marker is the number of base classes that
3607 the class is derived from, followed by information for each base class.
3608 For each base class, there are two visibility specifiers, a bit offset
3609 to the base class information within the derived class, a reference to
3610 the type for the base class, and a terminating semicolon.
3612 A typical example, with two base classes, would be "!2,020,19;0264,21;".
3614 Baseclass information marker __________________|| | | | | | |
3615 Number of baseclasses __________________________| | | | | | |
3616 Visibility specifiers (2) ________________________| | | | | |
3617 Offset in bits from start of class _________________| | | | |
3618 Type number for base class ___________________________| | | |
3619 Visibility specifiers (2) _______________________________| | |
3620 Offset in bits from start of class ________________________| |
3621 Type number of base class ____________________________________|
3623 Return 1 for success, 0 for (error-type-inducing) failure. */
3629 read_baseclasses (fip, pp, type, objfile)
3630 struct field_info *fip;
3633 struct objfile *objfile;
3636 struct nextfield *new;
3644 /* Skip the '!' baseclass information marker. */
3648 ALLOCATE_CPLUS_STRUCT_TYPE (type);
3651 TYPE_N_BASECLASSES (type) = read_huge_number (pp, ',', &nbits);
3657 /* Some stupid compilers have trouble with the following, so break
3658 it up into simpler expressions. */
3659 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
3660 TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
3663 int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
3666 pointer = (char *) TYPE_ALLOC (type, num_bytes);
3667 TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
3671 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
3673 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
3675 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3676 make_cleanup (free, new);
3677 memset (new, 0, sizeof (struct nextfield));
3678 new->next = fip->list;
3680 FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
3682 STABS_CONTINUE (pp, objfile);
3686 /* Nothing to do. */
3689 SET_TYPE_FIELD_VIRTUAL (type, i);
3692 /* Unknown character. Complain and treat it as non-virtual. */
3694 static struct complaint msg =
3696 "Unknown virtual character `%c' for baseclass", 0, 0};
3697 complain (&msg, **pp);
3702 new->visibility = *(*pp)++;
3703 switch (new->visibility)
3705 case VISIBILITY_PRIVATE:
3706 case VISIBILITY_PROTECTED:
3707 case VISIBILITY_PUBLIC:
3710 /* Bad visibility format. Complain and treat it as
3713 static struct complaint msg =
3715 "Unknown visibility `%c' for baseclass", 0, 0};
3716 complain (&msg, new->visibility);
3717 new->visibility = VISIBILITY_PUBLIC;
3724 /* The remaining value is the bit offset of the portion of the object
3725 corresponding to this baseclass. Always zero in the absence of
3726 multiple inheritance. */
3728 FIELD_BITPOS (new->field) = read_huge_number (pp, ',', &nbits);
3733 /* The last piece of baseclass information is the type of the
3734 base class. Read it, and remember it's type name as this
3737 new->field.type = read_type (pp, objfile);
3738 new->field.name = type_name_no_tag (new->field.type);
3740 /* skip trailing ';' and bump count of number of fields seen */
3749 /* The tail end of stabs for C++ classes that contain a virtual function
3750 pointer contains a tilde, a %, and a type number.
3751 The type number refers to the base class (possibly this class itself) which
3752 contains the vtable pointer for the current class.
3754 This function is called when we have parsed all the method declarations,
3755 so we can look for the vptr base class info. */
3758 read_tilde_fields (fip, pp, type, objfile)
3759 struct field_info *fip;
3762 struct objfile *objfile;
3766 STABS_CONTINUE (pp, objfile);
3768 /* If we are positioned at a ';', then skip it. */
3778 if (**pp == '=' || **pp == '+' || **pp == '-')
3780 /* Obsolete flags that used to indicate the presence
3781 of constructors and/or destructors. */
3785 /* Read either a '%' or the final ';'. */
3786 if (*(*pp)++ == '%')
3788 /* The next number is the type number of the base class
3789 (possibly our own class) which supplies the vtable for
3790 this class. Parse it out, and search that class to find
3791 its vtable pointer, and install those into TYPE_VPTR_BASETYPE
3792 and TYPE_VPTR_FIELDNO. */
3797 t = read_type (pp, objfile);
3799 while (*p != '\0' && *p != ';')
3805 /* Premature end of symbol. */
3809 TYPE_VPTR_BASETYPE (type) = t;
3810 if (type == t) /* Our own class provides vtbl ptr */
3812 for (i = TYPE_NFIELDS (t) - 1;
3813 i >= TYPE_N_BASECLASSES (t);
3816 if (!strncmp (TYPE_FIELD_NAME (t, i), vptr_name,
3817 sizeof (vptr_name) - 1))
3819 TYPE_VPTR_FIELDNO (type) = i;
3823 /* Virtual function table field not found. */
3824 complain (&vtbl_notfound_complaint, TYPE_NAME (type));
3829 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (t);
3840 attach_fn_fields_to_type (fip, type)
3841 struct field_info *fip;
3842 register struct type *type;
3846 for (n = TYPE_NFN_FIELDS (type);
3847 fip->fnlist != NULL;
3848 fip->fnlist = fip->fnlist->next)
3850 --n; /* Circumvent Sun3 compiler bug */
3851 TYPE_FN_FIELDLISTS (type)[n] = fip->fnlist->fn_fieldlist;
3856 /* read cfront class static data.
3857 pp points to string starting with the list of static data
3858 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
3861 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
3866 read_cfront_static_fields (fip, pp, type, objfile)
3867 struct field_info *fip;
3870 struct objfile *objfile;
3872 struct nextfield *new;
3875 struct symbol *ref_static = 0;
3877 if (**pp == ';') /* no static data; return */
3883 /* Process each field in the list until we find the terminating ";" */
3885 /* eg: p = "as__1A ;;;" */
3886 STABS_CONTINUE (pp, objfile); /* handle \\ */
3887 while (**pp != ';' && (sname = get_substring (pp, ' '), sname))
3889 ref_static = lookup_symbol (sname, 0, VAR_NAMESPACE, 0, 0); /*demangled_name */
3892 static struct complaint msg =
3894 Unable to find symbol for static data field %s\n",
3896 complain (&msg, sname);
3899 stype = SYMBOL_TYPE (ref_static);
3901 /* allocate a new fip */
3902 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3903 make_cleanup (free, new);
3904 memset (new, 0, sizeof (struct nextfield));
3905 new->next = fip->list;
3908 /* set visibility */
3909 /* FIXME! no way to tell visibility from stabs??? */
3910 new->visibility = VISIBILITY_PUBLIC;
3912 /* set field info into fip */
3913 fip->list->field.type = stype;
3915 /* set bitpos & bitsize */
3916 SET_FIELD_PHYSNAME (fip->list->field, savestring (sname, strlen (sname)));
3918 /* set name field */
3919 /* The following is code to work around cfront generated stabs.
3920 The stabs contains full mangled name for each field.
3921 We try to demangle the name and extract the field name out of it.
3926 dem = cplus_demangle (sname, DMGL_ANSI | DMGL_PARAMS);
3929 dem_p = strrchr (dem, ':');
3930 if (dem_p != 0 && *(dem_p - 1) == ':')
3932 fip->list->field.name =
3933 obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
3937 fip->list->field.name =
3938 obsavestring (sname, strlen (sname), &objfile->type_obstack);
3940 } /* end of code for cfront work around */
3941 } /* loop again for next static field */
3945 /* Copy structure fields to fip so attach_fields_to_type will work.
3946 type has already been created with the initial instance data fields.
3947 Now we want to be able to add the other members to the class,
3948 so we want to add them back to the fip and reattach them again
3949 once we have collected all the class members. */
3952 copy_cfront_struct_fields (fip, type, objfile)
3953 struct field_info *fip;
3955 struct objfile *objfile;
3957 int nfields = TYPE_NFIELDS (type);
3959 struct nextfield *new;
3961 /* Copy the fields into the list of fips and reset the types
3962 to remove the old fields */
3964 for (i = 0; i < nfields; i++)
3966 /* allocate a new fip */
3967 new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
3968 make_cleanup (free, new);
3969 memset (new, 0, sizeof (struct nextfield));
3970 new->next = fip->list;
3973 /* copy field info into fip */
3974 new->field = TYPE_FIELD (type, i);
3975 /* set visibility */
3976 if (TYPE_FIELD_PROTECTED (type, i))
3977 new->visibility = VISIBILITY_PROTECTED;
3978 else if (TYPE_FIELD_PRIVATE (type, i))
3979 new->visibility = VISIBILITY_PRIVATE;
3981 new->visibility = VISIBILITY_PUBLIC;
3983 /* Now delete the fields from the type since we will be
3984 allocing new space once we get the rest of the fields
3985 in attach_fields_to_type.
3986 The pointer TYPE_FIELDS(type) is left dangling but should
3987 be freed later by objstack_free */
3988 TYPE_FIELDS (type) = 0;
3989 TYPE_NFIELDS (type) = 0;
3994 /* Create the vector of fields, and record how big it is.
3995 We need this info to record proper virtual function table information
3996 for this class's virtual functions. */
3999 attach_fields_to_type (fip, type, objfile)
4000 struct field_info *fip;
4001 register struct type *type;
4002 struct objfile *objfile;
4004 register int nfields = 0;
4005 register int non_public_fields = 0;
4006 register struct nextfield *scan;
4008 /* Count up the number of fields that we have, as well as taking note of
4009 whether or not there are any non-public fields, which requires us to
4010 allocate and build the private_field_bits and protected_field_bits
4013 for (scan = fip->list; scan != NULL; scan = scan->next)
4016 if (scan->visibility != VISIBILITY_PUBLIC)
4018 non_public_fields++;
4022 /* Now we know how many fields there are, and whether or not there are any
4023 non-public fields. Record the field count, allocate space for the
4024 array of fields, and create blank visibility bitfields if necessary. */
4026 TYPE_NFIELDS (type) = nfields;
4027 TYPE_FIELDS (type) = (struct field *)
4028 TYPE_ALLOC (type, sizeof (struct field) * nfields);
4029 memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
4031 if (non_public_fields)
4033 ALLOCATE_CPLUS_STRUCT_TYPE (type);
4035 TYPE_FIELD_PRIVATE_BITS (type) =
4036 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
4037 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
4039 TYPE_FIELD_PROTECTED_BITS (type) =
4040 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
4041 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
4043 TYPE_FIELD_IGNORE_BITS (type) =
4044 (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
4045 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
4048 /* Copy the saved-up fields into the field vector. Start from the head
4049 of the list, adding to the tail of the field array, so that they end
4050 up in the same order in the array in which they were added to the list. */
4052 while (nfields-- > 0)
4054 TYPE_FIELD (type, nfields) = fip->list->field;
4055 switch (fip->list->visibility)
4057 case VISIBILITY_PRIVATE:
4058 SET_TYPE_FIELD_PRIVATE (type, nfields);
4061 case VISIBILITY_PROTECTED:
4062 SET_TYPE_FIELD_PROTECTED (type, nfields);
4065 case VISIBILITY_IGNORE:
4066 SET_TYPE_FIELD_IGNORE (type, nfields);
4069 case VISIBILITY_PUBLIC:
4073 /* Unknown visibility. Complain and treat it as public. */
4075 static struct complaint msg =
4077 "Unknown visibility `%c' for field", 0, 0};
4078 complain (&msg, fip->list->visibility);
4082 fip->list = fip->list->next;
4087 /* Read the description of a structure (or union type) and return an object
4088 describing the type.
4090 PP points to a character pointer that points to the next unconsumed token
4091 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
4092 *PP will point to "4a:1,0,32;;".
4094 TYPE points to an incomplete type that needs to be filled in.
4096 OBJFILE points to the current objfile from which the stabs information is
4097 being read. (Note that it is redundant in that TYPE also contains a pointer
4098 to this same objfile, so it might be a good idea to eliminate it. FIXME).
4101 static struct type *
4102 read_struct_type (pp, type, objfile)
4105 struct objfile *objfile;
4107 struct cleanup *back_to;
4108 struct field_info fi;
4113 back_to = make_cleanup (null_cleanup, 0);
4115 INIT_CPLUS_SPECIFIC (type);
4116 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
4118 /* First comes the total size in bytes. */
4122 TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits);
4124 return error_type (pp, objfile);
4127 /* Now read the baseclasses, if any, read the regular C struct or C++
4128 class member fields, attach the fields to the type, read the C++
4129 member functions, attach them to the type, and then read any tilde
4130 field (baseclass specifier for the class holding the main vtable). */
4132 if (!read_baseclasses (&fi, pp, type, objfile)
4133 || !read_struct_fields (&fi, pp, type, objfile)
4134 || !attach_fields_to_type (&fi, type, objfile)
4135 || !read_member_functions (&fi, pp, type, objfile)
4136 || !attach_fn_fields_to_type (&fi, type)
4137 || !read_tilde_fields (&fi, pp, type, objfile))
4139 type = error_type (pp, objfile);
4142 do_cleanups (back_to);
4146 /* Read a definition of an array type,
4147 and create and return a suitable type object.
4148 Also creates a range type which represents the bounds of that
4151 static struct type *
4152 read_array_type (pp, type, objfile)
4154 register struct type *type;
4155 struct objfile *objfile;
4157 struct type *index_type, *element_type, *range_type;
4162 /* Format of an array type:
4163 "ar<index type>;lower;upper;<array_contents_type>".
4164 OS9000: "arlower,upper;<array_contents_type>".
4166 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
4167 for these, produce a type like float[][]. */
4170 index_type = builtin_type_int;
4173 index_type = read_type (pp, objfile);
4175 /* Improper format of array type decl. */
4176 return error_type (pp, objfile);
4180 if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
4185 lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits);
4187 return error_type (pp, objfile);
4189 if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
4194 upper = read_huge_number (pp, ';', &nbits);
4196 return error_type (pp, objfile);
4198 element_type = read_type (pp, objfile);
4207 create_range_type ((struct type *) NULL, index_type, lower, upper);
4208 type = create_array_type (type, element_type, range_type);
4214 /* Read a definition of an enumeration type,
4215 and create and return a suitable type object.
4216 Also defines the symbols that represent the values of the type. */
4218 static struct type *
4219 read_enum_type (pp, type, objfile)
4221 register struct type *type;
4222 struct objfile *objfile;
4227 register struct symbol *sym;
4229 struct pending **symlist;
4230 struct pending *osyms, *syms;
4233 int unsigned_enum = 1;
4236 /* FIXME! The stabs produced by Sun CC merrily define things that ought
4237 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
4238 to do? For now, force all enum values to file scope. */
4239 if (within_function)
4240 symlist = &local_symbols;
4243 symlist = &file_symbols;
4245 o_nsyms = osyms ? osyms->nsyms : 0;
4249 /* Size. Perhaps this does not have to be conditionalized on
4250 os9k_stabs (assuming the name of an enum constant can't start
4252 read_huge_number (pp, 0, &nbits);
4254 return error_type (pp, objfile);
4257 /* The aix4 compiler emits an extra field before the enum members;
4258 my guess is it's a type of some sort. Just ignore it. */
4261 /* Skip over the type. */
4265 /* Skip over the colon. */
4269 /* Read the value-names and their values.
4270 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
4271 A semicolon or comma instead of a NAME means the end. */
4272 while (**pp && **pp != ';' && **pp != ',')
4274 STABS_CONTINUE (pp, objfile);
4278 name = obsavestring (*pp, p - *pp, &objfile->symbol_obstack);
4280 n = read_huge_number (pp, ',', &nbits);
4282 return error_type (pp, objfile);
4284 sym = (struct symbol *)
4285 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
4286 memset (sym, 0, sizeof (struct symbol));
4287 SYMBOL_NAME (sym) = name;
4288 SYMBOL_LANGUAGE (sym) = current_subfile->language;
4289 SYMBOL_CLASS (sym) = LOC_CONST;
4290 SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
4291 SYMBOL_VALUE (sym) = n;
4294 add_symbol_to_list (sym, symlist);
4299 (*pp)++; /* Skip the semicolon. */
4301 /* Now fill in the fields of the type-structure. */
4303 TYPE_LENGTH (type) = TARGET_INT_BIT / HOST_CHAR_BIT;
4304 TYPE_CODE (type) = TYPE_CODE_ENUM;
4305 TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
4307 TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
4308 TYPE_NFIELDS (type) = nsyms;
4309 TYPE_FIELDS (type) = (struct field *)
4310 TYPE_ALLOC (type, sizeof (struct field) * nsyms);
4311 memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nsyms);
4313 /* Find the symbols for the values and put them into the type.
4314 The symbols can be found in the symlist that we put them on
4315 to cause them to be defined. osyms contains the old value
4316 of that symlist; everything up to there was defined by us. */
4317 /* Note that we preserve the order of the enum constants, so
4318 that in something like "enum {FOO, LAST_THING=FOO}" we print
4319 FOO, not LAST_THING. */
4321 for (syms = *symlist, n = nsyms - 1; syms; syms = syms->next)
4323 int last = syms == osyms ? o_nsyms : 0;
4324 int j = syms->nsyms;
4325 for (; --j >= last; --n)
4327 struct symbol *xsym = syms->symbol[j];
4328 SYMBOL_TYPE (xsym) = type;
4329 TYPE_FIELD_NAME (type, n) = SYMBOL_NAME (xsym);
4330 TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
4331 TYPE_FIELD_BITSIZE (type, n) = 0;
4340 /* Sun's ACC uses a somewhat saner method for specifying the builtin
4341 typedefs in every file (for int, long, etc):
4343 type = b <signed> <width> <format type>; <offset>; <nbits>
4345 optional format type = c or b for char or boolean.
4346 offset = offset from high order bit to start bit of type.
4347 width is # bytes in object of this type, nbits is # bits in type.
4349 The width/offset stuff appears to be for small objects stored in
4350 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
4353 static struct type *
4354 read_sun_builtin_type (pp, typenums, objfile)
4357 struct objfile *objfile;
4362 enum type_code code = TYPE_CODE_INT;
4373 return error_type (pp, objfile);
4377 /* For some odd reason, all forms of char put a c here. This is strange
4378 because no other type has this honor. We can safely ignore this because
4379 we actually determine 'char'acterness by the number of bits specified in
4381 Boolean forms, e.g Fortran logical*X, put a b here. */
4385 else if (**pp == 'b')
4387 code = TYPE_CODE_BOOL;
4391 /* The first number appears to be the number of bytes occupied
4392 by this type, except that unsigned short is 4 instead of 2.
4393 Since this information is redundant with the third number,
4394 we will ignore it. */
4395 read_huge_number (pp, ';', &nbits);
4397 return error_type (pp, objfile);
4399 /* The second number is always 0, so ignore it too. */
4400 read_huge_number (pp, ';', &nbits);
4402 return error_type (pp, objfile);
4404 /* The third number is the number of bits for this type. */
4405 type_bits = read_huge_number (pp, 0, &nbits);
4407 return error_type (pp, objfile);
4408 /* The type *should* end with a semicolon. If it are embedded
4409 in a larger type the semicolon may be the only way to know where
4410 the type ends. If this type is at the end of the stabstring we
4411 can deal with the omitted semicolon (but we don't have to like
4412 it). Don't bother to complain(), Sun's compiler omits the semicolon
4418 return init_type (TYPE_CODE_VOID, 1,
4419 signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
4422 return init_type (code,
4423 type_bits / TARGET_CHAR_BIT,
4424 signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *) NULL,
4428 static struct type *
4429 read_sun_floating_type (pp, typenums, objfile)
4432 struct objfile *objfile;
4438 /* The first number has more details about the type, for example
4440 details = read_huge_number (pp, ';', &nbits);
4442 return error_type (pp, objfile);
4444 /* The second number is the number of bytes occupied by this type */
4445 nbytes = read_huge_number (pp, ';', &nbits);
4447 return error_type (pp, objfile);
4449 if (details == NF_COMPLEX || details == NF_COMPLEX16
4450 || details == NF_COMPLEX32)
4451 /* This is a type we can't handle, but we do know the size.
4452 We also will be able to give it a name. */
4453 return init_type (TYPE_CODE_COMPLEX, nbytes, 0, NULL, objfile);
4455 return init_type (TYPE_CODE_FLT, nbytes, 0, NULL, objfile);
4458 /* Read a number from the string pointed to by *PP.
4459 The value of *PP is advanced over the number.
4460 If END is nonzero, the character that ends the
4461 number must match END, or an error happens;
4462 and that character is skipped if it does match.
4463 If END is zero, *PP is left pointing to that character.
4465 If the number fits in a long, set *BITS to 0 and return the value.
4466 If not, set *BITS to be the number of bits in the number and return 0.
4468 If encounter garbage, set *BITS to -1 and return 0. */
4471 read_huge_number (pp, end, bits)
4491 /* Leading zero means octal. GCC uses this to output values larger
4492 than an int (because that would be hard in decimal). */
4500 upper_limit = ULONG_MAX / radix;
4502 upper_limit = LONG_MAX / radix;
4504 while ((c = *p++) >= '0' && c < ('0' + radix))
4506 if (n <= upper_limit)
4509 n += c - '0'; /* FIXME this overflows anyway */
4514 /* This depends on large values being output in octal, which is
4521 /* Ignore leading zeroes. */
4525 else if (c == '2' || c == '3')
4551 /* Large decimal constants are an error (because it is hard to
4552 count how many bits are in them). */
4558 /* -0x7f is the same as 0x80. So deal with it by adding one to
4559 the number of bits. */
4571 /* It's *BITS which has the interesting information. */
4575 static struct type *
4576 read_range_type (pp, typenums, objfile)
4579 struct objfile *objfile;
4581 char *orig_pp = *pp;
4586 struct type *result_type;
4587 struct type *index_type = NULL;
4589 /* First comes a type we are a subrange of.
4590 In C it is usually 0, 1 or the type being defined. */
4591 if (read_type_number (pp, rangenums) != 0)
4592 return error_type (pp, objfile);
4593 self_subrange = (rangenums[0] == typenums[0] &&
4594 rangenums[1] == typenums[1]);
4599 index_type = read_type (pp, objfile);
4602 /* A semicolon should now follow; skip it. */
4606 /* The remaining two operands are usually lower and upper bounds
4607 of the range. But in some special cases they mean something else. */
4608 n2 = read_huge_number (pp, ';', &n2bits);
4609 n3 = read_huge_number (pp, ';', &n3bits);
4611 if (n2bits == -1 || n3bits == -1)
4612 return error_type (pp, objfile);
4615 goto handle_true_range;
4617 /* If limits are huge, must be large integral type. */
4618 if (n2bits != 0 || n3bits != 0)
4620 char got_signed = 0;
4621 char got_unsigned = 0;
4622 /* Number of bits in the type. */
4625 /* Range from 0 to <large number> is an unsigned large integral type. */
4626 if ((n2bits == 0 && n2 == 0) && n3bits != 0)
4631 /* Range from <large number> to <large number>-1 is a large signed
4632 integral type. Take care of the case where <large number> doesn't
4633 fit in a long but <large number>-1 does. */
4634 else if ((n2bits != 0 && n3bits != 0 && n2bits == n3bits + 1)
4635 || (n2bits != 0 && n3bits == 0
4636 && (n2bits == sizeof (long) * HOST_CHAR_BIT)
4643 if (got_signed || got_unsigned)
4645 return init_type (TYPE_CODE_INT, nbits / TARGET_CHAR_BIT,
4646 got_unsigned ? TYPE_FLAG_UNSIGNED : 0, NULL,
4650 return error_type (pp, objfile);
4653 /* A type defined as a subrange of itself, with bounds both 0, is void. */
4654 if (self_subrange && n2 == 0 && n3 == 0)
4655 return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
4657 /* If n3 is zero and n2 is positive, we want a floating type, and n2
4658 is the width in bytes.
4660 Fortran programs appear to use this for complex types also. To
4661 distinguish between floats and complex, g77 (and others?) seem
4662 to use self-subranges for the complexes, and subranges of int for
4665 Also note that for complexes, g77 sets n2 to the size of one of
4666 the member floats, not the whole complex beast. My guess is that
4667 this was to work well with pre-COMPLEX versions of gdb. */
4669 if (n3 == 0 && n2 > 0)
4673 return init_type (TYPE_CODE_COMPLEX, 2 * n2, 0, NULL, objfile);
4677 return init_type (TYPE_CODE_FLT, n2, 0, NULL, objfile);
4681 /* If the upper bound is -1, it must really be an unsigned int. */
4683 else if (n2 == 0 && n3 == -1)
4685 /* It is unsigned int or unsigned long. */
4686 /* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
4687 compatibility hack. */
4688 return init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
4689 TYPE_FLAG_UNSIGNED, NULL, objfile);
4692 /* Special case: char is defined (Who knows why) as a subrange of
4693 itself with range 0-127. */
4694 else if (self_subrange && n2 == 0 && n3 == 127)
4695 return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
4697 else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill
4699 goto handle_true_range;
4701 /* We used to do this only for subrange of self or subrange of int. */
4705 /* n3 actually gives the size. */
4706 return init_type (TYPE_CODE_INT, -n3, TYPE_FLAG_UNSIGNED,
4709 return init_type (TYPE_CODE_INT, 1, TYPE_FLAG_UNSIGNED, NULL, objfile);
4711 return init_type (TYPE_CODE_INT, 2, TYPE_FLAG_UNSIGNED, NULL, objfile);
4713 /* -1 is used for the upper bound of (4 byte) "unsigned int" and
4714 "unsigned long", and we already checked for that,
4715 so don't need to test for it here. */
4717 /* I think this is for Convex "long long". Since I don't know whether
4718 Convex sets self_subrange, I also accept that particular size regardless
4719 of self_subrange. */
4720 else if (n3 == 0 && n2 < 0
4722 || n2 == -TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT))
4723 return init_type (TYPE_CODE_INT, -n2, 0, NULL, objfile);
4724 else if (n2 == -n3 - 1)
4727 return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
4729 return init_type (TYPE_CODE_INT, 2, 0, NULL, objfile);
4730 if (n3 == 0x7fffffff)
4731 return init_type (TYPE_CODE_INT, 4, 0, NULL, objfile);
4734 /* We have a real range type on our hands. Allocate space and
4735 return a real pointer. */
4739 index_type = builtin_type_int;
4741 index_type = *dbx_lookup_type (rangenums);
4742 if (index_type == NULL)
4744 /* Does this actually ever happen? Is that why we are worrying
4745 about dealing with it rather than just calling error_type? */
4747 static struct type *range_type_index;
4749 complain (&range_type_base_complaint, rangenums[1]);
4750 if (range_type_index == NULL)
4752 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
4753 0, "range type index type", NULL);
4754 index_type = range_type_index;
4757 result_type = create_range_type ((struct type *) NULL, index_type, n2, n3);
4758 return (result_type);
4761 /* Read in an argument list. This is a list of types, separated by commas
4762 and terminated with END. Return the list of types read in, or (struct type
4763 **)-1 if there is an error. */
4765 static struct type **
4766 read_args (pp, end, objfile)
4769 struct objfile *objfile;
4771 /* FIXME! Remove this arbitrary limit! */
4772 struct type *types[1024], **rval; /* allow for fns of 1023 parameters */
4778 /* Invalid argument list: no ','. */
4779 return (struct type **) -1;
4781 STABS_CONTINUE (pp, objfile);
4782 types[n++] = read_type (pp, objfile);
4784 (*pp)++; /* get past `end' (the ':' character) */
4788 rval = (struct type **) xmalloc (2 * sizeof (struct type *));
4790 else if (TYPE_CODE (types[n - 1]) != TYPE_CODE_VOID)
4792 rval = (struct type **) xmalloc ((n + 1) * sizeof (struct type *));
4793 memset (rval + n, 0, sizeof (struct type *));
4797 rval = (struct type **) xmalloc (n * sizeof (struct type *));
4799 memcpy (rval, types, n * sizeof (struct type *));
4803 /* Common block handling. */
4805 /* List of symbols declared since the last BCOMM. This list is a tail
4806 of local_symbols. When ECOMM is seen, the symbols on the list
4807 are noted so their proper addresses can be filled in later,
4808 using the common block base address gotten from the assembler
4811 static struct pending *common_block;
4812 static int common_block_i;
4814 /* Name of the current common block. We get it from the BCOMM instead of the
4815 ECOMM to match IBM documentation (even though IBM puts the name both places
4816 like everyone else). */
4817 static char *common_block_name;
4819 /* Process a N_BCOMM symbol. The storage for NAME is not guaranteed
4820 to remain after this function returns. */
4823 common_block_start (name, objfile)
4825 struct objfile *objfile;
4827 if (common_block_name != NULL)
4829 static struct complaint msg =
4831 "Invalid symbol data: common block within common block",
4835 common_block = local_symbols;
4836 common_block_i = local_symbols ? local_symbols->nsyms : 0;
4837 common_block_name = obsavestring (name, strlen (name),
4838 &objfile->symbol_obstack);
4841 /* Process a N_ECOMM symbol. */
4844 common_block_end (objfile)
4845 struct objfile *objfile;
4847 /* Symbols declared since the BCOMM are to have the common block
4848 start address added in when we know it. common_block and
4849 common_block_i point to the first symbol after the BCOMM in
4850 the local_symbols list; copy the list and hang it off the
4851 symbol for the common block name for later fixup. */
4854 struct pending *new = 0;
4855 struct pending *next;
4858 if (common_block_name == NULL)
4860 static struct complaint msg =
4861 {"ECOMM symbol unmatched by BCOMM", 0, 0};
4866 sym = (struct symbol *)
4867 obstack_alloc (&objfile->symbol_obstack, sizeof (struct symbol));
4868 memset (sym, 0, sizeof (struct symbol));
4869 /* Note: common_block_name already saved on symbol_obstack */
4870 SYMBOL_NAME (sym) = common_block_name;
4871 SYMBOL_CLASS (sym) = LOC_BLOCK;
4873 /* Now we copy all the symbols which have been defined since the BCOMM. */
4875 /* Copy all the struct pendings before common_block. */
4876 for (next = local_symbols;
4877 next != NULL && next != common_block;
4880 for (j = 0; j < next->nsyms; j++)
4881 add_symbol_to_list (next->symbol[j], &new);
4884 /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is
4885 NULL, it means copy all the local symbols (which we already did
4888 if (common_block != NULL)
4889 for (j = common_block_i; j < common_block->nsyms; j++)
4890 add_symbol_to_list (common_block->symbol[j], &new);
4892 SYMBOL_TYPE (sym) = (struct type *) new;
4894 /* Should we be putting local_symbols back to what it was?
4897 i = hashname (SYMBOL_NAME (sym));
4898 SYMBOL_VALUE_CHAIN (sym) = global_sym_chain[i];
4899 global_sym_chain[i] = sym;
4900 common_block_name = NULL;
4903 /* Add a common block's start address to the offset of each symbol
4904 declared to be in it (by being between a BCOMM/ECOMM pair that uses
4905 the common block name). */
4908 fix_common_block (sym, valu)
4912 struct pending *next = (struct pending *) SYMBOL_TYPE (sym);
4913 for (; next; next = next->next)
4916 for (j = next->nsyms - 1; j >= 0; j--)
4917 SYMBOL_VALUE_ADDRESS (next->symbol[j]) += valu;
4923 /* What about types defined as forward references inside of a small lexical
4925 /* Add a type to the list of undefined types to be checked through
4926 once this file has been read in. */
4929 add_undefined_type (type)
4932 if (undef_types_length == undef_types_allocated)
4934 undef_types_allocated *= 2;
4935 undef_types = (struct type **)
4936 xrealloc ((char *) undef_types,
4937 undef_types_allocated * sizeof (struct type *));
4939 undef_types[undef_types_length++] = type;
4942 /* Go through each undefined type, see if it's still undefined, and fix it
4943 up if possible. We have two kinds of undefined types:
4945 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
4946 Fix: update array length using the element bounds
4947 and the target type's length.
4948 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
4949 yet defined at the time a pointer to it was made.
4950 Fix: Do a full lookup on the struct/union tag. */
4952 cleanup_undefined_types ()
4956 for (type = undef_types; type < undef_types + undef_types_length; type++)
4958 switch (TYPE_CODE (*type))
4961 case TYPE_CODE_STRUCT:
4962 case TYPE_CODE_UNION:
4963 case TYPE_CODE_ENUM:
4965 /* Check if it has been defined since. Need to do this here
4966 as well as in check_typedef to deal with the (legitimate in
4967 C though not C++) case of several types with the same name
4968 in different source files. */
4969 if (TYPE_FLAGS (*type) & TYPE_FLAG_STUB)
4971 struct pending *ppt;
4973 /* Name of the type, without "struct" or "union" */
4974 char *typename = TYPE_TAG_NAME (*type);
4976 if (typename == NULL)
4978 static struct complaint msg =
4979 {"need a type name", 0, 0};
4983 for (ppt = file_symbols; ppt; ppt = ppt->next)
4985 for (i = 0; i < ppt->nsyms; i++)
4987 struct symbol *sym = ppt->symbol[i];
4989 if (SYMBOL_CLASS (sym) == LOC_TYPEDEF
4990 && SYMBOL_NAMESPACE (sym) == STRUCT_NAMESPACE
4991 && (TYPE_CODE (SYMBOL_TYPE (sym)) ==
4993 && STREQ (SYMBOL_NAME (sym), typename))
4995 memcpy (*type, SYMBOL_TYPE (sym),
4996 sizeof (struct type));
5006 static struct complaint msg =
5008 GDB internal error. cleanup_undefined_types with bad type %d.", 0, 0};
5009 complain (&msg, TYPE_CODE (*type));
5015 undef_types_length = 0;
5018 /* Scan through all of the global symbols defined in the object file,
5019 assigning values to the debugging symbols that need to be assigned
5020 to. Get these symbols from the minimal symbol table. */
5023 scan_file_globals (objfile)
5024 struct objfile *objfile;
5027 struct minimal_symbol *msymbol;
5028 struct symbol *sym, *prev, *rsym;
5029 struct objfile *resolve_objfile;
5031 /* SVR4 based linkers copy referenced global symbols from shared
5032 libraries to the main executable.
5033 If we are scanning the symbols for a shared library, try to resolve
5034 them from the minimal symbols of the main executable first. */
5036 if (symfile_objfile && objfile != symfile_objfile)
5037 resolve_objfile = symfile_objfile;
5039 resolve_objfile = objfile;
5043 /* Avoid expensive loop through all minimal symbols if there are
5044 no unresolved symbols. */
5045 for (hash = 0; hash < HASHSIZE; hash++)
5047 if (global_sym_chain[hash])
5050 if (hash >= HASHSIZE)
5053 for (msymbol = resolve_objfile->msymbols;
5054 msymbol && SYMBOL_NAME (msymbol) != NULL;
5059 /* Skip static symbols. */
5060 switch (MSYMBOL_TYPE (msymbol))
5072 /* Get the hash index and check all the symbols
5073 under that hash index. */
5075 hash = hashname (SYMBOL_NAME (msymbol));
5077 for (sym = global_sym_chain[hash]; sym;)
5079 if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
5080 STREQ (SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
5083 struct alias_list *aliases;
5085 /* Splice this symbol out of the hash chain and
5086 assign the value we have to it. */
5089 SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
5093 global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
5096 /* Check to see whether we need to fix up a common block. */
5097 /* Note: this code might be executed several times for
5098 the same symbol if there are multiple references. */
5100 /* If symbol has aliases, do minimal symbol fixups for each.
5101 These live aliases/references weren't added to
5102 global_sym_chain hash but may also need to be fixed up. */
5103 /* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal
5104 symbols? Still, we wouldn't want to add_to_list. */
5105 /* Now do the same for each alias of this symbol */
5107 aliases = SYMBOL_ALIASES (sym);
5110 if (SYMBOL_CLASS (rsym) == LOC_BLOCK)
5112 fix_common_block (rsym,
5113 SYMBOL_VALUE_ADDRESS (msymbol));
5117 SYMBOL_VALUE_ADDRESS (rsym)
5118 = SYMBOL_VALUE_ADDRESS (msymbol);
5120 SYMBOL_SECTION (rsym) = SYMBOL_SECTION (msymbol);
5123 rsym = aliases->sym;
5124 aliases = aliases->next;
5133 sym = SYMBOL_VALUE_CHAIN (prev);
5137 sym = global_sym_chain[hash];
5143 sym = SYMBOL_VALUE_CHAIN (sym);
5147 if (resolve_objfile == objfile)
5149 resolve_objfile = objfile;
5152 /* Change the storage class of any remaining unresolved globals to
5153 LOC_UNRESOLVED and remove them from the chain. */
5154 for (hash = 0; hash < HASHSIZE; hash++)
5156 sym = global_sym_chain[hash];
5160 sym = SYMBOL_VALUE_CHAIN (sym);
5162 /* Change the symbol address from the misleading chain value
5164 SYMBOL_VALUE_ADDRESS (prev) = 0;
5166 /* Complain about unresolved common block symbols. */
5167 if (SYMBOL_CLASS (prev) == LOC_STATIC)
5168 SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
5170 complain (&unresolved_sym_chain_complaint,
5171 objfile->name, SYMBOL_NAME (prev));
5174 memset (global_sym_chain, 0, sizeof (global_sym_chain));
5177 /* Initialize anything that needs initializing when starting to read
5178 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
5186 /* Initialize anything that needs initializing when a completely new
5187 symbol file is specified (not just adding some symbols from another
5188 file, e.g. a shared library). */
5191 stabsread_new_init ()
5193 /* Empty the hash table of global syms looking for values. */
5194 memset (global_sym_chain, 0, sizeof (global_sym_chain));
5197 /* Initialize anything that needs initializing at the same time as
5198 start_symtab() is called. */
5203 global_stabs = NULL; /* AIX COFF */
5204 /* Leave FILENUM of 0 free for builtin types and this file's types. */
5205 n_this_object_header_files = 1;
5206 type_vector_length = 0;
5207 type_vector = (struct type **) 0;
5209 /* FIXME: If common_block_name is not already NULL, we should complain(). */
5210 common_block_name = NULL;
5215 /* Call after end_symtab() */
5222 free ((char *) type_vector);
5225 type_vector_length = 0;
5226 previous_stab_code = 0;
5230 finish_global_stabs (objfile)
5231 struct objfile *objfile;
5235 patch_block_stabs (global_symbols, global_stabs, objfile);
5236 free ((PTR) global_stabs);
5237 global_stabs = NULL;
5241 /* Initializer for this module */
5244 _initialize_stabsread ()
5246 undef_types_allocated = 20;
5247 undef_types_length = 0;
5248 undef_types = (struct type **)
5249 xmalloc (undef_types_allocated * sizeof (struct type *));