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 /* end new functions added for cfront support */
175 add_live_range (struct objfile
*, struct symbol
*, CORE_ADDR
, CORE_ADDR
);
177 static int resolve_live_range (struct objfile
*, struct symbol
*, char *);
179 static int process_reference (char **string
);
181 static CORE_ADDR
ref_search_value (int refnum
);
184 resolve_symbol_reference (struct objfile
*, struct symbol
*, char *);
186 void stabsread_clear_cache (void);
188 static const char vptr_name
[] = "_vptr$";
189 static const char vb_name
[] = "_vb$";
191 /* Define this as 1 if a pcc declaration of a char or short argument
192 gives the correct address. Otherwise assume pcc gives the
193 address of the corresponding int, which is not the same on a
194 big-endian machine. */
196 #if !defined (BELIEVE_PCC_PROMOTION)
197 #define BELIEVE_PCC_PROMOTION 0
199 #if !defined (BELIEVE_PCC_PROMOTION_TYPE)
200 #define BELIEVE_PCC_PROMOTION_TYPE 0
203 static struct complaint invalid_cpp_abbrev_complaint
=
204 {"invalid C++ abbreviation `%s'", 0, 0};
206 static struct complaint invalid_cpp_type_complaint
=
207 {"C++ abbreviated type name unknown at symtab pos %d", 0, 0};
209 static struct complaint member_fn_complaint
=
210 {"member function type missing, got '%c'", 0, 0};
212 static struct complaint const_vol_complaint
=
213 {"const/volatile indicator missing, got '%c'", 0, 0};
215 static struct complaint error_type_complaint
=
216 {"couldn't parse type; debugger out of date?", 0, 0};
218 static struct complaint invalid_member_complaint
=
219 {"invalid (minimal) member type data format at symtab pos %d.", 0, 0};
221 static struct complaint range_type_base_complaint
=
222 {"base type %d of range type is not defined", 0, 0};
224 static struct complaint reg_value_complaint
=
225 {"register number %d too large (max %d) in symbol %s", 0, 0};
227 static struct complaint vtbl_notfound_complaint
=
228 {"virtual function table pointer not found when defining class `%s'", 0, 0};
230 static struct complaint unrecognized_cplus_name_complaint
=
231 {"Unknown C++ symbol name `%s'", 0, 0};
233 static struct complaint rs6000_builtin_complaint
=
234 {"Unknown builtin type %d", 0, 0};
236 static struct complaint unresolved_sym_chain_complaint
=
237 {"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
239 static struct complaint stabs_general_complaint
=
242 static struct complaint lrs_general_complaint
=
245 /* Make a list of forward references which haven't been defined. */
247 static struct type
**undef_types
;
248 static int undef_types_allocated
;
249 static int undef_types_length
;
250 static struct symbol
*current_symbol
= NULL
;
252 /* Check for and handle cretinous stabs symbol name continuation! */
253 #define STABS_CONTINUE(pp,objfile) \
255 if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
256 *(pp) = next_symbol_text (objfile); \
259 #if 0 /* OBSOLETE OS9K */
260 // OBSOLETE /* FIXME: These probably should be our own types (like rs6000_builtin_type
261 // OBSOLETE has its own types) rather than builtin_type_*. */
262 // OBSOLETE static struct type **os9k_type_vector[] =
265 // OBSOLETE &builtin_type_int,
266 // OBSOLETE &builtin_type_char,
267 // OBSOLETE &builtin_type_long,
268 // OBSOLETE &builtin_type_short,
269 // OBSOLETE &builtin_type_unsigned_char,
270 // OBSOLETE &builtin_type_unsigned_short,
271 // OBSOLETE &builtin_type_unsigned_long,
272 // OBSOLETE &builtin_type_unsigned_int,
273 // OBSOLETE &builtin_type_float,
274 // OBSOLETE &builtin_type_double,
275 // OBSOLETE &builtin_type_void,
276 // OBSOLETE &builtin_type_long_double
279 // OBSOLETE static void os9k_init_type_vector (struct type **);
281 // OBSOLETE static void
282 // OBSOLETE os9k_init_type_vector (struct type **tv)
284 // OBSOLETE unsigned int i;
285 // OBSOLETE for (i = 0; i < sizeof (os9k_type_vector) / sizeof (struct type **); i++)
286 // OBSOLETE tv[i] = (os9k_type_vector[i] == 0 ? 0 : *(os9k_type_vector[i]));
288 #endif /* OBSOLETE OS9K */
290 /* Look up a dbx type-number pair. Return the address of the slot
291 where the type for that number-pair is stored.
292 The number-pair is in TYPENUMS.
294 This can be used for finding the type associated with that pair
295 or for associating a new type with the pair. */
298 dbx_lookup_type (int typenums
[2])
300 register int filenum
= typenums
[0];
301 register int index
= typenums
[1];
303 register int real_filenum
;
304 register struct header_file
*f
;
307 if (filenum
== -1) /* -1,-1 is for temporary types. */
310 if (filenum
< 0 || filenum
>= n_this_object_header_files
)
312 static struct complaint msg
=
314 Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
316 complain (&msg
, filenum
, index
, symnum
);
324 /* Caller wants address of address of type. We think
325 that negative (rs6k builtin) types will never appear as
326 "lvalues", (nor should they), so we stuff the real type
327 pointer into a temp, and return its address. If referenced,
328 this will do the right thing. */
329 static struct type
*temp_type
;
331 temp_type
= rs6000_builtin_type (index
);
335 /* Type is defined outside of header files.
336 Find it in this object file's type vector. */
337 if (index
>= type_vector_length
)
339 old_len
= type_vector_length
;
342 type_vector_length
= INITIAL_TYPE_VECTOR_LENGTH
;
343 type_vector
= (struct type
**)
344 xmalloc (type_vector_length
* sizeof (struct type
*));
346 while (index
>= type_vector_length
)
348 type_vector_length
*= 2;
350 type_vector
= (struct type
**)
351 xrealloc ((char *) type_vector
,
352 (type_vector_length
* sizeof (struct type
*)));
353 memset (&type_vector
[old_len
], 0,
354 (type_vector_length
- old_len
) * sizeof (struct type
*));
356 #if 0 /* OBSOLETE OS9K */
357 // OBSOLETE if (os9k_stabs)
358 // OBSOLETE /* Deal with OS9000 fundamental types. */
359 // OBSOLETE os9k_init_type_vector (type_vector);
360 #endif /* OBSOLETE OS9K */
362 return (&type_vector
[index
]);
366 real_filenum
= this_object_header_files
[filenum
];
368 if (real_filenum
>= N_HEADER_FILES (current_objfile
))
370 struct type
*temp_type
;
371 struct type
**temp_type_p
;
373 warning ("GDB internal error: bad real_filenum");
376 temp_type
= init_type (TYPE_CODE_ERROR
, 0, 0, NULL
, NULL
);
377 temp_type_p
= (struct type
**) xmalloc (sizeof (struct type
*));
378 *temp_type_p
= temp_type
;
382 f
= HEADER_FILES (current_objfile
) + real_filenum
;
384 f_orig_length
= f
->length
;
385 if (index
>= f_orig_length
)
387 while (index
>= f
->length
)
391 f
->vector
= (struct type
**)
392 xrealloc ((char *) f
->vector
, f
->length
* sizeof (struct type
*));
393 memset (&f
->vector
[f_orig_length
], 0,
394 (f
->length
- f_orig_length
) * sizeof (struct type
*));
396 return (&f
->vector
[index
]);
400 /* Make sure there is a type allocated for type numbers TYPENUMS
401 and return the type object.
402 This can create an empty (zeroed) type object.
403 TYPENUMS may be (-1, -1) to return a new type object that is not
404 put into the type vector, and so may not be referred to by number. */
407 dbx_alloc_type (int typenums
[2], struct objfile
*objfile
)
409 register struct type
**type_addr
;
411 if (typenums
[0] == -1)
413 return (alloc_type (objfile
));
416 type_addr
= dbx_lookup_type (typenums
);
418 /* If we are referring to a type not known at all yet,
419 allocate an empty type for it.
420 We will fill it in later if we find out how. */
423 *type_addr
= alloc_type (objfile
);
429 /* for all the stabs in a given stab vector, build appropriate types
430 and fix their symbols in given symbol vector. */
433 patch_block_stabs (struct pending
*symbols
, struct pending_stabs
*stabs
,
434 struct objfile
*objfile
)
444 /* for all the stab entries, find their corresponding symbols and
445 patch their types! */
447 for (ii
= 0; ii
< stabs
->count
; ++ii
)
449 name
= stabs
->stab
[ii
];
450 pp
= (char *) strchr (name
, ':');
454 pp
= (char *) strchr (pp
, ':');
456 sym
= find_symbol_in_list (symbols
, name
, pp
- name
);
459 /* FIXME-maybe: it would be nice if we noticed whether
460 the variable was defined *anywhere*, not just whether
461 it is defined in this compilation unit. But neither
462 xlc or GCC seem to need such a definition, and until
463 we do psymtabs (so that the minimal symbols from all
464 compilation units are available now), I'm not sure
465 how to get the information. */
467 /* On xcoff, if a global is defined and never referenced,
468 ld will remove it from the executable. There is then
469 a N_GSYM stab for it, but no regular (C_EXT) symbol. */
470 sym
= (struct symbol
*)
471 obstack_alloc (&objfile
->symbol_obstack
,
472 sizeof (struct symbol
));
474 memset (sym
, 0, sizeof (struct symbol
));
475 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
476 SYMBOL_CLASS (sym
) = LOC_OPTIMIZED_OUT
;
478 obsavestring (name
, pp
- name
, &objfile
->symbol_obstack
);
480 if (*(pp
- 1) == 'F' || *(pp
- 1) == 'f')
482 /* I don't think the linker does this with functions,
483 so as far as I know this is never executed.
484 But it doesn't hurt to check. */
486 lookup_function_type (read_type (&pp
, objfile
));
490 SYMBOL_TYPE (sym
) = read_type (&pp
, objfile
);
492 add_symbol_to_list (sym
, &global_symbols
);
497 if (*(pp
- 1) == 'F' || *(pp
- 1) == 'f')
500 lookup_function_type (read_type (&pp
, objfile
));
504 SYMBOL_TYPE (sym
) = read_type (&pp
, objfile
);
512 /* Read a number by which a type is referred to in dbx data,
513 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
514 Just a single number N is equivalent to (0,N).
515 Return the two numbers by storing them in the vector TYPENUMS.
516 TYPENUMS will then be used as an argument to dbx_lookup_type.
518 Returns 0 for success, -1 for error. */
521 read_type_number (register char **pp
, register int *typenums
)
527 typenums
[0] = read_huge_number (pp
, ',', &nbits
);
530 typenums
[1] = read_huge_number (pp
, ')', &nbits
);
537 typenums
[1] = read_huge_number (pp
, 0, &nbits
);
545 #define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
546 #define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
547 #define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
548 #define VISIBILITY_IGNORE '9' /* Optimized out or zero length */
550 #define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */
551 #define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */
553 /* This code added to support parsing of ARM/Cfront stabs strings */
555 /* Get substring from string up to char c, advance string pointer past
559 get_substring (char **p
, int c
)
574 /* Physname gets strcat'd onto sname in order to recreate the mangled
575 name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
576 the physname look like that of g++ - take out the initial mangling
577 eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
580 get_cfront_method_physname (char *fname
)
583 /* FIXME would like to make this generic for g++ too, but
584 that is already handled in read_member_funcctions */
587 /* search ahead to find the start of the mangled suffix */
588 if (*p
== '_' && *(p
+ 1) == '_') /* compiler generated; probably a ctor/dtor */
590 while (p
&& (unsigned) ((p
+ 1) - fname
) < strlen (fname
) && *(p
+ 1) != '_')
592 if (!(p
&& *p
== '_' && *(p
+ 1) == '_'))
593 error ("Invalid mangled function name %s", fname
);
594 p
+= 2; /* advance past '__' */
596 /* struct name length and name of type should come next; advance past it */
599 len
= len
* 10 + (*p
- '0');
607 /* Read base classes within cfront class definition.
608 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
611 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
616 read_cfront_baseclasses (struct field_info
*fip
, char **pp
, struct type
*type
,
617 struct objfile
*objfile
)
619 static struct complaint msg_unknown
=
621 Unsupported token in stabs string %s.\n",
623 static struct complaint msg_notfound
=
625 Unable to find base type for %s.\n",
630 struct nextfield
*new;
632 if (**pp
== ';') /* no base classes; return */
638 /* first count base classes so we can allocate space before parsing */
639 for (p
= *pp
; p
&& *p
&& *p
!= ';'; p
++)
644 bnum
++; /* add one more for last one */
646 /* now parse the base classes until we get to the start of the methods
647 (code extracted and munged from read_baseclasses) */
648 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
649 TYPE_N_BASECLASSES (type
) = bnum
;
653 int num_bytes
= B_BYTES (TYPE_N_BASECLASSES (type
));
656 pointer
= (char *) TYPE_ALLOC (type
, num_bytes
);
657 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*) pointer
;
659 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type
), TYPE_N_BASECLASSES (type
));
661 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
663 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
664 make_cleanup (xfree
, new);
665 memset (new, 0, sizeof (struct nextfield
));
666 new->next
= fip
->list
;
668 FIELD_BITSIZE (new->field
) = 0; /* this should be an unpacked field! */
670 STABS_CONTINUE (pp
, objfile
);
672 /* virtual? eg: v2@Bvir */
675 SET_TYPE_FIELD_VIRTUAL (type
, i
);
679 /* access? eg: 2@Bvir */
680 /* Note: protected inheritance not supported in cfront */
683 case CFRONT_VISIBILITY_PRIVATE
:
684 new->visibility
= VISIBILITY_PRIVATE
;
686 case CFRONT_VISIBILITY_PUBLIC
:
687 new->visibility
= VISIBILITY_PUBLIC
;
690 /* Bad visibility format. Complain and treat it as
693 static struct complaint msg
=
695 "Unknown visibility `%c' for baseclass", 0, 0};
696 complain (&msg
, new->visibility
);
697 new->visibility
= VISIBILITY_PUBLIC
;
701 /* "@" comes next - eg: @Bvir */
704 complain (&msg_unknown
, *pp
);
710 /* Set the bit offset of the portion of the object corresponding
711 to this baseclass. Always zero in the absence of
712 multiple inheritance. */
713 /* Unable to read bit position from stabs;
714 Assuming no multiple inheritance for now FIXME! */
715 /* We may have read this in the structure definition;
716 now we should fixup the members to be the actual base classes */
717 FIELD_BITPOS (new->field
) = 0;
719 /* Get the base class name and type */
721 char *bname
; /* base class name */
722 struct symbol
*bsym
; /* base class */
724 p1
= strchr (*pp
, ' ');
725 p2
= strchr (*pp
, ';');
727 bname
= get_substring (pp
, ' ');
729 bname
= get_substring (pp
, ';');
730 if (!bname
|| !*bname
)
732 complain (&msg_unknown
, *pp
);
735 /* FIXME! attach base info to type */
736 bsym
= lookup_symbol (bname
, 0, STRUCT_NAMESPACE
, 0, 0); /*demangled_name */
739 new->field
.type
= SYMBOL_TYPE (bsym
);
740 new->field
.name
= type_name_no_tag (new->field
.type
);
744 complain (&msg_notfound
, *pp
);
749 /* If more base classes to parse, loop again.
750 We ate the last ' ' or ';' in get_substring,
751 so on exit we will have skipped the trailing ';' */
752 /* if invalid, return 0; add code to detect - FIXME! */
757 /* read cfront member functions.
758 pp points to string starting with list of functions
759 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
760 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
761 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
762 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
766 read_cfront_member_functions (struct field_info
*fip
, char **pp
,
767 struct type
*type
, struct objfile
*objfile
)
769 /* This code extracted from read_member_functions
770 so as to do the similar thing for our funcs */
774 /* Total number of member functions defined in this class. If the class
775 defines two `f' functions, and one `g' function, then this will have
777 int total_length
= 0;
781 struct next_fnfield
*next
;
782 struct fn_field fn_field
;
785 struct type
*look_ahead_type
;
786 struct next_fnfieldlist
*new_fnlist
;
787 struct next_fnfield
*new_sublist
;
790 struct symbol
*ref_func
= 0;
792 /* Process each list until we find the end of the member functions.
793 eg: p = "__ct__1AFv foo__1AFv ;;;" */
795 STABS_CONTINUE (pp
, objfile
); /* handle \\ */
797 while (**pp
!= ';' && (fname
= get_substring (pp
, ' '), fname
))
800 int sublist_count
= 0;
802 if (fname
[0] == '*') /* static member */
808 ref_func
= lookup_symbol (fname
, 0, VAR_NAMESPACE
, 0, 0); /* demangled name */
811 static struct complaint msg
=
813 Unable to find function symbol for %s\n",
815 complain (&msg
, fname
);
819 look_ahead_type
= NULL
;
822 new_fnlist
= (struct next_fnfieldlist
*)
823 xmalloc (sizeof (struct next_fnfieldlist
));
824 make_cleanup (xfree
, new_fnlist
);
825 memset (new_fnlist
, 0, sizeof (struct next_fnfieldlist
));
827 /* The following is code to work around cfront generated stabs.
828 The stabs contains full mangled name for each field.
829 We try to demangle the name and extract the field name out of it. */
831 char *dem
, *dem_p
, *dem_args
;
833 dem
= cplus_demangle (fname
, DMGL_ANSI
| DMGL_PARAMS
);
836 dem_p
= strrchr (dem
, ':');
837 if (dem_p
!= 0 && *(dem_p
- 1) == ':')
839 /* get rid of args */
840 dem_args
= strchr (dem_p
, '(');
841 if (dem_args
== NULL
)
842 dem_len
= strlen (dem_p
);
844 dem_len
= dem_args
- dem_p
;
846 obsavestring (dem_p
, dem_len
, &objfile
->type_obstack
);
851 obsavestring (fname
, strlen (fname
), &objfile
->type_obstack
);
853 } /* end of code for cfront work around */
855 new_fnlist
->fn_fieldlist
.name
= main_fn_name
;
857 /*-------------------------------------------------*/
858 /* Set up the sublists
859 Sublists are stuff like args, static, visibility, etc.
860 so in ARM, we have to set that info some other way.
861 Multiple sublists happen if overloading
862 eg: foo::26=##1;:;2A.;
863 In g++, we'd loop here thru all the sublists... */
866 (struct next_fnfield
*) xmalloc (sizeof (struct next_fnfield
));
867 make_cleanup (xfree
, new_sublist
);
868 memset (new_sublist
, 0, sizeof (struct next_fnfield
));
870 /* eat 1; from :;2A.; */
871 new_sublist
->fn_field
.type
= SYMBOL_TYPE (ref_func
); /* normally takes a read_type */
872 /* Make this type look like a method stub for gdb */
873 TYPE_FLAGS (new_sublist
->fn_field
.type
) |= TYPE_FLAG_STUB
;
874 TYPE_CODE (new_sublist
->fn_field
.type
) = TYPE_CODE_METHOD
;
876 /* If this is just a stub, then we don't have the real name here. */
877 if (TYPE_STUB (new_sublist
->fn_field
.type
))
879 if (!TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
))
880 TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
) = type
;
881 new_sublist
->fn_field
.is_stub
= 1;
884 /* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i
885 physname gets strcat'd in order to recreate the onto mangled name */
886 pname
= get_cfront_method_physname (fname
);
887 new_sublist
->fn_field
.physname
= savestring (pname
, strlen (pname
));
890 /* Set this member function's visibility fields.
891 Unable to distinguish access from stabs definition!
892 Assuming public for now. FIXME!
893 (for private, set new_sublist->fn_field.is_private = 1,
894 for public, set new_sublist->fn_field.is_protected = 1) */
896 /* Unable to distinguish const/volatile from stabs definition!
897 Assuming normal for now. FIXME! */
899 new_sublist
->fn_field
.is_const
= 0;
900 new_sublist
->fn_field
.is_volatile
= 0; /* volatile not implemented in cfront */
902 /* Set virtual/static function info
903 How to get vtable offsets ?
904 Assuming normal for now FIXME!!
905 For vtables, figure out from whence this virtual function came.
906 It may belong to virtual function table of
907 one of its baseclasses.
909 new_sublist -> fn_field.voffset = vtable offset,
910 new_sublist -> fn_field.fcontext = look_ahead_type;
911 where look_ahead_type is type of baseclass */
913 new_sublist
->fn_field
.voffset
= VOFFSET_STATIC
;
914 else /* normal member function. */
915 new_sublist
->fn_field
.voffset
= 0;
916 new_sublist
->fn_field
.fcontext
= 0;
919 /* Prepare new sublist */
920 new_sublist
->next
= sublist
;
921 sublist
= new_sublist
;
924 /* In g++, we loop thu sublists - now we set from functions. */
925 new_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
926 obstack_alloc (&objfile
->type_obstack
,
927 sizeof (struct fn_field
) * length
);
928 memset (new_fnlist
->fn_fieldlist
.fn_fields
, 0,
929 sizeof (struct fn_field
) * length
);
930 for (i
= length
; (i
--, sublist
); sublist
= sublist
->next
)
932 new_fnlist
->fn_fieldlist
.fn_fields
[i
] = sublist
->fn_field
;
935 new_fnlist
->fn_fieldlist
.length
= length
;
936 new_fnlist
->next
= fip
->fnlist
;
937 fip
->fnlist
= new_fnlist
;
939 total_length
+= length
;
940 STABS_CONTINUE (pp
, objfile
); /* handle \\ */
945 /* type should already have space */
946 TYPE_FN_FIELDLISTS (type
) = (struct fn_fieldlist
*)
947 TYPE_ALLOC (type
, sizeof (struct fn_fieldlist
) * nfn_fields
);
948 memset (TYPE_FN_FIELDLISTS (type
), 0,
949 sizeof (struct fn_fieldlist
) * nfn_fields
);
950 TYPE_NFN_FIELDS (type
) = nfn_fields
;
951 TYPE_NFN_FIELDS_TOTAL (type
) = total_length
;
954 /* end of scope for reading member func */
958 /* Skip trailing ';' and bump count of number of fields seen */
966 /* This routine fixes up partial cfront types that were created
967 while parsing the stabs. The main need for this function is
968 to add information such as methods to classes.
969 Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */
971 resolve_cfront_continuation (struct objfile
*objfile
, struct symbol
*sym
,
974 struct symbol
*ref_sym
= 0;
976 /* snarfed from read_struct_type */
977 struct field_info fi
;
979 struct cleanup
*back_to
;
981 /* Need to make sure that fi isn't gunna conflict with struct
982 in case struct already had some fnfs */
985 back_to
= make_cleanup (null_cleanup
, 0);
987 /* We only accept structs, classes and unions at the moment.
988 Other continuation types include t (typedef), r (long dbl), ...
989 We may want to add support for them as well;
990 right now they are handled by duplicating the symbol information
991 into the type information (see define_symbol) */
992 if (*p
!= 's' /* structs */
993 && *p
!= 'c' /* class */
994 && *p
!= 'u') /* union */
995 return 0; /* only handle C++ types */
998 /* Get symbol typs name and validate
999 eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */
1000 sname
= get_substring (&p
, ';');
1001 if (!sname
|| strcmp (sname
, SYMBOL_NAME (sym
)))
1002 error ("Internal error: base symbol type name does not match\n");
1004 /* Find symbol's internal gdb reference using demangled_name.
1005 This is the real sym that we want;
1006 sym was a temp hack to make debugger happy */
1007 ref_sym
= lookup_symbol (SYMBOL_NAME (sym
), 0, STRUCT_NAMESPACE
, 0, 0);
1008 type
= SYMBOL_TYPE (ref_sym
);
1011 /* Now read the baseclasses, if any, read the regular C struct or C++
1012 class member fields, attach the fields to the type, read the C++
1013 member functions, attach them to the type, and then read any tilde
1014 field (baseclass specifier for the class holding the main vtable). */
1016 if (!read_cfront_baseclasses (&fi
, &p
, type
, objfile
)
1017 /* g++ does this next, but cfront already did this:
1018 || !read_struct_fields (&fi, &p, type, objfile) */
1019 || !copy_cfront_struct_fields (&fi
, type
, objfile
)
1020 || !read_cfront_member_functions (&fi
, &p
, type
, objfile
)
1021 || !read_cfront_static_fields (&fi
, &p
, type
, objfile
)
1022 || !attach_fields_to_type (&fi
, type
, objfile
)
1023 || !attach_fn_fields_to_type (&fi
, type
)
1024 /* g++ does this next, but cfront doesn't seem to have this:
1025 || !read_tilde_fields (&fi, &p, type, objfile) */
1028 type
= error_type (&p
, objfile
);
1031 do_cleanups (back_to
);
1034 /* End of code added to support parsing of ARM/Cfront stabs strings */
1037 /* This routine fixes up symbol references/aliases to point to the original
1038 symbol definition. Returns 0 on failure, non-zero on success. */
1041 resolve_symbol_reference (struct objfile
*objfile
, struct symbol
*sym
, char *p
)
1044 struct symbol
*ref_sym
= 0;
1045 struct alias_list
*alias
;
1047 /* If this is not a symbol reference return now. */
1051 /* Use "#<num>" as the name; we'll fix the name later.
1052 We stored the original symbol name as "#<id>=<name>"
1053 so we can now search for "#<id>" to resolving the reference.
1054 We'll fix the names later by removing the "#<id>" or "#<id>=" */
1056 /*---------------------------------------------------------*/
1057 /* Get the reference id number, and
1058 advance p past the names so we can parse the rest.
1059 eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */
1060 /*---------------------------------------------------------*/
1062 /* This gets reference name from string. sym may not have a name. */
1064 /* Get the reference number associated with the reference id in the
1065 gdb stab string. From that reference number, get the main/primary
1066 symbol for this alias. */
1067 refnum
= process_reference (&p
);
1068 ref_sym
= ref_search (refnum
);
1071 complain (&lrs_general_complaint
, "symbol for reference not found");
1075 /* Parse the stab of the referencing symbol
1076 now that we have the referenced symbol.
1077 Add it as a new symbol and a link back to the referenced symbol.
1078 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1081 /* If the stab symbol table and string contain:
1082 RSYM 0 5 00000000 868 #15=z:r(0,1)
1083 LBRAC 0 0 00000000 899 #5=
1084 SLINE 0 16 00000003 923 #6=
1085 Then the same symbols can be later referenced by:
1086 RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6)
1087 This is used in live range splitting to:
1088 1) specify that a symbol (#15) is actually just a new storage
1089 class for a symbol (#15=z) which was previously defined.
1090 2) specify that the beginning and ending ranges for a symbol
1091 (#15) are the values of the beginning (#5) and ending (#6)
1094 /* Read number as reference id.
1095 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1096 /* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
1097 in case of "l(0,0)"? */
1099 /*--------------------------------------------------*/
1100 /* Add this symbol to the reference list. */
1101 /*--------------------------------------------------*/
1103 alias
= (struct alias_list
*) obstack_alloc (&objfile
->type_obstack
,
1104 sizeof (struct alias_list
));
1107 complain (&lrs_general_complaint
, "Unable to allocate alias list memory");
1114 if (!SYMBOL_ALIASES (ref_sym
))
1116 SYMBOL_ALIASES (ref_sym
) = alias
;
1120 struct alias_list
*temp
;
1122 /* Get to the end of the list. */
1123 for (temp
= SYMBOL_ALIASES (ref_sym
);
1130 /* Want to fix up name so that other functions (eg. valops)
1131 will correctly print the name.
1132 Don't add_symbol_to_list so that lookup_symbol won't find it.
1133 nope... needed for fixups. */
1134 SYMBOL_NAME (sym
) = SYMBOL_NAME (ref_sym
);
1140 /* Structure for storing pointers to reference definitions for fast lookup
1141 during "process_later". */
1150 #define MAX_CHUNK_REFS 100
1151 #define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map))
1152 #define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE)
1154 static struct ref_map
*ref_map
;
1156 /* Ptr to free cell in chunk's linked list. */
1157 static int ref_count
= 0;
1159 /* Number of chunks malloced. */
1160 static int ref_chunk
= 0;
1162 /* This file maintains a cache of stabs aliases found in the symbol
1163 table. If the symbol table changes, this cache must be cleared
1164 or we are left holding onto data in invalid obstacks. */
1166 stabsread_clear_cache (void)
1172 /* Create array of pointers mapping refids to symbols and stab strings.
1173 Add pointers to reference definition symbols and/or their values as we
1174 find them, using their reference numbers as our index.
1175 These will be used later when we resolve references. */
1177 ref_add (int refnum
, struct symbol
*sym
, char *stabs
, CORE_ADDR value
)
1181 if (refnum
>= ref_count
)
1182 ref_count
= refnum
+ 1;
1183 if (ref_count
> ref_chunk
* MAX_CHUNK_REFS
)
1185 int new_slots
= ref_count
- ref_chunk
* MAX_CHUNK_REFS
;
1186 int new_chunks
= new_slots
/ MAX_CHUNK_REFS
+ 1;
1187 ref_map
= (struct ref_map
*)
1188 xrealloc (ref_map
, REF_MAP_SIZE (ref_chunk
+ new_chunks
));
1189 memset (ref_map
+ ref_chunk
* MAX_CHUNK_REFS
, 0, new_chunks
* REF_CHUNK_SIZE
);
1190 ref_chunk
+= new_chunks
;
1192 ref_map
[refnum
].stabs
= stabs
;
1193 ref_map
[refnum
].sym
= sym
;
1194 ref_map
[refnum
].value
= value
;
1197 /* Return defined sym for the reference REFNUM. */
1199 ref_search (int refnum
)
1201 if (refnum
< 0 || refnum
> ref_count
)
1203 return ref_map
[refnum
].sym
;
1206 /* Return value for the reference REFNUM. */
1209 ref_search_value (int refnum
)
1211 if (refnum
< 0 || refnum
> ref_count
)
1213 return ref_map
[refnum
].value
;
1216 /* Parse a reference id in STRING and return the resulting
1217 reference number. Move STRING beyond the reference id. */
1220 process_reference (char **string
)
1225 if (**string
!= '#')
1228 /* Advance beyond the initial '#'. */
1231 /* Read number as reference id. */
1232 while (*p
&& isdigit (*p
))
1234 refnum
= refnum
* 10 + *p
- '0';
1241 /* If STRING defines a reference, store away a pointer to the reference
1242 definition for later use. Return the reference number. */
1245 symbol_reference_defined (char **string
)
1250 refnum
= process_reference (&p
);
1252 /* Defining symbols end in '=' */
1255 /* Symbol is being defined here. */
1261 /* Must be a reference. Either the symbol has already been defined,
1262 or this is a forward reference to it. */
1270 define_symbol (CORE_ADDR valu
, char *string
, int desc
, int type
,
1271 struct objfile
*objfile
)
1273 register struct symbol
*sym
;
1274 char *p
= (char *) strchr (string
, ':');
1279 /* We would like to eliminate nameless symbols, but keep their types.
1280 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1281 to type 2, but, should not create a symbol to address that type. Since
1282 the symbol will be nameless, there is no way any user can refer to it. */
1286 /* Ignore syms with empty names. */
1290 /* Ignore old-style symbols from cc -go */
1297 p
= strchr (p
, ':');
1300 /* If a nameless stab entry, all we need is the type, not the symbol.
1301 e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
1302 nameless
= (p
== string
|| ((string
[0] == ' ') && (string
[1] == ':')));
1304 current_symbol
= sym
= (struct symbol
*)
1305 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
1306 memset (sym
, 0, sizeof (struct symbol
));
1308 switch (type
& N_TYPE
)
1311 SYMBOL_SECTION (sym
) = SECT_OFF_TEXT (objfile
);
1314 SYMBOL_SECTION (sym
) = SECT_OFF_DATA (objfile
);
1317 SYMBOL_SECTION (sym
) = SECT_OFF_BSS (objfile
);
1321 if (processing_gcc_compilation
)
1323 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1324 number of bytes occupied by a type or object, which we ignore. */
1325 SYMBOL_LINE (sym
) = desc
;
1329 SYMBOL_LINE (sym
) = 0; /* unknown */
1332 if (is_cplus_marker (string
[0]))
1334 /* Special GNU C++ names. */
1338 SYMBOL_NAME (sym
) = obsavestring ("this", strlen ("this"),
1339 &objfile
->symbol_obstack
);
1342 case 'v': /* $vtbl_ptr_type */
1343 /* Was: SYMBOL_NAME (sym) = "vptr"; */
1347 SYMBOL_NAME (sym
) = obsavestring ("eh_throw", strlen ("eh_throw"),
1348 &objfile
->symbol_obstack
);
1352 /* This was an anonymous type that was never fixed up. */
1355 #ifdef STATIC_TRANSFORM_NAME
1357 /* SunPRO (3.0 at least) static variable encoding. */
1362 complain (&unrecognized_cplus_name_complaint
, string
);
1363 goto normal
; /* Do *something* with it */
1366 else if (string
[0] == '#')
1368 /* Special GNU C extension for referencing symbols. */
1372 /* If STRING defines a new reference id, then add it to the
1373 reference map. Else it must be referring to a previously
1374 defined symbol, so add it to the alias list of the previously
1377 refnum
= symbol_reference_defined (&s
);
1379 ref_add (refnum
, sym
, string
, SYMBOL_VALUE (sym
));
1380 else if (!resolve_symbol_reference (objfile
, sym
, string
))
1383 /* S..P contains the name of the symbol. We need to store
1384 the correct name into SYMBOL_NAME. */
1390 SYMBOL_NAME (sym
) = (char *)
1391 obstack_alloc (&objfile
->symbol_obstack
, nlen
);
1392 strncpy (SYMBOL_NAME (sym
), s
, nlen
);
1393 SYMBOL_NAME (sym
)[nlen
] = '\0';
1394 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
1397 /* FIXME! Want SYMBOL_NAME (sym) = 0;
1398 Get error if leave name 0. So give it something. */
1401 SYMBOL_NAME (sym
) = (char *)
1402 obstack_alloc (&objfile
->symbol_obstack
, nlen
);
1403 strncpy (SYMBOL_NAME (sym
), string
, nlen
);
1404 SYMBOL_NAME (sym
)[nlen
] = '\0';
1405 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
1408 /* Advance STRING beyond the reference id. */
1414 SYMBOL_LANGUAGE (sym
) = current_subfile
->language
;
1415 SYMBOL_NAME (sym
) = (char *)
1416 obstack_alloc (&objfile
->symbol_obstack
, ((p
- string
) + 1));
1417 /* Open-coded memcpy--saves function call time. */
1418 /* FIXME: Does it really? Try replacing with simple strcpy and
1419 try it on an executable with a large symbol table. */
1420 /* FIXME: considering that gcc can open code memcpy anyway, I
1421 doubt it. xoxorich. */
1423 register char *p1
= string
;
1424 register char *p2
= SYMBOL_NAME (sym
);
1432 /* If this symbol is from a C++ compilation, then attempt to cache the
1433 demangled form for future reference. This is a typical time versus
1434 space tradeoff, that was decided in favor of time because it sped up
1435 C++ symbol lookups by a factor of about 20. */
1437 SYMBOL_INIT_DEMANGLED_NAME (sym
, &objfile
->symbol_obstack
);
1441 /* Determine the type of name being defined. */
1443 /* Getting GDB to correctly skip the symbol on an undefined symbol
1444 descriptor and not ever dump core is a very dodgy proposition if
1445 we do things this way. I say the acorn RISC machine can just
1446 fix their compiler. */
1447 /* The Acorn RISC machine's compiler can put out locals that don't
1448 start with "234=" or "(3,4)=", so assume anything other than the
1449 deftypes we know how to handle is a local. */
1450 if (!strchr ("cfFGpPrStTvVXCR", *p
))
1452 if (isdigit (*p
) || *p
== '(' || *p
== '-')
1461 /* c is a special case, not followed by a type-number.
1462 SYMBOL:c=iVALUE for an integer constant symbol.
1463 SYMBOL:c=rVALUE for a floating constant symbol.
1464 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1465 e.g. "b:c=e6,0" for "const b = blob1"
1466 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1469 SYMBOL_CLASS (sym
) = LOC_CONST
;
1470 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1471 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1472 add_symbol_to_list (sym
, &file_symbols
);
1480 double d
= atof (p
);
1483 /* FIXME-if-picky-about-floating-accuracy: Should be using
1484 target arithmetic to get the value. real.c in GCC
1485 probably has the necessary code. */
1487 /* FIXME: lookup_fundamental_type is a hack. We should be
1488 creating a type especially for the type of float constants.
1489 Problem is, what type should it be?
1491 Also, what should the name of this type be? Should we
1492 be using 'S' constants (see stabs.texinfo) instead? */
1494 SYMBOL_TYPE (sym
) = lookup_fundamental_type (objfile
,
1497 obstack_alloc (&objfile
->symbol_obstack
,
1498 TYPE_LENGTH (SYMBOL_TYPE (sym
)));
1499 store_typed_floating (dbl_valu
, SYMBOL_TYPE (sym
), d
);
1500 SYMBOL_VALUE_BYTES (sym
) = dbl_valu
;
1501 SYMBOL_CLASS (sym
) = LOC_CONST_BYTES
;
1506 /* Defining integer constants this way is kind of silly,
1507 since 'e' constants allows the compiler to give not
1508 only the value, but the type as well. C has at least
1509 int, long, unsigned int, and long long as constant
1510 types; other languages probably should have at least
1511 unsigned as well as signed constants. */
1513 /* We just need one int constant type for all objfiles.
1514 It doesn't depend on languages or anything (arguably its
1515 name should be a language-specific name for a type of
1516 that size, but I'm inclined to say that if the compiler
1517 wants a nice name for the type, it can use 'e'). */
1518 static struct type
*int_const_type
;
1520 /* Yes, this is as long as a *host* int. That is because we
1522 if (int_const_type
== NULL
)
1524 init_type (TYPE_CODE_INT
,
1525 sizeof (int) * HOST_CHAR_BIT
/ TARGET_CHAR_BIT
, 0,
1527 (struct objfile
*) NULL
);
1528 SYMBOL_TYPE (sym
) = int_const_type
;
1529 SYMBOL_VALUE (sym
) = atoi (p
);
1530 SYMBOL_CLASS (sym
) = LOC_CONST
;
1534 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
1535 can be represented as integral.
1536 e.g. "b:c=e6,0" for "const b = blob1"
1537 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1539 SYMBOL_CLASS (sym
) = LOC_CONST
;
1540 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1544 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1549 /* If the value is too big to fit in an int (perhaps because
1550 it is unsigned), or something like that, we silently get
1551 a bogus value. The type and everything else about it is
1552 correct. Ideally, we should be using whatever we have
1553 available for parsing unsigned and long long values,
1555 SYMBOL_VALUE (sym
) = atoi (p
);
1560 SYMBOL_CLASS (sym
) = LOC_CONST
;
1561 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1564 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1565 add_symbol_to_list (sym
, &file_symbols
);
1569 /* The name of a caught exception. */
1570 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1571 SYMBOL_CLASS (sym
) = LOC_LABEL
;
1572 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1573 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
1574 add_symbol_to_list (sym
, &local_symbols
);
1578 /* A static function definition. */
1579 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1580 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
1581 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1582 add_symbol_to_list (sym
, &file_symbols
);
1583 /* fall into process_function_types. */
1585 process_function_types
:
1586 /* Function result types are described as the result type in stabs.
1587 We need to convert this to the function-returning-type-X type
1588 in GDB. E.g. "int" is converted to "function returning int". */
1589 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_FUNC
)
1590 SYMBOL_TYPE (sym
) = lookup_function_type (SYMBOL_TYPE (sym
));
1592 /* All functions in C++ have prototypes. */
1593 if (SYMBOL_LANGUAGE (sym
) == language_cplus
)
1594 TYPE_FLAGS (SYMBOL_TYPE (sym
)) |= TYPE_FLAG_PROTOTYPED
;
1596 /* fall into process_prototype_types */
1598 process_prototype_types
:
1599 /* Sun acc puts declared types of arguments here. */
1602 struct type
*ftype
= SYMBOL_TYPE (sym
);
1607 /* Obtain a worst case guess for the number of arguments
1608 by counting the semicolons. */
1615 /* Allocate parameter information fields and fill them in. */
1616 TYPE_FIELDS (ftype
) = (struct field
*)
1617 TYPE_ALLOC (ftype
, nsemi
* sizeof (struct field
));
1622 /* A type number of zero indicates the start of varargs.
1623 FIXME: GDB currently ignores vararg functions. */
1624 if (p
[0] == '0' && p
[1] == '\0')
1626 ptype
= read_type (&p
, objfile
);
1628 /* The Sun compilers mark integer arguments, which should
1629 be promoted to the width of the calling conventions, with
1630 a type which references itself. This type is turned into
1631 a TYPE_CODE_VOID type by read_type, and we have to turn
1632 it back into builtin_type_int here.
1633 FIXME: Do we need a new builtin_type_promoted_int_arg ? */
1634 if (TYPE_CODE (ptype
) == TYPE_CODE_VOID
)
1635 ptype
= builtin_type_int
;
1636 TYPE_FIELD_TYPE (ftype
, nparams
) = ptype
;
1637 TYPE_FIELD_ARTIFICIAL (ftype
, nparams
++) = 0;
1639 TYPE_NFIELDS (ftype
) = nparams
;
1640 TYPE_FLAGS (ftype
) |= TYPE_FLAG_PROTOTYPED
;
1645 /* A global function definition. */
1646 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1647 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
1648 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1649 add_symbol_to_list (sym
, &global_symbols
);
1650 goto process_function_types
;
1653 /* For a class G (global) symbol, it appears that the
1654 value is not correct. It is necessary to search for the
1655 corresponding linker definition to find the value.
1656 These definitions appear at the end of the namelist. */
1657 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1658 SYMBOL_CLASS (sym
) = LOC_STATIC
;
1659 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1660 /* Don't add symbol references to global_sym_chain.
1661 Symbol references don't have valid names and wont't match up with
1662 minimal symbols when the global_sym_chain is relocated.
1663 We'll fixup symbol references when we fixup the defining symbol. */
1664 if (SYMBOL_NAME (sym
) && SYMBOL_NAME (sym
)[0] != '#')
1666 i
= hashname (SYMBOL_NAME (sym
));
1667 SYMBOL_VALUE_CHAIN (sym
) = global_sym_chain
[i
];
1668 global_sym_chain
[i
] = sym
;
1670 add_symbol_to_list (sym
, &global_symbols
);
1673 /* This case is faked by a conditional above,
1674 when there is no code letter in the dbx data.
1675 Dbx data never actually contains 'l'. */
1678 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1679 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
1680 SYMBOL_VALUE (sym
) = valu
;
1681 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1682 add_symbol_to_list (sym
, &local_symbols
);
1687 /* pF is a two-letter code that means a function parameter in Fortran.
1688 The type-number specifies the type of the return value.
1689 Translate it into a pointer-to-function type. */
1693 = lookup_pointer_type
1694 (lookup_function_type (read_type (&p
, objfile
)));
1697 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1699 /* Normally this is a parameter, a LOC_ARG. On the i960, it
1700 can also be a LOC_LOCAL_ARG depending on symbol type. */
1701 #ifndef DBX_PARM_SYMBOL_CLASS
1702 #define DBX_PARM_SYMBOL_CLASS(type) LOC_ARG
1705 SYMBOL_CLASS (sym
) = DBX_PARM_SYMBOL_CLASS (type
);
1706 SYMBOL_VALUE (sym
) = valu
;
1707 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1708 add_symbol_to_list (sym
, &local_symbols
);
1710 if (TARGET_BYTE_ORDER
!= BFD_ENDIAN_BIG
)
1712 /* On little-endian machines, this crud is never necessary,
1713 and, if the extra bytes contain garbage, is harmful. */
1717 /* If it's gcc-compiled, if it says `short', believe it. */
1718 if (processing_gcc_compilation
|| BELIEVE_PCC_PROMOTION
)
1721 if (!BELIEVE_PCC_PROMOTION
)
1723 /* This is the signed type which arguments get promoted to. */
1724 static struct type
*pcc_promotion_type
;
1725 /* This is the unsigned type which arguments get promoted to. */
1726 static struct type
*pcc_unsigned_promotion_type
;
1728 /* Call it "int" because this is mainly C lossage. */
1729 if (pcc_promotion_type
== NULL
)
1730 pcc_promotion_type
=
1731 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
1734 if (pcc_unsigned_promotion_type
== NULL
)
1735 pcc_unsigned_promotion_type
=
1736 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
1737 TYPE_FLAG_UNSIGNED
, "unsigned int", NULL
);
1739 if (BELIEVE_PCC_PROMOTION_TYPE
)
1741 /* This is defined on machines (e.g. sparc) where we
1742 should believe the type of a PCC 'short' argument,
1743 but shouldn't believe the address (the address is the
1744 address of the corresponding int).
1746 My guess is that this correction, as opposed to
1747 changing the parameter to an 'int' (as done below,
1748 for PCC on most machines), is the right thing to do
1749 on all machines, but I don't want to risk breaking
1750 something that already works. On most PCC machines,
1751 the sparc problem doesn't come up because the calling
1752 function has to zero the top bytes (not knowing
1753 whether the called function wants an int or a short),
1754 so there is little practical difference between an
1755 int and a short (except perhaps what happens when the
1756 GDB user types "print short_arg = 0x10000;").
1758 Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the
1759 compiler actually produces the correct address (we
1760 don't need to fix it up). I made this code adapt so
1761 that it will offset the symbol if it was pointing at
1762 an int-aligned location and not otherwise. This way
1763 you can use the same gdb for 4.0.x and 4.1 systems.
1765 If the parameter is shorter than an int, and is
1766 integral (e.g. char, short, or unsigned equivalent),
1767 and is claimed to be passed on an integer boundary,
1768 don't believe it! Offset the parameter's address to
1769 the tail-end of that integer. */
1771 if (TYPE_LENGTH (SYMBOL_TYPE (sym
)) < TYPE_LENGTH (pcc_promotion_type
)
1772 && TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_INT
1773 && 0 == SYMBOL_VALUE (sym
) % TYPE_LENGTH (pcc_promotion_type
))
1775 SYMBOL_VALUE (sym
) += TYPE_LENGTH (pcc_promotion_type
)
1776 - TYPE_LENGTH (SYMBOL_TYPE (sym
));
1782 /* If PCC says a parameter is a short or a char,
1783 it is really an int. */
1784 if (TYPE_LENGTH (SYMBOL_TYPE (sym
)) < TYPE_LENGTH (pcc_promotion_type
)
1785 && TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_INT
)
1788 TYPE_UNSIGNED (SYMBOL_TYPE (sym
))
1789 ? pcc_unsigned_promotion_type
1790 : pcc_promotion_type
;
1797 /* acc seems to use P to declare the prototypes of functions that
1798 are referenced by this file. gdb is not prepared to deal
1799 with this extra information. FIXME, it ought to. */
1802 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1803 goto process_prototype_types
;
1808 /* Parameter which is in a register. */
1809 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1810 SYMBOL_CLASS (sym
) = LOC_REGPARM
;
1811 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
1812 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
1814 complain (®_value_complaint
, SYMBOL_VALUE (sym
),
1815 NUM_REGS
+ NUM_PSEUDO_REGS
,
1816 SYMBOL_SOURCE_NAME (sym
));
1817 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
1819 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1820 add_symbol_to_list (sym
, &local_symbols
);
1824 /* Register variable (either global or local). */
1825 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1826 SYMBOL_CLASS (sym
) = LOC_REGISTER
;
1827 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
1828 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
1830 complain (®_value_complaint
, SYMBOL_VALUE (sym
),
1831 NUM_REGS
+ NUM_PSEUDO_REGS
,
1832 SYMBOL_SOURCE_NAME (sym
));
1833 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
1835 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1836 if (within_function
)
1838 /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
1839 name to represent an argument passed in a register.
1840 GCC uses 'P' for the same case. So if we find such a symbol pair
1841 we combine it into one 'P' symbol. For Sun cc we need to do this
1842 regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
1843 the 'p' symbol even if it never saves the argument onto the stack.
1845 On most machines, we want to preserve both symbols, so that
1846 we can still get information about what is going on with the
1847 stack (VAX for computing args_printed, using stack slots instead
1848 of saved registers in backtraces, etc.).
1850 Note that this code illegally combines
1851 main(argc) struct foo argc; { register struct foo argc; }
1852 but this case is considered pathological and causes a warning
1853 from a decent compiler. */
1856 && local_symbols
->nsyms
> 0
1857 #ifndef USE_REGISTER_NOT_ARG
1858 && REG_STRUCT_HAS_ADDR_P ()
1859 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation
,
1861 && (TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_STRUCT
1862 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_UNION
1863 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_SET
1864 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_BITSTRING
)
1868 struct symbol
*prev_sym
;
1869 prev_sym
= local_symbols
->symbol
[local_symbols
->nsyms
- 1];
1870 if ((SYMBOL_CLASS (prev_sym
) == LOC_REF_ARG
1871 || SYMBOL_CLASS (prev_sym
) == LOC_ARG
)
1872 && STREQ (SYMBOL_NAME (prev_sym
), SYMBOL_NAME (sym
)))
1874 SYMBOL_CLASS (prev_sym
) = LOC_REGPARM
;
1875 /* Use the type from the LOC_REGISTER; that is the type
1876 that is actually in that register. */
1877 SYMBOL_TYPE (prev_sym
) = SYMBOL_TYPE (sym
);
1878 SYMBOL_VALUE (prev_sym
) = SYMBOL_VALUE (sym
);
1883 add_symbol_to_list (sym
, &local_symbols
);
1886 add_symbol_to_list (sym
, &file_symbols
);
1890 /* Static symbol at top level of file */
1891 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1892 SYMBOL_CLASS (sym
) = LOC_STATIC
;
1893 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
1894 #ifdef STATIC_TRANSFORM_NAME
1895 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
)))
1897 struct minimal_symbol
*msym
;
1898 msym
= lookup_minimal_symbol (SYMBOL_NAME (sym
), NULL
, objfile
);
1901 SYMBOL_NAME (sym
) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
));
1902 SYMBOL_VALUE_ADDRESS (sym
) = SYMBOL_VALUE_ADDRESS (msym
);
1906 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1907 add_symbol_to_list (sym
, &file_symbols
);
1912 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1914 /* For a nameless type, we don't want a create a symbol, thus we
1915 did not use `sym'. Return without further processing. */
1919 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
1920 SYMBOL_VALUE (sym
) = valu
;
1921 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
1922 /* C++ vagaries: we may have a type which is derived from
1923 a base type which did not have its name defined when the
1924 derived class was output. We fill in the derived class's
1925 base part member's name here in that case. */
1926 if (TYPE_NAME (SYMBOL_TYPE (sym
)) != NULL
)
1927 if ((TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_STRUCT
1928 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_UNION
)
1929 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym
)))
1932 for (j
= TYPE_N_BASECLASSES (SYMBOL_TYPE (sym
)) - 1; j
>= 0; j
--)
1933 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym
), j
) == 0)
1934 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym
), j
) =
1935 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym
), j
));
1938 if (TYPE_NAME (SYMBOL_TYPE (sym
)) == NULL
)
1940 /* gcc-2.6 or later (when using -fvtable-thunks)
1941 emits a unique named type for a vtable entry.
1942 Some gdb code depends on that specific name. */
1943 extern const char vtbl_ptr_name
[];
1945 if ((TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_PTR
1946 && strcmp (SYMBOL_NAME (sym
), vtbl_ptr_name
))
1947 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_FUNC
)
1949 /* If we are giving a name to a type such as "pointer to
1950 foo" or "function returning foo", we better not set
1951 the TYPE_NAME. If the program contains "typedef char
1952 *caddr_t;", we don't want all variables of type char
1953 * to print as caddr_t. This is not just a
1954 consequence of GDB's type management; PCC and GCC (at
1955 least through version 2.4) both output variables of
1956 either type char * or caddr_t with the type number
1957 defined in the 't' symbol for caddr_t. If a future
1958 compiler cleans this up it GDB is not ready for it
1959 yet, but if it becomes ready we somehow need to
1960 disable this check (without breaking the PCC/GCC2.4
1965 Fortunately, this check seems not to be necessary
1966 for anything except pointers or functions. */
1967 /* ezannoni: 2000-10-26. This seems to apply for
1968 versions of gcc older than 2.8. This was the original
1969 problem: with the following code gdb would tell that
1970 the type for name1 is caddr_t, and func is char()
1971 typedef char *caddr_t;
1983 /* Pascal accepts names for pointer types. */
1984 if (current_subfile
->language
== language_pascal
)
1986 TYPE_NAME (SYMBOL_TYPE (sym
)) = SYMBOL_NAME (sym
);
1990 TYPE_NAME (SYMBOL_TYPE (sym
)) = SYMBOL_NAME (sym
);
1993 add_symbol_to_list (sym
, &file_symbols
);
1997 /* Struct, union, or enum tag. For GNU C++, this can be be followed
1998 by 't' which means we are typedef'ing it as well. */
1999 synonym
= *p
== 't';
2003 /* The semantics of C++ state that "struct foo { ... }" also defines
2004 a typedef for "foo". Unfortunately, cfront never makes the typedef
2005 when translating C++ into C. We make the typedef here so that
2006 "ptype foo" works as expected for cfront translated code. */
2007 else if (current_subfile
->language
== language_cplus
)
2010 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2012 /* For a nameless type, we don't want a create a symbol, thus we
2013 did not use `sym'. Return without further processing. */
2017 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
2018 SYMBOL_VALUE (sym
) = valu
;
2019 SYMBOL_NAMESPACE (sym
) = STRUCT_NAMESPACE
;
2020 if (TYPE_TAG_NAME (SYMBOL_TYPE (sym
)) == 0)
2021 TYPE_TAG_NAME (SYMBOL_TYPE (sym
))
2022 = obconcat (&objfile
->type_obstack
, "", "", SYMBOL_NAME (sym
));
2023 add_symbol_to_list (sym
, &file_symbols
);
2027 /* Clone the sym and then modify it. */
2028 register struct symbol
*typedef_sym
= (struct symbol
*)
2029 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
2030 *typedef_sym
= *sym
;
2031 SYMBOL_CLASS (typedef_sym
) = LOC_TYPEDEF
;
2032 SYMBOL_VALUE (typedef_sym
) = valu
;
2033 SYMBOL_NAMESPACE (typedef_sym
) = VAR_NAMESPACE
;
2034 if (TYPE_NAME (SYMBOL_TYPE (sym
)) == 0)
2035 TYPE_NAME (SYMBOL_TYPE (sym
))
2036 = obconcat (&objfile
->type_obstack
, "", "", SYMBOL_NAME (sym
));
2037 add_symbol_to_list (typedef_sym
, &file_symbols
);
2042 /* Static symbol of local scope */
2043 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2044 SYMBOL_CLASS (sym
) = LOC_STATIC
;
2045 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
2046 #ifdef STATIC_TRANSFORM_NAME
2047 if (IS_STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
)))
2049 struct minimal_symbol
*msym
;
2050 msym
= lookup_minimal_symbol (SYMBOL_NAME (sym
), NULL
, objfile
);
2053 SYMBOL_NAME (sym
) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym
));
2054 SYMBOL_VALUE_ADDRESS (sym
) = SYMBOL_VALUE_ADDRESS (msym
);
2058 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2059 #if 0 /* OBSOLETE OS9K */
2060 // OBSOLETE if (os9k_stabs)
2061 // OBSOLETE add_symbol_to_list (sym, &global_symbols);
2063 #endif /* OBSOLETE OS9K */
2064 add_symbol_to_list (sym
, &local_symbols
);
2068 /* Reference parameter */
2069 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2070 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
2071 SYMBOL_VALUE (sym
) = valu
;
2072 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2073 add_symbol_to_list (sym
, &local_symbols
);
2077 /* Reference parameter which is in a register. */
2078 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2079 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
2080 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
2081 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
2083 complain (®_value_complaint
, SYMBOL_VALUE (sym
),
2084 NUM_REGS
+ NUM_PSEUDO_REGS
,
2085 SYMBOL_SOURCE_NAME (sym
));
2086 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
2088 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2089 add_symbol_to_list (sym
, &local_symbols
);
2093 /* This is used by Sun FORTRAN for "function result value".
2094 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
2095 that Pascal uses it too, but when I tried it Pascal used
2096 "x:3" (local symbol) instead. */
2097 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2098 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
2099 SYMBOL_VALUE (sym
) = valu
;
2100 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2101 add_symbol_to_list (sym
, &local_symbols
);
2104 /* New code added to support cfront stabs strings.
2105 Note: case 'P' already handled above */
2107 /* Cfront type continuation coming up!
2108 Find the original definition and add to it.
2109 We'll have to do this for the typedef too,
2110 since we cloned the symbol to define a type in read_type.
2111 Stabs info examples:
2113 foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24))
2114 C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;;
2115 where C is the name of the class.
2116 Unfortunately, we can't lookup the original symbol yet 'cuz
2117 we haven't finished reading all the symbols.
2118 Instead, we save it for processing later */
2119 process_later (sym
, p
, resolve_cfront_continuation
);
2120 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
); /* FIXME! change later */
2121 SYMBOL_CLASS (sym
) = LOC_CONST
;
2122 SYMBOL_VALUE (sym
) = 0;
2123 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2124 /* Don't add to list - we'll delete it later when
2125 we add the continuation to the real sym */
2127 /* End of new code added to support cfront stabs strings */
2130 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
2131 SYMBOL_CLASS (sym
) = LOC_CONST
;
2132 SYMBOL_VALUE (sym
) = 0;
2133 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
2134 add_symbol_to_list (sym
, &file_symbols
);
2138 /* When passing structures to a function, some systems sometimes pass
2139 the address in a register, not the structure itself. */
2141 if (REG_STRUCT_HAS_ADDR_P ()
2142 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation
, SYMBOL_TYPE (sym
))
2143 && (SYMBOL_CLASS (sym
) == LOC_REGPARM
|| SYMBOL_CLASS (sym
) == LOC_ARG
))
2145 struct type
*symbol_type
= check_typedef (SYMBOL_TYPE (sym
));
2147 if ((TYPE_CODE (symbol_type
) == TYPE_CODE_STRUCT
)
2148 || (TYPE_CODE (symbol_type
) == TYPE_CODE_UNION
)
2149 || (TYPE_CODE (symbol_type
) == TYPE_CODE_BITSTRING
)
2150 || (TYPE_CODE (symbol_type
) == TYPE_CODE_SET
))
2152 /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
2153 LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
2154 if (SYMBOL_CLASS (sym
) == LOC_REGPARM
)
2155 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
2156 /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
2157 and subsequent arguments on the sparc, for example). */
2158 else if (SYMBOL_CLASS (sym
) == LOC_ARG
)
2159 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
2163 /* Is there more to parse? For example LRS/alias information? */
2164 while (*p
&& *p
== ';')
2167 if (*p
&& p
[0] == 'l' && p
[1] == '(')
2169 /* GNU extensions for live range splitting may be appended to
2170 the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */
2172 /* Resolve the live range and add it to SYM's live range list. */
2173 if (!resolve_live_range (objfile
, sym
, p
))
2176 /* Find end of live range info. */
2177 p
= strchr (p
, ')');
2178 if (!*p
|| *p
!= ')')
2180 complain (&lrs_general_complaint
, "live range format not recognized");
2189 /* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns
2190 non-zero on success, zero otherwise. */
2193 resolve_live_range (struct objfile
*objfile
, struct symbol
*sym
, char *p
)
2196 CORE_ADDR start
, end
;
2198 /* Sanity check the beginning of the stabs string. */
2199 if (!*p
|| *p
!= 'l')
2201 complain (&lrs_general_complaint
, "live range string 1");
2206 if (!*p
|| *p
!= '(')
2208 complain (&lrs_general_complaint
, "live range string 2");
2213 /* Get starting value of range and advance P past the reference id.
2215 ?!? In theory, the process_reference should never fail, but we should
2216 catch that case just in case the compiler scrogged the stabs. */
2217 refnum
= process_reference (&p
);
2218 start
= ref_search_value (refnum
);
2221 complain (&lrs_general_complaint
, "Live range symbol not found 1");
2225 if (!*p
|| *p
!= ',')
2227 complain (&lrs_general_complaint
, "live range string 3");
2232 /* Get ending value of range and advance P past the reference id.
2234 ?!? In theory, the process_reference should never fail, but we should
2235 catch that case just in case the compiler scrogged the stabs. */
2236 refnum
= process_reference (&p
);
2237 end
= ref_search_value (refnum
);
2240 complain (&lrs_general_complaint
, "Live range symbol not found 2");
2244 if (!*p
|| *p
!= ')')
2246 complain (&lrs_general_complaint
, "live range string 4");
2250 /* Now that we know the bounds of the range, add it to the
2252 add_live_range (objfile
, sym
, start
, end
);
2257 /* Add a new live range defined by START and END to the symbol SYM
2258 in objfile OBJFILE. */
2261 add_live_range (struct objfile
*objfile
, struct symbol
*sym
, CORE_ADDR start
,
2264 struct range_list
*r
, *rs
;
2268 complain (&lrs_general_complaint
, "end of live range follows start");
2272 /* Alloc new live range structure. */
2273 r
= (struct range_list
*)
2274 obstack_alloc (&objfile
->type_obstack
,
2275 sizeof (struct range_list
));
2280 /* Append this range to the symbol's range list. */
2281 if (!SYMBOL_RANGES (sym
))
2282 SYMBOL_RANGES (sym
) = r
;
2285 /* Get the last range for the symbol. */
2286 for (rs
= SYMBOL_RANGES (sym
); rs
->next
; rs
= rs
->next
)
2293 /* Skip rest of this symbol and return an error type.
2295 General notes on error recovery: error_type always skips to the
2296 end of the symbol (modulo cretinous dbx symbol name continuation).
2297 Thus code like this:
2299 if (*(*pp)++ != ';')
2300 return error_type (pp, objfile);
2302 is wrong because if *pp starts out pointing at '\0' (typically as the
2303 result of an earlier error), it will be incremented to point to the
2304 start of the next symbol, which might produce strange results, at least
2305 if you run off the end of the string table. Instead use
2308 return error_type (pp, objfile);
2314 foo = error_type (pp, objfile);
2318 And in case it isn't obvious, the point of all this hair is so the compiler
2319 can define new types and new syntaxes, and old versions of the
2320 debugger will be able to read the new symbol tables. */
2322 static struct type
*
2323 error_type (char **pp
, struct objfile
*objfile
)
2325 complain (&error_type_complaint
);
2328 /* Skip to end of symbol. */
2329 while (**pp
!= '\0')
2334 /* Check for and handle cretinous dbx symbol name continuation! */
2335 if ((*pp
)[-1] == '\\' || (*pp
)[-1] == '?')
2337 *pp
= next_symbol_text (objfile
);
2344 return (builtin_type_error
);
2348 /* Read type information or a type definition; return the type. Even
2349 though this routine accepts either type information or a type
2350 definition, the distinction is relevant--some parts of stabsread.c
2351 assume that type information starts with a digit, '-', or '(' in
2352 deciding whether to call read_type. */
2355 read_type (register char **pp
, struct objfile
*objfile
)
2357 register struct type
*type
= 0;
2360 char type_descriptor
;
2362 /* Size in bits of type if specified by a type attribute, or -1 if
2363 there is no size attribute. */
2366 /* Used to distinguish string and bitstring from char-array and set. */
2369 /* Used to distinguish vector from array. */
2372 /* Read type number if present. The type number may be omitted.
2373 for instance in a two-dimensional array declared with type
2374 "ar1;1;10;ar1;1;10;4". */
2375 if ((**pp
>= '0' && **pp
<= '9')
2379 if (read_type_number (pp
, typenums
) != 0)
2380 return error_type (pp
, objfile
);
2382 /* Type is not being defined here. Either it already exists,
2383 or this is a forward reference to it. dbx_alloc_type handles
2386 return dbx_alloc_type (typenums
, objfile
);
2388 /* Type is being defined here. */
2390 Also skip the type descriptor - we get it below with (*pp)[-1]. */
2395 /* 'typenums=' not present, type is anonymous. Read and return
2396 the definition, but don't put it in the type vector. */
2397 typenums
[0] = typenums
[1] = -1;
2402 type_descriptor
= (*pp
)[-1];
2403 switch (type_descriptor
)
2407 enum type_code code
;
2409 /* Used to index through file_symbols. */
2410 struct pending
*ppt
;
2413 /* Name including "struct", etc. */
2417 char *from
, *to
, *p
, *q1
, *q2
;
2419 /* Set the type code according to the following letter. */
2423 code
= TYPE_CODE_STRUCT
;
2426 code
= TYPE_CODE_UNION
;
2429 code
= TYPE_CODE_ENUM
;
2433 /* Complain and keep going, so compilers can invent new
2434 cross-reference types. */
2435 static struct complaint msg
=
2436 {"Unrecognized cross-reference type `%c'", 0, 0};
2437 complain (&msg
, (*pp
)[0]);
2438 code
= TYPE_CODE_STRUCT
;
2443 q1
= strchr (*pp
, '<');
2444 p
= strchr (*pp
, ':');
2446 return error_type (pp
, objfile
);
2447 if (q1
&& p
> q1
&& p
[1] == ':')
2449 int nesting_level
= 0;
2450 for (q2
= q1
; *q2
; q2
++)
2454 else if (*q2
== '>')
2456 else if (*q2
== ':' && nesting_level
== 0)
2461 return error_type (pp
, objfile
);
2464 (char *) obstack_alloc (&objfile
->type_obstack
, p
- *pp
+ 1);
2466 /* Copy the name. */
2472 /* Set the pointer ahead of the name which we just read, and
2477 /* Now check to see whether the type has already been
2478 declared. This was written for arrays of cross-referenced
2479 types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty
2480 sure it is not necessary anymore. But it might be a good
2481 idea, to save a little memory. */
2483 for (ppt
= file_symbols
; ppt
; ppt
= ppt
->next
)
2484 for (i
= 0; i
< ppt
->nsyms
; i
++)
2486 struct symbol
*sym
= ppt
->symbol
[i
];
2488 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
2489 && SYMBOL_NAMESPACE (sym
) == STRUCT_NAMESPACE
2490 && (TYPE_CODE (SYMBOL_TYPE (sym
)) == code
)
2491 && STREQ (SYMBOL_NAME (sym
), type_name
))
2493 obstack_free (&objfile
->type_obstack
, type_name
);
2494 type
= SYMBOL_TYPE (sym
);
2499 /* Didn't find the type to which this refers, so we must
2500 be dealing with a forward reference. Allocate a type
2501 structure for it, and keep track of it so we can
2502 fill in the rest of the fields when we get the full
2504 type
= dbx_alloc_type (typenums
, objfile
);
2505 TYPE_CODE (type
) = code
;
2506 TYPE_TAG_NAME (type
) = type_name
;
2507 INIT_CPLUS_SPECIFIC (type
);
2508 TYPE_FLAGS (type
) |= TYPE_FLAG_STUB
;
2510 add_undefined_type (type
);
2514 case '-': /* RS/6000 built-in type */
2528 /* We deal with something like t(1,2)=(3,4)=... which
2529 the Lucid compiler and recent gcc versions (post 2.7.3) use. */
2531 /* Allocate and enter the typedef type first.
2532 This handles recursive types. */
2533 type
= dbx_alloc_type (typenums
, objfile
);
2534 TYPE_CODE (type
) = TYPE_CODE_TYPEDEF
;
2536 struct type
*xtype
= read_type (pp
, objfile
);
2539 /* It's being defined as itself. That means it is "void". */
2540 TYPE_CODE (type
) = TYPE_CODE_VOID
;
2541 TYPE_LENGTH (type
) = 1;
2543 else if (type_size
>= 0 || is_string
)
2545 /* This is the absolute wrong way to construct types. Every
2546 other debug format has found a way around this problem and
2547 the related problems with unnecessarily stubbed types;
2548 someone motivated should attempt to clean up the issue
2549 here as well. Once a type pointed to has been created it
2550 should not be modified.
2552 Well, it's not *absolutely* wrong. Constructing recursive
2553 types (trees, linked lists) necessarily entails modifying
2554 types after creating them. Constructing any loop structure
2555 entails side effects. The Dwarf 2 reader does handle this
2556 more gracefully (it never constructs more than once
2557 instance of a type object, so it doesn't have to copy type
2558 objects wholesale), but it still mutates type objects after
2559 other folks have references to them.
2561 Keep in mind that this circularity/mutation issue shows up
2562 at the source language level, too: C's "incomplete types",
2563 for example. So the proper cleanup, I think, would be to
2564 limit GDB's type smashing to match exactly those required
2565 by the source language. So GDB could have a
2566 "complete_this_type" function, but never create unnecessary
2567 copies of a type otherwise. */
2568 replace_type (type
, xtype
);
2569 TYPE_NAME (type
) = NULL
;
2570 TYPE_TAG_NAME (type
) = NULL
;
2574 TYPE_FLAGS (type
) |= TYPE_FLAG_TARGET_STUB
;
2575 TYPE_TARGET_TYPE (type
) = xtype
;
2580 /* In the following types, we must be sure to overwrite any existing
2581 type that the typenums refer to, rather than allocating a new one
2582 and making the typenums point to the new one. This is because there
2583 may already be pointers to the existing type (if it had been
2584 forward-referenced), and we must change it to a pointer, function,
2585 reference, or whatever, *in-place*. */
2587 case '*': /* Pointer to another type */
2588 type1
= read_type (pp
, objfile
);
2589 type
= make_pointer_type (type1
, dbx_lookup_type (typenums
));
2592 case '&': /* Reference to another type */
2593 type1
= read_type (pp
, objfile
);
2594 type
= make_reference_type (type1
, dbx_lookup_type (typenums
));
2597 case 'f': /* Function returning another type */
2598 #if 0 /* OBSOLETE OS9K */
2599 // OBSOLETE if (os9k_stabs && **pp == '(')
2601 // OBSOLETE /* Function prototype; parse it.
2602 // OBSOLETE We must conditionalize this on os9k_stabs because otherwise
2603 // OBSOLETE it could be confused with a Sun-style (1,3) typenumber
2604 // OBSOLETE (I think). */
2605 // OBSOLETE struct type *t;
2607 // OBSOLETE while (**pp != ')')
2609 // OBSOLETE t = read_type (pp, objfile);
2610 // OBSOLETE if (**pp == ',')
2611 // OBSOLETE ++ * pp;
2614 #endif /* OBSOLETE OS9K */
2616 type1
= read_type (pp
, objfile
);
2617 type
= make_function_type (type1
, dbx_lookup_type (typenums
));
2620 case 'g': /* Prototyped function. (Sun) */
2622 /* Unresolved questions:
2624 - According to Sun's ``STABS Interface Manual'', for 'f'
2625 and 'F' symbol descriptors, a `0' in the argument type list
2626 indicates a varargs function. But it doesn't say how 'g'
2627 type descriptors represent that info. Someone with access
2628 to Sun's toolchain should try it out.
2630 - According to the comment in define_symbol (search for
2631 `process_prototype_types:'), Sun emits integer arguments as
2632 types which ref themselves --- like `void' types. Do we
2633 have to deal with that here, too? Again, someone with
2634 access to Sun's toolchain should try it out and let us
2637 const char *type_start
= (*pp
) - 1;
2638 struct type
*return_type
= read_type (pp
, objfile
);
2639 struct type
*func_type
2640 = make_function_type (return_type
, dbx_lookup_type (typenums
));
2643 struct type_list
*next
;
2647 while (**pp
&& **pp
!= '#')
2649 struct type
*arg_type
= read_type (pp
, objfile
);
2650 struct type_list
*new = alloca (sizeof (*new));
2651 new->type
= arg_type
;
2652 new->next
= arg_types
;
2660 static struct complaint msg
= {
2661 "Prototyped function type didn't end arguments with `#':\n%s",
2664 complain (&msg
, type_start
);
2667 /* If there is just one argument whose type is `void', then
2668 that's just an empty argument list. */
2670 && ! arg_types
->next
2671 && TYPE_CODE (arg_types
->type
) == TYPE_CODE_VOID
)
2674 TYPE_FIELDS (func_type
)
2675 = (struct field
*) TYPE_ALLOC (func_type
,
2676 num_args
* sizeof (struct field
));
2677 memset (TYPE_FIELDS (func_type
), 0, num_args
* sizeof (struct field
));
2680 struct type_list
*t
;
2682 /* We stuck each argument type onto the front of the list
2683 when we read it, so the list is reversed. Build the
2684 fields array right-to-left. */
2685 for (t
= arg_types
, i
= num_args
- 1; t
; t
= t
->next
, i
--)
2686 TYPE_FIELD_TYPE (func_type
, i
) = t
->type
;
2688 TYPE_NFIELDS (func_type
) = num_args
;
2689 TYPE_FLAGS (func_type
) |= TYPE_FLAG_PROTOTYPED
;
2695 case 'k': /* Const qualifier on some type (Sun) */
2696 #if 0 /* OBSOLETE OS9K */
2697 // OBSOLETE /* ezannoni 2002-07-16: This can be safely deleted, because 'c'
2698 // OBSOLETE means complex type in AIX stabs, while it means const qualifier
2699 // OBSOLETE in os9k stabs. Obviously we were supporting only the os9k meaning.
2700 // OBSOLETE We were erroring out if we were reading AIX stabs. Right now the
2701 // OBSOLETE erroring out will happen in the default clause of the switch. */
2702 // OBSOLETE case 'c': /* Const qualifier on some type (OS9000) */
2703 // OBSOLETE /* Because 'c' means other things to AIX and 'k' is perfectly good,
2704 // OBSOLETE only accept 'c' in the os9k_stabs case. */
2705 // OBSOLETE if (type_descriptor == 'c' && !os9k_stabs)
2706 // OBSOLETE return error_type (pp, objfile);
2707 #endif /* OBSOLETE OS9K */
2708 type
= read_type (pp
, objfile
);
2709 type
= make_cv_type (1, TYPE_VOLATILE (type
), type
,
2710 dbx_lookup_type (typenums
));
2713 case 'B': /* Volatile qual on some type (Sun) */
2714 #if 0 /* OBSOLETE OS9K */
2715 // OBSOLETE /* ezannoni 2002-07-16: This can be safely deleted, because 'i'
2716 // OBSOLETE means imported type in AIX stabs, while it means volatile qualifier
2717 // OBSOLETE in os9k stabs. Obviously we were supporting only the os9k meaning.
2718 // OBSOLETE We were erroring out if we were reading AIX stabs. Right now the
2719 // OBSOLETE erroring out will happen in the default clause of the switch. */
2720 // OBSOLETE case 'i': /* Volatile qual on some type (OS9000) */
2721 // OBSOLETE /* Because 'i' means other things to AIX and 'B' is perfectly good,
2722 // OBSOLETE only accept 'i' in the os9k_stabs case. */
2723 // OBSOLETE if (type_descriptor == 'i' && !os9k_stabs)
2724 // OBSOLETE return error_type (pp, objfile);
2725 #endif /* OBSOLETE OS9K */
2726 type
= read_type (pp
, objfile
);
2727 type
= make_cv_type (TYPE_CONST (type
), 1, type
,
2728 dbx_lookup_type (typenums
));
2732 if (isdigit (**pp
) || **pp
== '(' || **pp
== '-')
2733 { /* Member (class & variable) type */
2734 /* FIXME -- we should be doing smash_to_XXX types here. */
2736 struct type
*domain
= read_type (pp
, objfile
);
2737 struct type
*memtype
;
2740 /* Invalid member type data format. */
2741 return error_type (pp
, objfile
);
2744 memtype
= read_type (pp
, objfile
);
2745 type
= dbx_alloc_type (typenums
, objfile
);
2746 smash_to_member_type (type
, domain
, memtype
);
2749 /* type attribute */
2752 /* Skip to the semicolon. */
2753 while (**pp
!= ';' && **pp
!= '\0')
2756 return error_type (pp
, objfile
);
2758 ++ * pp
; /* Skip the semicolon. */
2762 case 's': /* Size attribute */
2763 type_size
= atoi (attr
+ 1);
2768 case 'S': /* String attribute */
2769 /* FIXME: check to see if following type is array? */
2773 case 'V': /* Vector attribute */
2774 /* FIXME: check to see if following type is array? */
2779 /* Ignore unrecognized type attributes, so future compilers
2780 can invent new ones. */
2788 case '#': /* Method (class & fn) type */
2789 if ((*pp
)[0] == '#')
2791 /* We'll get the parameter types from the name. */
2792 struct type
*return_type
;
2795 return_type
= read_type (pp
, objfile
);
2796 if (*(*pp
)++ != ';')
2797 complain (&invalid_member_complaint
, symnum
);
2798 type
= allocate_stub_method (return_type
);
2799 if (typenums
[0] != -1)
2800 *dbx_lookup_type (typenums
) = type
;
2804 struct type
*domain
= read_type (pp
, objfile
);
2805 struct type
*return_type
;
2810 /* Invalid member type data format. */
2811 return error_type (pp
, objfile
);
2815 return_type
= read_type (pp
, objfile
);
2816 args
= read_args (pp
, ';', objfile
, &nargs
, &varargs
);
2817 type
= dbx_alloc_type (typenums
, objfile
);
2818 smash_to_method_type (type
, domain
, return_type
, args
,
2823 case 'r': /* Range type */
2824 type
= read_range_type (pp
, typenums
, objfile
);
2825 if (typenums
[0] != -1)
2826 *dbx_lookup_type (typenums
) = type
;
2830 #if 0 /* OBSOLETE OS9K */
2831 // OBSOLETE if (os9k_stabs)
2832 // OBSOLETE /* Const and volatile qualified type. */
2833 // OBSOLETE type = read_type (pp, objfile);
2835 #endif /* OBSOLETE OS9K */
2837 /* Sun ACC builtin int type */
2838 type
= read_sun_builtin_type (pp
, typenums
, objfile
);
2839 if (typenums
[0] != -1)
2840 *dbx_lookup_type (typenums
) = type
;
2844 case 'R': /* Sun ACC builtin float type */
2845 type
= read_sun_floating_type (pp
, typenums
, objfile
);
2846 if (typenums
[0] != -1)
2847 *dbx_lookup_type (typenums
) = type
;
2850 case 'e': /* Enumeration type */
2851 type
= dbx_alloc_type (typenums
, objfile
);
2852 type
= read_enum_type (pp
, type
, objfile
);
2853 if (typenums
[0] != -1)
2854 *dbx_lookup_type (typenums
) = type
;
2857 case 's': /* Struct type */
2858 case 'u': /* Union type */
2860 enum type_code type_code
= TYPE_CODE_UNDEF
;
2861 type
= dbx_alloc_type (typenums
, objfile
);
2862 switch (type_descriptor
)
2865 type_code
= TYPE_CODE_STRUCT
;
2868 type_code
= TYPE_CODE_UNION
;
2871 type
= read_struct_type (pp
, type
, type_code
, objfile
);
2875 case 'a': /* Array type */
2877 return error_type (pp
, objfile
);
2880 type
= dbx_alloc_type (typenums
, objfile
);
2881 type
= read_array_type (pp
, type
, objfile
);
2883 TYPE_CODE (type
) = TYPE_CODE_STRING
;
2885 TYPE_FLAGS (type
) |= TYPE_FLAG_VECTOR
;
2888 case 'S': /* Set or bitstring type */
2889 type1
= read_type (pp
, objfile
);
2890 type
= create_set_type ((struct type
*) NULL
, type1
);
2892 TYPE_CODE (type
) = TYPE_CODE_BITSTRING
;
2893 if (typenums
[0] != -1)
2894 *dbx_lookup_type (typenums
) = type
;
2898 --*pp
; /* Go back to the symbol in error */
2899 /* Particularly important if it was \0! */
2900 return error_type (pp
, objfile
);
2905 warning ("GDB internal error, type is NULL in stabsread.c\n");
2906 return error_type (pp
, objfile
);
2909 /* Size specified in a type attribute overrides any other size. */
2910 if (type_size
!= -1)
2911 TYPE_LENGTH (type
) = (type_size
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
2916 /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
2917 Return the proper type node for a given builtin type number. */
2919 static struct type
*
2920 rs6000_builtin_type (int typenum
)
2922 /* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
2923 #define NUMBER_RECOGNIZED 34
2924 /* This includes an empty slot for type number -0. */
2925 static struct type
*negative_types
[NUMBER_RECOGNIZED
+ 1];
2926 struct type
*rettype
= NULL
;
2928 if (typenum
>= 0 || typenum
< -NUMBER_RECOGNIZED
)
2930 complain (&rs6000_builtin_complaint
, typenum
);
2931 return builtin_type_error
;
2933 if (negative_types
[-typenum
] != NULL
)
2934 return negative_types
[-typenum
];
2936 #if TARGET_CHAR_BIT != 8
2937 #error This code wrong for TARGET_CHAR_BIT not 8
2938 /* These definitions all assume that TARGET_CHAR_BIT is 8. I think
2939 that if that ever becomes not true, the correct fix will be to
2940 make the size in the struct type to be in bits, not in units of
2947 /* The size of this and all the other types are fixed, defined
2948 by the debugging format. If there is a type called "int" which
2949 is other than 32 bits, then it should use a new negative type
2950 number (or avoid negative type numbers for that case).
2951 See stabs.texinfo. */
2952 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "int", NULL
);
2955 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "char", NULL
);
2958 rettype
= init_type (TYPE_CODE_INT
, 2, 0, "short", NULL
);
2961 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "long", NULL
);
2964 rettype
= init_type (TYPE_CODE_INT
, 1, TYPE_FLAG_UNSIGNED
,
2965 "unsigned char", NULL
);
2968 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "signed char", NULL
);
2971 rettype
= init_type (TYPE_CODE_INT
, 2, TYPE_FLAG_UNSIGNED
,
2972 "unsigned short", NULL
);
2975 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2976 "unsigned int", NULL
);
2979 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2982 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2983 "unsigned long", NULL
);
2986 rettype
= init_type (TYPE_CODE_VOID
, 1, 0, "void", NULL
);
2989 /* IEEE single precision (32 bit). */
2990 rettype
= init_type (TYPE_CODE_FLT
, 4, 0, "float", NULL
);
2993 /* IEEE double precision (64 bit). */
2994 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "double", NULL
);
2997 /* This is an IEEE double on the RS/6000, and different machines with
2998 different sizes for "long double" should use different negative
2999 type numbers. See stabs.texinfo. */
3000 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "long double", NULL
);
3003 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "integer", NULL
);
3006 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
3010 rettype
= init_type (TYPE_CODE_FLT
, 4, 0, "short real", NULL
);
3013 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "real", NULL
);
3016 rettype
= init_type (TYPE_CODE_ERROR
, 0, 0, "stringptr", NULL
);
3019 rettype
= init_type (TYPE_CODE_CHAR
, 1, TYPE_FLAG_UNSIGNED
,
3023 rettype
= init_type (TYPE_CODE_BOOL
, 1, TYPE_FLAG_UNSIGNED
,
3027 rettype
= init_type (TYPE_CODE_BOOL
, 2, TYPE_FLAG_UNSIGNED
,
3031 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
3035 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
3039 /* Complex type consisting of two IEEE single precision values. */
3040 rettype
= init_type (TYPE_CODE_COMPLEX
, 8, 0, "complex", NULL
);
3041 TYPE_TARGET_TYPE (rettype
) = init_type (TYPE_CODE_FLT
, 4, 0, "float",
3045 /* Complex type consisting of two IEEE double precision values. */
3046 rettype
= init_type (TYPE_CODE_COMPLEX
, 16, 0, "double complex", NULL
);
3047 TYPE_TARGET_TYPE (rettype
) = init_type (TYPE_CODE_FLT
, 8, 0, "double",
3051 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "integer*1", NULL
);
3054 rettype
= init_type (TYPE_CODE_INT
, 2, 0, "integer*2", NULL
);
3057 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "integer*4", NULL
);
3060 rettype
= init_type (TYPE_CODE_CHAR
, 2, 0, "wchar", NULL
);
3063 rettype
= init_type (TYPE_CODE_INT
, 8, 0, "long long", NULL
);
3066 rettype
= init_type (TYPE_CODE_INT
, 8, TYPE_FLAG_UNSIGNED
,
3067 "unsigned long long", NULL
);
3070 rettype
= init_type (TYPE_CODE_INT
, 8, TYPE_FLAG_UNSIGNED
,
3074 rettype
= init_type (TYPE_CODE_INT
, 8, 0, "integer*8", NULL
);
3077 negative_types
[-typenum
] = rettype
;
3081 /* This page contains subroutines of read_type. */
3083 /* Replace *OLD_NAME with the method name portion of PHYSNAME. */
3086 update_method_name_from_physname (char **old_name
, char *physname
)
3090 method_name
= method_name_from_physname (physname
);
3092 if (method_name
== NULL
)
3093 error ("bad physname %s\n", physname
);
3095 if (strcmp (*old_name
, method_name
) != 0)
3098 *old_name
= method_name
;
3101 xfree (method_name
);
3104 /* Read member function stabs info for C++ classes. The form of each member
3107 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
3109 An example with two member functions is:
3111 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
3113 For the case of overloaded operators, the format is op$::*.funcs, where
3114 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
3115 name (such as `+=') and `.' marks the end of the operator name.
3117 Returns 1 for success, 0 for failure. */
3120 read_member_functions (struct field_info
*fip
, char **pp
, struct type
*type
,
3121 struct objfile
*objfile
)
3125 /* Total number of member functions defined in this class. If the class
3126 defines two `f' functions, and one `g' function, then this will have
3128 int total_length
= 0;
3132 struct next_fnfield
*next
;
3133 struct fn_field fn_field
;
3136 struct type
*look_ahead_type
;
3137 struct next_fnfieldlist
*new_fnlist
;
3138 struct next_fnfield
*new_sublist
;
3142 /* Process each list until we find something that is not a member function
3143 or find the end of the functions. */
3147 /* We should be positioned at the start of the function name.
3148 Scan forward to find the first ':' and if it is not the
3149 first of a "::" delimiter, then this is not a member function. */
3161 look_ahead_type
= NULL
;
3164 new_fnlist
= (struct next_fnfieldlist
*)
3165 xmalloc (sizeof (struct next_fnfieldlist
));
3166 make_cleanup (xfree
, new_fnlist
);
3167 memset (new_fnlist
, 0, sizeof (struct next_fnfieldlist
));
3169 if ((*pp
)[0] == 'o' && (*pp
)[1] == 'p' && is_cplus_marker ((*pp
)[2]))
3171 /* This is a completely wierd case. In order to stuff in the
3172 names that might contain colons (the usual name delimiter),
3173 Mike Tiemann defined a different name format which is
3174 signalled if the identifier is "op$". In that case, the
3175 format is "op$::XXXX." where XXXX is the name. This is
3176 used for names like "+" or "=". YUUUUUUUK! FIXME! */
3177 /* This lets the user type "break operator+".
3178 We could just put in "+" as the name, but that wouldn't
3180 static char opname
[32] = "op$";
3181 char *o
= opname
+ 3;
3183 /* Skip past '::'. */
3186 STABS_CONTINUE (pp
, objfile
);
3192 main_fn_name
= savestring (opname
, o
- opname
);
3198 main_fn_name
= savestring (*pp
, p
- *pp
);
3199 /* Skip past '::'. */
3202 new_fnlist
->fn_fieldlist
.name
= main_fn_name
;
3207 (struct next_fnfield
*) xmalloc (sizeof (struct next_fnfield
));
3208 make_cleanup (xfree
, new_sublist
);
3209 memset (new_sublist
, 0, sizeof (struct next_fnfield
));
3211 /* Check for and handle cretinous dbx symbol name continuation! */
3212 if (look_ahead_type
== NULL
)
3215 STABS_CONTINUE (pp
, objfile
);
3217 new_sublist
->fn_field
.type
= read_type (pp
, objfile
);
3220 /* Invalid symtab info for member function. */
3226 /* g++ version 1 kludge */
3227 new_sublist
->fn_field
.type
= look_ahead_type
;
3228 look_ahead_type
= NULL
;
3238 /* If this is just a stub, then we don't have the real name here. */
3240 if (TYPE_STUB (new_sublist
->fn_field
.type
))
3242 if (!TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
))
3243 TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
) = type
;
3244 new_sublist
->fn_field
.is_stub
= 1;
3246 new_sublist
->fn_field
.physname
= savestring (*pp
, p
- *pp
);
3249 /* Set this member function's visibility fields. */
3252 case VISIBILITY_PRIVATE
:
3253 new_sublist
->fn_field
.is_private
= 1;
3255 case VISIBILITY_PROTECTED
:
3256 new_sublist
->fn_field
.is_protected
= 1;
3260 STABS_CONTINUE (pp
, objfile
);
3263 case 'A': /* Normal functions. */
3264 new_sublist
->fn_field
.is_const
= 0;
3265 new_sublist
->fn_field
.is_volatile
= 0;
3268 case 'B': /* `const' member functions. */
3269 new_sublist
->fn_field
.is_const
= 1;
3270 new_sublist
->fn_field
.is_volatile
= 0;
3273 case 'C': /* `volatile' member function. */
3274 new_sublist
->fn_field
.is_const
= 0;
3275 new_sublist
->fn_field
.is_volatile
= 1;
3278 case 'D': /* `const volatile' member function. */
3279 new_sublist
->fn_field
.is_const
= 1;
3280 new_sublist
->fn_field
.is_volatile
= 1;
3283 case '*': /* File compiled with g++ version 1 -- no info */
3288 complain (&const_vol_complaint
, **pp
);
3297 /* virtual member function, followed by index.
3298 The sign bit is set to distinguish pointers-to-methods
3299 from virtual function indicies. Since the array is
3300 in words, the quantity must be shifted left by 1
3301 on 16 bit machine, and by 2 on 32 bit machine, forcing
3302 the sign bit out, and usable as a valid index into
3303 the array. Remove the sign bit here. */
3304 new_sublist
->fn_field
.voffset
=
3305 (0x7fffffff & read_huge_number (pp
, ';', &nbits
)) + 2;
3309 STABS_CONTINUE (pp
, objfile
);
3310 if (**pp
== ';' || **pp
== '\0')
3312 /* Must be g++ version 1. */
3313 new_sublist
->fn_field
.fcontext
= 0;
3317 /* Figure out from whence this virtual function came.
3318 It may belong to virtual function table of
3319 one of its baseclasses. */
3320 look_ahead_type
= read_type (pp
, objfile
);
3323 /* g++ version 1 overloaded methods. */
3327 new_sublist
->fn_field
.fcontext
= look_ahead_type
;
3336 look_ahead_type
= NULL
;
3342 /* static member function. */
3344 int slen
= strlen (main_fn_name
);
3346 new_sublist
->fn_field
.voffset
= VOFFSET_STATIC
;
3348 /* For static member functions, we can't tell if they
3349 are stubbed, as they are put out as functions, and not as
3351 GCC v2 emits the fully mangled name if
3352 dbxout.c:flag_minimal_debug is not set, so we have to
3353 detect a fully mangled physname here and set is_stub
3354 accordingly. Fully mangled physnames in v2 start with
3355 the member function name, followed by two underscores.
3356 GCC v3 currently always emits stubbed member functions,
3357 but with fully mangled physnames, which start with _Z. */
3358 if (!(strncmp (new_sublist
->fn_field
.physname
,
3359 main_fn_name
, slen
) == 0
3360 && new_sublist
->fn_field
.physname
[slen
] == '_'
3361 && new_sublist
->fn_field
.physname
[slen
+ 1] == '_'))
3363 new_sublist
->fn_field
.is_stub
= 1;
3370 complain (&member_fn_complaint
, (*pp
)[-1]);
3371 /* Fall through into normal member function. */
3374 /* normal member function. */
3375 new_sublist
->fn_field
.voffset
= 0;
3376 new_sublist
->fn_field
.fcontext
= 0;
3380 new_sublist
->next
= sublist
;
3381 sublist
= new_sublist
;
3383 STABS_CONTINUE (pp
, objfile
);
3385 while (**pp
!= ';' && **pp
!= '\0');
3388 STABS_CONTINUE (pp
, objfile
);
3390 /* Skip GCC 3.X member functions which are duplicates of the callable
3391 constructor/destructor. */
3392 if (strcmp (main_fn_name
, "__base_ctor") == 0
3393 || strcmp (main_fn_name
, "__base_dtor") == 0
3394 || strcmp (main_fn_name
, "__deleting_dtor") == 0)
3396 xfree (main_fn_name
);
3401 int has_destructor
= 0, has_other
= 0;
3403 struct next_fnfield
*tmp_sublist
;
3405 /* Various versions of GCC emit various mostly-useless
3406 strings in the name field for special member functions.
3408 For stub methods, we need to defer correcting the name
3409 until we are ready to unstub the method, because the current
3410 name string is used by gdb_mangle_name. The only stub methods
3411 of concern here are GNU v2 operators; other methods have their
3412 names correct (see caveat below).
3414 For non-stub methods, in GNU v3, we have a complete physname.
3415 Therefore we can safely correct the name now. This primarily
3416 affects constructors and destructors, whose name will be
3417 __comp_ctor or __comp_dtor instead of Foo or ~Foo. Cast
3418 operators will also have incorrect names; for instance,
3419 "operator int" will be named "operator i" (i.e. the type is
3422 For non-stub methods in GNU v2, we have no easy way to
3423 know if we have a complete physname or not. For most
3424 methods the result depends on the platform (if CPLUS_MARKER
3425 can be `$' or `.', it will use minimal debug information, or
3426 otherwise the full physname will be included).
3428 Rather than dealing with this, we take a different approach.
3429 For v3 mangled names, we can use the full physname; for v2,
3430 we use cplus_demangle_opname (which is actually v2 specific),
3431 because the only interesting names are all operators - once again
3432 barring the caveat below. Skip this process if any method in the
3433 group is a stub, to prevent our fouling up the workings of
3436 The caveat: GCC 2.95.x (and earlier?) put constructors and
3437 destructors in the same method group. We need to split this
3438 into two groups, because they should have different names.
3439 So for each method group we check whether it contains both
3440 routines whose physname appears to be a destructor (the physnames
3441 for and destructors are always provided, due to quirks in v2
3442 mangling) and routines whose physname does not appear to be a
3443 destructor. If so then we break up the list into two halves.
3444 Even if the constructors and destructors aren't in the same group
3445 the destructor will still lack the leading tilde, so that also
3448 So, to summarize what we expect and handle here:
3450 Given Given Real Real Action
3451 method name physname physname method name
3453 __opi [none] __opi__3Foo operator int opname
3455 Foo _._3Foo _._3Foo ~Foo separate and
3457 operator i _ZN3FoocviEv _ZN3FoocviEv operator int demangle
3458 __comp_ctor _ZN3FooC1ERKS_ _ZN3FooC1ERKS_ Foo demangle
3461 tmp_sublist
= sublist
;
3462 while (tmp_sublist
!= NULL
)
3464 if (tmp_sublist
->fn_field
.is_stub
)
3466 if (tmp_sublist
->fn_field
.physname
[0] == '_'
3467 && tmp_sublist
->fn_field
.physname
[1] == 'Z')
3470 if (is_destructor_name (tmp_sublist
->fn_field
.physname
))
3475 tmp_sublist
= tmp_sublist
->next
;
3478 if (has_destructor
&& has_other
)
3480 struct next_fnfieldlist
*destr_fnlist
;
3481 struct next_fnfield
*last_sublist
;
3483 /* Create a new fn_fieldlist for the destructors. */
3485 destr_fnlist
= (struct next_fnfieldlist
*)
3486 xmalloc (sizeof (struct next_fnfieldlist
));
3487 make_cleanup (xfree
, destr_fnlist
);
3488 memset (destr_fnlist
, 0, sizeof (struct next_fnfieldlist
));
3489 destr_fnlist
->fn_fieldlist
.name
3490 = obconcat (&objfile
->type_obstack
, "", "~",
3491 new_fnlist
->fn_fieldlist
.name
);
3493 destr_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
3494 obstack_alloc (&objfile
->type_obstack
,
3495 sizeof (struct fn_field
) * has_destructor
);
3496 memset (destr_fnlist
->fn_fieldlist
.fn_fields
, 0,
3497 sizeof (struct fn_field
) * has_destructor
);
3498 tmp_sublist
= sublist
;
3499 last_sublist
= NULL
;
3501 while (tmp_sublist
!= NULL
)
3503 if (!is_destructor_name (tmp_sublist
->fn_field
.physname
))
3505 tmp_sublist
= tmp_sublist
->next
;
3509 destr_fnlist
->fn_fieldlist
.fn_fields
[i
++]
3510 = tmp_sublist
->fn_field
;
3512 last_sublist
->next
= tmp_sublist
->next
;
3514 sublist
= tmp_sublist
->next
;
3515 last_sublist
= tmp_sublist
;
3516 tmp_sublist
= tmp_sublist
->next
;
3519 destr_fnlist
->fn_fieldlist
.length
= has_destructor
;
3520 destr_fnlist
->next
= fip
->fnlist
;
3521 fip
->fnlist
= destr_fnlist
;
3523 total_length
+= has_destructor
;
3524 length
-= has_destructor
;
3528 /* v3 mangling prevents the use of abbreviated physnames,
3529 so we can do this here. There are stubbed methods in v3
3531 - in -gstabs instead of -gstabs+
3532 - or for static methods, which are output as a function type
3533 instead of a method type. */
3535 update_method_name_from_physname (&new_fnlist
->fn_fieldlist
.name
,
3536 sublist
->fn_field
.physname
);
3538 else if (has_destructor
&& new_fnlist
->fn_fieldlist
.name
[0] != '~')
3540 new_fnlist
->fn_fieldlist
.name
= concat ("~", main_fn_name
, NULL
);
3541 xfree (main_fn_name
);
3545 char dem_opname
[256];
3547 ret
= cplus_demangle_opname (new_fnlist
->fn_fieldlist
.name
,
3548 dem_opname
, DMGL_ANSI
);
3550 ret
= cplus_demangle_opname (new_fnlist
->fn_fieldlist
.name
,
3553 new_fnlist
->fn_fieldlist
.name
3554 = obsavestring (dem_opname
, strlen (dem_opname
),
3555 &objfile
->type_obstack
);
3558 new_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
3559 obstack_alloc (&objfile
->type_obstack
,
3560 sizeof (struct fn_field
) * length
);
3561 memset (new_fnlist
->fn_fieldlist
.fn_fields
, 0,
3562 sizeof (struct fn_field
) * length
);
3563 for (i
= length
; (i
--, sublist
); sublist
= sublist
->next
)
3565 new_fnlist
->fn_fieldlist
.fn_fields
[i
] = sublist
->fn_field
;
3568 new_fnlist
->fn_fieldlist
.length
= length
;
3569 new_fnlist
->next
= fip
->fnlist
;
3570 fip
->fnlist
= new_fnlist
;
3572 total_length
+= length
;
3578 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
3579 TYPE_FN_FIELDLISTS (type
) = (struct fn_fieldlist
*)
3580 TYPE_ALLOC (type
, sizeof (struct fn_fieldlist
) * nfn_fields
);
3581 memset (TYPE_FN_FIELDLISTS (type
), 0,
3582 sizeof (struct fn_fieldlist
) * nfn_fields
);
3583 TYPE_NFN_FIELDS (type
) = nfn_fields
;
3584 TYPE_NFN_FIELDS_TOTAL (type
) = total_length
;
3590 /* Special GNU C++ name.
3592 Returns 1 for success, 0 for failure. "failure" means that we can't
3593 keep parsing and it's time for error_type(). */
3596 read_cpp_abbrev (struct field_info
*fip
, char **pp
, struct type
*type
,
3597 struct objfile
*objfile
)
3602 struct type
*context
;
3612 /* At this point, *pp points to something like "22:23=*22...",
3613 where the type number before the ':' is the "context" and
3614 everything after is a regular type definition. Lookup the
3615 type, find it's name, and construct the field name. */
3617 context
= read_type (pp
, objfile
);
3621 case 'f': /* $vf -- a virtual function table pointer */
3622 name
= type_name_no_tag (context
);
3627 fip
->list
->field
.name
=
3628 obconcat (&objfile
->type_obstack
, vptr_name
, name
, "");
3631 case 'b': /* $vb -- a virtual bsomethingorother */
3632 name
= type_name_no_tag (context
);
3635 complain (&invalid_cpp_type_complaint
, symnum
);
3638 fip
->list
->field
.name
=
3639 obconcat (&objfile
->type_obstack
, vb_name
, name
, "");
3643 complain (&invalid_cpp_abbrev_complaint
, *pp
);
3644 fip
->list
->field
.name
=
3645 obconcat (&objfile
->type_obstack
,
3646 "INVALID_CPLUSPLUS_ABBREV", "", "");
3650 /* At this point, *pp points to the ':'. Skip it and read the
3656 complain (&invalid_cpp_abbrev_complaint
, *pp
);
3659 fip
->list
->field
.type
= read_type (pp
, objfile
);
3661 (*pp
)++; /* Skip the comma. */
3667 FIELD_BITPOS (fip
->list
->field
) = read_huge_number (pp
, ';', &nbits
);
3671 /* This field is unpacked. */
3672 FIELD_BITSIZE (fip
->list
->field
) = 0;
3673 fip
->list
->visibility
= VISIBILITY_PRIVATE
;
3677 complain (&invalid_cpp_abbrev_complaint
, *pp
);
3678 /* We have no idea what syntax an unrecognized abbrev would have, so
3679 better return 0. If we returned 1, we would need to at least advance
3680 *pp to avoid an infinite loop. */
3687 read_one_struct_field (struct field_info
*fip
, char **pp
, char *p
,
3688 struct type
*type
, struct objfile
*objfile
)
3690 /* The following is code to work around cfront generated stabs.
3691 The stabs contains full mangled name for each field.
3692 We try to demangle the name and extract the field name out of it.
3694 if (ARM_DEMANGLING
&& current_subfile
->language
== language_cplus
)
3700 dem
= cplus_demangle (*pp
, DMGL_ANSI
| DMGL_PARAMS
);
3703 dem_p
= strrchr (dem
, ':');
3704 if (dem_p
!= 0 && *(dem_p
- 1) == ':')
3706 FIELD_NAME (fip
->list
->field
) =
3707 obsavestring (dem_p
, strlen (dem_p
), &objfile
->type_obstack
);
3711 FIELD_NAME (fip
->list
->field
) =
3712 obsavestring (*pp
, p
- *pp
, &objfile
->type_obstack
);
3716 /* end of code for cfront work around */
3719 fip
->list
->field
.name
=
3720 obsavestring (*pp
, p
- *pp
, &objfile
->type_obstack
);
3723 /* This means we have a visibility for a field coming. */
3727 fip
->list
->visibility
= *(*pp
)++;
3731 /* normal dbx-style format, no explicit visibility */
3732 fip
->list
->visibility
= VISIBILITY_PUBLIC
;
3735 fip
->list
->field
.type
= read_type (pp
, objfile
);
3740 /* Possible future hook for nested types. */
3743 fip
->list
->field
.bitpos
= (long) -2; /* nested type */
3753 /* Static class member. */
3754 SET_FIELD_PHYSNAME (fip
->list
->field
, savestring (*pp
, p
- *pp
));
3758 else if (**pp
!= ',')
3760 /* Bad structure-type format. */
3761 complain (&stabs_general_complaint
, "bad structure-type format");
3765 (*pp
)++; /* Skip the comma. */
3769 FIELD_BITPOS (fip
->list
->field
) = read_huge_number (pp
, ',', &nbits
);
3772 complain (&stabs_general_complaint
, "bad structure-type format");
3775 FIELD_BITSIZE (fip
->list
->field
) = read_huge_number (pp
, ';', &nbits
);
3778 complain (&stabs_general_complaint
, "bad structure-type format");
3783 if (FIELD_BITPOS (fip
->list
->field
) == 0
3784 && FIELD_BITSIZE (fip
->list
->field
) == 0)
3786 /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
3787 it is a field which has been optimized out. The correct stab for
3788 this case is to use VISIBILITY_IGNORE, but that is a recent
3789 invention. (2) It is a 0-size array. For example
3790 union { int num; char str[0]; } foo. Printing "<no value>" for
3791 str in "p foo" is OK, since foo.str (and thus foo.str[3])
3792 will continue to work, and a 0-size array as a whole doesn't
3793 have any contents to print.
3795 I suspect this probably could also happen with gcc -gstabs (not
3796 -gstabs+) for static fields, and perhaps other C++ extensions.
3797 Hopefully few people use -gstabs with gdb, since it is intended
3798 for dbx compatibility. */
3800 /* Ignore this field. */
3801 fip
->list
->visibility
= VISIBILITY_IGNORE
;
3805 /* Detect an unpacked field and mark it as such.
3806 dbx gives a bit size for all fields.
3807 Note that forward refs cannot be packed,
3808 and treat enums as if they had the width of ints. */
3810 struct type
*field_type
= check_typedef (FIELD_TYPE (fip
->list
->field
));
3812 if (TYPE_CODE (field_type
) != TYPE_CODE_INT
3813 && TYPE_CODE (field_type
) != TYPE_CODE_RANGE
3814 && TYPE_CODE (field_type
) != TYPE_CODE_BOOL
3815 && TYPE_CODE (field_type
) != TYPE_CODE_ENUM
)
3817 FIELD_BITSIZE (fip
->list
->field
) = 0;
3819 if ((FIELD_BITSIZE (fip
->list
->field
)
3820 == TARGET_CHAR_BIT
* TYPE_LENGTH (field_type
)
3821 || (TYPE_CODE (field_type
) == TYPE_CODE_ENUM
3822 && FIELD_BITSIZE (fip
->list
->field
) == TARGET_INT_BIT
)
3825 FIELD_BITPOS (fip
->list
->field
) % 8 == 0)
3827 FIELD_BITSIZE (fip
->list
->field
) = 0;
3833 /* Read struct or class data fields. They have the form:
3835 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
3837 At the end, we see a semicolon instead of a field.
3839 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
3842 The optional VISIBILITY is one of:
3844 '/0' (VISIBILITY_PRIVATE)
3845 '/1' (VISIBILITY_PROTECTED)
3846 '/2' (VISIBILITY_PUBLIC)
3847 '/9' (VISIBILITY_IGNORE)
3849 or nothing, for C style fields with public visibility.
3851 Returns 1 for success, 0 for failure. */
3854 read_struct_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
3855 struct objfile
*objfile
)
3858 struct nextfield
*new;
3860 /* We better set p right now, in case there are no fields at all... */
3864 /* Read each data member type until we find the terminating ';' at the end of
3865 the data member list, or break for some other reason such as finding the
3866 start of the member function list. */
3867 /* Stab string for structure/union does not end with two ';' in
3868 SUN C compiler 5.3 i.e. F6U2, hence check for end of string. */
3870 while (**pp
!= ';' && **pp
!= '\0')
3872 #if 0 /* OBSOLETE OS9K */
3873 // OBSOLETE if (os9k_stabs && **pp == ',')
3875 #endif /* OBSOLETE OS9K */
3876 STABS_CONTINUE (pp
, objfile
);
3877 /* Get space to record the next field's data. */
3878 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
3879 make_cleanup (xfree
, new);
3880 memset (new, 0, sizeof (struct nextfield
));
3881 new->next
= fip
->list
;
3884 /* Get the field name. */
3887 /* If is starts with CPLUS_MARKER it is a special abbreviation,
3888 unless the CPLUS_MARKER is followed by an underscore, in
3889 which case it is just the name of an anonymous type, which we
3890 should handle like any other type name. */
3892 if (is_cplus_marker (p
[0]) && p
[1] != '_')
3894 if (!read_cpp_abbrev (fip
, pp
, type
, objfile
))
3899 /* Look for the ':' that separates the field name from the field
3900 values. Data members are delimited by a single ':', while member
3901 functions are delimited by a pair of ':'s. When we hit the member
3902 functions (if any), terminate scan loop and return. */
3904 while (*p
!= ':' && *p
!= '\0')
3911 /* Check to see if we have hit the member functions yet. */
3916 read_one_struct_field (fip
, pp
, p
, type
, objfile
);
3918 if (p
[0] == ':' && p
[1] == ':')
3920 /* (OBSOLETE) chill (OBSOLETE) the list of fields: the last
3921 entry (at the head) is a partially constructed entry which we
3923 fip
->list
= fip
->list
->next
;
3928 /* The stabs for C++ derived classes contain baseclass information which
3929 is marked by a '!' character after the total size. This function is
3930 called when we encounter the baseclass marker, and slurps up all the
3931 baseclass information.
3933 Immediately following the '!' marker is the number of base classes that
3934 the class is derived from, followed by information for each base class.
3935 For each base class, there are two visibility specifiers, a bit offset
3936 to the base class information within the derived class, a reference to
3937 the type for the base class, and a terminating semicolon.
3939 A typical example, with two base classes, would be "!2,020,19;0264,21;".
3941 Baseclass information marker __________________|| | | | | | |
3942 Number of baseclasses __________________________| | | | | | |
3943 Visibility specifiers (2) ________________________| | | | | |
3944 Offset in bits from start of class _________________| | | | |
3945 Type number for base class ___________________________| | | |
3946 Visibility specifiers (2) _______________________________| | |
3947 Offset in bits from start of class ________________________| |
3948 Type number of base class ____________________________________|
3950 Return 1 for success, 0 for (error-type-inducing) failure. */
3956 read_baseclasses (struct field_info
*fip
, char **pp
, struct type
*type
,
3957 struct objfile
*objfile
)
3960 struct nextfield
*new;
3968 /* Skip the '!' baseclass information marker. */
3972 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
3975 TYPE_N_BASECLASSES (type
) = read_huge_number (pp
, ',', &nbits
);
3981 /* Some stupid compilers have trouble with the following, so break
3982 it up into simpler expressions. */
3983 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*)
3984 TYPE_ALLOC (type
, B_BYTES (TYPE_N_BASECLASSES (type
)));
3987 int num_bytes
= B_BYTES (TYPE_N_BASECLASSES (type
));
3990 pointer
= (char *) TYPE_ALLOC (type
, num_bytes
);
3991 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*) pointer
;
3995 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type
), TYPE_N_BASECLASSES (type
));
3997 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
3999 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
4000 make_cleanup (xfree
, new);
4001 memset (new, 0, sizeof (struct nextfield
));
4002 new->next
= fip
->list
;
4004 FIELD_BITSIZE (new->field
) = 0; /* this should be an unpacked field! */
4006 STABS_CONTINUE (pp
, objfile
);
4010 /* Nothing to do. */
4013 SET_TYPE_FIELD_VIRTUAL (type
, i
);
4016 /* Unknown character. Complain and treat it as non-virtual. */
4018 static struct complaint msg
=
4020 "Unknown virtual character `%c' for baseclass", 0, 0};
4021 complain (&msg
, **pp
);
4026 new->visibility
= *(*pp
)++;
4027 switch (new->visibility
)
4029 case VISIBILITY_PRIVATE
:
4030 case VISIBILITY_PROTECTED
:
4031 case VISIBILITY_PUBLIC
:
4034 /* Bad visibility format. Complain and treat it as
4037 static struct complaint msg
=
4039 "Unknown visibility `%c' for baseclass", 0, 0
4041 complain (&msg
, new->visibility
);
4042 new->visibility
= VISIBILITY_PUBLIC
;
4049 /* The remaining value is the bit offset of the portion of the object
4050 corresponding to this baseclass. Always zero in the absence of
4051 multiple inheritance. */
4053 FIELD_BITPOS (new->field
) = read_huge_number (pp
, ',', &nbits
);
4058 /* The last piece of baseclass information is the type of the
4059 base class. Read it, and remember it's type name as this
4062 new->field
.type
= read_type (pp
, objfile
);
4063 new->field
.name
= type_name_no_tag (new->field
.type
);
4065 /* skip trailing ';' and bump count of number of fields seen */
4074 /* The tail end of stabs for C++ classes that contain a virtual function
4075 pointer contains a tilde, a %, and a type number.
4076 The type number refers to the base class (possibly this class itself) which
4077 contains the vtable pointer for the current class.
4079 This function is called when we have parsed all the method declarations,
4080 so we can look for the vptr base class info. */
4083 read_tilde_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
4084 struct objfile
*objfile
)
4088 STABS_CONTINUE (pp
, objfile
);
4090 /* If we are positioned at a ';', then skip it. */
4100 if (**pp
== '=' || **pp
== '+' || **pp
== '-')
4102 /* Obsolete flags that used to indicate the presence
4103 of constructors and/or destructors. */
4107 /* Read either a '%' or the final ';'. */
4108 if (*(*pp
)++ == '%')
4110 /* The next number is the type number of the base class
4111 (possibly our own class) which supplies the vtable for
4112 this class. Parse it out, and search that class to find
4113 its vtable pointer, and install those into TYPE_VPTR_BASETYPE
4114 and TYPE_VPTR_FIELDNO. */
4119 t
= read_type (pp
, objfile
);
4121 while (*p
!= '\0' && *p
!= ';')
4127 /* Premature end of symbol. */
4131 TYPE_VPTR_BASETYPE (type
) = t
;
4132 if (type
== t
) /* Our own class provides vtbl ptr */
4134 for (i
= TYPE_NFIELDS (t
) - 1;
4135 i
>= TYPE_N_BASECLASSES (t
);
4138 char *name
= TYPE_FIELD_NAME (t
, i
);
4139 if (!strncmp (name
, vptr_name
, sizeof (vptr_name
) - 2)
4140 && is_cplus_marker (name
[sizeof (vptr_name
) - 1]))
4142 TYPE_VPTR_FIELDNO (type
) = i
;
4146 /* Virtual function table field not found. */
4147 complain (&vtbl_notfound_complaint
, TYPE_NAME (type
));
4152 TYPE_VPTR_FIELDNO (type
) = TYPE_VPTR_FIELDNO (t
);
4163 attach_fn_fields_to_type (struct field_info
*fip
, register struct type
*type
)
4167 for (n
= TYPE_NFN_FIELDS (type
);
4168 fip
->fnlist
!= NULL
;
4169 fip
->fnlist
= fip
->fnlist
->next
)
4171 --n
; /* Circumvent Sun3 compiler bug */
4172 TYPE_FN_FIELDLISTS (type
)[n
] = fip
->fnlist
->fn_fieldlist
;
4177 /* read cfront class static data.
4178 pp points to string starting with the list of static data
4179 eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
4182 A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
4187 read_cfront_static_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
4188 struct objfile
*objfile
)
4190 struct nextfield
*new;
4193 struct symbol
*ref_static
= 0;
4195 if (**pp
== ';') /* no static data; return */
4201 /* Process each field in the list until we find the terminating ";" */
4203 /* eg: p = "as__1A ;;;" */
4204 STABS_CONTINUE (pp
, objfile
); /* handle \\ */
4205 while (**pp
!= ';' && (sname
= get_substring (pp
, ' '), sname
))
4207 ref_static
= lookup_symbol (sname
, 0, VAR_NAMESPACE
, 0, 0); /*demangled_name */
4210 static struct complaint msg
=
4212 Unable to find symbol for static data field %s\n",
4214 complain (&msg
, sname
);
4217 stype
= SYMBOL_TYPE (ref_static
);
4219 /* allocate a new fip */
4220 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
4221 make_cleanup (xfree
, new);
4222 memset (new, 0, sizeof (struct nextfield
));
4223 new->next
= fip
->list
;
4226 /* set visibility */
4227 /* FIXME! no way to tell visibility from stabs??? */
4228 new->visibility
= VISIBILITY_PUBLIC
;
4230 /* set field info into fip */
4231 fip
->list
->field
.type
= stype
;
4233 /* set bitpos & bitsize */
4234 SET_FIELD_PHYSNAME (fip
->list
->field
, savestring (sname
, strlen (sname
)));
4236 /* set name field */
4237 /* The following is code to work around cfront generated stabs.
4238 The stabs contains full mangled name for each field.
4239 We try to demangle the name and extract the field name out of it.
4244 dem
= cplus_demangle (sname
, DMGL_ANSI
| DMGL_PARAMS
);
4247 dem_p
= strrchr (dem
, ':');
4248 if (dem_p
!= 0 && *(dem_p
- 1) == ':')
4250 fip
->list
->field
.name
=
4251 obsavestring (dem_p
, strlen (dem_p
), &objfile
->type_obstack
);
4255 fip
->list
->field
.name
=
4256 obsavestring (sname
, strlen (sname
), &objfile
->type_obstack
);
4258 } /* end of code for cfront work around */
4259 } /* loop again for next static field */
4263 /* Copy structure fields to fip so attach_fields_to_type will work.
4264 type has already been created with the initial instance data fields.
4265 Now we want to be able to add the other members to the class,
4266 so we want to add them back to the fip and reattach them again
4267 once we have collected all the class members. */
4270 copy_cfront_struct_fields (struct field_info
*fip
, struct type
*type
,
4271 struct objfile
*objfile
)
4273 int nfields
= TYPE_NFIELDS (type
);
4275 struct nextfield
*new;
4277 /* Copy the fields into the list of fips and reset the types
4278 to remove the old fields */
4280 for (i
= 0; i
< nfields
; i
++)
4282 /* allocate a new fip */
4283 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
4284 make_cleanup (xfree
, new);
4285 memset (new, 0, sizeof (struct nextfield
));
4286 new->next
= fip
->list
;
4289 /* copy field info into fip */
4290 new->field
= TYPE_FIELD (type
, i
);
4291 /* set visibility */
4292 if (TYPE_FIELD_PROTECTED (type
, i
))
4293 new->visibility
= VISIBILITY_PROTECTED
;
4294 else if (TYPE_FIELD_PRIVATE (type
, i
))
4295 new->visibility
= VISIBILITY_PRIVATE
;
4297 new->visibility
= VISIBILITY_PUBLIC
;
4299 /* Now delete the fields from the type since we will be
4300 allocing new space once we get the rest of the fields
4301 in attach_fields_to_type.
4302 The pointer TYPE_FIELDS(type) is left dangling but should
4303 be freed later by objstack_free */
4304 TYPE_FIELDS (type
) = 0;
4305 TYPE_NFIELDS (type
) = 0;
4310 /* Create the vector of fields, and record how big it is.
4311 We need this info to record proper virtual function table information
4312 for this class's virtual functions. */
4315 attach_fields_to_type (struct field_info
*fip
, register struct type
*type
,
4316 struct objfile
*objfile
)
4318 register int nfields
= 0;
4319 register int non_public_fields
= 0;
4320 register struct nextfield
*scan
;
4322 /* Count up the number of fields that we have, as well as taking note of
4323 whether or not there are any non-public fields, which requires us to
4324 allocate and build the private_field_bits and protected_field_bits
4327 for (scan
= fip
->list
; scan
!= NULL
; scan
= scan
->next
)
4330 if (scan
->visibility
!= VISIBILITY_PUBLIC
)
4332 non_public_fields
++;
4336 /* Now we know how many fields there are, and whether or not there are any
4337 non-public fields. Record the field count, allocate space for the
4338 array of fields, and create blank visibility bitfields if necessary. */
4340 TYPE_NFIELDS (type
) = nfields
;
4341 TYPE_FIELDS (type
) = (struct field
*)
4342 TYPE_ALLOC (type
, sizeof (struct field
) * nfields
);
4343 memset (TYPE_FIELDS (type
), 0, sizeof (struct field
) * nfields
);
4345 if (non_public_fields
)
4347 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
4349 TYPE_FIELD_PRIVATE_BITS (type
) =
4350 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4351 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type
), nfields
);
4353 TYPE_FIELD_PROTECTED_BITS (type
) =
4354 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4355 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type
), nfields
);
4357 TYPE_FIELD_IGNORE_BITS (type
) =
4358 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4359 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type
), nfields
);
4362 /* Copy the saved-up fields into the field vector. Start from the head
4363 of the list, adding to the tail of the field array, so that they end
4364 up in the same order in the array in which they were added to the list. */
4366 while (nfields
-- > 0)
4368 TYPE_FIELD (type
, nfields
) = fip
->list
->field
;
4369 switch (fip
->list
->visibility
)
4371 case VISIBILITY_PRIVATE
:
4372 SET_TYPE_FIELD_PRIVATE (type
, nfields
);
4375 case VISIBILITY_PROTECTED
:
4376 SET_TYPE_FIELD_PROTECTED (type
, nfields
);
4379 case VISIBILITY_IGNORE
:
4380 SET_TYPE_FIELD_IGNORE (type
, nfields
);
4383 case VISIBILITY_PUBLIC
:
4387 /* Unknown visibility. Complain and treat it as public. */
4389 static struct complaint msg
=
4391 "Unknown visibility `%c' for field", 0, 0};
4392 complain (&msg
, fip
->list
->visibility
);
4396 fip
->list
= fip
->list
->next
;
4402 static struct complaint multiply_defined_struct
=
4403 {"struct/union type gets multiply defined: %s%s", 0, 0};
4406 /* Complain that the compiler has emitted more than one definition for the
4407 structure type TYPE. */
4409 complain_about_struct_wipeout (struct type
*type
)
4414 if (TYPE_TAG_NAME (type
))
4416 name
= TYPE_TAG_NAME (type
);
4417 switch (TYPE_CODE (type
))
4419 case TYPE_CODE_STRUCT
: kind
= "struct "; break;
4420 case TYPE_CODE_UNION
: kind
= "union "; break;
4421 case TYPE_CODE_ENUM
: kind
= "enum "; break;
4425 else if (TYPE_NAME (type
))
4427 name
= TYPE_NAME (type
);
4436 complain (&multiply_defined_struct
, kind
, name
);
4440 /* Read the description of a structure (or union type) and return an object
4441 describing the type.
4443 PP points to a character pointer that points to the next unconsumed token
4444 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
4445 *PP will point to "4a:1,0,32;;".
4447 TYPE points to an incomplete type that needs to be filled in.
4449 OBJFILE points to the current objfile from which the stabs information is
4450 being read. (Note that it is redundant in that TYPE also contains a pointer
4451 to this same objfile, so it might be a good idea to eliminate it. FIXME).
4454 static struct type
*
4455 read_struct_type (char **pp
, struct type
*type
, enum type_code type_code
,
4456 struct objfile
*objfile
)
4458 struct cleanup
*back_to
;
4459 struct field_info fi
;
4464 /* When describing struct/union/class types in stabs, G++ always drops
4465 all qualifications from the name. So if you've got:
4466 struct A { ... struct B { ... }; ... };
4467 then G++ will emit stabs for `struct A::B' that call it simply
4468 `struct B'. Obviously, if you've got a real top-level definition for
4469 `struct B', or other nested definitions, this is going to cause
4472 Obviously, GDB can't fix this by itself, but it can at least avoid
4473 scribbling on existing structure type objects when new definitions
4475 if (! (TYPE_CODE (type
) == TYPE_CODE_UNDEF
4476 || TYPE_STUB (type
)))
4478 complain_about_struct_wipeout (type
);
4480 /* It's probably best to return the type unchanged. */
4484 back_to
= make_cleanup (null_cleanup
, 0);
4486 INIT_CPLUS_SPECIFIC (type
);
4487 TYPE_CODE (type
) = type_code
;
4488 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
4490 /* First comes the total size in bytes. */
4494 TYPE_LENGTH (type
) = read_huge_number (pp
, 0, &nbits
);
4496 return error_type (pp
, objfile
);
4499 /* Now read the baseclasses, if any, read the regular C struct or C++
4500 class member fields, attach the fields to the type, read the C++
4501 member functions, attach them to the type, and then read any tilde
4502 field (baseclass specifier for the class holding the main vtable). */
4504 if (!read_baseclasses (&fi
, pp
, type
, objfile
)
4505 || !read_struct_fields (&fi
, pp
, type
, objfile
)
4506 || !attach_fields_to_type (&fi
, type
, objfile
)
4507 || !read_member_functions (&fi
, pp
, type
, objfile
)
4508 || !attach_fn_fields_to_type (&fi
, type
)
4509 || !read_tilde_fields (&fi
, pp
, type
, objfile
))
4511 type
= error_type (pp
, objfile
);
4514 do_cleanups (back_to
);
4518 /* Read a definition of an array type,
4519 and create and return a suitable type object.
4520 Also creates a range type which represents the bounds of that
4523 static struct type
*
4524 read_array_type (register char **pp
, register struct type
*type
,
4525 struct objfile
*objfile
)
4527 struct type
*index_type
, *element_type
, *range_type
;
4532 /* Format of an array type:
4533 "ar<index type>;lower;upper;<array_contents_type>".
4534 OS9000: "arlower,upper;<array_contents_type>".
4536 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
4537 for these, produce a type like float[][]. */
4539 #if 0 /* OBSOLETE OS9K */
4540 // OBSOLETE if (os9k_stabs)
4541 // OBSOLETE index_type = builtin_type_int;
4543 #endif /* OBSOLETE OS9K */
4545 index_type
= read_type (pp
, objfile
);
4547 /* Improper format of array type decl. */
4548 return error_type (pp
, objfile
);
4552 if (!(**pp
>= '0' && **pp
<= '9') && **pp
!= '-')
4557 #if 0 /* OBSOLETE OS9K */
4558 // OBSOLETE lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits);
4559 #else /* OBSOLETE OS9K */
4560 lower
= read_huge_number (pp
, ';', &nbits
);
4561 #endif /* OBSOLETE OS9K */
4564 return error_type (pp
, objfile
);
4566 if (!(**pp
>= '0' && **pp
<= '9') && **pp
!= '-')
4571 upper
= read_huge_number (pp
, ';', &nbits
);
4573 return error_type (pp
, objfile
);
4575 element_type
= read_type (pp
, objfile
);
4584 create_range_type ((struct type
*) NULL
, index_type
, lower
, upper
);
4585 type
= create_array_type (type
, element_type
, range_type
);
4591 /* Read a definition of an enumeration type,
4592 and create and return a suitable type object.
4593 Also defines the symbols that represent the values of the type. */
4595 static struct type
*
4596 read_enum_type (register char **pp
, register struct type
*type
,
4597 struct objfile
*objfile
)
4602 register struct symbol
*sym
;
4604 struct pending
**symlist
;
4605 struct pending
*osyms
, *syms
;
4608 int unsigned_enum
= 1;
4611 /* FIXME! The stabs produced by Sun CC merrily define things that ought
4612 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
4613 to do? For now, force all enum values to file scope. */
4614 if (within_function
)
4615 symlist
= &local_symbols
;
4618 symlist
= &file_symbols
;
4620 o_nsyms
= osyms
? osyms
->nsyms
: 0;
4622 #if 0 /* OBSOLETE OS9K */
4623 // OBSOLETE if (os9k_stabs)
4625 // OBSOLETE /* Size. Perhaps this does not have to be conditionalized on
4626 // OBSOLETE os9k_stabs (assuming the name of an enum constant can't start
4627 // OBSOLETE with a digit). */
4628 // OBSOLETE read_huge_number (pp, 0, &nbits);
4629 // OBSOLETE if (nbits != 0)
4630 // OBSOLETE return error_type (pp, objfile);
4632 #endif /* OBSOLETE OS9K */
4634 /* The aix4 compiler emits an extra field before the enum members;
4635 my guess is it's a type of some sort. Just ignore it. */
4638 /* Skip over the type. */
4642 /* Skip over the colon. */
4646 /* Read the value-names and their values.
4647 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
4648 A semicolon or comma instead of a NAME means the end. */
4649 while (**pp
&& **pp
!= ';' && **pp
!= ',')
4651 STABS_CONTINUE (pp
, objfile
);
4655 name
= obsavestring (*pp
, p
- *pp
, &objfile
->symbol_obstack
);
4657 n
= read_huge_number (pp
, ',', &nbits
);
4659 return error_type (pp
, objfile
);
4661 sym
= (struct symbol
*)
4662 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
4663 memset (sym
, 0, sizeof (struct symbol
));
4664 SYMBOL_NAME (sym
) = name
;
4665 SYMBOL_LANGUAGE (sym
) = current_subfile
->language
;
4666 SYMBOL_CLASS (sym
) = LOC_CONST
;
4667 SYMBOL_NAMESPACE (sym
) = VAR_NAMESPACE
;
4668 SYMBOL_VALUE (sym
) = n
;
4671 add_symbol_to_list (sym
, symlist
);
4676 (*pp
)++; /* Skip the semicolon. */
4678 /* Now fill in the fields of the type-structure. */
4680 TYPE_LENGTH (type
) = TARGET_INT_BIT
/ HOST_CHAR_BIT
;
4681 TYPE_CODE (type
) = TYPE_CODE_ENUM
;
4682 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
4684 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
4685 TYPE_NFIELDS (type
) = nsyms
;
4686 TYPE_FIELDS (type
) = (struct field
*)
4687 TYPE_ALLOC (type
, sizeof (struct field
) * nsyms
);
4688 memset (TYPE_FIELDS (type
), 0, sizeof (struct field
) * nsyms
);
4690 /* Find the symbols for the values and put them into the type.
4691 The symbols can be found in the symlist that we put them on
4692 to cause them to be defined. osyms contains the old value
4693 of that symlist; everything up to there was defined by us. */
4694 /* Note that we preserve the order of the enum constants, so
4695 that in something like "enum {FOO, LAST_THING=FOO}" we print
4696 FOO, not LAST_THING. */
4698 for (syms
= *symlist
, n
= nsyms
- 1; syms
; syms
= syms
->next
)
4700 int last
= syms
== osyms
? o_nsyms
: 0;
4701 int j
= syms
->nsyms
;
4702 for (; --j
>= last
; --n
)
4704 struct symbol
*xsym
= syms
->symbol
[j
];
4705 SYMBOL_TYPE (xsym
) = type
;
4706 TYPE_FIELD_NAME (type
, n
) = SYMBOL_NAME (xsym
);
4707 TYPE_FIELD_BITPOS (type
, n
) = SYMBOL_VALUE (xsym
);
4708 TYPE_FIELD_BITSIZE (type
, n
) = 0;
4717 /* Sun's ACC uses a somewhat saner method for specifying the builtin
4718 typedefs in every file (for int, long, etc):
4720 type = b <signed> <width> <format type>; <offset>; <nbits>
4722 optional format type = c or b for char or boolean.
4723 offset = offset from high order bit to start bit of type.
4724 width is # bytes in object of this type, nbits is # bits in type.
4726 The width/offset stuff appears to be for small objects stored in
4727 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
4730 static struct type
*
4731 read_sun_builtin_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4736 enum type_code code
= TYPE_CODE_INT
;
4747 return error_type (pp
, objfile
);
4751 /* For some odd reason, all forms of char put a c here. This is strange
4752 because no other type has this honor. We can safely ignore this because
4753 we actually determine 'char'acterness by the number of bits specified in
4755 Boolean forms, e.g Fortran logical*X, put a b here. */
4759 else if (**pp
== 'b')
4761 code
= TYPE_CODE_BOOL
;
4765 /* The first number appears to be the number of bytes occupied
4766 by this type, except that unsigned short is 4 instead of 2.
4767 Since this information is redundant with the third number,
4768 we will ignore it. */
4769 read_huge_number (pp
, ';', &nbits
);
4771 return error_type (pp
, objfile
);
4773 /* The second number is always 0, so ignore it too. */
4774 read_huge_number (pp
, ';', &nbits
);
4776 return error_type (pp
, objfile
);
4778 /* The third number is the number of bits for this type. */
4779 type_bits
= read_huge_number (pp
, 0, &nbits
);
4781 return error_type (pp
, objfile
);
4782 /* The type *should* end with a semicolon. If it are embedded
4783 in a larger type the semicolon may be the only way to know where
4784 the type ends. If this type is at the end of the stabstring we
4785 can deal with the omitted semicolon (but we don't have to like
4786 it). Don't bother to complain(), Sun's compiler omits the semicolon
4792 return init_type (TYPE_CODE_VOID
, 1,
4793 signed_type
? 0 : TYPE_FLAG_UNSIGNED
, (char *) NULL
,
4796 return init_type (code
,
4797 type_bits
/ TARGET_CHAR_BIT
,
4798 signed_type
? 0 : TYPE_FLAG_UNSIGNED
, (char *) NULL
,
4802 static struct type
*
4803 read_sun_floating_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4808 struct type
*rettype
;
4810 /* The first number has more details about the type, for example
4812 details
= read_huge_number (pp
, ';', &nbits
);
4814 return error_type (pp
, objfile
);
4816 /* The second number is the number of bytes occupied by this type */
4817 nbytes
= read_huge_number (pp
, ';', &nbits
);
4819 return error_type (pp
, objfile
);
4821 if (details
== NF_COMPLEX
|| details
== NF_COMPLEX16
4822 || details
== NF_COMPLEX32
)
4824 rettype
= init_type (TYPE_CODE_COMPLEX
, nbytes
, 0, NULL
, objfile
);
4825 TYPE_TARGET_TYPE (rettype
)
4826 = init_type (TYPE_CODE_FLT
, nbytes
/ 2, 0, NULL
, objfile
);
4830 return init_type (TYPE_CODE_FLT
, nbytes
, 0, NULL
, objfile
);
4833 /* Read a number from the string pointed to by *PP.
4834 The value of *PP is advanced over the number.
4835 If END is nonzero, the character that ends the
4836 number must match END, or an error happens;
4837 and that character is skipped if it does match.
4838 If END is zero, *PP is left pointing to that character.
4840 If the number fits in a long, set *BITS to 0 and return the value.
4841 If not, set *BITS to be the number of bits in the number and return 0.
4843 If encounter garbage, set *BITS to -1 and return 0. */
4846 read_huge_number (char **pp
, int end
, int *bits
)
4863 /* Leading zero means octal. GCC uses this to output values larger
4864 than an int (because that would be hard in decimal). */
4871 #if 0 /* OBSOLETE OS9K */
4872 // OBSOLETE if (os9k_stabs)
4873 // OBSOLETE upper_limit = ULONG_MAX / radix;
4875 #endif /* OBSOLETE OS9K */
4876 upper_limit
= LONG_MAX
/ radix
;
4878 while ((c
= *p
++) >= '0' && c
< ('0' + radix
))
4880 if (n
<= upper_limit
)
4883 n
+= c
- '0'; /* FIXME this overflows anyway */
4888 /* This depends on large values being output in octal, which is
4895 /* Ignore leading zeroes. */
4899 else if (c
== '2' || c
== '3')
4925 /* Large decimal constants are an error (because it is hard to
4926 count how many bits are in them). */
4932 /* -0x7f is the same as 0x80. So deal with it by adding one to
4933 the number of bits. */
4945 /* It's *BITS which has the interesting information. */
4949 static struct type
*
4950 read_range_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4952 char *orig_pp
= *pp
;
4957 struct type
*result_type
;
4958 struct type
*index_type
= NULL
;
4960 /* First comes a type we are a subrange of.
4961 In C it is usually 0, 1 or the type being defined. */
4962 if (read_type_number (pp
, rangenums
) != 0)
4963 return error_type (pp
, objfile
);
4964 self_subrange
= (rangenums
[0] == typenums
[0] &&
4965 rangenums
[1] == typenums
[1]);
4970 index_type
= read_type (pp
, objfile
);
4973 /* A semicolon should now follow; skip it. */
4977 /* The remaining two operands are usually lower and upper bounds
4978 of the range. But in some special cases they mean something else. */
4979 n2
= read_huge_number (pp
, ';', &n2bits
);
4980 n3
= read_huge_number (pp
, ';', &n3bits
);
4982 if (n2bits
== -1 || n3bits
== -1)
4983 return error_type (pp
, objfile
);
4986 goto handle_true_range
;
4988 /* If limits are huge, must be large integral type. */
4989 if (n2bits
!= 0 || n3bits
!= 0)
4991 char got_signed
= 0;
4992 char got_unsigned
= 0;
4993 /* Number of bits in the type. */
4996 /* Range from 0 to <large number> is an unsigned large integral type. */
4997 if ((n2bits
== 0 && n2
== 0) && n3bits
!= 0)
5002 /* Range from <large number> to <large number>-1 is a large signed
5003 integral type. Take care of the case where <large number> doesn't
5004 fit in a long but <large number>-1 does. */
5005 else if ((n2bits
!= 0 && n3bits
!= 0 && n2bits
== n3bits
+ 1)
5006 || (n2bits
!= 0 && n3bits
== 0
5007 && (n2bits
== sizeof (long) * HOST_CHAR_BIT
)
5014 if (got_signed
|| got_unsigned
)
5016 return init_type (TYPE_CODE_INT
, nbits
/ TARGET_CHAR_BIT
,
5017 got_unsigned
? TYPE_FLAG_UNSIGNED
: 0, NULL
,
5021 return error_type (pp
, objfile
);
5024 /* A type defined as a subrange of itself, with bounds both 0, is void. */
5025 if (self_subrange
&& n2
== 0 && n3
== 0)
5026 return init_type (TYPE_CODE_VOID
, 1, 0, NULL
, objfile
);
5028 /* If n3 is zero and n2 is positive, we want a floating type, and n2
5029 is the width in bytes.
5031 Fortran programs appear to use this for complex types also. To
5032 distinguish between floats and complex, g77 (and others?) seem
5033 to use self-subranges for the complexes, and subranges of int for
5036 Also note that for complexes, g77 sets n2 to the size of one of
5037 the member floats, not the whole complex beast. My guess is that
5038 this was to work well with pre-COMPLEX versions of gdb. */
5040 if (n3
== 0 && n2
> 0)
5042 struct type
*float_type
5043 = init_type (TYPE_CODE_FLT
, n2
, 0, NULL
, objfile
);
5047 struct type
*complex_type
=
5048 init_type (TYPE_CODE_COMPLEX
, 2 * n2
, 0, NULL
, objfile
);
5049 TYPE_TARGET_TYPE (complex_type
) = float_type
;
5050 return complex_type
;
5056 /* If the upper bound is -1, it must really be an unsigned int. */
5058 else if (n2
== 0 && n3
== -1)
5060 /* It is unsigned int or unsigned long. */
5061 /* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
5062 compatibility hack. */
5063 return init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
5064 TYPE_FLAG_UNSIGNED
, NULL
, objfile
);
5067 /* Special case: char is defined (Who knows why) as a subrange of
5068 itself with range 0-127. */
5069 else if (self_subrange
&& n2
== 0 && n3
== 127)
5070 return init_type (TYPE_CODE_INT
, 1, 0, NULL
, objfile
);
5073 /* OBSOLETE else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill */
5074 /* OBSOLETE && !self_subrange) */
5075 /* OBSOLETE goto handle_true_range; */
5078 /* We used to do this only for subrange of self or subrange of int. */
5081 /* -1 is used for the upper bound of (4 byte) "unsigned int" and
5082 "unsigned long", and we already checked for that,
5083 so don't need to test for it here. */
5086 /* n3 actually gives the size. */
5087 return init_type (TYPE_CODE_INT
, -n3
, TYPE_FLAG_UNSIGNED
,
5090 /* Is n3 == 2**(8n)-1 for some integer n? Then it's an
5091 unsigned n-byte integer. But do require n to be a power of
5092 two; we don't want 3- and 5-byte integers flying around. */
5098 for (bytes
= 0; (bits
& 0xff) == 0xff; bytes
++)
5101 && ((bytes
- 1) & bytes
) == 0) /* "bytes is a power of two" */
5102 return init_type (TYPE_CODE_INT
, bytes
, TYPE_FLAG_UNSIGNED
, NULL
,
5106 /* I think this is for Convex "long long". Since I don't know whether
5107 Convex sets self_subrange, I also accept that particular size regardless
5108 of self_subrange. */
5109 else if (n3
== 0 && n2
< 0
5111 || n2
== -TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
))
5112 return init_type (TYPE_CODE_INT
, -n2
, 0, NULL
, objfile
);
5113 else if (n2
== -n3
- 1)
5116 return init_type (TYPE_CODE_INT
, 1, 0, NULL
, objfile
);
5118 return init_type (TYPE_CODE_INT
, 2, 0, NULL
, objfile
);
5119 if (n3
== 0x7fffffff)
5120 return init_type (TYPE_CODE_INT
, 4, 0, NULL
, objfile
);
5123 /* We have a real range type on our hands. Allocate space and
5124 return a real pointer. */
5128 index_type
= builtin_type_int
;
5130 index_type
= *dbx_lookup_type (rangenums
);
5131 if (index_type
== NULL
)
5133 /* Does this actually ever happen? Is that why we are worrying
5134 about dealing with it rather than just calling error_type? */
5136 static struct type
*range_type_index
;
5138 complain (&range_type_base_complaint
, rangenums
[1]);
5139 if (range_type_index
== NULL
)
5141 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
5142 0, "range type index type", NULL
);
5143 index_type
= range_type_index
;
5146 result_type
= create_range_type ((struct type
*) NULL
, index_type
, n2
, n3
);
5147 return (result_type
);
5150 /* Read in an argument list. This is a list of types, separated by commas
5151 and terminated with END. Return the list of types read in, or (struct type
5152 **)-1 if there is an error. */
5154 static struct field
*
5155 read_args (char **pp
, int end
, struct objfile
*objfile
, int *nargsp
,
5158 /* FIXME! Remove this arbitrary limit! */
5159 struct type
*types
[1024]; /* allow for fns of 1023 parameters */
5166 /* Invalid argument list: no ','. */
5167 return (struct field
*) -1;
5169 STABS_CONTINUE (pp
, objfile
);
5170 types
[n
++] = read_type (pp
, objfile
);
5172 (*pp
)++; /* get past `end' (the ':' character) */
5174 if (TYPE_CODE (types
[n
- 1]) != TYPE_CODE_VOID
)
5182 rval
= (struct field
*) xmalloc (n
* sizeof (struct field
));
5183 memset (rval
, 0, n
* sizeof (struct field
));
5184 for (i
= 0; i
< n
; i
++)
5185 rval
[i
].type
= types
[i
];
5190 /* Common block handling. */
5192 /* List of symbols declared since the last BCOMM. This list is a tail
5193 of local_symbols. When ECOMM is seen, the symbols on the list
5194 are noted so their proper addresses can be filled in later,
5195 using the common block base address gotten from the assembler
5198 static struct pending
*common_block
;
5199 static int common_block_i
;
5201 /* Name of the current common block. We get it from the BCOMM instead of the
5202 ECOMM to match IBM documentation (even though IBM puts the name both places
5203 like everyone else). */
5204 static char *common_block_name
;
5206 /* Process a N_BCOMM symbol. The storage for NAME is not guaranteed
5207 to remain after this function returns. */
5210 common_block_start (char *name
, struct objfile
*objfile
)
5212 if (common_block_name
!= NULL
)
5214 static struct complaint msg
=
5216 "Invalid symbol data: common block within common block",
5220 common_block
= local_symbols
;
5221 common_block_i
= local_symbols
? local_symbols
->nsyms
: 0;
5222 common_block_name
= obsavestring (name
, strlen (name
),
5223 &objfile
->symbol_obstack
);
5226 /* Process a N_ECOMM symbol. */
5229 common_block_end (struct objfile
*objfile
)
5231 /* Symbols declared since the BCOMM are to have the common block
5232 start address added in when we know it. common_block and
5233 common_block_i point to the first symbol after the BCOMM in
5234 the local_symbols list; copy the list and hang it off the
5235 symbol for the common block name for later fixup. */
5238 struct pending
*new = 0;
5239 struct pending
*next
;
5242 if (common_block_name
== NULL
)
5244 static struct complaint msg
=
5245 {"ECOMM symbol unmatched by BCOMM", 0, 0};
5250 sym
= (struct symbol
*)
5251 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
5252 memset (sym
, 0, sizeof (struct symbol
));
5253 /* Note: common_block_name already saved on symbol_obstack */
5254 SYMBOL_NAME (sym
) = common_block_name
;
5255 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
5257 /* Now we copy all the symbols which have been defined since the BCOMM. */
5259 /* Copy all the struct pendings before common_block. */
5260 for (next
= local_symbols
;
5261 next
!= NULL
&& next
!= common_block
;
5264 for (j
= 0; j
< next
->nsyms
; j
++)
5265 add_symbol_to_list (next
->symbol
[j
], &new);
5268 /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is
5269 NULL, it means copy all the local symbols (which we already did
5272 if (common_block
!= NULL
)
5273 for (j
= common_block_i
; j
< common_block
->nsyms
; j
++)
5274 add_symbol_to_list (common_block
->symbol
[j
], &new);
5276 SYMBOL_TYPE (sym
) = (struct type
*) new;
5278 /* Should we be putting local_symbols back to what it was?
5281 i
= hashname (SYMBOL_NAME (sym
));
5282 SYMBOL_VALUE_CHAIN (sym
) = global_sym_chain
[i
];
5283 global_sym_chain
[i
] = sym
;
5284 common_block_name
= NULL
;
5287 /* Add a common block's start address to the offset of each symbol
5288 declared to be in it (by being between a BCOMM/ECOMM pair that uses
5289 the common block name). */
5292 fix_common_block (struct symbol
*sym
, int valu
)
5294 struct pending
*next
= (struct pending
*) SYMBOL_TYPE (sym
);
5295 for (; next
; next
= next
->next
)
5298 for (j
= next
->nsyms
- 1; j
>= 0; j
--)
5299 SYMBOL_VALUE_ADDRESS (next
->symbol
[j
]) += valu
;
5305 /* What about types defined as forward references inside of a small lexical
5307 /* Add a type to the list of undefined types to be checked through
5308 once this file has been read in. */
5311 add_undefined_type (struct type
*type
)
5313 if (undef_types_length
== undef_types_allocated
)
5315 undef_types_allocated
*= 2;
5316 undef_types
= (struct type
**)
5317 xrealloc ((char *) undef_types
,
5318 undef_types_allocated
* sizeof (struct type
*));
5320 undef_types
[undef_types_length
++] = type
;
5323 /* Go through each undefined type, see if it's still undefined, and fix it
5324 up if possible. We have two kinds of undefined types:
5326 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
5327 Fix: update array length using the element bounds
5328 and the target type's length.
5329 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
5330 yet defined at the time a pointer to it was made.
5331 Fix: Do a full lookup on the struct/union tag. */
5333 cleanup_undefined_types (void)
5337 for (type
= undef_types
; type
< undef_types
+ undef_types_length
; type
++)
5339 switch (TYPE_CODE (*type
))
5342 case TYPE_CODE_STRUCT
:
5343 case TYPE_CODE_UNION
:
5344 case TYPE_CODE_ENUM
:
5346 /* Check if it has been defined since. Need to do this here
5347 as well as in check_typedef to deal with the (legitimate in
5348 C though not C++) case of several types with the same name
5349 in different source files. */
5350 if (TYPE_STUB (*type
))
5352 struct pending
*ppt
;
5354 /* Name of the type, without "struct" or "union" */
5355 char *typename
= TYPE_TAG_NAME (*type
);
5357 if (typename
== NULL
)
5359 static struct complaint msg
=
5360 {"need a type name", 0, 0};
5364 for (ppt
= file_symbols
; ppt
; ppt
= ppt
->next
)
5366 for (i
= 0; i
< ppt
->nsyms
; i
++)
5368 struct symbol
*sym
= ppt
->symbol
[i
];
5370 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
5371 && SYMBOL_NAMESPACE (sym
) == STRUCT_NAMESPACE
5372 && (TYPE_CODE (SYMBOL_TYPE (sym
)) ==
5374 && STREQ (SYMBOL_NAME (sym
), typename
))
5375 replace_type (*type
, SYMBOL_TYPE (sym
));
5384 static struct complaint msg
=
5386 GDB internal error. cleanup_undefined_types with bad type %d.", 0, 0};
5387 complain (&msg
, TYPE_CODE (*type
));
5393 undef_types_length
= 0;
5396 /* Scan through all of the global symbols defined in the object file,
5397 assigning values to the debugging symbols that need to be assigned
5398 to. Get these symbols from the minimal symbol table. */
5401 scan_file_globals (struct objfile
*objfile
)
5404 struct minimal_symbol
*msymbol
;
5405 struct symbol
*sym
, *prev
, *rsym
;
5406 struct objfile
*resolve_objfile
;
5408 /* SVR4 based linkers copy referenced global symbols from shared
5409 libraries to the main executable.
5410 If we are scanning the symbols for a shared library, try to resolve
5411 them from the minimal symbols of the main executable first. */
5413 if (symfile_objfile
&& objfile
!= symfile_objfile
)
5414 resolve_objfile
= symfile_objfile
;
5416 resolve_objfile
= objfile
;
5420 /* Avoid expensive loop through all minimal symbols if there are
5421 no unresolved symbols. */
5422 for (hash
= 0; hash
< HASHSIZE
; hash
++)
5424 if (global_sym_chain
[hash
])
5427 if (hash
>= HASHSIZE
)
5430 for (msymbol
= resolve_objfile
->msymbols
;
5431 msymbol
&& SYMBOL_NAME (msymbol
) != NULL
;
5436 /* Skip static symbols. */
5437 switch (MSYMBOL_TYPE (msymbol
))
5449 /* Get the hash index and check all the symbols
5450 under that hash index. */
5452 hash
= hashname (SYMBOL_NAME (msymbol
));
5454 for (sym
= global_sym_chain
[hash
]; sym
;)
5456 if (SYMBOL_NAME (msymbol
)[0] == SYMBOL_NAME (sym
)[0] &&
5457 STREQ (SYMBOL_NAME (msymbol
) + 1, SYMBOL_NAME (sym
) + 1))
5460 struct alias_list
*aliases
;
5462 /* Splice this symbol out of the hash chain and
5463 assign the value we have to it. */
5466 SYMBOL_VALUE_CHAIN (prev
) = SYMBOL_VALUE_CHAIN (sym
);
5470 global_sym_chain
[hash
] = SYMBOL_VALUE_CHAIN (sym
);
5473 /* Check to see whether we need to fix up a common block. */
5474 /* Note: this code might be executed several times for
5475 the same symbol if there are multiple references. */
5477 /* If symbol has aliases, do minimal symbol fixups for each.
5478 These live aliases/references weren't added to
5479 global_sym_chain hash but may also need to be fixed up. */
5480 /* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal
5481 symbols? Still, we wouldn't want to add_to_list. */
5482 /* Now do the same for each alias of this symbol */
5484 aliases
= SYMBOL_ALIASES (sym
);
5487 if (SYMBOL_CLASS (rsym
) == LOC_BLOCK
)
5489 fix_common_block (rsym
,
5490 SYMBOL_VALUE_ADDRESS (msymbol
));
5494 SYMBOL_VALUE_ADDRESS (rsym
)
5495 = SYMBOL_VALUE_ADDRESS (msymbol
);
5497 SYMBOL_SECTION (rsym
) = SYMBOL_SECTION (msymbol
);
5500 rsym
= aliases
->sym
;
5501 aliases
= aliases
->next
;
5510 sym
= SYMBOL_VALUE_CHAIN (prev
);
5514 sym
= global_sym_chain
[hash
];
5520 sym
= SYMBOL_VALUE_CHAIN (sym
);
5524 if (resolve_objfile
== objfile
)
5526 resolve_objfile
= objfile
;
5529 /* Change the storage class of any remaining unresolved globals to
5530 LOC_UNRESOLVED and remove them from the chain. */
5531 for (hash
= 0; hash
< HASHSIZE
; hash
++)
5533 sym
= global_sym_chain
[hash
];
5537 sym
= SYMBOL_VALUE_CHAIN (sym
);
5539 /* Change the symbol address from the misleading chain value
5541 SYMBOL_VALUE_ADDRESS (prev
) = 0;
5543 /* Complain about unresolved common block symbols. */
5544 if (SYMBOL_CLASS (prev
) == LOC_STATIC
)
5545 SYMBOL_CLASS (prev
) = LOC_UNRESOLVED
;
5547 complain (&unresolved_sym_chain_complaint
,
5548 objfile
->name
, SYMBOL_NAME (prev
));
5551 memset (global_sym_chain
, 0, sizeof (global_sym_chain
));
5554 /* Initialize anything that needs initializing when starting to read
5555 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
5559 stabsread_init (void)
5563 /* Initialize anything that needs initializing when a completely new
5564 symbol file is specified (not just adding some symbols from another
5565 file, e.g. a shared library). */
5568 stabsread_new_init (void)
5570 /* Empty the hash table of global syms looking for values. */
5571 memset (global_sym_chain
, 0, sizeof (global_sym_chain
));
5574 /* Initialize anything that needs initializing at the same time as
5575 start_symtab() is called. */
5580 global_stabs
= NULL
; /* AIX COFF */
5581 /* Leave FILENUM of 0 free for builtin types and this file's types. */
5582 n_this_object_header_files
= 1;
5583 type_vector_length
= 0;
5584 type_vector
= (struct type
**) 0;
5586 /* FIXME: If common_block_name is not already NULL, we should complain(). */
5587 common_block_name
= NULL
;
5589 #if 0 /* OBSOLETE OS9K */
5590 // OBSOLETE os9k_stabs = 0;
5591 #endif /* OBSOLETE OS9K */
5594 /* Call after end_symtab() */
5601 xfree (type_vector
);
5604 type_vector_length
= 0;
5605 previous_stab_code
= 0;
5609 finish_global_stabs (struct objfile
*objfile
)
5613 patch_block_stabs (global_symbols
, global_stabs
, objfile
);
5614 xfree (global_stabs
);
5615 global_stabs
= NULL
;
5619 /* Initializer for this module */
5622 _initialize_stabsread (void)
5624 undef_types_allocated
= 20;
5625 undef_types_length
= 0;
5626 undef_types
= (struct type
**)
5627 xmalloc (undef_types_allocated
* sizeof (struct type
*));