1 /* Support routines for decoding "stabs" debugging information format.
2 Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
3 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* Support routines for reading and decoding debugging information in
24 the "stabs" format. This format is used with many systems that use
25 the a.out object file format, as well as some systems that use
26 COFF or ELF where the stabs data is placed in a special section.
27 Avoid placing any object file format specific code in this file. */
30 #include "gdb_string.h"
32 #include "gdb_obstack.h"
35 #include "expression.h"
38 #include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
40 #include "aout/aout64.h"
41 #include "gdb-stabs.h"
43 #include "complaints.h"
48 #include "cp-support.h"
52 /* Ask stabsread.h to define the vars it normally declares `extern'. */
55 #include "stabsread.h" /* Our own declarations */
58 extern void _initialize_stabsread (void);
60 /* The routines that read and process a complete stabs for a C struct or
61 C++ class pass lists of data member fields and lists of member function
62 fields in an instance of a field_info structure, as defined below.
63 This is part of some reorganization of low level C++ support and is
64 expected to eventually go away... (FIXME) */
70 struct nextfield
*next
;
72 /* This is the raw visibility from the stab. It is not checked
73 for being one of the visibilities we recognize, so code which
74 examines this field better be able to deal. */
80 struct next_fnfieldlist
82 struct next_fnfieldlist
*next
;
83 struct fn_fieldlist fn_fieldlist
;
89 read_one_struct_field (struct field_info
*, char **, char *,
90 struct type
*, struct objfile
*);
92 static char *get_substring (char **, int);
94 static struct type
*dbx_alloc_type (int[2], struct objfile
*);
96 static long read_huge_number (char **, int, int *);
98 static struct type
*error_type (char **, struct objfile
*);
101 patch_block_stabs (struct pending
*, struct pending_stabs
*,
104 static void fix_common_block (struct symbol
*, int);
106 static int read_type_number (char **, int *);
108 static struct type
*read_range_type (char **, int[2], struct objfile
*);
110 static struct type
*read_sun_builtin_type (char **, int[2], struct objfile
*);
112 static struct type
*read_sun_floating_type (char **, int[2],
115 static struct type
*read_enum_type (char **, struct type
*, struct objfile
*);
117 static struct type
*rs6000_builtin_type (int);
120 read_member_functions (struct field_info
*, char **, struct type
*,
124 read_struct_fields (struct field_info
*, char **, struct type
*,
128 read_baseclasses (struct field_info
*, char **, struct type
*,
132 read_tilde_fields (struct field_info
*, char **, struct type
*,
135 static int attach_fn_fields_to_type (struct field_info
*, struct type
*);
138 attach_fields_to_type (struct field_info
*, struct type
*, struct objfile
*);
140 static struct type
*read_struct_type (char **, struct type
*,
144 static struct type
*read_array_type (char **, struct type
*,
147 static struct field
*read_args (char **, int, struct objfile
*, int *, int *);
150 read_cpp_abbrev (struct field_info
*, char **, struct type
*,
153 /* new functions added for cfront support */
156 copy_cfront_struct_fields (struct field_info
*, struct type
*,
159 static char *get_cfront_method_physname (char *);
162 read_cfront_baseclasses (struct field_info
*, char **,
163 struct type
*, struct objfile
*);
166 read_cfront_static_fields (struct field_info
*, char **,
167 struct type
*, struct objfile
*);
169 read_cfront_member_functions (struct field_info
*, char **,
170 struct type
*, struct objfile
*);
172 static char *find_name_end (char *name
);
174 /* end new functions added for cfront support */
177 add_live_range (struct objfile
*, struct symbol
*, CORE_ADDR
, CORE_ADDR
);
179 static int resolve_live_range (struct objfile
*, struct symbol
*, char *);
181 static int process_reference (char **string
);
183 static CORE_ADDR
ref_search_value (int refnum
);
186 resolve_symbol_reference (struct objfile
*, struct symbol
*, char *);
188 void stabsread_clear_cache (void);
190 static const char vptr_name
[] = "_vptr$";
191 static const char vb_name
[] = "_vb$";
193 /* Define this as 1 if a pcc declaration of a char or short argument
194 gives the correct address. Otherwise assume pcc gives the
195 address of the corresponding int, which is not the same on a
196 big-endian machine. */
198 #if !defined (BELIEVE_PCC_PROMOTION)
199 #define BELIEVE_PCC_PROMOTION 0
201 #if !defined (BELIEVE_PCC_PROMOTION_TYPE)
202 #define BELIEVE_PCC_PROMOTION_TYPE 0
205 static struct deprecated_complaint invalid_cpp_abbrev_complaint
=
206 {"invalid C++ abbreviation `%s'", 0, 0};
208 static struct deprecated_complaint invalid_cpp_type_complaint
=
209 {"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
211 static struct deprecated_complaint member_fn_complaint
=
212 {"member function type missing, got '%c'", 0, 0};
214 static struct deprecated_complaint const_vol_complaint
=
215 {"const/volatile indicator missing, got '%c'", 0, 0};
217 static struct deprecated_complaint error_type_complaint
=
218 {"couldn't parse type; debugger out of date?", 0, 0};
220 static struct deprecated_complaint invalid_member_complaint
=
221 {"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
223 static struct deprecated_complaint range_type_base_complaint
=
224 {"base type %d of range type is not defined", 0, 0};
226 static struct deprecated_complaint reg_value_complaint
=
227 {"register number %d too large (max %d) in symbol %s", 0, 0};
229 static struct deprecated_complaint vtbl_notfound_complaint
=
230 {"virtual function table pointer not found when defining class `%s'", 0, 0};
232 static struct deprecated_complaint unrecognized_cplus_name_complaint
=
233 {"Unknown C++ symbol name `%s'", 0, 0};
235 static struct deprecated_complaint rs6000_builtin_complaint
=
236 {"Unknown builtin type %d", 0, 0};
238 static struct deprecated_complaint unresolved_sym_chain_complaint
=
239 {"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
241 static struct deprecated_complaint stabs_general_complaint
=
244 static struct deprecated_complaint lrs_general_complaint
=
247 /* Make a list of forward references which haven't been defined. */
249 static struct type
**undef_types
;
250 static int undef_types_allocated
;
251 static int undef_types_length
;
252 static struct symbol
*current_symbol
= NULL
;
254 /* Check for and handle cretinous stabs symbol name continuation! */
255 #define STABS_CONTINUE(pp,objfile) \
257 if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
258 *(pp) = next_symbol_text (objfile); \
261 #if 0 /* OBSOLETE OS9K */
262 // OBSOLETE /* FIXME: These probably should be our own types (like rs6000_builtin_type
263 // OBSOLETE has its own types) rather than builtin_type_*. */
264 // OBSOLETE static struct type **os9k_type_vector[] =
267 // OBSOLETE &builtin_type_int,
268 // OBSOLETE &builtin_type_char,
269 // OBSOLETE &builtin_type_long,
270 // OBSOLETE &builtin_type_short,
271 // OBSOLETE &builtin_type_unsigned_char,
272 // OBSOLETE &builtin_type_unsigned_short,
273 // OBSOLETE &builtin_type_unsigned_long,
274 // OBSOLETE &builtin_type_unsigned_int,
275 // OBSOLETE &builtin_type_float,
276 // OBSOLETE &builtin_type_double,
277 // OBSOLETE &builtin_type_void,
278 // OBSOLETE &builtin_type_long_double
281 // OBSOLETE static void os9k_init_type_vector (struct type **);
283 // OBSOLETE static void
284 // OBSOLETE os9k_init_type_vector (struct type **tv)
286 // OBSOLETE unsigned int i;
287 // OBSOLETE for (i = 0; i < sizeof (os9k_type_vector) / sizeof (struct type **); i++)
288 // OBSOLETE tv[i] = (os9k_type_vector[i] == 0 ? 0 : *(os9k_type_vector[i]));
290 #endif /* OBSOLETE OS9K */
292 /* Look up a dbx type-number pair. Return the address of the slot
293 where the type for that number-pair is stored.
294 The number-pair is in TYPENUMS.
296 This can be used for finding the type associated with that pair
297 or for associating a new type with the pair. */
300 dbx_lookup_type (int typenums
[2])
302 register int filenum
= typenums
[0];
303 register int index
= typenums
[1];
305 register int real_filenum
;
306 register struct header_file
*f
;
309 if (filenum
== -1) /* -1,-1 is for temporary types. */
312 if (filenum
< 0 || filenum
>= n_this_object_header_files
)
314 static struct deprecated_complaint msg
=
316 Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
318 complain (&msg
, filenum
, index
, symnum
);
326 /* Caller wants address of address of type. We think
327 that negative (rs6k builtin) types will never appear as
328 "lvalues", (nor should they), so we stuff the real type
329 pointer into a temp, and return its address. If referenced,
330 this will do the right thing. */
331 static struct type
*temp_type
;
333 temp_type
= rs6000_builtin_type (index
);
337 /* Type is defined outside of header files.
338 Find it in this object file's type vector. */
339 if (index
>= type_vector_length
)
341 old_len
= type_vector_length
;
344 type_vector_length
= INITIAL_TYPE_VECTOR_LENGTH
;
345 type_vector
= (struct type
**)
346 xmalloc (type_vector_length
* sizeof (struct type
*));
348 while (index
>= type_vector_length
)
350 type_vector_length
*= 2;
352 type_vector
= (struct type
**)
353 xrealloc ((char *) type_vector
,
354 (type_vector_length
* sizeof (struct type
*)));
355 memset (&type_vector
[old_len
], 0,
356 (type_vector_length
- old_len
) * sizeof (struct type
*));
358 #if 0 /* OBSOLETE OS9K */
359 // OBSOLETE if (os9k_stabs)
360 // OBSOLETE /* Deal with OS9000 fundamental types. */
361 // OBSOLETE os9k_init_type_vector (type_vector);
362 #endif /* OBSOLETE OS9K */
364 return (&type_vector
[index
]);
368 real_filenum
= this_object_header_files
[filenum
];
370 if (real_filenum
>= N_HEADER_FILES (current_objfile
))
372 struct type
*temp_type
;
373 struct type
**temp_type_p
;
375 warning ("GDB internal error: bad real_filenum");
378 temp_type
= init_type (TYPE_CODE_ERROR
, 0, 0, NULL
, NULL
);
379 temp_type_p
= (struct type
**) xmalloc (sizeof (struct type
*));
380 *temp_type_p
= temp_type
;
384 f
= HEADER_FILES (current_objfile
) + real_filenum
;
386 f_orig_length
= f
->length
;
387 if (index
>= f_orig_length
)
389 while (index
>= f
->length
)
393 f
->vector
= (struct type
**)
394 xrealloc ((char *) f
->vector
, f
->length
* sizeof (struct type
*));
395 memset (&f
->vector
[f_orig_length
], 0,
396 (f
->length
- f_orig_length
) * sizeof (struct type
*));
398 return (&f
->vector
[index
]);
402 /* Make sure there is a type allocated for type numbers TYPENUMS
403 and return the type object.
404 This can create an empty (zeroed) type object.
405 TYPENUMS may be (-1, -1) to return a new type object that is not
406 put into the type vector, and so may not be referred to by number. */
409 dbx_alloc_type (int typenums
[2], struct objfile
*objfile
)
411 register struct type
**type_addr
;
413 if (typenums
[0] == -1)
415 return (alloc_type (objfile
));
418 type_addr
= dbx_lookup_type (typenums
);
420 /* If we are referring to a type not known at all yet,
421 allocate an empty type for it.
422 We will fill it in later if we find out how. */
425 *type_addr
= alloc_type (objfile
);
431 /* for all the stabs in a given stab vector, build appropriate types
432 and fix their symbols in given symbol vector. */
435 patch_block_stabs (struct pending
*symbols
, struct pending_stabs
*stabs
,
436 struct objfile
*objfile
)
446 /* for all the stab entries, find their corresponding symbols and
447 patch their types! */
449 for (ii
= 0; ii
< stabs
->count
; ++ii
)
451 name
= stabs
->stab
[ii
];
452 pp
= (char *) strchr (name
, ':');
456 pp
= (char *) strchr (pp
, ':');
458 sym
= find_symbol_in_list (symbols
, name
, pp
- name
);
461 /* FIXME-maybe: it would be nice if we noticed whether
462 the variable was defined *anywhere*, not just whether
463 it is defined in this compilation unit. But neither
464 xlc or GCC seem to need such a definition, and until
465 we do psymtabs (so that the minimal symbols from all
466 compilation units are available now), I'm not sure
467 how to get the information. */
469 /* On xcoff, if a global is defined and never referenced,
470 ld will remove it from the executable. There is then
471 a N_GSYM stab for it, but no regular (C_EXT) symbol. */
472 sym
= (struct symbol
*)
473 obstack_alloc (&objfile
->symbol_obstack
,
474 sizeof (struct symbol
));
476 memset (sym
, 0, sizeof (struct symbol
));
477 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
478 SYMBOL_CLASS (sym
) = LOC_OPTIMIZED_OUT
;
480 obsavestring (name
, pp
- name
, &objfile
->symbol_obstack
);
482 if (*(pp
- 1) == 'F' || *(pp
- 1) == 'f')
484 /* I don't think the linker does this with functions,
485 so as far as I know this is never executed.
486 But it doesn't hurt to check. */
488 lookup_function_type (read_type (&pp
, objfile
));
492 SYMBOL_TYPE (sym
) = read_type (&pp
, objfile
);
494 add_symbol_to_list (sym
, &global_symbols
);
499 if (*(pp
- 1) == 'F' || *(pp
- 1) == 'f')
502 lookup_function_type (read_type (&pp
, objfile
));
506 SYMBOL_TYPE (sym
) = read_type (&pp
, objfile
);
514 /* Read a number by which a type is referred to in dbx data,
515 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
516 Just a single number N is equivalent to (0,N).
517 Return the two numbers by storing them in the vector TYPENUMS.
518 TYPENUMS will then be used as an argument to dbx_lookup_type.
520 Returns 0 for success, -1 for error. */
523 read_type_number (register char **pp
, register int *typenums
)
529 typenums
[0] = read_huge_number (pp
, ',', &nbits
);
532 typenums
[1] = read_huge_number (pp
, ')', &nbits
);
539 typenums
[1] = read_huge_number (pp
, 0, &nbits
);
547 #define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
548 #define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
549 #define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
550 #define VISIBILITY_IGNORE '9' /* Optimized out or zero length */
552 #define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */
553 #define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */
555 /* This code added to support parsing of ARM/Cfront stabs strings */
557 /* Get substring from string up to char c, advance string pointer past
561 get_substring (char **p
, int c
)
576 /* Physname gets strcat'd onto sname in order to recreate the mangled
577 name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
578 the physname look like that of g++ - take out the initial mangling
579 eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
582 get_cfront_method_physname (char *fname
)
585 /* FIXME would like to make this generic for g++ too, but
586 that is already handled in read_member_funcctions */
589 /* search ahead to find the start of the mangled suffix */
590 if (*p
== '_' && *(p
+ 1) == '_') /* compiler generated; probably a ctor/dtor */
592 while (p
&& (unsigned) ((p
+ 1) - fname
) < strlen (fname
) && *(p
+ 1) != '_')
594 if (!(p
&& *p
== '_' && *(p
+ 1) == '_'))
595 error ("Invalid mangled function name %s", fname
);
596 p
+= 2; /* advance past '__' */
598 /* struct name length and name of type should come next; advance past it */
601 len
= len
* 10 + (*p
- '0');
609 /* Read base classes within cfront class definition.
610 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
613 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
618 read_cfront_baseclasses (struct field_info
*fip
, char **pp
, struct type
*type
,
619 struct objfile
*objfile
)
621 static struct deprecated_complaint msg_unknown
=
623 Unsupported token in stabs string %s.\n",
625 static struct deprecated_complaint msg_notfound
=
627 Unable to find base type for %s.\n",
632 struct nextfield
*new;
634 if (**pp
== ';') /* no base classes; return */
640 /* first count base classes so we can allocate space before parsing */
641 for (p
= *pp
; p
&& *p
&& *p
!= ';'; p
++)
646 bnum
++; /* add one more for last one */
648 /* now parse the base classes until we get to the start of the methods
649 (code extracted and munged from read_baseclasses) */
650 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
651 TYPE_N_BASECLASSES (type
) = bnum
;
655 int num_bytes
= B_BYTES (TYPE_N_BASECLASSES (type
));
658 pointer
= (char *) TYPE_ALLOC (type
, num_bytes
);
659 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*) pointer
;
661 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type
), TYPE_N_BASECLASSES (type
));
663 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
665 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
666 make_cleanup (xfree
, new);
667 memset (new, 0, sizeof (struct nextfield
));
668 new->next
= fip
->list
;
670 FIELD_BITSIZE (new->field
) = 0; /* this should be an unpacked field! */
672 STABS_CONTINUE (pp
, objfile
);
674 /* virtual? eg: v2@Bvir */
677 SET_TYPE_FIELD_VIRTUAL (type
, i
);
681 /* access? eg: 2@Bvir */
682 /* Note: protected inheritance not supported in cfront */
685 case CFRONT_VISIBILITY_PRIVATE
:
686 new->visibility
= VISIBILITY_PRIVATE
;
688 case CFRONT_VISIBILITY_PUBLIC
:
689 new->visibility
= VISIBILITY_PUBLIC
;
692 /* Bad visibility format. Complain and treat it as
695 static struct deprecated_complaint msg
=
697 "Unknown visibility `%c' for baseclass", 0, 0};
698 complain (&msg
, new->visibility
);
699 new->visibility
= VISIBILITY_PUBLIC
;
703 /* "@" comes next - eg: @Bvir */
706 complain (&msg_unknown
, *pp
);
712 /* Set the bit offset of the portion of the object corresponding
713 to this baseclass. Always zero in the absence of
714 multiple inheritance. */
715 /* Unable to read bit position from stabs;
716 Assuming no multiple inheritance for now FIXME! */
717 /* We may have read this in the structure definition;
718 now we should fixup the members to be the actual base classes */
719 FIELD_BITPOS (new->field
) = 0;
721 /* Get the base class name and type */
723 char *bname
; /* base class name */
724 struct symbol
*bsym
; /* base class */
726 p1
= strchr (*pp
, ' ');
727 p2
= strchr (*pp
, ';');
729 bname
= get_substring (pp
, ' ');
731 bname
= get_substring (pp
, ';');
732 if (!bname
|| !*bname
)
734 complain (&msg_unknown
, *pp
);
737 /* FIXME! attach base info to type */
738 bsym
= lookup_symbol (bname
, 0, STRUCT_NAMESPACE
, 0, 0); /*demangled_name */
741 new->field
.type
= SYMBOL_TYPE (bsym
);
742 new->field
.name
= type_name_no_tag (new->field
.type
);
746 complain (&msg_notfound
, *pp
);
751 /* If more base classes to parse, loop again.
752 We ate the last ' ' or ';' in get_substring,
753 so on exit we will have skipped the trailing ';' */
754 /* if invalid, return 0; add code to detect - FIXME! */
759 /* read cfront member functions.
760 pp points to string starting with list of functions
761 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
762 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
763 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
764 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
768 read_cfront_member_functions (struct field_info
*fip
, char **pp
,
769 struct type
*type
, struct objfile
*objfile
)
771 /* This code extracted from read_member_functions
772 so as to do the similar thing for our funcs */
776 /* Total number of member functions defined in this class. If the class
777 defines two `f' functions, and one `g' function, then this will have
779 int total_length
= 0;
783 struct next_fnfield
*next
;
784 struct fn_field fn_field
;
787 struct type
*look_ahead_type
;
788 struct next_fnfieldlist
*new_fnlist
;
789 struct next_fnfield
*new_sublist
;
792 struct symbol
*ref_func
= 0;
794 /* Process each list until we find the end of the member functions.
795 eg: p = "__ct__1AFv foo__1AFv ;;;" */
797 STABS_CONTINUE (pp
, objfile
); /* handle \\ */
799 while (**pp
!= ';' && (fname
= get_substring (pp
, ' '), fname
))
802 int sublist_count
= 0;
804 if (fname
[0] == '*') /* static member */
810 ref_func
= lookup_symbol (fname
, 0, VAR_NAMESPACE
, 0, 0); /* demangled name */
813 static struct deprecated_complaint msg
=
815 Unable to find function symbol for %s\n",
817 complain (&msg
, fname
);
821 look_ahead_type
= NULL
;
824 new_fnlist
= (struct next_fnfieldlist
*)
825 xmalloc (sizeof (struct next_fnfieldlist
));
826 make_cleanup (xfree
, new_fnlist
);
827 memset (new_fnlist
, 0, sizeof (struct next_fnfieldlist
));
829 /* The following is code to work around cfront generated stabs.
830 The stabs contains full mangled name for each field.
831 We try to demangle the name and extract the field name out of it. */
833 char *dem
, *dem_p
, *dem_args
;
835 dem
= cplus_demangle (fname
, DMGL_ANSI
| DMGL_PARAMS
);
838 dem_p
= strrchr (dem
, ':');
839 if (dem_p
!= 0 && *(dem_p
- 1) == ':')
841 /* get rid of args */
842 dem_args
= strchr (dem_p
, '(');
843 if (dem_args
== NULL
)
844 dem_len
= strlen (dem_p
);
846 dem_len
= dem_args
- dem_p
;
848 obsavestring (dem_p
, dem_len
, &objfile
->type_obstack
);
853 obsavestring (fname
, strlen (fname
), &objfile
->type_obstack
);
855 } /* end of code for cfront work around */
857 new_fnlist
->fn_fieldlist
.name
= main_fn_name
;
859 /*-------------------------------------------------*/
860 /* Set up the sublists
861 Sublists are stuff like args, static, visibility, etc.
862 so in ARM, we have to set that info some other way.
863 Multiple sublists happen if overloading
864 eg: foo::26=##1;:;2A.;
865 In g++, we'd loop here thru all the sublists... */
868 (struct next_fnfield
*) xmalloc (sizeof (struct next_fnfield
));
869 make_cleanup (xfree
, new_sublist
);
870 memset (new_sublist
, 0, sizeof (struct next_fnfield
));
872 /* eat 1; from :;2A.; */
873 new_sublist
->fn_field
.type
= SYMBOL_TYPE (ref_func
); /* normally takes a read_type */
874 /* Make this type look like a method stub for gdb */
875 TYPE_FLAGS (new_sublist
->fn_field
.type
) |= TYPE_FLAG_STUB
;
876 TYPE_CODE (new_sublist
->fn_field
.type
) = TYPE_CODE_METHOD
;
878 /* If this is just a stub, then we don't have the real name here. */
879 if (TYPE_STUB (new_sublist
->fn_field
.type
))
881 if (!TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
))
882 TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
) = type
;
883 new_sublist
->fn_field
.is_stub
= 1;
886 /* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i
887 physname gets strcat'd in order to recreate the onto mangled name */
888 pname
= get_cfront_method_physname (fname
);
889 new_sublist
->fn_field
.physname
= savestring (pname
, strlen (pname
));
892 /* Set this member function's visibility fields.
893 Unable to distinguish access from stabs definition!
894 Assuming public for now. FIXME!
895 (for private, set new_sublist->fn_field.is_private = 1,
896 for public, set new_sublist->fn_field.is_protected = 1) */
898 /* Unable to distinguish const/volatile from stabs definition!
899 Assuming normal for now. FIXME! */
901 new_sublist
->fn_field
.is_const
= 0;
902 new_sublist
->fn_field
.is_volatile
= 0; /* volatile not implemented in cfront */
904 /* Set virtual/static function info
905 How to get vtable offsets ?
906 Assuming normal for now FIXME!!
907 For vtables, figure out from whence this virtual function came.
908 It may belong to virtual function table of
909 one of its baseclasses.
911 new_sublist -> fn_field.voffset = vtable offset,
912 new_sublist -> fn_field.fcontext = look_ahead_type;
913 where look_ahead_type is type of baseclass */
915 new_sublist
->fn_field
.voffset
= VOFFSET_STATIC
;
916 else /* normal member function. */
917 new_sublist
->fn_field
.voffset
= 0;
918 new_sublist
->fn_field
.fcontext
= 0;
921 /* Prepare new sublist */
922 new_sublist
->next
= sublist
;
923 sublist
= new_sublist
;
926 /* In g++, we loop thu sublists - now we set from functions. */
927 new_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
928 obstack_alloc (&objfile
->type_obstack
,
929 sizeof (struct fn_field
) * length
);
930 memset (new_fnlist
->fn_fieldlist
.fn_fields
, 0,
931 sizeof (struct fn_field
) * length
);
932 for (i
= length
; (i
--, sublist
); sublist
= sublist
->next
)
934 new_fnlist
->fn_fieldlist
.fn_fields
[i
] = sublist
->fn_field
;
937 new_fnlist
->fn_fieldlist
.length
= length
;
938 new_fnlist
->next
= fip
->fnlist
;
939 fip
->fnlist
= new_fnlist
;
941 total_length
+= length
;
942 STABS_CONTINUE (pp
, objfile
); /* handle \\ */
947 /* type should already have space */
948 TYPE_FN_FIELDLISTS (type
) = (struct fn_fieldlist
*)
949 TYPE_ALLOC (type
, sizeof (struct fn_fieldlist
) * nfn_fields
);
950 memset (TYPE_FN_FIELDLISTS (type
), 0,
951 sizeof (struct fn_fieldlist
) * nfn_fields
);
952 TYPE_NFN_FIELDS (type
) = nfn_fields
;
953 TYPE_NFN_FIELDS_TOTAL (type
) = total_length
;
956 /* end of scope for reading member func */
960 /* Skip trailing ';' and bump count of number of fields seen */
968 /* This routine fixes up partial cfront types that were created
969 while parsing the stabs. The main need for this function is
970 to add information such as methods to classes.
971 Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */
973 resolve_cfront_continuation (struct objfile
*objfile
, struct symbol
*sym
,
976 struct symbol
*ref_sym
= 0;
978 /* snarfed from read_struct_type */
979 struct field_info fi
;
981 struct cleanup
*back_to
;
983 /* Need to make sure that fi isn't gunna conflict with struct
984 in case struct already had some fnfs */
987 back_to
= make_cleanup (null_cleanup
, 0);
989 /* We only accept structs, classes and unions at the moment.
990 Other continuation types include t (typedef), r (long dbl), ...
991 We may want to add support for them as well;
992 right now they are handled by duplicating the symbol information
993 into the type information (see define_symbol) */
994 if (*p
!= 's' /* structs */
995 && *p
!= 'c' /* class */
996 && *p
!= 'u') /* union */
997 return 0; /* only handle C++ types */
1000 /* Get symbol typs name and validate
1001 eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */
1002 sname
= get_substring (&p
, ';');
1003 if (!sname
|| strcmp (sname
, SYMBOL_NAME (sym
)))
1004 error ("Internal error: base symbol type name does not match\n");
1006 /* Find symbol's internal gdb reference using demangled_name.
1007 This is the real sym that we want;
1008 sym was a temp hack to make debugger happy */
1009 ref_sym
= lookup_symbol (SYMBOL_NAME (sym
), 0, STRUCT_NAMESPACE
, 0, 0);
1010 type
= SYMBOL_TYPE (ref_sym
);
1013 /* Now read the baseclasses, if any, read the regular C struct or C++
1014 class member fields, attach the fields to the type, read the C++
1015 member functions, attach them to the type, and then read any tilde
1016 field (baseclass specifier for the class holding the main vtable). */
1018 if (!read_cfront_baseclasses (&fi
, &p
, type
, objfile
)
1019 /* g++ does this next, but cfront already did this:
1020 || !read_struct_fields (&fi, &p, type, objfile) */
1021 || !copy_cfront_struct_fields (&fi
, type
, objfile
)
1022 || !read_cfront_member_functions (&fi
, &p
, type
, objfile
)
1023 || !read_cfront_static_fields (&fi
, &p
, type
, objfile
)
1024 || !attach_fields_to_type (&fi
, type
, objfile
)
1025 || !attach_fn_fields_to_type (&fi
, type
)
1026 /* g++ does this next, but cfront doesn't seem to have this:
1027 || !read_tilde_fields (&fi, &p, type, objfile) */
1030 type
= error_type (&p
, objfile
);
1033 do_cleanups (back_to
);
1036 /* End of code added to support parsing of ARM/Cfront stabs strings */
1039 /* This routine fixes up symbol references/aliases to point to the original
1040 symbol definition. Returns 0 on failure, non-zero on success. */
1043 resolve_symbol_reference (struct objfile
*objfile
, struct symbol
*sym
, char *p
)
1046 struct symbol
*ref_sym
= 0;
1047 struct alias_list
*alias
;
1049 /* If this is not a symbol reference return now. */
1053 /* Use "#<num>" as the name; we'll fix the name later.
1054 We stored the original symbol name as "#<id>=<name>"
1055 so we can now search for "#<id>" to resolving the reference.
1056 We'll fix the names later by removing the "#<id>" or "#<id>=" */
1058 /*---------------------------------------------------------*/
1059 /* Get the reference id number, and
1060 advance p past the names so we can parse the rest.
1061 eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */
1062 /*---------------------------------------------------------*/
1064 /* This gets reference name from string. sym may not have a name. */
1066 /* Get the reference number associated with the reference id in the
1067 gdb stab string. From that reference number, get the main/primary
1068 symbol for this alias. */
1069 refnum
= process_reference (&p
);
1070 ref_sym
= ref_search (refnum
);
1073 complain (&lrs_general_complaint
, "symbol for reference not found");
1077 /* Parse the stab of the referencing symbol
1078 now that we have the referenced symbol.
1079 Add it as a new symbol and a link back to the referenced symbol.
1080 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1083 /* If the stab symbol table and string contain:
1084 RSYM 0 5 00000000 868 #15=z:r(0,1)
1085 LBRAC 0 0 00000000 899 #5=
1086 SLINE 0 16 00000003 923 #6=
1087 Then the same symbols can be later referenced by:
1088 RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6)
1089 This is used in live range splitting to:
1090 1) specify that a symbol (#15) is actually just a new storage
1091 class for a symbol (#15=z) which was previously defined.
1092 2) specify that the beginning and ending ranges for a symbol
1093 (#15) are the values of the beginning (#5) and ending (#6)
1096 /* Read number as reference id.
1097 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1098 /* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
1099 in case of "l(0,0)"? */
1101 /*--------------------------------------------------*/
1102 /* Add this symbol to the reference list. */
1103 /*--------------------------------------------------*/
1105 alias
= (struct alias_list
*) obstack_alloc (&objfile
->type_obstack
,
1106 sizeof (struct alias_list
));
1109 complain (&lrs_general_complaint
, "Unable to allocate alias list memory");
1116 if (!SYMBOL_ALIASES (ref_sym
))
1118 SYMBOL_ALIASES (ref_sym
) = alias
;
1122 struct alias_list
*temp
;
1124 /* Get to the end of the list. */
1125 for (temp
= SYMBOL_ALIASES (ref_sym
);
1132 /* Want to fix up name so that other functions (eg. valops)
1133 will correctly print the name.
1134 Don't add_symbol_to_list so that lookup_symbol won't find it.
1135 nope... needed for fixups. */
1136 SYMBOL_NAME (sym
) = SYMBOL_NAME (ref_sym
);
1142 /* Structure for storing pointers to reference definitions for fast lookup
1143 during "process_later". */
1152 #define MAX_CHUNK_REFS 100
1153 #define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map))
1154 #define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE)
1156 static struct ref_map
*ref_map
;
1158 /* Ptr to free cell in chunk's linked list. */
1159 static int ref_count
= 0;
1161 /* Number of chunks malloced. */
1162 static int ref_chunk
= 0;
1164 /* This file maintains a cache of stabs aliases found in the symbol
1165 table. If the symbol table changes, this cache must be cleared
1166 or we are left holding onto data in invalid obstacks. */
1168 stabsread_clear_cache (void)
1174 /* Create array of pointers mapping refids to symbols and stab strings.
1175 Add pointers to reference definition symbols and/or their values as we
1176 find them, using their reference numbers as our index.
1177 These will be used later when we resolve references. */
1179 ref_add (int refnum
, struct symbol
*sym
, char *stabs
, CORE_ADDR value
)
1183 if (refnum
>= ref_count
)
1184 ref_count
= refnum
+ 1;
1185 if (ref_count
> ref_chunk
* MAX_CHUNK_REFS
)
1187 int new_slots
= ref_count
- ref_chunk
* MAX_CHUNK_REFS
;
1188 int new_chunks
= new_slots
/ MAX_CHUNK_REFS
+ 1;
1189 ref_map
= (struct ref_map
*)
1190 xrealloc (ref_map
, REF_MAP_SIZE (ref_chunk
+ new_chunks
));
1191 memset (ref_map
+ ref_chunk
* MAX_CHUNK_REFS
, 0, new_chunks
* REF_CHUNK_SIZE
);
1192 ref_chunk
+= new_chunks
;
1194 ref_map
[refnum
].stabs
= stabs
;
1195 ref_map
[refnum
].sym
= sym
;
1196 ref_map
[refnum
].value
= value
;
1199 /* Return defined sym for the reference REFNUM. */
1201 ref_search (int refnum
)
1203 if (refnum
< 0 || refnum
> ref_count
)
1205 return ref_map
[refnum
].sym
;
1208 /* Return value for the reference REFNUM. */
1211 ref_search_value (int refnum
)
1213 if (refnum
< 0 || refnum
> ref_count
)
1215 return ref_map
[refnum
].value
;
1218 /* Parse a reference id in STRING and return the resulting
1219 reference number. Move STRING beyond the reference id. */
1222 process_reference (char **string
)
1227 if (**string
!= '#')
1230 /* Advance beyond the initial '#'. */
1233 /* Read number as reference id. */
1234 while (*p
&& isdigit (*p
))
1236 refnum
= refnum
* 10 + *p
- '0';
1243 /* If STRING defines a reference, store away a pointer to the reference
1244 definition for later use. Return the reference number. */
1247 symbol_reference_defined (char **string
)
1252 refnum
= process_reference (&p
);
1254 /* Defining symbols end in '=' */
1257 /* Symbol is being defined here. */
1263 /* Must be a reference. Either the symbol has already been defined,
1264 or this is a forward reference to it. */
1272 define_symbol (CORE_ADDR valu
, char *string
, int desc
, int type
,
1273 struct objfile
*objfile
)
1275 register struct symbol
*sym
;
1276 char *p
= (char *) find_name_end (string
);
1281 /* We would like to eliminate nameless symbols, but keep their types.
1282 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1283 to type 2, but, should not create a symbol to address that type. Since
1284 the symbol will be nameless, there is no way any user can refer to it. */
1288 /* Ignore syms with empty names. */
1292 /* Ignore old-style symbols from cc -go */
1299 p
= strchr (p
, ':');
1302 /* If a nameless stab entry, all we need is the type, not the symbol.
1303 e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
1304 nameless
= (p
== string
|| ((string
[0] == ' ') && (string
[1] == ':')));
1306 current_symbol
= sym
= (struct symbol
*)
1307 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
1308 memset (sym
, 0, sizeof (struct symbol
));
1310 switch (type
& N_TYPE
)
1313 SYMBOL_SECTION (sym
) = SECT_OFF_TEXT (objfile
);
1316 SYMBOL_SECTION (sym
) = SECT_OFF_DATA (objfile
);
1319 SYMBOL_SECTION (sym
) = SECT_OFF_BSS (objfile
);
1323 if (processing_gcc_compilation
)
1325 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1326 number of bytes occupied by a type or object, which we ignore. */
1327 SYMBOL_LINE (sym
) = desc
;
1331 SYMBOL_LINE (sym
) = 0; /* unknown */
1334 if (is_cplus_marker (string
[0]))
1336 /* Special GNU C++ names. */
1340 SYMBOL_NAME (sym
) = obsavestring ("this", strlen ("this"),
1341 &objfile
->symbol_obstack
);
1344 case 'v': /* $vtbl_ptr_type */
1345 /* Was: SYMBOL_NAME (sym) = "vptr"; */
1349 SYMBOL_NAME (sym
) = obsavestring ("eh_throw", strlen ("eh_throw"),
1350 &objfile
->symbol_obstack
);
1354 /* This was an anonymous type that was never fixed up. */
1357 #ifdef STATIC_TRANSFORM_NAME
1359 /* SunPRO (3.0 at least) static variable encoding. */
1364 complain (&unrecognized_cplus_name_complaint
, string
);
1365 goto normal
; /* Do *something* with it */
1368 else if (string
[0] == '#')
1370 /* Special GNU C extension for referencing symbols. */
1374 /* If STRING defines a new reference id, then add it to the
1375 reference map. Else it must be referring to a previously
1376 defined symbol, so add it to the alias list of the previously
1379 refnum
= symbol_reference_defined (&s
);
1381 ref_add (refnum
, sym
, string
, SYMBOL_VALUE (sym
));
1382 else if (!resolve_symbol_reference (objfile
, sym
, string
))
1385 /* S..P contains the name of the symbol. We need to store
1386 the correct name into SYMBOL_NAME. */
1392 SYMBOL_NAME (sym
) = (char *)
1393 obstack_alloc (&objfile
->symbol_obstack
, nlen
);
1394 strncpy (SYMBOL_NAME (sym
), s
, nlen
);
1395 SYMBOL_NAME (sym
)[nlen
] = '\0';
1396 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
1399 /* FIXME! Want SYMBOL_NAME (sym) = 0;
1400 Get error if leave name 0. So give it something. */
1403 SYMBOL_NAME (sym
) = (char *)
1404 obstack_alloc (&objfile
->symbol_obstack
, nlen
);
1405 strncpy (SYMBOL_NAME (sym
), string
, nlen
);
1406 SYMBOL_NAME (sym
)[nlen
] = '\0';
1407 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
1410 /* Advance STRING beyond the reference id. */
1416 SYMBOL_LANGUAGE (sym
) = current_subfile
->language
;
1417 SYMBOL_NAME (sym
) = (char *)
1418 obstack_alloc (&objfile
->symbol_obstack
, ((p
- string
) + 1));
1419 /* Open-coded memcpy--saves function call time. */
1420 /* FIXME: Does it really? Try replacing with simple strcpy and
1421 try it on an executable with a large symbol table. */
1422 /* FIXME: considering that gcc can open code memcpy anyway, I
1423 doubt it. xoxorich. */
1425 register char *p1
= string
;
1426 register char *p2
= SYMBOL_NAME (sym
);
1434 /* If this symbol is from a C++ compilation, then attempt to cache the
1435 demangled form for future reference. This is a typical time versus
1436 space tradeoff, that was decided in favor of time because it sped up
1437 C++ symbol lookups by a factor of about 20. */
1439 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
1443 /* Determine the type of name being defined. */
1445 /* Getting GDB to correctly skip the symbol on an undefined symbol
1446 descriptor and not ever dump core is a very dodgy proposition if
1447 we do things this way. I say the acorn RISC machine can just
1448 fix their compiler. */
1449 /* The Acorn RISC machine's compiler can put out locals that don't
1450 start with "234=" or "(3,4)=", so assume anything other than the
1451 deftypes we know how to handle is a local. */
1452 if (!strchr ("cfFGpPrStTvVXCR", *p
))
1454 if (isdigit (*p
) || *p
== '(' || *p
== '-')
1463 /* c is a special case, not followed by a type-number.
1464 SYMBOL:c=iVALUE for an integer constant symbol.
1465 SYMBOL:c=rVALUE for a floating constant symbol.
1466 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1467 e.g. "b:c=e6,0" for "const b = blob1"
1468 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1471 SYMBOL_CLASS (sym
) = LOC_CONST
;
1472 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1473 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1474 add_symbol_to_list (sym
, &file_symbols
);
1482 double d
= atof (p
);
1485 /* FIXME-if-picky-about-floating-accuracy: Should be using
1486 target arithmetic to get the value. real.c in GCC
1487 probably has the necessary code. */
1489 /* FIXME: lookup_fundamental_type is a hack. We should be
1490 creating a type especially for the type of float constants.
1491 Problem is, what type should it be?
1493 Also, what should the name of this type be? Should we
1494 be using 'S' constants (see stabs.texinfo) instead? */
1496 SYMBOL_TYPE (sym
) = lookup_fundamental_type (objfile
,
1499 obstack_alloc (&objfile
->symbol_obstack
,
1500 TYPE_LENGTH (SYMBOL_TYPE (sym
)));
1501 store_typed_floating (dbl_valu
, SYMBOL_TYPE (sym
), d
);
1502 SYMBOL_VALUE_BYTES (sym
) = dbl_valu
;
1503 SYMBOL_CLASS (sym
) = LOC_CONST_BYTES
;
1508 /* Defining integer constants this way is kind of silly,
1509 since 'e' constants allows the compiler to give not
1510 only the value, but the type as well. C has at least
1511 int, long, unsigned int, and long long as constant
1512 types; other languages probably should have at least
1513 unsigned as well as signed constants. */
1515 /* We just need one int constant type for all objfiles.
1516 It doesn't depend on languages or anything (arguably its
1517 name should be a language-specific name for a type of
1518 that size, but I'm inclined to say that if the compiler
1519 wants a nice name for the type, it can use 'e'). */
1520 static struct type
*int_const_type
;
1522 /* Yes, this is as long as a *host* int. That is because we
1524 if (int_const_type
== NULL
)
1526 init_type (TYPE_CODE_INT
,
1527 sizeof (int) * HOST_CHAR_BIT
/ TARGET_CHAR_BIT
, 0,
1529 (struct objfile
*) NULL
);
1530 SYMBOL_TYPE (sym
) = int_const_type
;
1531 SYMBOL_VALUE (sym
) = atoi (p
);
1532 SYMBOL_CLASS (sym
) = LOC_CONST
;
1536 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
1537 can be represented as integral.
1538 e.g. "b:c=e6,0" for "const b = blob1"
1539 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1541 SYMBOL_CLASS (sym
) = LOC_CONST
;
1542 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1546 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1551 /* If the value is too big to fit in an int (perhaps because
1552 it is unsigned), or something like that, we silently get
1553 a bogus value. The type and everything else about it is
1554 correct. Ideally, we should be using whatever we have
1555 available for parsing unsigned and long long values,
1557 SYMBOL_VALUE (sym
) = atoi (p
);
1562 SYMBOL_CLASS (sym
) = LOC_CONST
;
1563 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1566 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1567 add_symbol_to_list (sym
, &file_symbols
);
1571 /* The name of a caught exception. */
1572 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1573 SYMBOL_CLASS (sym
) = LOC_LABEL
;
1574 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1575 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
1576 add_symbol_to_list (sym
, &local_symbols
);
1580 /* A static function definition. */
1581 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1582 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
1583 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1584 add_symbol_to_list (sym
, &file_symbols
);
1585 /* fall into process_function_types. */
1587 process_function_types
:
1588 /* Function result types are described as the result type in stabs.
1589 We need to convert this to the function-returning-type-X type
1590 in GDB. E.g. "int" is converted to "function returning int". */
1591 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_FUNC
)
1592 SYMBOL_TYPE (sym
) = lookup_function_type (SYMBOL_TYPE (sym
));
1594 /* All functions in C++ have prototypes. */
1595 if (SYMBOL_LANGUAGE (sym
) == language_cplus
)
1596 TYPE_FLAGS (SYMBOL_TYPE (sym
)) |= TYPE_FLAG_PROTOTYPED
;
1598 /* fall into process_prototype_types */
1600 process_prototype_types
:
1601 /* Sun acc puts declared types of arguments here. */
1604 struct type
*ftype
= SYMBOL_TYPE (sym
);
1609 /* Obtain a worst case guess for the number of arguments
1610 by counting the semicolons. */
1617 /* Allocate parameter information fields and fill them in. */
1618 TYPE_FIELDS (ftype
) = (struct field
*)
1619 TYPE_ALLOC (ftype
, nsemi
* sizeof (struct field
));
1624 /* A type number of zero indicates the start of varargs.
1625 FIXME: GDB currently ignores vararg functions. */
1626 if (p
[0] == '0' && p
[1] == '\0')
1628 ptype
= read_type (&p
, objfile
);
1630 /* The Sun compilers mark integer arguments, which should
1631 be promoted to the width of the calling conventions, with
1632 a type which references itself. This type is turned into
1633 a TYPE_CODE_VOID type by read_type, and we have to turn
1634 it back into builtin_type_int here.
1635 FIXME: Do we need a new builtin_type_promoted_int_arg ? */
1636 if (TYPE_CODE (ptype
) == TYPE_CODE_VOID
)
1637 ptype
= builtin_type_int
;
1638 TYPE_FIELD_TYPE (ftype
, nparams
) = ptype
;
1639 TYPE_FIELD_ARTIFICIAL (ftype
, nparams
++) = 0;
1641 TYPE_NFIELDS (ftype
) = nparams
;
1642 TYPE_FLAGS (ftype
) |= TYPE_FLAG_PROTOTYPED
;
1647 /* A global function definition. */
1648 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1649 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
1650 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1651 add_symbol_to_list (sym
, &global_symbols
);
1652 goto process_function_types
;
1655 /* For a class G (global) symbol, it appears that the
1656 value is not correct. It is necessary to search for the
1657 corresponding linker definition to find the value.
1658 These definitions appear at the end of the namelist. */
1659 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1660 SYMBOL_CLASS (sym
) = LOC_STATIC
;
1661 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1662 /* Don't add symbol references to global_sym_chain.
1663 Symbol references don't have valid names and wont't match up with
1664 minimal symbols when the global_sym_chain is relocated.
1665 We'll fixup symbol references when we fixup the defining symbol. */
1666 if (SYMBOL_NAME (sym
) && SYMBOL_NAME (sym
)[0] != '#')
1668 i
= hashname (SYMBOL_NAME (sym
));
1669 SYMBOL_VALUE_CHAIN (sym
) = global_sym_chain
[i
];
1670 global_sym_chain
[i
] = sym
;
1672 add_symbol_to_list (sym
, &global_symbols
);
1675 /* This case is faked by a conditional above,
1676 when there is no code letter in the dbx data.
1677 Dbx data never actually contains 'l'. */
1680 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1681 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
1682 SYMBOL_VALUE (sym
) = valu
;
1683 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1684 add_symbol_to_list (sym
, &local_symbols
);
1689 /* pF is a two-letter code that means a function parameter in Fortran.
1690 The type-number specifies the type of the return value.
1691 Translate it into a pointer-to-function type. */
1695 = lookup_pointer_type
1696 (lookup_function_type (read_type (&p
, objfile
)));
1699 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1701 /* Normally this is a parameter, a LOC_ARG. On the i960, it
1702 can also be a LOC_LOCAL_ARG depending on symbol type. */
1703 #ifndef DBX_PARM_SYMBOL_CLASS
1704 #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
1707 SYMBOL_CLASS (sym
) = DBX_PARM_SYMBOL_CLASS (type
);
1708 SYMBOL_VALUE (sym
) = valu
;
1709 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1710 add_symbol_to_list (sym
, &local_symbols
);
1712 if (TARGET_BYTE_ORDER
!= BFD_ENDIAN_BIG
)
1714 /* On little-endian machines, this crud is never necessary,
1715 and, if the extra bytes contain garbage, is harmful. */
1719 /* If it's gcc-compiled, if it says `short', believe it. */
1720 if (processing_gcc_compilation
|| BELIEVE_PCC_PROMOTION
)
1723 if (!BELIEVE_PCC_PROMOTION
)
1725 /* This is the signed type which arguments get promoted to. */
1726 static struct type
*pcc_promotion_type
;
1727 /* This is the unsigned type which arguments get promoted to. */
1728 static struct type
*pcc_unsigned_promotion_type
;
1730 /* Call it "int" because this is mainly C lossage. */
1731 if (pcc_promotion_type
== NULL
)
1732 pcc_promotion_type
=
1733 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
1736 if (pcc_unsigned_promotion_type
== NULL
)
1737 pcc_unsigned_promotion_type
=
1738 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
1739 TYPE_FLAG_UNSIGNED
, "unsigned int", NULL
);
1741 if (BELIEVE_PCC_PROMOTION_TYPE
)
1743 /* This is defined on machines (e.g. sparc) where we
1744 should believe the type of a PCC 'short' argument,
1745 but shouldn't believe the address (the address is the
1746 address of the corresponding int).
1748 My guess is that this correction, as opposed to
1749 changing the parameter to an 'int' (as done below,
1750 for PCC on most machines), is the right thing to do
1751 on all machines, but I don't want to risk breaking
1752 something that already works. On most PCC machines,
1753 the sparc problem doesn't come up because the calling
1754 function has to zero the top bytes (not knowing
1755 whether the called function wants an int or a short),
1756 so there is little practical difference between an
1757 int and a short (except perhaps what happens when the
1758 GDB user types "print short_arg = 0x10000;").
1760 Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the
1761 compiler actually produces the correct address (we
1762 don't need to fix it up). I made this code adapt so
1763 that it will offset the symbol if it was pointing at
1764 an int-aligned location and not otherwise. This way
1765 you can use the same gdb for 4.0.x and 4.1 systems.
1767 If the parameter is shorter than an int, and is
1768 integral (e.g. char, short, or unsigned equivalent),
1769 and is claimed to be passed on an integer boundary,
1770 don't believe it! Offset the parameter's address to
1771 the tail-end of that integer. */
1773 if (TYPE_LENGTH (SYMBOL_TYPE (sym
)) < TYPE_LENGTH (pcc_promotion_type
)
1774 && TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_INT
1775 && 0 == SYMBOL_VALUE (sym
) % TYPE_LENGTH (pcc_promotion_type
))
1777 SYMBOL_VALUE (sym
) += TYPE_LENGTH (pcc_promotion_type
)
1778 - TYPE_LENGTH (SYMBOL_TYPE (sym
));
1784 /* If PCC says a parameter is a short or a char,
1785 it is really an int. */
1786 if (TYPE_LENGTH (SYMBOL_TYPE (sym
)) < TYPE_LENGTH (pcc_promotion_type
)
1787 && TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_INT
)
1790 TYPE_UNSIGNED (SYMBOL_TYPE (sym
))
1791 ? pcc_unsigned_promotion_type
1792 : pcc_promotion_type
;
1799 /* acc seems to use P to declare the prototypes of functions that
1800 are referenced by this file. gdb is not prepared to deal
1801 with this extra information. FIXME, it ought to. */
1804 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1805 goto process_prototype_types
;
1810 /* Parameter which is in a register. */
1811 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1812 SYMBOL_CLASS (sym
) = LOC_REGPARM
;
1813 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
1814 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
1816 complain (®_value_complaint
, SYMBOL_VALUE (sym
),
1817 NUM_REGS
+ NUM_PSEUDO_REGS
,
1818 SYMBOL_SOURCE_NAME (sym
));
1819 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
1821 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1822 add_symbol_to_list (sym
, &local_symbols
);
1826 /* Register variable (either global or local). */
1827 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1828 SYMBOL_CLASS (sym
) = LOC_REGISTER
;
1829 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
1830 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
1832 complain (®_value_complaint
, SYMBOL_VALUE (sym
),
1833 NUM_REGS
+ NUM_PSEUDO_REGS
,
1834 SYMBOL_SOURCE_NAME (sym
));
1835 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
1837 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1838 if (within_function
)
1840 /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
1841 name to represent an argument passed in a register.
1842 GCC uses 'P' for the same case. So if we find such a symbol pair
1843 we combine it into one 'P' symbol. For Sun cc we need to do this
1844 regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
1845 the 'p' symbol even if it never saves the argument onto the stack.
1847 On most machines, we want to preserve both symbols, so that
1848 we can still get information about what is going on with the
1849 stack (VAX for computing args_printed, using stack slots instead
1850 of saved registers in backtraces, etc.).
1852 Note that this code illegally combines
1853 main(argc) struct foo argc; { register struct foo argc; }
1854 but this case is considered pathological and causes a warning
1855 from a decent compiler. */
1858 && local_symbols
->nsyms
> 0
1859 #ifndef USE_REGISTER_NOT_ARG
1860 && REG_STRUCT_HAS_ADDR_P ()
1861 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation
,
1863 && (TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_STRUCT
1864 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_UNION
1865 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_SET
1866 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_BITSTRING
)
1870 struct symbol
*prev_sym
;
1871 prev_sym
= local_symbols
->symbol
[local_symbols
->nsyms
- 1];
1872 if ((SYMBOL_CLASS (prev_sym
) == LOC_REF_ARG
1873 || SYMBOL_CLASS (prev_sym
) == LOC_ARG
)
1874 && STREQ (SYMBOL_NAME (prev_sym
), SYMBOL_NAME (sym
)))
1876 SYMBOL_CLASS (prev_sym
) = LOC_REGPARM
;
1877 /* Use the type from the LOC_REGISTER; that is the type
1878 that is actually in that register. */
1879 SYMBOL_TYPE (prev_sym
) = SYMBOL_TYPE (sym
);
1880 SYMBOL_VALUE (prev_sym
) = SYMBOL_VALUE (sym
);
1885 add_symbol_to_list (sym
, &local_symbols
);
1888 add_symbol_to_list (sym
, &file_symbols
);
1892 /* Static symbol at top level of file */
1893 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1894 SYMBOL_CLASS (sym
) = LOC_STATIC
;
1895 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
1896 #ifdef STATIC_TRANSFORM_NAME
1897 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
)))
1899 struct minimal_symbol
*msym
;
1900 msym
= lookup_minimal_symbol (SYMBOL_NAME (sym
), NULL
, objfile
);
1903 SYMBOL_NAME (sym
) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
));
1904 SYMBOL_VALUE_ADDRESS (sym
) = SYMBOL_VALUE_ADDRESS (msym
);
1908 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1909 add_symbol_to_list (sym
, &file_symbols
);
1914 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1916 /* For a nameless type, we don't want a create a symbol, thus we
1917 did not use `sym'. Return without further processing. */
1921 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
1922 SYMBOL_VALUE (sym
) = valu
;
1923 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1924 /* C++ vagaries: we may have a type which is derived from
1925 a base type which did not have its name defined when the
1926 derived class was output. We fill in the derived class's
1927 base part member's name here in that case. */
1928 if (TYPE_NAME (SYMBOL_TYPE (sym
)) != NULL
)
1929 if ((TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_STRUCT
1930 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_UNION
)
1931 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym
)))
1934 for (j
= TYPE_N_BASECLASSES (SYMBOL_TYPE (sym
)) - 1; j
>= 0; j
--)
1935 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym
), j
) == 0)
1936 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym
), j
) =
1937 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym
), j
));
1940 if (TYPE_NAME (SYMBOL_TYPE (sym
)) == NULL
)
1942 /* gcc-2.6 or later (when using -fvtable-thunks)
1943 emits a unique named type for a vtable entry.
1944 Some gdb code depends on that specific name. */
1945 extern const char vtbl_ptr_name
[];
1947 if ((TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_PTR
1948 && strcmp (SYMBOL_NAME (sym
), vtbl_ptr_name
))
1949 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_FUNC
)
1951 /* If we are giving a name to a type such as "pointer to
1952 foo" or "function returning foo", we better not set
1953 the TYPE_NAME. If the program contains "typedef char
1954 *caddr_t;", we don't want all variables of type char
1955 * to print as caddr_t. This is not just a
1956 consequence of GDB's type management; PCC and GCC (at
1957 least through version 2.4) both output variables of
1958 either type char * or caddr_t with the type number
1959 defined in the 't' symbol for caddr_t. If a future
1960 compiler cleans this up it GDB is not ready for it
1961 yet, but if it becomes ready we somehow need to
1962 disable this check (without breaking the PCC/GCC2.4
1967 Fortunately, this check seems not to be necessary
1968 for anything except pointers or functions. */
1969 /* ezannoni: 2000-10-26. This seems to apply for
1970 versions of gcc older than 2.8. This was the original
1971 problem: with the following code gdb would tell that
1972 the type for name1 is caddr_t, and func is char()
1973 typedef char *caddr_t;
1985 /* Pascal accepts names for pointer types. */
1986 if (current_subfile
->language
== language_pascal
)
1988 TYPE_NAME (SYMBOL_TYPE (sym
)) = SYMBOL_NAME (sym
);
1992 TYPE_NAME (SYMBOL_TYPE (sym
)) = SYMBOL_NAME (sym
);
1995 add_symbol_to_list (sym
, &file_symbols
);
1999 /* Struct, union, or enum tag. For GNU C++, this can be be followed
2000 by 't' which means we are typedef'ing it as well. */
2001 synonym
= *p
== 't';
2005 /* The semantics of C++ state that "struct foo { ... }" also defines
2006 a typedef for "foo". Unfortunately, cfront never makes the typedef
2007 when translating C++ into C. We make the typedef here so that
2008 "ptype foo" works as expected for cfront translated code. */
2009 else if ((current_subfile
->language
== language_cplus
)
2010 || (current_subfile
->language
== language_objc
))
2013 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2015 /* For a nameless type, we don't want a create a symbol, thus we
2016 did not use `sym'. Return without further processing. */
2020 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
2021 SYMBOL_VALUE (sym
) = valu
;
2022 SYMBOL_NAMESPACE (sym
) = STRUCT_NAMESPACE
;
2023 if (TYPE_TAG_NAME (SYMBOL_TYPE (sym
)) == 0)
2024 TYPE_TAG_NAME (SYMBOL_TYPE (sym
))
2025 = obconcat (&objfile
->type_obstack
, "", "", SYMBOL_NAME (sym
));
2026 add_symbol_to_list (sym
, &file_symbols
);
2030 /* Clone the sym and then modify it. */
2031 register struct symbol
*typedef_sym
= (struct symbol
*)
2032 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
2033 *typedef_sym
= *sym
;
2034 SYMBOL_CLASS (typedef_sym
) = LOC_TYPEDEF
;
2035 SYMBOL_VALUE (typedef_sym
) = valu
;
2036 SYMBOL_NAMESPACE (typedef_sym
) = VAR_NAMESPACE
;
2037 if (TYPE_NAME (SYMBOL_TYPE (sym
)) == 0)
2038 TYPE_NAME (SYMBOL_TYPE (sym
))
2039 = obconcat (&objfile
->type_obstack
, "", "", SYMBOL_NAME (sym
));
2040 add_symbol_to_list (typedef_sym
, &file_symbols
);
2045 /* Static symbol of local scope */
2046 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2047 SYMBOL_CLASS (sym
) = LOC_STATIC
;
2048 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
2049 #ifdef STATIC_TRANSFORM_NAME
2050 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
)))
2052 struct minimal_symbol
*msym
;
2053 msym
= lookup_minimal_symbol (SYMBOL_NAME (sym
), NULL
, objfile
);
2056 SYMBOL_NAME (sym
) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
));
2057 SYMBOL_VALUE_ADDRESS (sym
) = SYMBOL_VALUE_ADDRESS (msym
);
2061 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2062 #if 0 /* OBSOLETE OS9K */
2063 // OBSOLETE if (os9k_stabs)
2064 // OBSOLETE add_symbol_to_list (sym, &global_symbols);
2066 #endif /* OBSOLETE OS9K */
2067 add_symbol_to_list (sym
, &local_symbols
);
2071 /* Reference parameter */
2072 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2073 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
2074 SYMBOL_VALUE (sym
) = valu
;
2075 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2076 add_symbol_to_list (sym
, &local_symbols
);
2080 /* Reference parameter which is in a register. */
2081 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2082 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
2083 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
2084 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
2086 complain (®_value_complaint
, SYMBOL_VALUE (sym
),
2087 NUM_REGS
+ NUM_PSEUDO_REGS
,
2088 SYMBOL_SOURCE_NAME (sym
));
2089 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
2091 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2092 add_symbol_to_list (sym
, &local_symbols
);
2096 /* This is used by Sun FORTRAN for "function result value".
2097 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
2098 that Pascal uses it too, but when I tried it Pascal used
2099 "x:3" (local symbol) instead. */
2100 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2101 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
2102 SYMBOL_VALUE (sym
) = valu
;
2103 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2104 add_symbol_to_list (sym
, &local_symbols
);
2107 /* New code added to support cfront stabs strings.
2108 Note: case 'P' already handled above */
2110 /* Cfront type continuation coming up!
2111 Find the original definition and add to it.
2112 We'll have to do this for the typedef too,
2113 since we cloned the symbol to define a type in read_type.
2114 Stabs info examples:
2116 foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24))
2117 C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;;
2118 where C is the name of the class.
2119 Unfortunately, we can't lookup the original symbol yet 'cuz
2120 we haven't finished reading all the symbols.
2121 Instead, we save it for processing later */
2122 process_later (sym
, p
, resolve_cfront_continuation
);
2123 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
); /* FIXME! change later */
2124 SYMBOL_CLASS (sym
) = LOC_CONST
;
2125 SYMBOL_VALUE (sym
) = 0;
2126 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2127 /* Don't add to list - we'll delete it later when
2128 we add the continuation to the real sym */
2130 /* End of new code added to support cfront stabs strings */
2133 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
2134 SYMBOL_CLASS (sym
) = LOC_CONST
;
2135 SYMBOL_VALUE (sym
) = 0;
2136 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2137 add_symbol_to_list (sym
, &file_symbols
);
2141 /* When passing structures to a function, some systems sometimes pass
2142 the address in a register, not the structure itself. */
2144 if (REG_STRUCT_HAS_ADDR_P ()
2145 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation
, SYMBOL_TYPE (sym
))
2146 && (SYMBOL_CLASS (sym
) == LOC_REGPARM
|| SYMBOL_CLASS (sym
) == LOC_ARG
))
2148 struct type
*symbol_type
= check_typedef (SYMBOL_TYPE (sym
));
2150 if ((TYPE_CODE (symbol_type
) == TYPE_CODE_STRUCT
)
2151 || (TYPE_CODE (symbol_type
) == TYPE_CODE_UNION
)
2152 || (TYPE_CODE (symbol_type
) == TYPE_CODE_BITSTRING
)
2153 || (TYPE_CODE (symbol_type
) == TYPE_CODE_SET
))
2155 /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
2156 LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
2157 if (SYMBOL_CLASS (sym
) == LOC_REGPARM
)
2158 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
2159 /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
2160 and subsequent arguments on the sparc, for example). */
2161 else if (SYMBOL_CLASS (sym
) == LOC_ARG
)
2162 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
2166 /* Is there more to parse? For example LRS/alias information? */
2167 while (*p
&& *p
== ';')
2170 if (*p
&& p
[0] == 'l' && p
[1] == '(')
2172 /* GNU extensions for live range splitting may be appended to
2173 the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */
2175 /* Resolve the live range and add it to SYM's live range list. */
2176 if (!resolve_live_range (objfile
, sym
, p
))
2179 /* Find end of live range info. */
2180 p
= strchr (p
, ')');
2181 if (!*p
|| *p
!= ')')
2183 complain (&lrs_general_complaint
, "live range format not recognized");
2192 /* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns
2193 non-zero on success, zero otherwise. */
2196 resolve_live_range (struct objfile
*objfile
, struct symbol
*sym
, char *p
)
2199 CORE_ADDR start
, end
;
2201 /* Sanity check the beginning of the stabs string. */
2202 if (!*p
|| *p
!= 'l')
2204 complain (&lrs_general_complaint
, "live range string 1");
2209 if (!*p
|| *p
!= '(')
2211 complain (&lrs_general_complaint
, "live range string 2");
2216 /* Get starting value of range and advance P past the reference id.
2218 ?!? In theory, the process_reference should never fail, but we should
2219 catch that case just in case the compiler scrogged the stabs. */
2220 refnum
= process_reference (&p
);
2221 start
= ref_search_value (refnum
);
2224 complain (&lrs_general_complaint
, "Live range symbol not found 1");
2228 if (!*p
|| *p
!= ',')
2230 complain (&lrs_general_complaint
, "live range string 3");
2235 /* Get ending value of range and advance P past the reference id.
2237 ?!? In theory, the process_reference should never fail, but we should
2238 catch that case just in case the compiler scrogged the stabs. */
2239 refnum
= process_reference (&p
);
2240 end
= ref_search_value (refnum
);
2243 complain (&lrs_general_complaint
, "Live range symbol not found 2");
2247 if (!*p
|| *p
!= ')')
2249 complain (&lrs_general_complaint
, "live range string 4");
2253 /* Now that we know the bounds of the range, add it to the
2255 add_live_range (objfile
, sym
, start
, end
);
2260 /* Add a new live range defined by START and END to the symbol SYM
2261 in objfile OBJFILE. */
2264 add_live_range (struct objfile
*objfile
, struct symbol
*sym
, CORE_ADDR start
,
2267 struct range_list
*r
, *rs
;
2271 complain (&lrs_general_complaint
, "end of live range follows start");
2275 /* Alloc new live range structure. */
2276 r
= (struct range_list
*)
2277 obstack_alloc (&objfile
->type_obstack
,
2278 sizeof (struct range_list
));
2283 /* Append this range to the symbol's range list. */
2284 if (!SYMBOL_RANGES (sym
))
2285 SYMBOL_RANGES (sym
) = r
;
2288 /* Get the last range for the symbol. */
2289 for (rs
= SYMBOL_RANGES (sym
); rs
->next
; rs
= rs
->next
)
2296 /* Skip rest of this symbol and return an error type.
2298 General notes on error recovery: error_type always skips to the
2299 end of the symbol (modulo cretinous dbx symbol name continuation).
2300 Thus code like this:
2302 if (*(*pp)++ != ';')
2303 return error_type (pp, objfile);
2305 is wrong because if *pp starts out pointing at '\0' (typically as the
2306 result of an earlier error), it will be incremented to point to the
2307 start of the next symbol, which might produce strange results, at least
2308 if you run off the end of the string table. Instead use
2311 return error_type (pp, objfile);
2317 foo = error_type (pp, objfile);
2321 And in case it isn't obvious, the point of all this hair is so the compiler
2322 can define new types and new syntaxes, and old versions of the
2323 debugger will be able to read the new symbol tables. */
2325 static struct type
*
2326 error_type (char **pp
, struct objfile
*objfile
)
2328 complain (&error_type_complaint
);
2331 /* Skip to end of symbol. */
2332 while (**pp
!= '\0')
2337 /* Check for and handle cretinous dbx symbol name continuation! */
2338 if ((*pp
)[-1] == '\\' || (*pp
)[-1] == '?')
2340 *pp
= next_symbol_text (objfile
);
2347 return (builtin_type_error
);
2351 /* Read type information or a type definition; return the type. Even
2352 though this routine accepts either type information or a type
2353 definition, the distinction is relevant--some parts of stabsread.c
2354 assume that type information starts with a digit, '-', or '(' in
2355 deciding whether to call read_type. */
2358 read_type (register char **pp
, struct objfile
*objfile
)
2360 register struct type
*type
= 0;
2363 char type_descriptor
;
2365 /* Size in bits of type if specified by a type attribute, or -1 if
2366 there is no size attribute. */
2369 /* Used to distinguish string and bitstring from char-array and set. */
2372 /* Used to distinguish vector from array. */
2375 /* Read type number if present. The type number may be omitted.
2376 for instance in a two-dimensional array declared with type
2377 "ar1;1;10;ar1;1;10;4". */
2378 if ((**pp
>= '0' && **pp
<= '9')
2382 if (read_type_number (pp
, typenums
) != 0)
2383 return error_type (pp
, objfile
);
2385 /* Type is not being defined here. Either it already exists,
2386 or this is a forward reference to it. dbx_alloc_type handles
2389 return dbx_alloc_type (typenums
, objfile
);
2391 /* Type is being defined here. */
2393 Also skip the type descriptor - we get it below with (*pp)[-1]. */
2398 /* 'typenums=' not present, type is anonymous. Read and return
2399 the definition, but don't put it in the type vector. */
2400 typenums
[0] = typenums
[1] = -1;
2405 type_descriptor
= (*pp
)[-1];
2406 switch (type_descriptor
)
2410 enum type_code code
;
2412 /* Used to index through file_symbols. */
2413 struct pending
*ppt
;
2416 /* Name including "struct", etc. */
2420 char *from
, *to
, *p
, *q1
, *q2
;
2422 /* Set the type code according to the following letter. */
2426 code
= TYPE_CODE_STRUCT
;
2429 code
= TYPE_CODE_UNION
;
2432 code
= TYPE_CODE_ENUM
;
2436 /* Complain and keep going, so compilers can invent new
2437 cross-reference types. */
2438 static struct deprecated_complaint msg
=
2439 {"Unrecognized cross-reference type `%c'", 0, 0};
2440 complain (&msg
, (*pp
)[0]);
2441 code
= TYPE_CODE_STRUCT
;
2446 q1
= strchr (*pp
, '<');
2447 p
= strchr (*pp
, ':');
2449 return error_type (pp
, objfile
);
2450 if (q1
&& p
> q1
&& p
[1] == ':')
2452 int nesting_level
= 0;
2453 for (q2
= q1
; *q2
; q2
++)
2457 else if (*q2
== '>')
2459 else if (*q2
== ':' && nesting_level
== 0)
2464 return error_type (pp
, objfile
);
2467 (char *) obstack_alloc (&objfile
->type_obstack
, p
- *pp
+ 1);
2469 /* Copy the name. */
2475 /* Set the pointer ahead of the name which we just read, and
2480 /* Now check to see whether the type has already been
2481 declared. This was written for arrays of cross-referenced
2482 types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty
2483 sure it is not necessary anymore. But it might be a good
2484 idea, to save a little memory. */
2486 for (ppt
= file_symbols
; ppt
; ppt
= ppt
->next
)
2487 for (i
= 0; i
< ppt
->nsyms
; i
++)
2489 struct symbol
*sym
= ppt
->symbol
[i
];
2491 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
2492 && SYMBOL_NAMESPACE (sym
) == STRUCT_NAMESPACE
2493 && (TYPE_CODE (SYMBOL_TYPE (sym
)) == code
)
2494 && STREQ (SYMBOL_NAME (sym
), type_name
))
2496 obstack_free (&objfile
->type_obstack
, type_name
);
2497 type
= SYMBOL_TYPE (sym
);
2502 /* Didn't find the type to which this refers, so we must
2503 be dealing with a forward reference. Allocate a type
2504 structure for it, and keep track of it so we can
2505 fill in the rest of the fields when we get the full
2507 type
= dbx_alloc_type (typenums
, objfile
);
2508 TYPE_CODE (type
) = code
;
2509 TYPE_TAG_NAME (type
) = type_name
;
2510 INIT_CPLUS_SPECIFIC (type
);
2511 TYPE_FLAGS (type
) |= TYPE_FLAG_STUB
;
2513 add_undefined_type (type
);
2517 case '-': /* RS/6000 built-in type */
2531 /* We deal with something like t(1,2)=(3,4)=... which
2532 the Lucid compiler and recent gcc versions (post 2.7.3) use. */
2534 /* Allocate and enter the typedef type first.
2535 This handles recursive types. */
2536 type
= dbx_alloc_type (typenums
, objfile
);
2537 TYPE_CODE (type
) = TYPE_CODE_TYPEDEF
;
2539 struct type
*xtype
= read_type (pp
, objfile
);
2542 /* It's being defined as itself. That means it is "void". */
2543 TYPE_CODE (type
) = TYPE_CODE_VOID
;
2544 TYPE_LENGTH (type
) = 1;
2546 else if (type_size
>= 0 || is_string
)
2548 /* This is the absolute wrong way to construct types. Every
2549 other debug format has found a way around this problem and
2550 the related problems with unnecessarily stubbed types;
2551 someone motivated should attempt to clean up the issue
2552 here as well. Once a type pointed to has been created it
2553 should not be modified.
2555 Well, it's not *absolutely* wrong. Constructing recursive
2556 types (trees, linked lists) necessarily entails modifying
2557 types after creating them. Constructing any loop structure
2558 entails side effects. The Dwarf 2 reader does handle this
2559 more gracefully (it never constructs more than once
2560 instance of a type object, so it doesn't have to copy type
2561 objects wholesale), but it still mutates type objects after
2562 other folks have references to them.
2564 Keep in mind that this circularity/mutation issue shows up
2565 at the source language level, too: C's "incomplete types",
2566 for example. So the proper cleanup, I think, would be to
2567 limit GDB's type smashing to match exactly those required
2568 by the source language. So GDB could have a
2569 "complete_this_type" function, but never create unnecessary
2570 copies of a type otherwise. */
2571 replace_type (type
, xtype
);
2572 TYPE_NAME (type
) = NULL
;
2573 TYPE_TAG_NAME (type
) = NULL
;
2577 TYPE_FLAGS (type
) |= TYPE_FLAG_TARGET_STUB
;
2578 TYPE_TARGET_TYPE (type
) = xtype
;
2583 /* In the following types, we must be sure to overwrite any existing
2584 type that the typenums refer to, rather than allocating a new one
2585 and making the typenums point to the new one. This is because there
2586 may already be pointers to the existing type (if it had been
2587 forward-referenced), and we must change it to a pointer, function,
2588 reference, or whatever, *in-place*. */
2590 case '*': /* Pointer to another type */
2591 type1
= read_type (pp
, objfile
);
2592 type
= make_pointer_type (type1
, dbx_lookup_type (typenums
));
2595 case '&': /* Reference to another type */
2596 type1
= read_type (pp
, objfile
);
2597 type
= make_reference_type (type1
, dbx_lookup_type (typenums
));
2600 case 'f': /* Function returning another type */
2601 #if 0 /* OBSOLETE OS9K */
2602 // OBSOLETE if (os9k_stabs && **pp == '(')
2604 // OBSOLETE /* Function prototype; parse it.
2605 // OBSOLETE We must conditionalize this on os9k_stabs because otherwise
2606 // OBSOLETE it could be confused with a Sun-style (1,3) typenumber
2607 // OBSOLETE (I think). */
2608 // OBSOLETE struct type *t;
2610 // OBSOLETE while (**pp != ')')
2612 // OBSOLETE t = read_type (pp, objfile);
2613 // OBSOLETE if (**pp == ',')
2614 // OBSOLETE ++ * pp;
2617 #endif /* OBSOLETE OS9K */
2619 type1
= read_type (pp
, objfile
);
2620 type
= make_function_type (type1
, dbx_lookup_type (typenums
));
2623 case 'g': /* Prototyped function. (Sun) */
2625 /* Unresolved questions:
2627 - According to Sun's ``STABS Interface Manual'', for 'f'
2628 and 'F' symbol descriptors, a `0' in the argument type list
2629 indicates a varargs function. But it doesn't say how 'g'
2630 type descriptors represent that info. Someone with access
2631 to Sun's toolchain should try it out.
2633 - According to the comment in define_symbol (search for
2634 `process_prototype_types:'), Sun emits integer arguments as
2635 types which ref themselves --- like `void' types. Do we
2636 have to deal with that here, too? Again, someone with
2637 access to Sun's toolchain should try it out and let us
2640 const char *type_start
= (*pp
) - 1;
2641 struct type
*return_type
= read_type (pp
, objfile
);
2642 struct type
*func_type
2643 = make_function_type (return_type
, dbx_lookup_type (typenums
));
2646 struct type_list
*next
;
2650 while (**pp
&& **pp
!= '#')
2652 struct type
*arg_type
= read_type (pp
, objfile
);
2653 struct type_list
*new = alloca (sizeof (*new));
2654 new->type
= arg_type
;
2655 new->next
= arg_types
;
2663 static struct deprecated_complaint msg
= {
2664 "Prototyped function type didn't end arguments with `#':\n%s",
2667 complain (&msg
, type_start
);
2670 /* If there is just one argument whose type is `void', then
2671 that's just an empty argument list. */
2673 && ! arg_types
->next
2674 && TYPE_CODE (arg_types
->type
) == TYPE_CODE_VOID
)
2677 TYPE_FIELDS (func_type
)
2678 = (struct field
*) TYPE_ALLOC (func_type
,
2679 num_args
* sizeof (struct field
));
2680 memset (TYPE_FIELDS (func_type
), 0, num_args
* sizeof (struct field
));
2683 struct type_list
*t
;
2685 /* We stuck each argument type onto the front of the list
2686 when we read it, so the list is reversed. Build the
2687 fields array right-to-left. */
2688 for (t
= arg_types
, i
= num_args
- 1; t
; t
= t
->next
, i
--)
2689 TYPE_FIELD_TYPE (func_type
, i
) = t
->type
;
2691 TYPE_NFIELDS (func_type
) = num_args
;
2692 TYPE_FLAGS (func_type
) |= TYPE_FLAG_PROTOTYPED
;
2698 case 'k': /* Const qualifier on some type (Sun) */
2699 #if 0 /* OBSOLETE OS9K */
2700 // OBSOLETE /* ezannoni 2002-07-16: This can be safely deleted, because 'c'
2701 // OBSOLETE means complex type in AIX stabs, while it means const qualifier
2702 // OBSOLETE in os9k stabs. Obviously we were supporting only the os9k meaning.
2703 // OBSOLETE We were erroring out if we were reading AIX stabs. Right now the
2704 // OBSOLETE erroring out will happen in the default clause of the switch. */
2705 // OBSOLETE case 'c': /* Const qualifier on some type (OS9000) */
2706 // OBSOLETE /* Because 'c' means other things to AIX and 'k' is perfectly good,
2707 // OBSOLETE only accept 'c' in the os9k_stabs case. */
2708 // OBSOLETE if (type_descriptor == 'c' && !os9k_stabs)
2709 // OBSOLETE return error_type (pp, objfile);
2710 #endif /* OBSOLETE OS9K */
2711 type
= read_type (pp
, objfile
);
2712 type
= make_cv_type (1, TYPE_VOLATILE (type
), type
,
2713 dbx_lookup_type (typenums
));
2716 case 'B': /* Volatile qual on some type (Sun) */
2717 #if 0 /* OBSOLETE OS9K */
2718 // OBSOLETE /* ezannoni 2002-07-16: This can be safely deleted, because 'i'
2719 // OBSOLETE means imported type in AIX stabs, while it means volatile qualifier
2720 // OBSOLETE in os9k stabs. Obviously we were supporting only the os9k meaning.
2721 // OBSOLETE We were erroring out if we were reading AIX stabs. Right now the
2722 // OBSOLETE erroring out will happen in the default clause of the switch. */
2723 // OBSOLETE case 'i': /* Volatile qual on some type (OS9000) */
2724 // OBSOLETE /* Because 'i' means other things to AIX and 'B' is perfectly good,
2725 // OBSOLETE only accept 'i' in the os9k_stabs case. */
2726 // OBSOLETE if (type_descriptor == 'i' && !os9k_stabs)
2727 // OBSOLETE return error_type (pp, objfile);
2728 #endif /* OBSOLETE OS9K */
2729 type
= read_type (pp
, objfile
);
2730 type
= make_cv_type (TYPE_CONST (type
), 1, type
,
2731 dbx_lookup_type (typenums
));
2735 if (isdigit (**pp
) || **pp
== '(' || **pp
== '-')
2736 { /* Member (class & variable) type */
2737 /* FIXME -- we should be doing smash_to_XXX types here. */
2739 struct type
*domain
= read_type (pp
, objfile
);
2740 struct type
*memtype
;
2743 /* Invalid member type data format. */
2744 return error_type (pp
, objfile
);
2747 memtype
= read_type (pp
, objfile
);
2748 type
= dbx_alloc_type (typenums
, objfile
);
2749 smash_to_member_type (type
, domain
, memtype
);
2752 /* type attribute */
2755 /* Skip to the semicolon. */
2756 while (**pp
!= ';' && **pp
!= '\0')
2759 return error_type (pp
, objfile
);
2761 ++ * pp
; /* Skip the semicolon. */
2765 case 's': /* Size attribute */
2766 type_size
= atoi (attr
+ 1);
2771 case 'S': /* String attribute */
2772 /* FIXME: check to see if following type is array? */
2776 case 'V': /* Vector attribute */
2777 /* FIXME: check to see if following type is array? */
2782 /* Ignore unrecognized type attributes, so future compilers
2783 can invent new ones. */
2791 case '#': /* Method (class & fn) type */
2792 if ((*pp
)[0] == '#')
2794 /* We'll get the parameter types from the name. */
2795 struct type
*return_type
;
2798 return_type
= read_type (pp
, objfile
);
2799 if (*(*pp
)++ != ';')
2800 complain (&invalid_member_complaint
, symnum
);
2801 type
= allocate_stub_method (return_type
);
2802 if (typenums
[0] != -1)
2803 *dbx_lookup_type (typenums
) = type
;
2807 struct type
*domain
= read_type (pp
, objfile
);
2808 struct type
*return_type
;
2813 /* Invalid member type data format. */
2814 return error_type (pp
, objfile
);
2818 return_type
= read_type (pp
, objfile
);
2819 args
= read_args (pp
, ';', objfile
, &nargs
, &varargs
);
2820 type
= dbx_alloc_type (typenums
, objfile
);
2821 smash_to_method_type (type
, domain
, return_type
, args
,
2826 case 'r': /* Range type */
2827 type
= read_range_type (pp
, typenums
, objfile
);
2828 if (typenums
[0] != -1)
2829 *dbx_lookup_type (typenums
) = type
;
2833 #if 0 /* OBSOLETE OS9K */
2834 // OBSOLETE if (os9k_stabs)
2835 // OBSOLETE /* Const and volatile qualified type. */
2836 // OBSOLETE type = read_type (pp, objfile);
2838 #endif /* OBSOLETE OS9K */
2840 /* Sun ACC builtin int type */
2841 type
= read_sun_builtin_type (pp
, typenums
, objfile
);
2842 if (typenums
[0] != -1)
2843 *dbx_lookup_type (typenums
) = type
;
2847 case 'R': /* Sun ACC builtin float type */
2848 type
= read_sun_floating_type (pp
, typenums
, objfile
);
2849 if (typenums
[0] != -1)
2850 *dbx_lookup_type (typenums
) = type
;
2853 case 'e': /* Enumeration type */
2854 type
= dbx_alloc_type (typenums
, objfile
);
2855 type
= read_enum_type (pp
, type
, objfile
);
2856 if (typenums
[0] != -1)
2857 *dbx_lookup_type (typenums
) = type
;
2860 case 's': /* Struct type */
2861 case 'u': /* Union type */
2863 enum type_code type_code
= TYPE_CODE_UNDEF
;
2864 type
= dbx_alloc_type (typenums
, objfile
);
2865 switch (type_descriptor
)
2868 type_code
= TYPE_CODE_STRUCT
;
2871 type_code
= TYPE_CODE_UNION
;
2874 type
= read_struct_type (pp
, type
, type_code
, objfile
);
2878 case 'a': /* Array type */
2880 return error_type (pp
, objfile
);
2883 type
= dbx_alloc_type (typenums
, objfile
);
2884 type
= read_array_type (pp
, type
, objfile
);
2886 TYPE_CODE (type
) = TYPE_CODE_STRING
;
2888 TYPE_FLAGS (type
) |= TYPE_FLAG_VECTOR
;
2891 case 'S': /* Set or bitstring type */
2892 type1
= read_type (pp
, objfile
);
2893 type
= create_set_type ((struct type
*) NULL
, type1
);
2895 TYPE_CODE (type
) = TYPE_CODE_BITSTRING
;
2896 if (typenums
[0] != -1)
2897 *dbx_lookup_type (typenums
) = type
;
2901 --*pp
; /* Go back to the symbol in error */
2902 /* Particularly important if it was \0! */
2903 return error_type (pp
, objfile
);
2908 warning ("GDB internal error, type is NULL in stabsread.c\n");
2909 return error_type (pp
, objfile
);
2912 /* Size specified in a type attribute overrides any other size. */
2913 if (type_size
!= -1)
2914 TYPE_LENGTH (type
) = (type_size
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
2919 /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
2920 Return the proper type node for a given builtin type number. */
2922 static struct type
*
2923 rs6000_builtin_type (int typenum
)
2925 /* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
2926 #define NUMBER_RECOGNIZED 34
2927 /* This includes an empty slot for type number -0. */
2928 static struct type
*negative_types
[NUMBER_RECOGNIZED
+ 1];
2929 struct type
*rettype
= NULL
;
2931 if (typenum
>= 0 || typenum
< -NUMBER_RECOGNIZED
)
2933 complain (&rs6000_builtin_complaint
, typenum
);
2934 return builtin_type_error
;
2936 if (negative_types
[-typenum
] != NULL
)
2937 return negative_types
[-typenum
];
2939 #if TARGET_CHAR_BIT != 8
2940 #error This code wrong for TARGET_CHAR_BIT not 8
2941 /* These definitions all assume that TARGET_CHAR_BIT is 8. I think
2942 that if that ever becomes not true, the correct fix will be to
2943 make the size in the struct type to be in bits, not in units of
2950 /* The size of this and all the other types are fixed, defined
2951 by the debugging format. If there is a type called "int" which
2952 is other than 32 bits, then it should use a new negative type
2953 number (or avoid negative type numbers for that case).
2954 See stabs.texinfo. */
2955 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "int", NULL
);
2958 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "char", NULL
);
2961 rettype
= init_type (TYPE_CODE_INT
, 2, 0, "short", NULL
);
2964 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "long", NULL
);
2967 rettype
= init_type (TYPE_CODE_INT
, 1, TYPE_FLAG_UNSIGNED
,
2968 "unsigned char", NULL
);
2971 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "signed char", NULL
);
2974 rettype
= init_type (TYPE_CODE_INT
, 2, TYPE_FLAG_UNSIGNED
,
2975 "unsigned short", NULL
);
2978 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2979 "unsigned int", NULL
);
2982 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2985 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2986 "unsigned long", NULL
);
2989 rettype
= init_type (TYPE_CODE_VOID
, 1, 0, "void", NULL
);
2992 /* IEEE single precision (32 bit). */
2993 rettype
= init_type (TYPE_CODE_FLT
, 4, 0, "float", NULL
);
2996 /* IEEE double precision (64 bit). */
2997 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "double", NULL
);
3000 /* This is an IEEE double on the RS/6000, and different machines with
3001 different sizes for "long double" should use different negative
3002 type numbers. See stabs.texinfo. */
3003 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "long double", NULL
);
3006 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "integer", NULL
);
3009 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
3013 rettype
= init_type (TYPE_CODE_FLT
, 4, 0, "short real", NULL
);
3016 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "real", NULL
);
3019 rettype
= init_type (TYPE_CODE_ERROR
, 0, 0, "stringptr", NULL
);
3022 rettype
= init_type (TYPE_CODE_CHAR
, 1, TYPE_FLAG_UNSIGNED
,
3026 rettype
= init_type (TYPE_CODE_BOOL
, 1, TYPE_FLAG_UNSIGNED
,
3030 rettype
= init_type (TYPE_CODE_BOOL
, 2, TYPE_FLAG_UNSIGNED
,
3034 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
3038 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
3042 /* Complex type consisting of two IEEE single precision values. */
3043 rettype
= init_type (TYPE_CODE_COMPLEX
, 8, 0, "complex", NULL
);
3044 TYPE_TARGET_TYPE (rettype
) = init_type (TYPE_CODE_FLT
, 4, 0, "float",
3048 /* Complex type consisting of two IEEE double precision values. */
3049 rettype
= init_type (TYPE_CODE_COMPLEX
, 16, 0, "double complex", NULL
);
3050 TYPE_TARGET_TYPE (rettype
) = init_type (TYPE_CODE_FLT
, 8, 0, "double",
3054 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "integer*1", NULL
);
3057 rettype
= init_type (TYPE_CODE_INT
, 2, 0, "integer*2", NULL
);
3060 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "integer*4", NULL
);
3063 rettype
= init_type (TYPE_CODE_CHAR
, 2, 0, "wchar", NULL
);
3066 rettype
= init_type (TYPE_CODE_INT
, 8, 0, "long long", NULL
);
3069 rettype
= init_type (TYPE_CODE_INT
, 8, TYPE_FLAG_UNSIGNED
,
3070 "unsigned long long", NULL
);
3073 rettype
= init_type (TYPE_CODE_INT
, 8, TYPE_FLAG_UNSIGNED
,
3077 rettype
= init_type (TYPE_CODE_INT
, 8, 0, "integer*8", NULL
);
3080 negative_types
[-typenum
] = rettype
;
3084 /* This page contains subroutines of read_type. */
3086 /* Replace *OLD_NAME with the method name portion of PHYSNAME. */
3089 update_method_name_from_physname (char **old_name
, char *physname
)
3093 method_name
= method_name_from_physname (physname
);
3095 if (method_name
== NULL
)
3096 error ("bad physname %s\n", physname
);
3098 if (strcmp (*old_name
, method_name
) != 0)
3101 *old_name
= method_name
;
3104 xfree (method_name
);
3107 /* Read member function stabs info for C++ classes. The form of each member
3110 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
3112 An example with two member functions is:
3114 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
3116 For the case of overloaded operators, the format is op$::*.funcs, where
3117 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
3118 name (such as `+=') and `.' marks the end of the operator name.
3120 Returns 1 for success, 0 for failure. */
3123 read_member_functions (struct field_info
*fip
, char **pp
, struct type
*type
,
3124 struct objfile
*objfile
)
3128 /* Total number of member functions defined in this class. If the class
3129 defines two `f' functions, and one `g' function, then this will have
3131 int total_length
= 0;
3135 struct next_fnfield
*next
;
3136 struct fn_field fn_field
;
3139 struct type
*look_ahead_type
;
3140 struct next_fnfieldlist
*new_fnlist
;
3141 struct next_fnfield
*new_sublist
;
3145 /* Process each list until we find something that is not a member function
3146 or find the end of the functions. */
3150 /* We should be positioned at the start of the function name.
3151 Scan forward to find the first ':' and if it is not the
3152 first of a "::" delimiter, then this is not a member function. */
3164 look_ahead_type
= NULL
;
3167 new_fnlist
= (struct next_fnfieldlist
*)
3168 xmalloc (sizeof (struct next_fnfieldlist
));
3169 make_cleanup (xfree
, new_fnlist
);
3170 memset (new_fnlist
, 0, sizeof (struct next_fnfieldlist
));
3172 if ((*pp
)[0] == 'o' && (*pp
)[1] == 'p' && is_cplus_marker ((*pp
)[2]))
3174 /* This is a completely wierd case. In order to stuff in the
3175 names that might contain colons (the usual name delimiter),
3176 Mike Tiemann defined a different name format which is
3177 signalled if the identifier is "op$". In that case, the
3178 format is "op$::XXXX." where XXXX is the name. This is
3179 used for names like "+" or "=". YUUUUUUUK! FIXME! */
3180 /* This lets the user type "break operator+".
3181 We could just put in "+" as the name, but that wouldn't
3183 static char opname
[32] = "op$";
3184 char *o
= opname
+ 3;
3186 /* Skip past '::'. */
3189 STABS_CONTINUE (pp
, objfile
);
3195 main_fn_name
= savestring (opname
, o
- opname
);
3201 main_fn_name
= savestring (*pp
, p
- *pp
);
3202 /* Skip past '::'. */
3205 new_fnlist
->fn_fieldlist
.name
= main_fn_name
;
3210 (struct next_fnfield
*) xmalloc (sizeof (struct next_fnfield
));
3211 make_cleanup (xfree
, new_sublist
);
3212 memset (new_sublist
, 0, sizeof (struct next_fnfield
));
3214 /* Check for and handle cretinous dbx symbol name continuation! */
3215 if (look_ahead_type
== NULL
)
3218 STABS_CONTINUE (pp
, objfile
);
3220 new_sublist
->fn_field
.type
= read_type (pp
, objfile
);
3223 /* Invalid symtab info for member function. */
3229 /* g++ version 1 kludge */
3230 new_sublist
->fn_field
.type
= look_ahead_type
;
3231 look_ahead_type
= NULL
;
3241 /* If this is just a stub, then we don't have the real name here. */
3243 if (TYPE_STUB (new_sublist
->fn_field
.type
))
3245 if (!TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
))
3246 TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
) = type
;
3247 new_sublist
->fn_field
.is_stub
= 1;
3249 new_sublist
->fn_field
.physname
= savestring (*pp
, p
- *pp
);
3252 /* Set this member function's visibility fields. */
3255 case VISIBILITY_PRIVATE
:
3256 new_sublist
->fn_field
.is_private
= 1;
3258 case VISIBILITY_PROTECTED
:
3259 new_sublist
->fn_field
.is_protected
= 1;
3263 STABS_CONTINUE (pp
, objfile
);
3266 case 'A': /* Normal functions. */
3267 new_sublist
->fn_field
.is_const
= 0;
3268 new_sublist
->fn_field
.is_volatile
= 0;
3271 case 'B': /* `const' member functions. */
3272 new_sublist
->fn_field
.is_const
= 1;
3273 new_sublist
->fn_field
.is_volatile
= 0;
3276 case 'C': /* `volatile' member function. */
3277 new_sublist
->fn_field
.is_const
= 0;
3278 new_sublist
->fn_field
.is_volatile
= 1;
3281 case 'D': /* `const volatile' member function. */
3282 new_sublist
->fn_field
.is_const
= 1;
3283 new_sublist
->fn_field
.is_volatile
= 1;
3286 case '*': /* File compiled with g++ version 1 -- no info */
3291 complain (&const_vol_complaint
, **pp
);
3300 /* virtual member function, followed by index.
3301 The sign bit is set to distinguish pointers-to-methods
3302 from virtual function indicies. Since the array is
3303 in words, the quantity must be shifted left by 1
3304 on 16 bit machine, and by 2 on 32 bit machine, forcing
3305 the sign bit out, and usable as a valid index into
3306 the array. Remove the sign bit here. */
3307 new_sublist
->fn_field
.voffset
=
3308 (0x7fffffff & read_huge_number (pp
, ';', &nbits
)) + 2;
3312 STABS_CONTINUE (pp
, objfile
);
3313 if (**pp
== ';' || **pp
== '\0')
3315 /* Must be g++ version 1. */
3316 new_sublist
->fn_field
.fcontext
= 0;
3320 /* Figure out from whence this virtual function came.
3321 It may belong to virtual function table of
3322 one of its baseclasses. */
3323 look_ahead_type
= read_type (pp
, objfile
);
3326 /* g++ version 1 overloaded methods. */
3330 new_sublist
->fn_field
.fcontext
= look_ahead_type
;
3339 look_ahead_type
= NULL
;
3345 /* static member function. */
3347 int slen
= strlen (main_fn_name
);
3349 new_sublist
->fn_field
.voffset
= VOFFSET_STATIC
;
3351 /* For static member functions, we can't tell if they
3352 are stubbed, as they are put out as functions, and not as
3354 GCC v2 emits the fully mangled name if
3355 dbxout.c:flag_minimal_debug is not set, so we have to
3356 detect a fully mangled physname here and set is_stub
3357 accordingly. Fully mangled physnames in v2 start with
3358 the member function name, followed by two underscores.
3359 GCC v3 currently always emits stubbed member functions,
3360 but with fully mangled physnames, which start with _Z. */
3361 if (!(strncmp (new_sublist
->fn_field
.physname
,
3362 main_fn_name
, slen
) == 0
3363 && new_sublist
->fn_field
.physname
[slen
] == '_'
3364 && new_sublist
->fn_field
.physname
[slen
+ 1] == '_'))
3366 new_sublist
->fn_field
.is_stub
= 1;
3373 complain (&member_fn_complaint
, (*pp
)[-1]);
3374 /* Fall through into normal member function. */
3377 /* normal member function. */
3378 new_sublist
->fn_field
.voffset
= 0;
3379 new_sublist
->fn_field
.fcontext
= 0;
3383 new_sublist
->next
= sublist
;
3384 sublist
= new_sublist
;
3386 STABS_CONTINUE (pp
, objfile
);
3388 while (**pp
!= ';' && **pp
!= '\0');
3391 STABS_CONTINUE (pp
, objfile
);
3393 /* Skip GCC 3.X member functions which are duplicates of the callable
3394 constructor/destructor. */
3395 if (strcmp (main_fn_name
, "__base_ctor") == 0
3396 || strcmp (main_fn_name
, "__base_dtor") == 0
3397 || strcmp (main_fn_name
, "__deleting_dtor") == 0)
3399 xfree (main_fn_name
);
3404 int has_destructor
= 0, has_other
= 0;
3406 struct next_fnfield
*tmp_sublist
;
3408 /* Various versions of GCC emit various mostly-useless
3409 strings in the name field for special member functions.
3411 For stub methods, we need to defer correcting the name
3412 until we are ready to unstub the method, because the current
3413 name string is used by gdb_mangle_name. The only stub methods
3414 of concern here are GNU v2 operators; other methods have their
3415 names correct (see caveat below).
3417 For non-stub methods, in GNU v3, we have a complete physname.
3418 Therefore we can safely correct the name now. This primarily
3419 affects constructors and destructors, whose name will be
3420 __comp_ctor or __comp_dtor instead of Foo or ~Foo. Cast
3421 operators will also have incorrect names; for instance,
3422 "operator int" will be named "operator i" (i.e. the type is
3425 For non-stub methods in GNU v2, we have no easy way to
3426 know if we have a complete physname or not. For most
3427 methods the result depends on the platform (if CPLUS_MARKER
3428 can be `$' or `.', it will use minimal debug information, or
3429 otherwise the full physname will be included).
3431 Rather than dealing with this, we take a different approach.
3432 For v3 mangled names, we can use the full physname; for v2,
3433 we use cplus_demangle_opname (which is actually v2 specific),
3434 because the only interesting names are all operators - once again
3435 barring the caveat below. Skip this process if any method in the
3436 group is a stub, to prevent our fouling up the workings of
3439 The caveat: GCC 2.95.x (and earlier?) put constructors and
3440 destructors in the same method group. We need to split this
3441 into two groups, because they should have different names.
3442 So for each method group we check whether it contains both
3443 routines whose physname appears to be a destructor (the physnames
3444 for and destructors are always provided, due to quirks in v2
3445 mangling) and routines whose physname does not appear to be a
3446 destructor. If so then we break up the list into two halves.
3447 Even if the constructors and destructors aren't in the same group
3448 the destructor will still lack the leading tilde, so that also
3451 So, to summarize what we expect and handle here:
3453 Given Given Real Real Action
3454 method name physname physname method name
3456 __opi [none] __opi__3Foo operator int opname
3458 Foo _._3Foo _._3Foo ~Foo separate and
3460 operator i _ZN3FoocviEv _ZN3FoocviEv operator int demangle
3461 __comp_ctor _ZN3FooC1ERKS_ _ZN3FooC1ERKS_ Foo demangle
3464 tmp_sublist
= sublist
;
3465 while (tmp_sublist
!= NULL
)
3467 if (tmp_sublist
->fn_field
.is_stub
)
3469 if (tmp_sublist
->fn_field
.physname
[0] == '_'
3470 && tmp_sublist
->fn_field
.physname
[1] == 'Z')
3473 if (is_destructor_name (tmp_sublist
->fn_field
.physname
))
3478 tmp_sublist
= tmp_sublist
->next
;
3481 if (has_destructor
&& has_other
)
3483 struct next_fnfieldlist
*destr_fnlist
;
3484 struct next_fnfield
*last_sublist
;
3486 /* Create a new fn_fieldlist for the destructors. */
3488 destr_fnlist
= (struct next_fnfieldlist
*)
3489 xmalloc (sizeof (struct next_fnfieldlist
));
3490 make_cleanup (xfree
, destr_fnlist
);
3491 memset (destr_fnlist
, 0, sizeof (struct next_fnfieldlist
));
3492 destr_fnlist
->fn_fieldlist
.name
3493 = obconcat (&objfile
->type_obstack
, "", "~",
3494 new_fnlist
->fn_fieldlist
.name
);
3496 destr_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
3497 obstack_alloc (&objfile
->type_obstack
,
3498 sizeof (struct fn_field
) * has_destructor
);
3499 memset (destr_fnlist
->fn_fieldlist
.fn_fields
, 0,
3500 sizeof (struct fn_field
) * has_destructor
);
3501 tmp_sublist
= sublist
;
3502 last_sublist
= NULL
;
3504 while (tmp_sublist
!= NULL
)
3506 if (!is_destructor_name (tmp_sublist
->fn_field
.physname
))
3508 tmp_sublist
= tmp_sublist
->next
;
3512 destr_fnlist
->fn_fieldlist
.fn_fields
[i
++]
3513 = tmp_sublist
->fn_field
;
3515 last_sublist
->next
= tmp_sublist
->next
;
3517 sublist
= tmp_sublist
->next
;
3518 last_sublist
= tmp_sublist
;
3519 tmp_sublist
= tmp_sublist
->next
;
3522 destr_fnlist
->fn_fieldlist
.length
= has_destructor
;
3523 destr_fnlist
->next
= fip
->fnlist
;
3524 fip
->fnlist
= destr_fnlist
;
3526 total_length
+= has_destructor
;
3527 length
-= has_destructor
;
3531 /* v3 mangling prevents the use of abbreviated physnames,
3532 so we can do this here. There are stubbed methods in v3
3534 - in -gstabs instead of -gstabs+
3535 - or for static methods, which are output as a function type
3536 instead of a method type. */
3538 update_method_name_from_physname (&new_fnlist
->fn_fieldlist
.name
,
3539 sublist
->fn_field
.physname
);
3541 else if (has_destructor
&& new_fnlist
->fn_fieldlist
.name
[0] != '~')
3543 new_fnlist
->fn_fieldlist
.name
= concat ("~", main_fn_name
, NULL
);
3544 xfree (main_fn_name
);
3548 char dem_opname
[256];
3550 ret
= cplus_demangle_opname (new_fnlist
->fn_fieldlist
.name
,
3551 dem_opname
, DMGL_ANSI
);
3553 ret
= cplus_demangle_opname (new_fnlist
->fn_fieldlist
.name
,
3556 new_fnlist
->fn_fieldlist
.name
3557 = obsavestring (dem_opname
, strlen (dem_opname
),
3558 &objfile
->type_obstack
);
3561 new_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
3562 obstack_alloc (&objfile
->type_obstack
,
3563 sizeof (struct fn_field
) * length
);
3564 memset (new_fnlist
->fn_fieldlist
.fn_fields
, 0,
3565 sizeof (struct fn_field
) * length
);
3566 for (i
= length
; (i
--, sublist
); sublist
= sublist
->next
)
3568 new_fnlist
->fn_fieldlist
.fn_fields
[i
] = sublist
->fn_field
;
3571 new_fnlist
->fn_fieldlist
.length
= length
;
3572 new_fnlist
->next
= fip
->fnlist
;
3573 fip
->fnlist
= new_fnlist
;
3575 total_length
+= length
;
3581 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
3582 TYPE_FN_FIELDLISTS (type
) = (struct fn_fieldlist
*)
3583 TYPE_ALLOC (type
, sizeof (struct fn_fieldlist
) * nfn_fields
);
3584 memset (TYPE_FN_FIELDLISTS (type
), 0,
3585 sizeof (struct fn_fieldlist
) * nfn_fields
);
3586 TYPE_NFN_FIELDS (type
) = nfn_fields
;
3587 TYPE_NFN_FIELDS_TOTAL (type
) = total_length
;
3593 /* Special GNU C++ name.
3595 Returns 1 for success, 0 for failure. "failure" means that we can't
3596 keep parsing and it's time for error_type(). */
3599 read_cpp_abbrev (struct field_info
*fip
, char **pp
, struct type
*type
,
3600 struct objfile
*objfile
)
3605 struct type
*context
;
3615 /* At this point, *pp points to something like "22:23=*22...",
3616 where the type number before the ':' is the "context" and
3617 everything after is a regular type definition. Lookup the
3618 type, find it's name, and construct the field name. */
3620 context
= read_type (pp
, objfile
);
3624 case 'f': /* $vf -- a virtual function table pointer */
3625 name
= type_name_no_tag (context
);
3630 fip
->list
->field
.name
=
3631 obconcat (&objfile
->type_obstack
, vptr_name
, name
, "");
3634 case 'b': /* $vb -- a virtual bsomethingorother */
3635 name
= type_name_no_tag (context
);
3638 complain (&invalid_cpp_type_complaint
, symnum
);
3641 fip
->list
->field
.name
=
3642 obconcat (&objfile
->type_obstack
, vb_name
, name
, "");
3646 complain (&invalid_cpp_abbrev_complaint
, *pp
);
3647 fip
->list
->field
.name
=
3648 obconcat (&objfile
->type_obstack
,
3649 "INVALID_CPLUSPLUS_ABBREV", "", "");
3653 /* At this point, *pp points to the ':'. Skip it and read the
3659 complain (&invalid_cpp_abbrev_complaint
, *pp
);
3662 fip
->list
->field
.type
= read_type (pp
, objfile
);
3664 (*pp
)++; /* Skip the comma. */
3670 FIELD_BITPOS (fip
->list
->field
) = read_huge_number (pp
, ';', &nbits
);
3674 /* This field is unpacked. */
3675 FIELD_BITSIZE (fip
->list
->field
) = 0;
3676 fip
->list
->visibility
= VISIBILITY_PRIVATE
;
3680 complain (&invalid_cpp_abbrev_complaint
, *pp
);
3681 /* We have no idea what syntax an unrecognized abbrev would have, so
3682 better return 0. If we returned 1, we would need to at least advance
3683 *pp to avoid an infinite loop. */
3690 read_one_struct_field (struct field_info
*fip
, char **pp
, char *p
,
3691 struct type
*type
, struct objfile
*objfile
)
3693 /* The following is code to work around cfront generated stabs.
3694 The stabs contains full mangled name for each field.
3695 We try to demangle the name and extract the field name out of it.
3697 if (ARM_DEMANGLING
&& current_subfile
->language
== language_cplus
)
3703 dem
= cplus_demangle (*pp
, DMGL_ANSI
| DMGL_PARAMS
);
3706 dem_p
= strrchr (dem
, ':');
3707 if (dem_p
!= 0 && *(dem_p
- 1) == ':')
3709 FIELD_NAME (fip
->list
->field
) =
3710 obsavestring (dem_p
, strlen (dem_p
), &objfile
->type_obstack
);
3714 FIELD_NAME (fip
->list
->field
) =
3715 obsavestring (*pp
, p
- *pp
, &objfile
->type_obstack
);
3719 /* end of code for cfront work around */
3722 fip
->list
->field
.name
=
3723 obsavestring (*pp
, p
- *pp
, &objfile
->type_obstack
);
3726 /* This means we have a visibility for a field coming. */
3730 fip
->list
->visibility
= *(*pp
)++;
3734 /* normal dbx-style format, no explicit visibility */
3735 fip
->list
->visibility
= VISIBILITY_PUBLIC
;
3738 fip
->list
->field
.type
= read_type (pp
, objfile
);
3743 /* Possible future hook for nested types. */
3746 fip
->list
->field
.bitpos
= (long) -2; /* nested type */
3756 /* Static class member. */
3757 SET_FIELD_PHYSNAME (fip
->list
->field
, savestring (*pp
, p
- *pp
));
3761 else if (**pp
!= ',')
3763 /* Bad structure-type format. */
3764 complain (&stabs_general_complaint
, "bad structure-type format");
3768 (*pp
)++; /* Skip the comma. */
3772 FIELD_BITPOS (fip
->list
->field
) = read_huge_number (pp
, ',', &nbits
);
3775 complain (&stabs_general_complaint
, "bad structure-type format");
3778 FIELD_BITSIZE (fip
->list
->field
) = read_huge_number (pp
, ';', &nbits
);
3781 complain (&stabs_general_complaint
, "bad structure-type format");
3786 if (FIELD_BITPOS (fip
->list
->field
) == 0
3787 && FIELD_BITSIZE (fip
->list
->field
) == 0)
3789 /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
3790 it is a field which has been optimized out. The correct stab for
3791 this case is to use VISIBILITY_IGNORE, but that is a recent
3792 invention. (2) It is a 0-size array. For example
3793 union { int num; char str[0]; } foo. Printing "<no value>" for
3794 str in "p foo" is OK, since foo.str (and thus foo.str[3])
3795 will continue to work, and a 0-size array as a whole doesn't
3796 have any contents to print.
3798 I suspect this probably could also happen with gcc -gstabs (not
3799 -gstabs+) for static fields, and perhaps other C++ extensions.
3800 Hopefully few people use -gstabs with gdb, since it is intended
3801 for dbx compatibility. */
3803 /* Ignore this field. */
3804 fip
->list
->visibility
= VISIBILITY_IGNORE
;
3808 /* Detect an unpacked field and mark it as such.
3809 dbx gives a bit size for all fields.
3810 Note that forward refs cannot be packed,
3811 and treat enums as if they had the width of ints. */
3813 struct type
*field_type
= check_typedef (FIELD_TYPE (fip
->list
->field
));
3815 if (TYPE_CODE (field_type
) != TYPE_CODE_INT
3816 && TYPE_CODE (field_type
) != TYPE_CODE_RANGE
3817 && TYPE_CODE (field_type
) != TYPE_CODE_BOOL
3818 && TYPE_CODE (field_type
) != TYPE_CODE_ENUM
)
3820 FIELD_BITSIZE (fip
->list
->field
) = 0;
3822 if ((FIELD_BITSIZE (fip
->list
->field
)
3823 == TARGET_CHAR_BIT
* TYPE_LENGTH (field_type
)
3824 || (TYPE_CODE (field_type
) == TYPE_CODE_ENUM
3825 && FIELD_BITSIZE (fip
->list
->field
) == TARGET_INT_BIT
)
3828 FIELD_BITPOS (fip
->list
->field
) % 8 == 0)
3830 FIELD_BITSIZE (fip
->list
->field
) = 0;
3836 /* Read struct or class data fields. They have the form:
3838 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
3840 At the end, we see a semicolon instead of a field.
3842 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
3845 The optional VISIBILITY is one of:
3847 '/0' (VISIBILITY_PRIVATE)
3848 '/1' (VISIBILITY_PROTECTED)
3849 '/2' (VISIBILITY_PUBLIC)
3850 '/9' (VISIBILITY_IGNORE)
3852 or nothing, for C style fields with public visibility.
3854 Returns 1 for success, 0 for failure. */
3857 read_struct_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
3858 struct objfile
*objfile
)
3861 struct nextfield
*new;
3863 /* We better set p right now, in case there are no fields at all... */
3867 /* Read each data member type until we find the terminating ';' at the end of
3868 the data member list, or break for some other reason such as finding the
3869 start of the member function list. */
3870 /* Stab string for structure/union does not end with two ';' in
3871 SUN C compiler 5.3 i.e. F6U2, hence check for end of string. */
3873 while (**pp
!= ';' && **pp
!= '\0')
3875 #if 0 /* OBSOLETE OS9K */
3876 // OBSOLETE if (os9k_stabs && **pp == ',')
3878 #endif /* OBSOLETE OS9K */
3879 STABS_CONTINUE (pp
, objfile
);
3880 /* Get space to record the next field's data. */
3881 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
3882 make_cleanup (xfree
, new);
3883 memset (new, 0, sizeof (struct nextfield
));
3884 new->next
= fip
->list
;
3887 /* Get the field name. */
3890 /* If is starts with CPLUS_MARKER it is a special abbreviation,
3891 unless the CPLUS_MARKER is followed by an underscore, in
3892 which case it is just the name of an anonymous type, which we
3893 should handle like any other type name. */
3895 if (is_cplus_marker (p
[0]) && p
[1] != '_')
3897 if (!read_cpp_abbrev (fip
, pp
, type
, objfile
))
3902 /* Look for the ':' that separates the field name from the field
3903 values. Data members are delimited by a single ':', while member
3904 functions are delimited by a pair of ':'s. When we hit the member
3905 functions (if any), terminate scan loop and return. */
3907 while (*p
!= ':' && *p
!= '\0')
3914 /* Check to see if we have hit the member functions yet. */
3919 read_one_struct_field (fip
, pp
, p
, type
, objfile
);
3921 if (p
[0] == ':' && p
[1] == ':')
3923 /* (OBSOLETE) chill (OBSOLETE) the list of fields: the last
3924 entry (at the head) is a partially constructed entry which we
3926 fip
->list
= fip
->list
->next
;
3931 /* The stabs for C++ derived classes contain baseclass information which
3932 is marked by a '!' character after the total size. This function is
3933 called when we encounter the baseclass marker, and slurps up all the
3934 baseclass information.
3936 Immediately following the '!' marker is the number of base classes that
3937 the class is derived from, followed by information for each base class.
3938 For each base class, there are two visibility specifiers, a bit offset
3939 to the base class information within the derived class, a reference to
3940 the type for the base class, and a terminating semicolon.
3942 A typical example, with two base classes, would be "!2,020,19;0264,21;".
3944 Baseclass information marker __________________|| | | | | | |
3945 Number of baseclasses __________________________| | | | | | |
3946 Visibility specifiers (2) ________________________| | | | | |
3947 Offset in bits from start of class _________________| | | | |
3948 Type number for base class ___________________________| | | |
3949 Visibility specifiers (2) _______________________________| | |
3950 Offset in bits from start of class ________________________| |
3951 Type number of base class ____________________________________|
3953 Return 1 for success, 0 for (error-type-inducing) failure. */
3959 read_baseclasses (struct field_info
*fip
, char **pp
, struct type
*type
,
3960 struct objfile
*objfile
)
3963 struct nextfield
*new;
3971 /* Skip the '!' baseclass information marker. */
3975 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
3978 TYPE_N_BASECLASSES (type
) = read_huge_number (pp
, ',', &nbits
);
3984 /* Some stupid compilers have trouble with the following, so break
3985 it up into simpler expressions. */
3986 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*)
3987 TYPE_ALLOC (type
, B_BYTES (TYPE_N_BASECLASSES (type
)));
3990 int num_bytes
= B_BYTES (TYPE_N_BASECLASSES (type
));
3993 pointer
= (char *) TYPE_ALLOC (type
, num_bytes
);
3994 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*) pointer
;
3998 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type
), TYPE_N_BASECLASSES (type
));
4000 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
4002 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
4003 make_cleanup (xfree
, new);
4004 memset (new, 0, sizeof (struct nextfield
));
4005 new->next
= fip
->list
;
4007 FIELD_BITSIZE (new->field
) = 0; /* this should be an unpacked field! */
4009 STABS_CONTINUE (pp
, objfile
);
4013 /* Nothing to do. */
4016 SET_TYPE_FIELD_VIRTUAL (type
, i
);
4019 /* Unknown character. Complain and treat it as non-virtual. */
4021 static struct deprecated_complaint msg
=
4023 "Unknown virtual character `%c' for baseclass", 0, 0};
4024 complain (&msg
, **pp
);
4029 new->visibility
= *(*pp
)++;
4030 switch (new->visibility
)
4032 case VISIBILITY_PRIVATE
:
4033 case VISIBILITY_PROTECTED
:
4034 case VISIBILITY_PUBLIC
:
4037 /* Bad visibility format. Complain and treat it as
4040 static struct deprecated_complaint msg
=
4042 "Unknown visibility `%c' for baseclass", 0, 0
4044 complain (&msg
, new->visibility
);
4045 new->visibility
= VISIBILITY_PUBLIC
;
4052 /* The remaining value is the bit offset of the portion of the object
4053 corresponding to this baseclass. Always zero in the absence of
4054 multiple inheritance. */
4056 FIELD_BITPOS (new->field
) = read_huge_number (pp
, ',', &nbits
);
4061 /* The last piece of baseclass information is the type of the
4062 base class. Read it, and remember it's type name as this
4065 new->field
.type
= read_type (pp
, objfile
);
4066 new->field
.name
= type_name_no_tag (new->field
.type
);
4068 /* skip trailing ';' and bump count of number of fields seen */
4077 /* The tail end of stabs for C++ classes that contain a virtual function
4078 pointer contains a tilde, a %, and a type number.
4079 The type number refers to the base class (possibly this class itself) which
4080 contains the vtable pointer for the current class.
4082 This function is called when we have parsed all the method declarations,
4083 so we can look for the vptr base class info. */
4086 read_tilde_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
4087 struct objfile
*objfile
)
4091 STABS_CONTINUE (pp
, objfile
);
4093 /* If we are positioned at a ';', then skip it. */
4103 if (**pp
== '=' || **pp
== '+' || **pp
== '-')
4105 /* Obsolete flags that used to indicate the presence
4106 of constructors and/or destructors. */
4110 /* Read either a '%' or the final ';'. */
4111 if (*(*pp
)++ == '%')
4113 /* The next number is the type number of the base class
4114 (possibly our own class) which supplies the vtable for
4115 this class. Parse it out, and search that class to find
4116 its vtable pointer, and install those into TYPE_VPTR_BASETYPE
4117 and TYPE_VPTR_FIELDNO. */
4122 t
= read_type (pp
, objfile
);
4124 while (*p
!= '\0' && *p
!= ';')
4130 /* Premature end of symbol. */
4134 TYPE_VPTR_BASETYPE (type
) = t
;
4135 if (type
== t
) /* Our own class provides vtbl ptr */
4137 for (i
= TYPE_NFIELDS (t
) - 1;
4138 i
>= TYPE_N_BASECLASSES (t
);
4141 char *name
= TYPE_FIELD_NAME (t
, i
);
4142 if (!strncmp (name
, vptr_name
, sizeof (vptr_name
) - 2)
4143 && is_cplus_marker (name
[sizeof (vptr_name
) - 2]))
4145 TYPE_VPTR_FIELDNO (type
) = i
;
4149 /* Virtual function table field not found. */
4150 complain (&vtbl_notfound_complaint
, TYPE_NAME (type
));
4155 TYPE_VPTR_FIELDNO (type
) = TYPE_VPTR_FIELDNO (t
);
4166 attach_fn_fields_to_type (struct field_info
*fip
, register struct type
*type
)
4170 for (n
= TYPE_NFN_FIELDS (type
);
4171 fip
->fnlist
!= NULL
;
4172 fip
->fnlist
= fip
->fnlist
->next
)
4174 --n
; /* Circumvent Sun3 compiler bug */
4175 TYPE_FN_FIELDLISTS (type
)[n
] = fip
->fnlist
->fn_fieldlist
;
4180 /* read cfront class static data.
4181 pp points to string starting with the list of static data
4182 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
4185 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
4190 read_cfront_static_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
4191 struct objfile
*objfile
)
4193 struct nextfield
*new;
4196 struct symbol
*ref_static
= 0;
4198 if (**pp
== ';') /* no static data; return */
4204 /* Process each field in the list until we find the terminating ";" */
4206 /* eg: p = "as__1A ;;;" */
4207 STABS_CONTINUE (pp
, objfile
); /* handle \\ */
4208 while (**pp
!= ';' && (sname
= get_substring (pp
, ' '), sname
))
4210 ref_static
= lookup_symbol (sname
, 0, VAR_NAMESPACE
, 0, 0); /*demangled_name */
4213 static struct deprecated_complaint msg
=
4215 Unable to find symbol for static data field %s\n",
4217 complain (&msg
, sname
);
4220 stype
= SYMBOL_TYPE (ref_static
);
4222 /* allocate a new fip */
4223 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
4224 make_cleanup (xfree
, new);
4225 memset (new, 0, sizeof (struct nextfield
));
4226 new->next
= fip
->list
;
4229 /* set visibility */
4230 /* FIXME! no way to tell visibility from stabs??? */
4231 new->visibility
= VISIBILITY_PUBLIC
;
4233 /* set field info into fip */
4234 fip
->list
->field
.type
= stype
;
4236 /* set bitpos & bitsize */
4237 SET_FIELD_PHYSNAME (fip
->list
->field
, savestring (sname
, strlen (sname
)));
4239 /* set name field */
4240 /* The following is code to work around cfront generated stabs.
4241 The stabs contains full mangled name for each field.
4242 We try to demangle the name and extract the field name out of it.
4247 dem
= cplus_demangle (sname
, DMGL_ANSI
| DMGL_PARAMS
);
4250 dem_p
= strrchr (dem
, ':');
4251 if (dem_p
!= 0 && *(dem_p
- 1) == ':')
4253 fip
->list
->field
.name
=
4254 obsavestring (dem_p
, strlen (dem_p
), &objfile
->type_obstack
);
4258 fip
->list
->field
.name
=
4259 obsavestring (sname
, strlen (sname
), &objfile
->type_obstack
);
4261 } /* end of code for cfront work around */
4262 } /* loop again for next static field */
4266 /* Copy structure fields to fip so attach_fields_to_type will work.
4267 type has already been created with the initial instance data fields.
4268 Now we want to be able to add the other members to the class,
4269 so we want to add them back to the fip and reattach them again
4270 once we have collected all the class members. */
4273 copy_cfront_struct_fields (struct field_info
*fip
, struct type
*type
,
4274 struct objfile
*objfile
)
4276 int nfields
= TYPE_NFIELDS (type
);
4278 struct nextfield
*new;
4280 /* Copy the fields into the list of fips and reset the types
4281 to remove the old fields */
4283 for (i
= 0; i
< nfields
; i
++)
4285 /* allocate a new fip */
4286 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
4287 make_cleanup (xfree
, new);
4288 memset (new, 0, sizeof (struct nextfield
));
4289 new->next
= fip
->list
;
4292 /* copy field info into fip */
4293 new->field
= TYPE_FIELD (type
, i
);
4294 /* set visibility */
4295 if (TYPE_FIELD_PROTECTED (type
, i
))
4296 new->visibility
= VISIBILITY_PROTECTED
;
4297 else if (TYPE_FIELD_PRIVATE (type
, i
))
4298 new->visibility
= VISIBILITY_PRIVATE
;
4300 new->visibility
= VISIBILITY_PUBLIC
;
4302 /* Now delete the fields from the type since we will be
4303 allocing new space once we get the rest of the fields
4304 in attach_fields_to_type.
4305 The pointer TYPE_FIELDS(type) is left dangling but should
4306 be freed later by objstack_free */
4307 TYPE_FIELDS (type
) = 0;
4308 TYPE_NFIELDS (type
) = 0;
4313 /* Create the vector of fields, and record how big it is.
4314 We need this info to record proper virtual function table information
4315 for this class's virtual functions. */
4318 attach_fields_to_type (struct field_info
*fip
, register struct type
*type
,
4319 struct objfile
*objfile
)
4321 register int nfields
= 0;
4322 register int non_public_fields
= 0;
4323 register struct nextfield
*scan
;
4325 /* Count up the number of fields that we have, as well as taking note of
4326 whether or not there are any non-public fields, which requires us to
4327 allocate and build the private_field_bits and protected_field_bits
4330 for (scan
= fip
->list
; scan
!= NULL
; scan
= scan
->next
)
4333 if (scan
->visibility
!= VISIBILITY_PUBLIC
)
4335 non_public_fields
++;
4339 /* Now we know how many fields there are, and whether or not there are any
4340 non-public fields. Record the field count, allocate space for the
4341 array of fields, and create blank visibility bitfields if necessary. */
4343 TYPE_NFIELDS (type
) = nfields
;
4344 TYPE_FIELDS (type
) = (struct field
*)
4345 TYPE_ALLOC (type
, sizeof (struct field
) * nfields
);
4346 memset (TYPE_FIELDS (type
), 0, sizeof (struct field
) * nfields
);
4348 if (non_public_fields
)
4350 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
4352 TYPE_FIELD_PRIVATE_BITS (type
) =
4353 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4354 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type
), nfields
);
4356 TYPE_FIELD_PROTECTED_BITS (type
) =
4357 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4358 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type
), nfields
);
4360 TYPE_FIELD_IGNORE_BITS (type
) =
4361 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4362 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type
), nfields
);
4365 /* Copy the saved-up fields into the field vector. Start from the head
4366 of the list, adding to the tail of the field array, so that they end
4367 up in the same order in the array in which they were added to the list. */
4369 while (nfields
-- > 0)
4371 TYPE_FIELD (type
, nfields
) = fip
->list
->field
;
4372 switch (fip
->list
->visibility
)
4374 case VISIBILITY_PRIVATE
:
4375 SET_TYPE_FIELD_PRIVATE (type
, nfields
);
4378 case VISIBILITY_PROTECTED
:
4379 SET_TYPE_FIELD_PROTECTED (type
, nfields
);
4382 case VISIBILITY_IGNORE
:
4383 SET_TYPE_FIELD_IGNORE (type
, nfields
);
4386 case VISIBILITY_PUBLIC
:
4390 /* Unknown visibility. Complain and treat it as public. */
4392 static struct deprecated_complaint msg
=
4394 "Unknown visibility `%c' for field", 0, 0};
4395 complain (&msg
, fip
->list
->visibility
);
4399 fip
->list
= fip
->list
->next
;
4405 static struct deprecated_complaint multiply_defined_struct
=
4406 {"struct/union type gets multiply defined: %s%s", 0, 0};
4409 /* Complain that the compiler has emitted more than one definition for the
4410 structure type TYPE. */
4412 complain_about_struct_wipeout (struct type
*type
)
4417 if (TYPE_TAG_NAME (type
))
4419 name
= TYPE_TAG_NAME (type
);
4420 switch (TYPE_CODE (type
))
4422 case TYPE_CODE_STRUCT
: kind
= "struct "; break;
4423 case TYPE_CODE_UNION
: kind
= "union "; break;
4424 case TYPE_CODE_ENUM
: kind
= "enum "; break;
4428 else if (TYPE_NAME (type
))
4430 name
= TYPE_NAME (type
);
4439 complain (&multiply_defined_struct
, kind
, name
);
4443 /* Read the description of a structure (or union type) and return an object
4444 describing the type.
4446 PP points to a character pointer that points to the next unconsumed token
4447 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
4448 *PP will point to "4a:1,0,32;;".
4450 TYPE points to an incomplete type that needs to be filled in.
4452 OBJFILE points to the current objfile from which the stabs information is
4453 being read. (Note that it is redundant in that TYPE also contains a pointer
4454 to this same objfile, so it might be a good idea to eliminate it. FIXME).
4457 static struct type
*
4458 read_struct_type (char **pp
, struct type
*type
, enum type_code type_code
,
4459 struct objfile
*objfile
)
4461 struct cleanup
*back_to
;
4462 struct field_info fi
;
4467 /* When describing struct/union/class types in stabs, G++ always drops
4468 all qualifications from the name. So if you've got:
4469 struct A { ... struct B { ... }; ... };
4470 then G++ will emit stabs for `struct A::B' that call it simply
4471 `struct B'. Obviously, if you've got a real top-level definition for
4472 `struct B', or other nested definitions, this is going to cause
4475 Obviously, GDB can't fix this by itself, but it can at least avoid
4476 scribbling on existing structure type objects when new definitions
4478 if (! (TYPE_CODE (type
) == TYPE_CODE_UNDEF
4479 || TYPE_STUB (type
)))
4481 complain_about_struct_wipeout (type
);
4483 /* It's probably best to return the type unchanged. */
4487 back_to
= make_cleanup (null_cleanup
, 0);
4489 INIT_CPLUS_SPECIFIC (type
);
4490 TYPE_CODE (type
) = type_code
;
4491 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
4493 /* First comes the total size in bytes. */
4497 TYPE_LENGTH (type
) = read_huge_number (pp
, 0, &nbits
);
4499 return error_type (pp
, objfile
);
4502 /* Now read the baseclasses, if any, read the regular C struct or C++
4503 class member fields, attach the fields to the type, read the C++
4504 member functions, attach them to the type, and then read any tilde
4505 field (baseclass specifier for the class holding the main vtable). */
4507 if (!read_baseclasses (&fi
, pp
, type
, objfile
)
4508 || !read_struct_fields (&fi
, pp
, type
, objfile
)
4509 || !attach_fields_to_type (&fi
, type
, objfile
)
4510 || !read_member_functions (&fi
, pp
, type
, objfile
)
4511 || !attach_fn_fields_to_type (&fi
, type
)
4512 || !read_tilde_fields (&fi
, pp
, type
, objfile
))
4514 type
= error_type (pp
, objfile
);
4517 do_cleanups (back_to
);
4521 /* Read a definition of an array type,
4522 and create and return a suitable type object.
4523 Also creates a range type which represents the bounds of that
4526 static struct type
*
4527 read_array_type (register char **pp
, register struct type
*type
,
4528 struct objfile
*objfile
)
4530 struct type
*index_type
, *element_type
, *range_type
;
4535 /* Format of an array type:
4536 "ar<index type>;lower;upper;<array_contents_type>".
4537 OS9000: "arlower,upper;<array_contents_type>".
4539 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
4540 for these, produce a type like float[][]. */
4542 #if 0 /* OBSOLETE OS9K */
4543 // OBSOLETE if (os9k_stabs)
4544 // OBSOLETE index_type = builtin_type_int;
4546 #endif /* OBSOLETE OS9K */
4548 index_type
= read_type (pp
, objfile
);
4550 /* Improper format of array type decl. */
4551 return error_type (pp
, objfile
);
4555 if (!(**pp
>= '0' && **pp
<= '9') && **pp
!= '-')
4560 #if 0 /* OBSOLETE OS9K */
4561 // OBSOLETE lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits);
4562 #else /* OBSOLETE OS9K */
4563 lower
= read_huge_number (pp
, ';', &nbits
);
4564 #endif /* OBSOLETE OS9K */
4567 return error_type (pp
, objfile
);
4569 if (!(**pp
>= '0' && **pp
<= '9') && **pp
!= '-')
4574 upper
= read_huge_number (pp
, ';', &nbits
);
4576 return error_type (pp
, objfile
);
4578 element_type
= read_type (pp
, objfile
);
4587 create_range_type ((struct type
*) NULL
, index_type
, lower
, upper
);
4588 type
= create_array_type (type
, element_type
, range_type
);
4594 /* Read a definition of an enumeration type,
4595 and create and return a suitable type object.
4596 Also defines the symbols that represent the values of the type. */
4598 static struct type
*
4599 read_enum_type (register char **pp
, register struct type
*type
,
4600 struct objfile
*objfile
)
4605 register struct symbol
*sym
;
4607 struct pending
**symlist
;
4608 struct pending
*osyms
, *syms
;
4611 int unsigned_enum
= 1;
4614 /* FIXME! The stabs produced by Sun CC merrily define things that ought
4615 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
4616 to do? For now, force all enum values to file scope. */
4617 if (within_function
)
4618 symlist
= &local_symbols
;
4621 symlist
= &file_symbols
;
4623 o_nsyms
= osyms
? osyms
->nsyms
: 0;
4625 #if 0 /* OBSOLETE OS9K */
4626 // OBSOLETE if (os9k_stabs)
4628 // OBSOLETE /* Size. Perhaps this does not have to be conditionalized on
4629 // OBSOLETE os9k_stabs (assuming the name of an enum constant can't start
4630 // OBSOLETE with a digit). */
4631 // OBSOLETE read_huge_number (pp, 0, &nbits);
4632 // OBSOLETE if (nbits != 0)
4633 // OBSOLETE return error_type (pp, objfile);
4635 #endif /* OBSOLETE OS9K */
4637 /* The aix4 compiler emits an extra field before the enum members;
4638 my guess is it's a type of some sort. Just ignore it. */
4641 /* Skip over the type. */
4645 /* Skip over the colon. */
4649 /* Read the value-names and their values.
4650 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
4651 A semicolon or comma instead of a NAME means the end. */
4652 while (**pp
&& **pp
!= ';' && **pp
!= ',')
4654 STABS_CONTINUE (pp
, objfile
);
4658 name
= obsavestring (*pp
, p
- *pp
, &objfile
->symbol_obstack
);
4660 n
= read_huge_number (pp
, ',', &nbits
);
4662 return error_type (pp
, objfile
);
4664 sym
= (struct symbol
*)
4665 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
4666 memset (sym
, 0, sizeof (struct symbol
));
4667 SYMBOL_NAME (sym
) = name
;
4668 SYMBOL_LANGUAGE (sym
) = current_subfile
->language
;
4669 SYMBOL_CLASS (sym
) = LOC_CONST
;
4670 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
4671 SYMBOL_VALUE (sym
) = n
;
4674 add_symbol_to_list (sym
, symlist
);
4679 (*pp
)++; /* Skip the semicolon. */
4681 /* Now fill in the fields of the type-structure. */
4683 TYPE_LENGTH (type
) = TARGET_INT_BIT
/ HOST_CHAR_BIT
;
4684 TYPE_CODE (type
) = TYPE_CODE_ENUM
;
4685 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
4687 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
4688 TYPE_NFIELDS (type
) = nsyms
;
4689 TYPE_FIELDS (type
) = (struct field
*)
4690 TYPE_ALLOC (type
, sizeof (struct field
) * nsyms
);
4691 memset (TYPE_FIELDS (type
), 0, sizeof (struct field
) * nsyms
);
4693 /* Find the symbols for the values and put them into the type.
4694 The symbols can be found in the symlist that we put them on
4695 to cause them to be defined. osyms contains the old value
4696 of that symlist; everything up to there was defined by us. */
4697 /* Note that we preserve the order of the enum constants, so
4698 that in something like "enum {FOO, LAST_THING=FOO}" we print
4699 FOO, not LAST_THING. */
4701 for (syms
= *symlist
, n
= nsyms
- 1; syms
; syms
= syms
->next
)
4703 int last
= syms
== osyms
? o_nsyms
: 0;
4704 int j
= syms
->nsyms
;
4705 for (; --j
>= last
; --n
)
4707 struct symbol
*xsym
= syms
->symbol
[j
];
4708 SYMBOL_TYPE (xsym
) = type
;
4709 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
4710 TYPE_FIELD_BITPOS (type
, n
) = SYMBOL_VALUE (xsym
);
4711 TYPE_FIELD_BITSIZE (type
, n
) = 0;
4720 /* Sun's ACC uses a somewhat saner method for specifying the builtin
4721 typedefs in every file (for int, long, etc):
4723 type = b <signed> <width> <format type>; <offset>; <nbits>
4725 optional format type = c or b for char or boolean.
4726 offset = offset from high order bit to start bit of type.
4727 width is # bytes in object of this type, nbits is # bits in type.
4729 The width/offset stuff appears to be for small objects stored in
4730 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
4733 static struct type
*
4734 read_sun_builtin_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4739 enum type_code code
= TYPE_CODE_INT
;
4750 return error_type (pp
, objfile
);
4754 /* For some odd reason, all forms of char put a c here. This is strange
4755 because no other type has this honor. We can safely ignore this because
4756 we actually determine 'char'acterness by the number of bits specified in
4758 Boolean forms, e.g Fortran logical*X, put a b here. */
4762 else if (**pp
== 'b')
4764 code
= TYPE_CODE_BOOL
;
4768 /* The first number appears to be the number of bytes occupied
4769 by this type, except that unsigned short is 4 instead of 2.
4770 Since this information is redundant with the third number,
4771 we will ignore it. */
4772 read_huge_number (pp
, ';', &nbits
);
4774 return error_type (pp
, objfile
);
4776 /* The second number is always 0, so ignore it too. */
4777 read_huge_number (pp
, ';', &nbits
);
4779 return error_type (pp
, objfile
);
4781 /* The third number is the number of bits for this type. */
4782 type_bits
= read_huge_number (pp
, 0, &nbits
);
4784 return error_type (pp
, objfile
);
4785 /* The type *should* end with a semicolon. If it are embedded
4786 in a larger type the semicolon may be the only way to know where
4787 the type ends. If this type is at the end of the stabstring we
4788 can deal with the omitted semicolon (but we don't have to like
4789 it). Don't bother to complain(), Sun's compiler omits the semicolon
4795 return init_type (TYPE_CODE_VOID
, 1,
4796 signed_type
? 0 : TYPE_FLAG_UNSIGNED
, (char *) NULL
,
4799 return init_type (code
,
4800 type_bits
/ TARGET_CHAR_BIT
,
4801 signed_type
? 0 : TYPE_FLAG_UNSIGNED
, (char *) NULL
,
4805 static struct type
*
4806 read_sun_floating_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4811 struct type
*rettype
;
4813 /* The first number has more details about the type, for example
4815 details
= read_huge_number (pp
, ';', &nbits
);
4817 return error_type (pp
, objfile
);
4819 /* The second number is the number of bytes occupied by this type */
4820 nbytes
= read_huge_number (pp
, ';', &nbits
);
4822 return error_type (pp
, objfile
);
4824 if (details
== NF_COMPLEX
|| details
== NF_COMPLEX16
4825 || details
== NF_COMPLEX32
)
4827 rettype
= init_type (TYPE_CODE_COMPLEX
, nbytes
, 0, NULL
, objfile
);
4828 TYPE_TARGET_TYPE (rettype
)
4829 = init_type (TYPE_CODE_FLT
, nbytes
/ 2, 0, NULL
, objfile
);
4833 return init_type (TYPE_CODE_FLT
, nbytes
, 0, NULL
, objfile
);
4836 /* Read a number from the string pointed to by *PP.
4837 The value of *PP is advanced over the number.
4838 If END is nonzero, the character that ends the
4839 number must match END, or an error happens;
4840 and that character is skipped if it does match.
4841 If END is zero, *PP is left pointing to that character.
4843 If the number fits in a long, set *BITS to 0 and return the value.
4844 If not, set *BITS to be the number of bits in the number and return 0.
4846 If encounter garbage, set *BITS to -1 and return 0. */
4849 read_huge_number (char **pp
, int end
, int *bits
)
4866 /* Leading zero means octal. GCC uses this to output values larger
4867 than an int (because that would be hard in decimal). */
4874 #if 0 /* OBSOLETE OS9K */
4875 // OBSOLETE if (os9k_stabs)
4876 // OBSOLETE upper_limit = ULONG_MAX / radix;
4878 #endif /* OBSOLETE OS9K */
4879 upper_limit
= LONG_MAX
/ radix
;
4881 while ((c
= *p
++) >= '0' && c
< ('0' + radix
))
4883 if (n
<= upper_limit
)
4886 n
+= c
- '0'; /* FIXME this overflows anyway */
4891 /* This depends on large values being output in octal, which is
4898 /* Ignore leading zeroes. */
4902 else if (c
== '2' || c
== '3')
4928 /* Large decimal constants are an error (because it is hard to
4929 count how many bits are in them). */
4935 /* -0x7f is the same as 0x80. So deal with it by adding one to
4936 the number of bits. */
4948 /* It's *BITS which has the interesting information. */
4952 static struct type
*
4953 read_range_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4955 char *orig_pp
= *pp
;
4960 struct type
*result_type
;
4961 struct type
*index_type
= NULL
;
4963 /* First comes a type we are a subrange of.
4964 In C it is usually 0, 1 or the type being defined. */
4965 if (read_type_number (pp
, rangenums
) != 0)
4966 return error_type (pp
, objfile
);
4967 self_subrange
= (rangenums
[0] == typenums
[0] &&
4968 rangenums
[1] == typenums
[1]);
4973 index_type
= read_type (pp
, objfile
);
4976 /* A semicolon should now follow; skip it. */
4980 /* The remaining two operands are usually lower and upper bounds
4981 of the range. But in some special cases they mean something else. */
4982 n2
= read_huge_number (pp
, ';', &n2bits
);
4983 n3
= read_huge_number (pp
, ';', &n3bits
);
4985 if (n2bits
== -1 || n3bits
== -1)
4986 return error_type (pp
, objfile
);
4989 goto handle_true_range
;
4991 /* If limits are huge, must be large integral type. */
4992 if (n2bits
!= 0 || n3bits
!= 0)
4994 char got_signed
= 0;
4995 char got_unsigned
= 0;
4996 /* Number of bits in the type. */
4999 /* Range from 0 to <large number> is an unsigned large integral type. */
5000 if ((n2bits
== 0 && n2
== 0) && n3bits
!= 0)
5005 /* Range from <large number> to <large number>-1 is a large signed
5006 integral type. Take care of the case where <large number> doesn't
5007 fit in a long but <large number>-1 does. */
5008 else if ((n2bits
!= 0 && n3bits
!= 0 && n2bits
== n3bits
+ 1)
5009 || (n2bits
!= 0 && n3bits
== 0
5010 && (n2bits
== sizeof (long) * HOST_CHAR_BIT
)
5017 if (got_signed
|| got_unsigned
)
5019 return init_type (TYPE_CODE_INT
, nbits
/ TARGET_CHAR_BIT
,
5020 got_unsigned
? TYPE_FLAG_UNSIGNED
: 0, NULL
,
5024 return error_type (pp
, objfile
);
5027 /* A type defined as a subrange of itself, with bounds both 0, is void. */
5028 if (self_subrange
&& n2
== 0 && n3
== 0)
5029 return init_type (TYPE_CODE_VOID
, 1, 0, NULL
, objfile
);
5031 /* If n3 is zero and n2 is positive, we want a floating type, and n2
5032 is the width in bytes.
5034 Fortran programs appear to use this for complex types also. To
5035 distinguish between floats and complex, g77 (and others?) seem
5036 to use self-subranges for the complexes, and subranges of int for
5039 Also note that for complexes, g77 sets n2 to the size of one of
5040 the member floats, not the whole complex beast. My guess is that
5041 this was to work well with pre-COMPLEX versions of gdb. */
5043 if (n3
== 0 && n2
> 0)
5045 struct type
*float_type
5046 = init_type (TYPE_CODE_FLT
, n2
, 0, NULL
, objfile
);
5050 struct type
*complex_type
=
5051 init_type (TYPE_CODE_COMPLEX
, 2 * n2
, 0, NULL
, objfile
);
5052 TYPE_TARGET_TYPE (complex_type
) = float_type
;
5053 return complex_type
;
5059 /* If the upper bound is -1, it must really be an unsigned int. */
5061 else if (n2
== 0 && n3
== -1)
5063 /* It is unsigned int or unsigned long. */
5064 /* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
5065 compatibility hack. */
5066 return init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
5067 TYPE_FLAG_UNSIGNED
, NULL
, objfile
);
5070 /* Special case: char is defined (Who knows why) as a subrange of
5071 itself with range 0-127. */
5072 else if (self_subrange
&& n2
== 0 && n3
== 127)
5073 return init_type (TYPE_CODE_INT
, 1, 0, NULL
, objfile
);
5076 /* OBSOLETE else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill */
5077 /* OBSOLETE && !self_subrange) */
5078 /* OBSOLETE goto handle_true_range; */
5081 /* We used to do this only for subrange of self or subrange of int. */
5084 /* -1 is used for the upper bound of (4 byte) "unsigned int" and
5085 "unsigned long", and we already checked for that,
5086 so don't need to test for it here. */
5089 /* n3 actually gives the size. */
5090 return init_type (TYPE_CODE_INT
, -n3
, TYPE_FLAG_UNSIGNED
,
5093 /* Is n3 == 2**(8n)-1 for some integer n? Then it's an
5094 unsigned n-byte integer. But do require n to be a power of
5095 two; we don't want 3- and 5-byte integers flying around. */
5101 for (bytes
= 0; (bits
& 0xff) == 0xff; bytes
++)
5104 && ((bytes
- 1) & bytes
) == 0) /* "bytes is a power of two" */
5105 return init_type (TYPE_CODE_INT
, bytes
, TYPE_FLAG_UNSIGNED
, NULL
,
5109 /* I think this is for Convex "long long". Since I don't know whether
5110 Convex sets self_subrange, I also accept that particular size regardless
5111 of self_subrange. */
5112 else if (n3
== 0 && n2
< 0
5114 || n2
== -TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
))
5115 return init_type (TYPE_CODE_INT
, -n2
, 0, NULL
, objfile
);
5116 else if (n2
== -n3
- 1)
5119 return init_type (TYPE_CODE_INT
, 1, 0, NULL
, objfile
);
5121 return init_type (TYPE_CODE_INT
, 2, 0, NULL
, objfile
);
5122 if (n3
== 0x7fffffff)
5123 return init_type (TYPE_CODE_INT
, 4, 0, NULL
, objfile
);
5126 /* We have a real range type on our hands. Allocate space and
5127 return a real pointer. */
5131 index_type
= builtin_type_int
;
5133 index_type
= *dbx_lookup_type (rangenums
);
5134 if (index_type
== NULL
)
5136 /* Does this actually ever happen? Is that why we are worrying
5137 about dealing with it rather than just calling error_type? */
5139 static struct type
*range_type_index
;
5141 complain (&range_type_base_complaint
, rangenums
[1]);
5142 if (range_type_index
== NULL
)
5144 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
5145 0, "range type index type", NULL
);
5146 index_type
= range_type_index
;
5149 result_type
= create_range_type ((struct type
*) NULL
, index_type
, n2
, n3
);
5150 return (result_type
);
5153 /* Read in an argument list. This is a list of types, separated by commas
5154 and terminated with END. Return the list of types read in, or (struct type
5155 **)-1 if there is an error. */
5157 static struct field
*
5158 read_args (char **pp
, int end
, struct objfile
*objfile
, int *nargsp
,
5161 /* FIXME! Remove this arbitrary limit! */
5162 struct type
*types
[1024]; /* allow for fns of 1023 parameters */
5169 /* Invalid argument list: no ','. */
5170 return (struct field
*) -1;
5172 STABS_CONTINUE (pp
, objfile
);
5173 types
[n
++] = read_type (pp
, objfile
);
5175 (*pp
)++; /* get past `end' (the ':' character) */
5177 if (TYPE_CODE (types
[n
- 1]) != TYPE_CODE_VOID
)
5185 rval
= (struct field
*) xmalloc (n
* sizeof (struct field
));
5186 memset (rval
, 0, n
* sizeof (struct field
));
5187 for (i
= 0; i
< n
; i
++)
5188 rval
[i
].type
= types
[i
];
5193 /* Common block handling. */
5195 /* List of symbols declared since the last BCOMM. This list is a tail
5196 of local_symbols. When ECOMM is seen, the symbols on the list
5197 are noted so their proper addresses can be filled in later,
5198 using the common block base address gotten from the assembler
5201 static struct pending
*common_block
;
5202 static int common_block_i
;
5204 /* Name of the current common block. We get it from the BCOMM instead of the
5205 ECOMM to match IBM documentation (even though IBM puts the name both places
5206 like everyone else). */
5207 static char *common_block_name
;
5209 /* Process a N_BCOMM symbol. The storage for NAME is not guaranteed
5210 to remain after this function returns. */
5213 common_block_start (char *name
, struct objfile
*objfile
)
5215 if (common_block_name
!= NULL
)
5217 static struct deprecated_complaint msg
=
5219 "Invalid symbol data: common block within common block",
5223 common_block
= local_symbols
;
5224 common_block_i
= local_symbols
? local_symbols
->nsyms
: 0;
5225 common_block_name
= obsavestring (name
, strlen (name
),
5226 &objfile
->symbol_obstack
);
5229 /* Process a N_ECOMM symbol. */
5232 common_block_end (struct objfile
*objfile
)
5234 /* Symbols declared since the BCOMM are to have the common block
5235 start address added in when we know it. common_block and
5236 common_block_i point to the first symbol after the BCOMM in
5237 the local_symbols list; copy the list and hang it off the
5238 symbol for the common block name for later fixup. */
5241 struct pending
*new = 0;
5242 struct pending
*next
;
5245 if (common_block_name
== NULL
)
5247 static struct deprecated_complaint msg
=
5248 {"ECOMM symbol unmatched by BCOMM", 0, 0};
5253 sym
= (struct symbol
*)
5254 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
5255 memset (sym
, 0, sizeof (struct symbol
));
5256 /* Note: common_block_name already saved on symbol_obstack */
5257 SYMBOL_NAME (sym
) = common_block_name
;
5258 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
5260 /* Now we copy all the symbols which have been defined since the BCOMM. */
5262 /* Copy all the struct pendings before common_block. */
5263 for (next
= local_symbols
;
5264 next
!= NULL
&& next
!= common_block
;
5267 for (j
= 0; j
< next
->nsyms
; j
++)
5268 add_symbol_to_list (next
->symbol
[j
], &new);
5271 /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is
5272 NULL, it means copy all the local symbols (which we already did
5275 if (common_block
!= NULL
)
5276 for (j
= common_block_i
; j
< common_block
->nsyms
; j
++)
5277 add_symbol_to_list (common_block
->symbol
[j
], &new);
5279 SYMBOL_TYPE (sym
) = (struct type
*) new;
5281 /* Should we be putting local_symbols back to what it was?
5284 i
= hashname (SYMBOL_NAME (sym
));
5285 SYMBOL_VALUE_CHAIN (sym
) = global_sym_chain
[i
];
5286 global_sym_chain
[i
] = sym
;
5287 common_block_name
= NULL
;
5290 /* Add a common block's start address to the offset of each symbol
5291 declared to be in it (by being between a BCOMM/ECOMM pair that uses
5292 the common block name). */
5295 fix_common_block (struct symbol
*sym
, int valu
)
5297 struct pending
*next
= (struct pending
*) SYMBOL_TYPE (sym
);
5298 for (; next
; next
= next
->next
)
5301 for (j
= next
->nsyms
- 1; j
>= 0; j
--)
5302 SYMBOL_VALUE_ADDRESS (next
->symbol
[j
]) += valu
;
5308 /* What about types defined as forward references inside of a small lexical
5310 /* Add a type to the list of undefined types to be checked through
5311 once this file has been read in. */
5314 add_undefined_type (struct type
*type
)
5316 if (undef_types_length
== undef_types_allocated
)
5318 undef_types_allocated
*= 2;
5319 undef_types
= (struct type
**)
5320 xrealloc ((char *) undef_types
,
5321 undef_types_allocated
* sizeof (struct type
*));
5323 undef_types
[undef_types_length
++] = type
;
5326 /* Go through each undefined type, see if it's still undefined, and fix it
5327 up if possible. We have two kinds of undefined types:
5329 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
5330 Fix: update array length using the element bounds
5331 and the target type's length.
5332 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
5333 yet defined at the time a pointer to it was made.
5334 Fix: Do a full lookup on the struct/union tag. */
5336 cleanup_undefined_types (void)
5340 for (type
= undef_types
; type
< undef_types
+ undef_types_length
; type
++)
5342 switch (TYPE_CODE (*type
))
5345 case TYPE_CODE_STRUCT
:
5346 case TYPE_CODE_UNION
:
5347 case TYPE_CODE_ENUM
:
5349 /* Check if it has been defined since. Need to do this here
5350 as well as in check_typedef to deal with the (legitimate in
5351 C though not C++) case of several types with the same name
5352 in different source files. */
5353 if (TYPE_STUB (*type
))
5355 struct pending
*ppt
;
5357 /* Name of the type, without "struct" or "union" */
5358 char *typename
= TYPE_TAG_NAME (*type
);
5360 if (typename
== NULL
)
5362 static struct deprecated_complaint msg
=
5363 {"need a type name", 0, 0};
5367 for (ppt
= file_symbols
; ppt
; ppt
= ppt
->next
)
5369 for (i
= 0; i
< ppt
->nsyms
; i
++)
5371 struct symbol
*sym
= ppt
->symbol
[i
];
5373 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
5374 && SYMBOL_NAMESPACE (sym
) == STRUCT_NAMESPACE
5375 && (TYPE_CODE (SYMBOL_TYPE (sym
)) ==
5377 && STREQ (SYMBOL_NAME (sym
), typename
))
5378 replace_type (*type
, SYMBOL_TYPE (sym
));
5387 static struct deprecated_complaint msg
=
5389 GDB internal error. cleanup_undefined_types with bad type %d.", 0, 0};
5390 complain (&msg
, TYPE_CODE (*type
));
5396 undef_types_length
= 0;
5399 /* Scan through all of the global symbols defined in the object file,
5400 assigning values to the debugging symbols that need to be assigned
5401 to. Get these symbols from the minimal symbol table. */
5404 scan_file_globals (struct objfile
*objfile
)
5407 struct minimal_symbol
*msymbol
;
5408 struct symbol
*sym
, *prev
, *rsym
;
5409 struct objfile
*resolve_objfile
;
5411 /* SVR4 based linkers copy referenced global symbols from shared
5412 libraries to the main executable.
5413 If we are scanning the symbols for a shared library, try to resolve
5414 them from the minimal symbols of the main executable first. */
5416 if (symfile_objfile
&& objfile
!= symfile_objfile
)
5417 resolve_objfile
= symfile_objfile
;
5419 resolve_objfile
= objfile
;
5423 /* Avoid expensive loop through all minimal symbols if there are
5424 no unresolved symbols. */
5425 for (hash
= 0; hash
< HASHSIZE
; hash
++)
5427 if (global_sym_chain
[hash
])
5430 if (hash
>= HASHSIZE
)
5433 for (msymbol
= resolve_objfile
->msymbols
;
5434 msymbol
&& SYMBOL_NAME (msymbol
) != NULL
;
5439 /* Skip static symbols. */
5440 switch (MSYMBOL_TYPE (msymbol
))
5452 /* Get the hash index and check all the symbols
5453 under that hash index. */
5455 hash
= hashname (SYMBOL_NAME (msymbol
));
5457 for (sym
= global_sym_chain
[hash
]; sym
;)
5459 if (SYMBOL_NAME (msymbol
)[0] == SYMBOL_NAME (sym
)[0] &&
5460 STREQ (SYMBOL_NAME (msymbol
) + 1, SYMBOL_NAME (sym
) + 1))
5463 struct alias_list
*aliases
;
5465 /* Splice this symbol out of the hash chain and
5466 assign the value we have to it. */
5469 SYMBOL_VALUE_CHAIN (prev
) = SYMBOL_VALUE_CHAIN (sym
);
5473 global_sym_chain
[hash
] = SYMBOL_VALUE_CHAIN (sym
);
5476 /* Check to see whether we need to fix up a common block. */
5477 /* Note: this code might be executed several times for
5478 the same symbol if there are multiple references. */
5480 /* If symbol has aliases, do minimal symbol fixups for each.
5481 These live aliases/references weren't added to
5482 global_sym_chain hash but may also need to be fixed up. */
5483 /* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal
5484 symbols? Still, we wouldn't want to add_to_list. */
5485 /* Now do the same for each alias of this symbol */
5487 aliases
= SYMBOL_ALIASES (sym
);
5490 if (SYMBOL_CLASS (rsym
) == LOC_BLOCK
)
5492 fix_common_block (rsym
,
5493 SYMBOL_VALUE_ADDRESS (msymbol
));
5497 SYMBOL_VALUE_ADDRESS (rsym
)
5498 = SYMBOL_VALUE_ADDRESS (msymbol
);
5500 SYMBOL_SECTION (rsym
) = SYMBOL_SECTION (msymbol
);
5503 rsym
= aliases
->sym
;
5504 aliases
= aliases
->next
;
5513 sym
= SYMBOL_VALUE_CHAIN (prev
);
5517 sym
= global_sym_chain
[hash
];
5523 sym
= SYMBOL_VALUE_CHAIN (sym
);
5527 if (resolve_objfile
== objfile
)
5529 resolve_objfile
= objfile
;
5532 /* Change the storage class of any remaining unresolved globals to
5533 LOC_UNRESOLVED and remove them from the chain. */
5534 for (hash
= 0; hash
< HASHSIZE
; hash
++)
5536 sym
= global_sym_chain
[hash
];
5540 sym
= SYMBOL_VALUE_CHAIN (sym
);
5542 /* Change the symbol address from the misleading chain value
5544 SYMBOL_VALUE_ADDRESS (prev
) = 0;
5546 /* Complain about unresolved common block symbols. */
5547 if (SYMBOL_CLASS (prev
) == LOC_STATIC
)
5548 SYMBOL_CLASS (prev
) = LOC_UNRESOLVED
;
5550 complain (&unresolved_sym_chain_complaint
,
5551 objfile
->name
, SYMBOL_NAME (prev
));
5554 memset (global_sym_chain
, 0, sizeof (global_sym_chain
));
5557 /* Initialize anything that needs initializing when starting to read
5558 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
5562 stabsread_init (void)
5566 /* Initialize anything that needs initializing when a completely new
5567 symbol file is specified (not just adding some symbols from another
5568 file, e.g. a shared library). */
5571 stabsread_new_init (void)
5573 /* Empty the hash table of global syms looking for values. */
5574 memset (global_sym_chain
, 0, sizeof (global_sym_chain
));
5577 /* Initialize anything that needs initializing at the same time as
5578 start_symtab() is called. */
5583 global_stabs
= NULL
; /* AIX COFF */
5584 /* Leave FILENUM of 0 free for builtin types and this file's types. */
5585 n_this_object_header_files
= 1;
5586 type_vector_length
= 0;
5587 type_vector
= (struct type
**) 0;
5589 /* FIXME: If common_block_name is not already NULL, we should complain(). */
5590 common_block_name
= NULL
;
5592 #if 0 /* OBSOLETE OS9K */
5593 // OBSOLETE os9k_stabs = 0;
5594 #endif /* OBSOLETE OS9K */
5597 /* Call after end_symtab() */
5604 xfree (type_vector
);
5607 type_vector_length
= 0;
5608 previous_stab_code
= 0;
5612 finish_global_stabs (struct objfile
*objfile
)
5616 patch_block_stabs (global_symbols
, global_stabs
, objfile
);
5617 xfree (global_stabs
);
5618 global_stabs
= NULL
;
5622 /* Find the end of the name, delimited by a ':', but don't match
5623 ObjC symbols which look like -[Foo bar::]:bla. */
5625 find_name_end (char *name
)
5628 if (s
[0] == '-' || *s
== '+')
5630 /* Must be an ObjC method symbol. */
5633 error ("invalid symbol name \"%s\"", name
);
5635 s
= strchr (s
, ']');
5638 error ("invalid symbol name \"%s\"", name
);
5640 return strchr (s
, ':');
5644 return strchr (s
, ':');
5648 /* Initializer for this module */
5651 _initialize_stabsread (void)
5653 undef_types_allocated
= 20;
5654 undef_types_length
= 0;
5655 undef_types
= (struct type
**)
5656 xmalloc (undef_types_allocated
* sizeof (struct type
*));