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, 2003
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_type (char **, struct objfile
*);
110 static struct type
*read_range_type (char **, int[2], struct objfile
*);
112 static struct type
*read_sun_builtin_type (char **, int[2], struct objfile
*);
114 static struct type
*read_sun_floating_type (char **, int[2],
117 static struct type
*read_enum_type (char **, struct type
*, struct objfile
*);
119 static struct type
*rs6000_builtin_type (int);
122 read_member_functions (struct field_info
*, char **, struct type
*,
126 read_struct_fields (struct field_info
*, char **, struct type
*,
130 read_baseclasses (struct field_info
*, char **, struct type
*,
134 read_tilde_fields (struct field_info
*, char **, struct type
*,
137 static int attach_fn_fields_to_type (struct field_info
*, struct type
*);
139 static int attach_fields_to_type (struct field_info
*, struct type
*,
142 static struct type
*read_struct_type (char **, struct type
*,
146 static struct type
*read_array_type (char **, struct type
*,
149 static struct field
*read_args (char **, int, struct objfile
*, int *, int *);
151 static void add_undefined_type (struct type
*);
154 read_cpp_abbrev (struct field_info
*, char **, struct type
*,
156 #if 0 /* OBSOLETE CFront */
157 // OBSOLETE /* new functions added for cfront support */
159 // OBSOLETE static int
160 // OBSOLETE copy_cfront_struct_fields (struct field_info *, struct type *,
161 // OBSOLETE struct objfile *);
163 // OBSOLETE static char *get_cfront_method_physname (char *);
165 // OBSOLETE static int
166 // OBSOLETE read_cfront_baseclasses (struct field_info *, char **,
167 // OBSOLETE struct type *, struct objfile *);
169 // OBSOLETE static int
170 // OBSOLETE read_cfront_static_fields (struct field_info *, char **,
171 // OBSOLETE struct type *, struct objfile *);
172 // OBSOLETE static int
173 // OBSOLETE read_cfront_member_functions (struct field_info *, char **,
174 // OBSOLETE struct type *, struct objfile *);
176 // OBSOLETE /* end new functions added for cfront support */
177 #endif /* OBSOLETE CFront */
179 static char *find_name_end (char *name
);
181 static void add_live_range (struct objfile
*, struct symbol
*, CORE_ADDR
,
184 static int resolve_live_range (struct objfile
*, struct symbol
*, char *);
186 static int process_reference (char **string
);
188 static CORE_ADDR
ref_search_value (int refnum
);
190 static int resolve_symbol_reference (struct objfile
*, struct symbol
*,
193 void stabsread_clear_cache (void);
195 static const char vptr_name
[] = "_vptr$";
196 static const char vb_name
[] = "_vb$";
198 /* Define this as 1 if a pcc declaration of a char or short argument
199 gives the correct address. Otherwise assume pcc gives the
200 address of the corresponding int, which is not the same on a
201 big-endian machine. */
203 #if !defined (BELIEVE_PCC_PROMOTION)
204 #define BELIEVE_PCC_PROMOTION 0
208 invalid_cpp_abbrev_complaint (const char *arg1
)
210 complaint (&symfile_complaints
, "invalid C++ abbreviation `%s'", arg1
);
214 reg_value_complaint (int arg1
, int arg2
, const char *arg3
)
216 complaint (&symfile_complaints
,
217 "register number %d too large (max %d) in symbol %s", arg1
, arg2
,
222 stabs_general_complaint (const char *arg1
)
224 complaint (&symfile_complaints
, "%s", arg1
);
228 lrs_general_complaint (const char *arg1
)
230 complaint (&symfile_complaints
, "%s", arg1
);
233 /* Make a list of forward references which haven't been defined. */
235 static struct type
**undef_types
;
236 static int undef_types_allocated
;
237 static int undef_types_length
;
238 static struct symbol
*current_symbol
= NULL
;
240 /* Check for and handle cretinous stabs symbol name continuation! */
241 #define STABS_CONTINUE(pp,objfile) \
243 if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
244 *(pp) = next_symbol_text (objfile); \
248 /* Look up a dbx type-number pair. Return the address of the slot
249 where the type for that number-pair is stored.
250 The number-pair is in TYPENUMS.
252 This can be used for finding the type associated with that pair
253 or for associating a new type with the pair. */
255 static struct type
**
256 dbx_lookup_type (int typenums
[2])
258 register int filenum
= typenums
[0];
259 register int index
= typenums
[1];
261 register int real_filenum
;
262 register struct header_file
*f
;
265 if (filenum
== -1) /* -1,-1 is for temporary types. */
268 if (filenum
< 0 || filenum
>= n_this_object_header_files
)
270 complaint (&symfile_complaints
,
271 "Invalid symbol data: type number (%d,%d) out of range at symtab pos %d.",
272 filenum
, index
, symnum
);
280 /* Caller wants address of address of type. We think
281 that negative (rs6k builtin) types will never appear as
282 "lvalues", (nor should they), so we stuff the real type
283 pointer into a temp, and return its address. If referenced,
284 this will do the right thing. */
285 static struct type
*temp_type
;
287 temp_type
= rs6000_builtin_type (index
);
291 /* Type is defined outside of header files.
292 Find it in this object file's type vector. */
293 if (index
>= type_vector_length
)
295 old_len
= type_vector_length
;
298 type_vector_length
= INITIAL_TYPE_VECTOR_LENGTH
;
299 type_vector
= (struct type
**)
300 xmalloc (type_vector_length
* sizeof (struct type
*));
302 while (index
>= type_vector_length
)
304 type_vector_length
*= 2;
306 type_vector
= (struct type
**)
307 xrealloc ((char *) type_vector
,
308 (type_vector_length
* sizeof (struct type
*)));
309 memset (&type_vector
[old_len
], 0,
310 (type_vector_length
- old_len
) * sizeof (struct type
*));
312 return (&type_vector
[index
]);
316 real_filenum
= this_object_header_files
[filenum
];
318 if (real_filenum
>= N_HEADER_FILES (current_objfile
))
320 struct type
*temp_type
;
321 struct type
**temp_type_p
;
323 warning ("GDB internal error: bad real_filenum");
326 temp_type
= init_type (TYPE_CODE_ERROR
, 0, 0, NULL
, NULL
);
327 temp_type_p
= (struct type
**) xmalloc (sizeof (struct type
*));
328 *temp_type_p
= temp_type
;
332 f
= HEADER_FILES (current_objfile
) + real_filenum
;
334 f_orig_length
= f
->length
;
335 if (index
>= f_orig_length
)
337 while (index
>= f
->length
)
341 f
->vector
= (struct type
**)
342 xrealloc ((char *) f
->vector
, f
->length
* sizeof (struct type
*));
343 memset (&f
->vector
[f_orig_length
], 0,
344 (f
->length
- f_orig_length
) * sizeof (struct type
*));
346 return (&f
->vector
[index
]);
350 /* Make sure there is a type allocated for type numbers TYPENUMS
351 and return the type object.
352 This can create an empty (zeroed) type object.
353 TYPENUMS may be (-1, -1) to return a new type object that is not
354 put into the type vector, and so may not be referred to by number. */
357 dbx_alloc_type (int typenums
[2], struct objfile
*objfile
)
359 register struct type
**type_addr
;
361 if (typenums
[0] == -1)
363 return (alloc_type (objfile
));
366 type_addr
= dbx_lookup_type (typenums
);
368 /* If we are referring to a type not known at all yet,
369 allocate an empty type for it.
370 We will fill it in later if we find out how. */
373 *type_addr
= alloc_type (objfile
);
379 /* for all the stabs in a given stab vector, build appropriate types
380 and fix their symbols in given symbol vector. */
383 patch_block_stabs (struct pending
*symbols
, struct pending_stabs
*stabs
,
384 struct objfile
*objfile
)
394 /* for all the stab entries, find their corresponding symbols and
395 patch their types! */
397 for (ii
= 0; ii
< stabs
->count
; ++ii
)
399 name
= stabs
->stab
[ii
];
400 pp
= (char *) strchr (name
, ':');
404 pp
= (char *) strchr (pp
, ':');
406 sym
= find_symbol_in_list (symbols
, name
, pp
- name
);
409 /* FIXME-maybe: it would be nice if we noticed whether
410 the variable was defined *anywhere*, not just whether
411 it is defined in this compilation unit. But neither
412 xlc or GCC seem to need such a definition, and until
413 we do psymtabs (so that the minimal symbols from all
414 compilation units are available now), I'm not sure
415 how to get the information. */
417 /* On xcoff, if a global is defined and never referenced,
418 ld will remove it from the executable. There is then
419 a N_GSYM stab for it, but no regular (C_EXT) symbol. */
420 sym
= (struct symbol
*)
421 obstack_alloc (&objfile
->symbol_obstack
,
422 sizeof (struct symbol
));
424 memset (sym
, 0, sizeof (struct symbol
));
425 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
426 SYMBOL_CLASS (sym
) = LOC_OPTIMIZED_OUT
;
427 DEPRECATED_SYMBOL_NAME (sym
) =
428 obsavestring (name
, pp
- name
, &objfile
->symbol_obstack
);
430 if (*(pp
- 1) == 'F' || *(pp
- 1) == 'f')
432 /* I don't think the linker does this with functions,
433 so as far as I know this is never executed.
434 But it doesn't hurt to check. */
436 lookup_function_type (read_type (&pp
, objfile
));
440 SYMBOL_TYPE (sym
) = read_type (&pp
, objfile
);
442 add_symbol_to_list (sym
, &global_symbols
);
447 if (*(pp
- 1) == 'F' || *(pp
- 1) == 'f')
450 lookup_function_type (read_type (&pp
, objfile
));
454 SYMBOL_TYPE (sym
) = read_type (&pp
, objfile
);
462 /* Read a number by which a type is referred to in dbx data,
463 or perhaps read a pair (FILENUM, TYPENUM) in parentheses.
464 Just a single number N is equivalent to (0,N).
465 Return the two numbers by storing them in the vector TYPENUMS.
466 TYPENUMS will then be used as an argument to dbx_lookup_type.
468 Returns 0 for success, -1 for error. */
471 read_type_number (register char **pp
, register int *typenums
)
477 typenums
[0] = read_huge_number (pp
, ',', &nbits
);
480 typenums
[1] = read_huge_number (pp
, ')', &nbits
);
487 typenums
[1] = read_huge_number (pp
, 0, &nbits
);
495 #define VISIBILITY_PRIVATE '0' /* Stabs character for private field */
496 #define VISIBILITY_PROTECTED '1' /* Stabs character for protected fld */
497 #define VISIBILITY_PUBLIC '2' /* Stabs character for public field */
498 #define VISIBILITY_IGNORE '9' /* Optimized out or zero length */
500 #if 0 /* OBSOLETE CFront */
501 // OBSOLETE #define CFRONT_VISIBILITY_PRIVATE '2' /* Stabs character for private field */
502 // OBSOLETE #define CFRONT_VISIBILITY_PUBLIC '1' /* Stabs character for public field */
504 // OBSOLETE /* This code added to support parsing of ARM/Cfront stabs strings */
506 // OBSOLETE /* Get substring from string up to char c, advance string pointer past
507 // OBSOLETE suibstring. */
509 // OBSOLETE static char *
510 // OBSOLETE get_substring (char **p, int c)
512 // OBSOLETE char *str;
513 // OBSOLETE str = *p;
514 // OBSOLETE *p = strchr (*p, c);
522 // OBSOLETE return str;
525 // OBSOLETE /* Physname gets strcat'd onto sname in order to recreate the mangled
526 // OBSOLETE name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
527 // OBSOLETE the physname look like that of g++ - take out the initial mangling
528 // OBSOLETE eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
530 // OBSOLETE static char *
531 // OBSOLETE get_cfront_method_physname (char *fname)
533 // OBSOLETE int len = 0;
534 // OBSOLETE /* FIXME would like to make this generic for g++ too, but
535 // OBSOLETE that is already handled in read_member_funcctions */
536 // OBSOLETE char *p = fname;
538 // OBSOLETE /* search ahead to find the start of the mangled suffix */
539 // OBSOLETE if (*p == '_' && *(p + 1) == '_') /* compiler generated; probably a ctor/dtor */
541 // OBSOLETE while (p && (unsigned) ((p + 1) - fname) < strlen (fname) && *(p + 1) != '_')
542 // OBSOLETE p = strchr (p, '_');
543 // OBSOLETE if (!(p && *p == '_' && *(p + 1) == '_'))
544 // OBSOLETE error ("Invalid mangled function name %s", fname);
545 // OBSOLETE p += 2; /* advance past '__' */
547 // OBSOLETE /* struct name length and name of type should come next; advance past it */
548 // OBSOLETE while (isdigit (*p))
550 // OBSOLETE len = len * 10 + (*p - '0');
553 // OBSOLETE p += len;
555 // OBSOLETE return p;
558 // OBSOLETE static void
559 // OBSOLETE msg_unknown_complaint (const char *arg1)
561 // OBSOLETE complaint (&symfile_complaints, "Unsupported token in stabs string %s", arg1);
564 // OBSOLETE /* Read base classes within cfront class definition.
565 // OBSOLETE eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
566 // OBSOLETE ^^^^^^^^^^^^^^^^^^
568 // OBSOLETE A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
572 // OBSOLETE static int
573 // OBSOLETE read_cfront_baseclasses (struct field_info *fip, char **pp, struct type *type,
574 // OBSOLETE struct objfile *objfile)
576 // OBSOLETE int bnum = 0;
579 // OBSOLETE struct nextfield *new;
581 // OBSOLETE if (**pp == ';') /* no base classes; return */
584 // OBSOLETE return 1;
587 // OBSOLETE /* first count base classes so we can allocate space before parsing */
588 // OBSOLETE for (p = *pp; p && *p && *p != ';'; p++)
590 // OBSOLETE if (*p == ' ')
593 // OBSOLETE bnum++; /* add one more for last one */
595 // OBSOLETE /* now parse the base classes until we get to the start of the methods
596 // OBSOLETE (code extracted and munged from read_baseclasses) */
597 // OBSOLETE ALLOCATE_CPLUS_STRUCT_TYPE (type);
598 // OBSOLETE TYPE_N_BASECLASSES (type) = bnum;
600 // OBSOLETE /* allocate space */
602 // OBSOLETE int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
603 // OBSOLETE char *pointer;
605 // OBSOLETE pointer = (char *) TYPE_ALLOC (type, num_bytes);
606 // OBSOLETE TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
608 // OBSOLETE B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
610 // OBSOLETE for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
612 // OBSOLETE new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
613 // OBSOLETE make_cleanup (xfree, new);
614 // OBSOLETE memset (new, 0, sizeof (struct nextfield));
615 // OBSOLETE new->next = fip->list;
616 // OBSOLETE fip->list = new;
617 // OBSOLETE FIELD_BITSIZE (new->field) = 0; /* this should be an unpacked field! */
619 // OBSOLETE STABS_CONTINUE (pp, objfile);
621 // OBSOLETE /* virtual? eg: v2@Bvir */
622 // OBSOLETE if (**pp == 'v')
624 // OBSOLETE SET_TYPE_FIELD_VIRTUAL (type, i);
628 // OBSOLETE /* access? eg: 2@Bvir */
629 // OBSOLETE /* Note: protected inheritance not supported in cfront */
630 // OBSOLETE switch (*(*pp)++)
632 // OBSOLETE case CFRONT_VISIBILITY_PRIVATE:
633 // OBSOLETE new->visibility = VISIBILITY_PRIVATE;
635 // OBSOLETE case CFRONT_VISIBILITY_PUBLIC:
636 // OBSOLETE new->visibility = VISIBILITY_PUBLIC;
639 // OBSOLETE /* Bad visibility format. Complain and treat it as
640 // OBSOLETE public. */
642 // OBSOLETE complaint (&symfile_complaints,
643 // OBSOLETE "Unknown visibility `%c' for baseclass",
644 // OBSOLETE new->visibility);
645 // OBSOLETE new->visibility = VISIBILITY_PUBLIC;
649 // OBSOLETE /* "@" comes next - eg: @Bvir */
650 // OBSOLETE if (**pp != '@')
652 // OBSOLETE msg_unknown_complaint (*pp);
653 // OBSOLETE return 1;
658 // OBSOLETE /* Set the bit offset of the portion of the object corresponding
659 // OBSOLETE to this baseclass. Always zero in the absence of
660 // OBSOLETE multiple inheritance. */
661 // OBSOLETE /* Unable to read bit position from stabs;
662 // OBSOLETE Assuming no multiple inheritance for now FIXME! */
663 // OBSOLETE /* We may have read this in the structure definition;
664 // OBSOLETE now we should fixup the members to be the actual base classes */
665 // OBSOLETE FIELD_BITPOS (new->field) = 0;
667 // OBSOLETE /* Get the base class name and type */
669 // OBSOLETE char *bname; /* base class name */
670 // OBSOLETE struct symbol *bsym; /* base class */
671 // OBSOLETE char *p1, *p2;
672 // OBSOLETE p1 = strchr (*pp, ' ');
673 // OBSOLETE p2 = strchr (*pp, ';');
674 // OBSOLETE if (p1 < p2)
675 // OBSOLETE bname = get_substring (pp, ' ');
677 // OBSOLETE bname = get_substring (pp, ';');
678 // OBSOLETE if (!bname || !*bname)
680 // OBSOLETE msg_unknown_complaint (*pp);
681 // OBSOLETE return 1;
683 // OBSOLETE /* FIXME! attach base info to type */
684 // OBSOLETE bsym = lookup_symbol (bname, 0, STRUCT_DOMAIN, 0, 0); /*demangled_name */
685 // OBSOLETE if (bsym)
687 // OBSOLETE new->field.type = SYMBOL_TYPE (bsym);
688 // OBSOLETE new->field.name = type_name_no_tag (new->field.type);
692 // OBSOLETE complaint (&symfile_complaints, "Unable to find base type for %s",
694 // OBSOLETE return 1;
698 // OBSOLETE /* If more base classes to parse, loop again.
699 // OBSOLETE We ate the last ' ' or ';' in get_substring,
700 // OBSOLETE so on exit we will have skipped the trailing ';' */
701 // OBSOLETE /* if invalid, return 0; add code to detect - FIXME! */
703 // OBSOLETE return 1;
706 // OBSOLETE /* read cfront member functions.
707 // OBSOLETE pp points to string starting with list of functions
708 // OBSOLETE eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
709 // OBSOLETE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
710 // OBSOLETE A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
711 // OBSOLETE ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
714 // OBSOLETE static int
715 // OBSOLETE read_cfront_member_functions (struct field_info *fip, char **pp,
716 // OBSOLETE struct type *type, struct objfile *objfile)
718 // OBSOLETE /* This code extracted from read_member_functions
719 // OBSOLETE so as to do the similar thing for our funcs */
721 // OBSOLETE int nfn_fields = 0;
722 // OBSOLETE int length = 0;
723 // OBSOLETE /* Total number of member functions defined in this class. If the class
724 // OBSOLETE defines two `f' functions, and one `g' function, then this will have
725 // OBSOLETE the value 3. */
726 // OBSOLETE int total_length = 0;
728 // OBSOLETE struct next_fnfield
730 // OBSOLETE struct next_fnfield *next;
731 // OBSOLETE struct fn_field fn_field;
733 // OBSOLETE *sublist;
734 // OBSOLETE struct type *look_ahead_type;
735 // OBSOLETE struct next_fnfieldlist *new_fnlist;
736 // OBSOLETE struct next_fnfield *new_sublist;
737 // OBSOLETE char *main_fn_name;
738 // OBSOLETE char *fname;
739 // OBSOLETE struct symbol *ref_func = 0;
741 // OBSOLETE /* Process each list until we find the end of the member functions.
742 // OBSOLETE eg: p = "__ct__1AFv foo__1AFv ;;;" */
744 // OBSOLETE STABS_CONTINUE (pp, objfile); /* handle \\ */
746 // OBSOLETE while (**pp != ';' && (fname = get_substring (pp, ' '), fname))
748 // OBSOLETE int is_static = 0;
749 // OBSOLETE int sublist_count = 0;
750 // OBSOLETE char *pname;
751 // OBSOLETE if (fname[0] == '*') /* static member */
753 // OBSOLETE is_static = 1;
754 // OBSOLETE sublist_count++;
757 // OBSOLETE ref_func = lookup_symbol (fname, 0, VAR_DOMAIN, 0, 0); /* demangled name */
758 // OBSOLETE if (!ref_func)
760 // OBSOLETE complaint (&symfile_complaints,
761 // OBSOLETE "Unable to find function symbol for %s", fname);
762 // OBSOLETE continue;
764 // OBSOLETE sublist = NULL;
765 // OBSOLETE look_ahead_type = NULL;
766 // OBSOLETE length = 0;
768 // OBSOLETE new_fnlist = (struct next_fnfieldlist *)
769 // OBSOLETE xmalloc (sizeof (struct next_fnfieldlist));
770 // OBSOLETE make_cleanup (xfree, new_fnlist);
771 // OBSOLETE memset (new_fnlist, 0, sizeof (struct next_fnfieldlist));
773 // OBSOLETE /* The following is code to work around cfront generated stabs.
774 // OBSOLETE The stabs contains full mangled name for each field.
775 // OBSOLETE We try to demangle the name and extract the field name out of it. */
777 // OBSOLETE char *dem, *dem_p, *dem_args;
778 // OBSOLETE int dem_len;
779 // OBSOLETE dem = cplus_demangle (fname, DMGL_ANSI | DMGL_PARAMS);
780 // OBSOLETE if (dem != NULL)
782 // OBSOLETE dem_p = strrchr (dem, ':');
783 // OBSOLETE if (dem_p != 0 && *(dem_p - 1) == ':')
785 // OBSOLETE /* get rid of args */
786 // OBSOLETE dem_args = strchr (dem_p, '(');
787 // OBSOLETE if (dem_args == NULL)
788 // OBSOLETE dem_len = strlen (dem_p);
790 // OBSOLETE dem_len = dem_args - dem_p;
791 // OBSOLETE main_fn_name =
792 // OBSOLETE obsavestring (dem_p, dem_len, &objfile->type_obstack);
796 // OBSOLETE main_fn_name =
797 // OBSOLETE obsavestring (fname, strlen (fname), &objfile->type_obstack);
799 // OBSOLETE } /* end of code for cfront work around */
801 // OBSOLETE new_fnlist->fn_fieldlist.name = main_fn_name;
803 // OBSOLETE /*-------------------------------------------------*/
804 // OBSOLETE /* Set up the sublists
805 // OBSOLETE Sublists are stuff like args, static, visibility, etc.
806 // OBSOLETE so in ARM, we have to set that info some other way.
807 // OBSOLETE Multiple sublists happen if overloading
808 // OBSOLETE eg: foo::26=##1;:;2A.;
809 // OBSOLETE In g++, we'd loop here thru all the sublists... */
811 // OBSOLETE new_sublist =
812 // OBSOLETE (struct next_fnfield *) xmalloc (sizeof (struct next_fnfield));
813 // OBSOLETE make_cleanup (xfree, new_sublist);
814 // OBSOLETE memset (new_sublist, 0, sizeof (struct next_fnfield));
816 // OBSOLETE /* eat 1; from :;2A.; */
817 // OBSOLETE new_sublist->fn_field.type = SYMBOL_TYPE (ref_func); /* normally takes a read_type */
818 // OBSOLETE /* Make this type look like a method stub for gdb */
819 // OBSOLETE TYPE_FLAGS (new_sublist->fn_field.type) |= TYPE_FLAG_STUB;
820 // OBSOLETE TYPE_CODE (new_sublist->fn_field.type) = TYPE_CODE_METHOD;
822 // OBSOLETE /* If this is just a stub, then we don't have the real name here. */
823 // OBSOLETE if (TYPE_STUB (new_sublist->fn_field.type))
825 // OBSOLETE if (!TYPE_DOMAIN_TYPE (new_sublist->fn_field.type))
826 // OBSOLETE TYPE_DOMAIN_TYPE (new_sublist->fn_field.type) = type;
827 // OBSOLETE new_sublist->fn_field.is_stub = 1;
830 // OBSOLETE /* physname used later in mangling; eg PFs_i,5 for foo__1aFPFs_i
831 // OBSOLETE physname gets strcat'd in order to recreate the onto mangled name */
832 // OBSOLETE pname = get_cfront_method_physname (fname);
833 // OBSOLETE new_sublist->fn_field.physname = savestring (pname, strlen (pname));
836 // OBSOLETE /* Set this member function's visibility fields.
837 // OBSOLETE Unable to distinguish access from stabs definition!
838 // OBSOLETE Assuming public for now. FIXME!
839 // OBSOLETE (for private, set new_sublist->fn_field.is_private = 1,
840 // OBSOLETE for public, set new_sublist->fn_field.is_protected = 1) */
842 // OBSOLETE /* Unable to distinguish const/volatile from stabs definition!
843 // OBSOLETE Assuming normal for now. FIXME! */
845 // OBSOLETE new_sublist->fn_field.is_const = 0;
846 // OBSOLETE new_sublist->fn_field.is_volatile = 0; /* volatile not implemented in cfront */
848 // OBSOLETE /* Set virtual/static function info
849 // OBSOLETE How to get vtable offsets ?
850 // OBSOLETE Assuming normal for now FIXME!!
851 // OBSOLETE For vtables, figure out from whence this virtual function came.
852 // OBSOLETE It may belong to virtual function table of
853 // OBSOLETE one of its baseclasses.
855 // OBSOLETE new_sublist -> fn_field.voffset = vtable offset,
856 // OBSOLETE new_sublist -> fn_field.fcontext = look_ahead_type;
857 // OBSOLETE where look_ahead_type is type of baseclass */
858 // OBSOLETE if (is_static)
859 // OBSOLETE new_sublist->fn_field.voffset = VOFFSET_STATIC;
860 // OBSOLETE else /* normal member function. */
861 // OBSOLETE new_sublist->fn_field.voffset = 0;
862 // OBSOLETE new_sublist->fn_field.fcontext = 0;
865 // OBSOLETE /* Prepare new sublist */
866 // OBSOLETE new_sublist->next = sublist;
867 // OBSOLETE sublist = new_sublist;
868 // OBSOLETE length++;
870 // OBSOLETE /* In g++, we loop thu sublists - now we set from functions. */
871 // OBSOLETE new_fnlist->fn_fieldlist.fn_fields = (struct fn_field *)
872 // OBSOLETE obstack_alloc (&objfile->type_obstack,
873 // OBSOLETE sizeof (struct fn_field) * length);
874 // OBSOLETE memset (new_fnlist->fn_fieldlist.fn_fields, 0,
875 // OBSOLETE sizeof (struct fn_field) * length);
876 // OBSOLETE for (i = length; (i--, sublist); sublist = sublist->next)
878 // OBSOLETE new_fnlist->fn_fieldlist.fn_fields[i] = sublist->fn_field;
881 // OBSOLETE new_fnlist->fn_fieldlist.length = length;
882 // OBSOLETE new_fnlist->next = fip->fnlist;
883 // OBSOLETE fip->fnlist = new_fnlist;
884 // OBSOLETE nfn_fields++;
885 // OBSOLETE total_length += length;
886 // OBSOLETE STABS_CONTINUE (pp, objfile); /* handle \\ */
887 // OBSOLETE } /* end of loop */
889 // OBSOLETE if (nfn_fields)
891 // OBSOLETE /* type should already have space */
892 // OBSOLETE TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
893 // OBSOLETE TYPE_ALLOC (type, sizeof (struct fn_fieldlist) * nfn_fields);
894 // OBSOLETE memset (TYPE_FN_FIELDLISTS (type), 0,
895 // OBSOLETE sizeof (struct fn_fieldlist) * nfn_fields);
896 // OBSOLETE TYPE_NFN_FIELDS (type) = nfn_fields;
897 // OBSOLETE TYPE_NFN_FIELDS_TOTAL (type) = total_length;
900 // OBSOLETE /* end of scope for reading member func */
902 // OBSOLETE /* eg: ";;" */
904 // OBSOLETE /* Skip trailing ';' and bump count of number of fields seen */
905 // OBSOLETE if (**pp == ';')
908 // OBSOLETE return 0;
909 // OBSOLETE return 1;
912 // OBSOLETE /* This routine fixes up partial cfront types that were created
913 // OBSOLETE while parsing the stabs. The main need for this function is
914 // OBSOLETE to add information such as methods to classes.
915 // OBSOLETE Examples of "p": "sA;;__ct__1AFv foo__1AFv ;;;" */
917 // OBSOLETE resolve_cfront_continuation (struct objfile *objfile, struct symbol *sym,
920 // OBSOLETE struct symbol *ref_sym = 0;
921 // OBSOLETE char *sname;
922 // OBSOLETE /* snarfed from read_struct_type */
923 // OBSOLETE struct field_info fi;
924 // OBSOLETE struct type *type;
925 // OBSOLETE struct cleanup *back_to;
927 // OBSOLETE /* Need to make sure that fi isn't gunna conflict with struct
928 // OBSOLETE in case struct already had some fnfs */
929 // OBSOLETE fi.list = NULL;
930 // OBSOLETE fi.fnlist = NULL;
931 // OBSOLETE back_to = make_cleanup (null_cleanup, 0);
933 // OBSOLETE /* We only accept structs, classes and unions at the moment.
934 // OBSOLETE Other continuation types include t (typedef), r (long dbl), ...
935 // OBSOLETE We may want to add support for them as well;
936 // OBSOLETE right now they are handled by duplicating the symbol information
937 // OBSOLETE into the type information (see define_symbol) */
938 // OBSOLETE if (*p != 's' /* structs */
939 // OBSOLETE && *p != 'c' /* class */
940 // OBSOLETE && *p != 'u') /* union */
941 // OBSOLETE return 0; /* only handle C++ types */
944 // OBSOLETE /* Get symbol typs name and validate
945 // OBSOLETE eg: p = "A;;__ct__1AFv foo__1AFv ;;;" */
946 // OBSOLETE sname = get_substring (&p, ';');
947 // OBSOLETE if (!sname || strcmp (sname, DEPRECATED_SYMBOL_NAME (sym)))
948 // OBSOLETE error ("Internal error: base symbol type name does not match\n");
950 // OBSOLETE /* Find symbol's internal gdb reference using demangled_name.
951 // OBSOLETE This is the real sym that we want;
952 // OBSOLETE sym was a temp hack to make debugger happy */
953 // OBSOLETE ref_sym = lookup_symbol (DEPRECATED_SYMBOL_NAME (sym), 0, STRUCT_DOMAIN, 0, 0);
954 // OBSOLETE type = SYMBOL_TYPE (ref_sym);
957 // OBSOLETE /* Now read the baseclasses, if any, read the regular C struct or C++
958 // OBSOLETE class member fields, attach the fields to the type, read the C++
959 // OBSOLETE member functions, attach them to the type, and then read any tilde
960 // OBSOLETE field (baseclass specifier for the class holding the main vtable). */
962 // OBSOLETE if (!read_cfront_baseclasses (&fi, &p, type, objfile)
963 // OBSOLETE /* g++ does this next, but cfront already did this:
964 // OBSOLETE || !read_struct_fields (&fi, &p, type, objfile) */
965 // OBSOLETE || !copy_cfront_struct_fields (&fi, type, objfile)
966 // OBSOLETE || !read_cfront_member_functions (&fi, &p, type, objfile)
967 // OBSOLETE || !read_cfront_static_fields (&fi, &p, type, objfile)
968 // OBSOLETE || !attach_fields_to_type (&fi, type, objfile)
969 // OBSOLETE || !attach_fn_fields_to_type (&fi, type)
970 // OBSOLETE /* g++ does this next, but cfront doesn't seem to have this:
971 // OBSOLETE || !read_tilde_fields (&fi, &p, type, objfile) */
974 // OBSOLETE type = error_type (&p, objfile);
977 // OBSOLETE do_cleanups (back_to);
978 // OBSOLETE return 0;
980 // OBSOLETE /* End of code added to support parsing of ARM/Cfront stabs strings */
981 #endif /* OBSOLETE CFront */
983 /* This routine fixes up symbol references/aliases to point to the original
984 symbol definition. Returns 0 on failure, non-zero on success. */
987 resolve_symbol_reference (struct objfile
*objfile
, struct symbol
*sym
, char *p
)
990 struct symbol
*ref_sym
= 0;
991 struct alias_list
*alias
;
993 /* If this is not a symbol reference return now. */
997 /* Use "#<num>" as the name; we'll fix the name later.
998 We stored the original symbol name as "#<id>=<name>"
999 so we can now search for "#<id>" to resolving the reference.
1000 We'll fix the names later by removing the "#<id>" or "#<id>=" */
1002 /*---------------------------------------------------------*/
1003 /* Get the reference id number, and
1004 advance p past the names so we can parse the rest.
1005 eg: id=2 for p : "2=", "2=z:r(0,1)" "2:r(0,1);l(#5,#6),l(#7,#4)" */
1006 /*---------------------------------------------------------*/
1008 /* This gets reference name from string. sym may not have a name. */
1010 /* Get the reference number associated with the reference id in the
1011 gdb stab string. From that reference number, get the main/primary
1012 symbol for this alias. */
1013 refnum
= process_reference (&p
);
1014 ref_sym
= ref_search (refnum
);
1017 lrs_general_complaint ("symbol for reference not found");
1021 /* Parse the stab of the referencing symbol
1022 now that we have the referenced symbol.
1023 Add it as a new symbol and a link back to the referenced symbol.
1024 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1027 /* If the stab symbol table and string contain:
1028 RSYM 0 5 00000000 868 #15=z:r(0,1)
1029 LBRAC 0 0 00000000 899 #5=
1030 SLINE 0 16 00000003 923 #6=
1031 Then the same symbols can be later referenced by:
1032 RSYM 0 5 00000000 927 #15:r(0,1);l(#5,#6)
1033 This is used in live range splitting to:
1034 1) specify that a symbol (#15) is actually just a new storage
1035 class for a symbol (#15=z) which was previously defined.
1036 2) specify that the beginning and ending ranges for a symbol
1037 (#15) are the values of the beginning (#5) and ending (#6)
1040 /* Read number as reference id.
1041 eg: p : "=", "=z:r(0,1)" ":r(0,1);l(#5,#6),l(#7,#4)" */
1042 /* FIXME! Might I want to use SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
1043 in case of "l(0,0)"? */
1045 /*--------------------------------------------------*/
1046 /* Add this symbol to the reference list. */
1047 /*--------------------------------------------------*/
1049 alias
= (struct alias_list
*) obstack_alloc (&objfile
->type_obstack
,
1050 sizeof (struct alias_list
));
1053 lrs_general_complaint ("Unable to allocate alias list memory");
1060 if (!SYMBOL_ALIASES (ref_sym
))
1062 SYMBOL_ALIASES (ref_sym
) = alias
;
1066 struct alias_list
*temp
;
1068 /* Get to the end of the list. */
1069 for (temp
= SYMBOL_ALIASES (ref_sym
);
1076 /* Want to fix up name so that other functions (eg. valops)
1077 will correctly print the name.
1078 Don't add_symbol_to_list so that lookup_symbol won't find it.
1079 nope... needed for fixups. */
1080 DEPRECATED_SYMBOL_NAME (sym
) = DEPRECATED_SYMBOL_NAME (ref_sym
);
1086 /* Structure for storing pointers to reference definitions for fast lookup
1087 during "process_later". */
1096 #define MAX_CHUNK_REFS 100
1097 #define REF_CHUNK_SIZE (MAX_CHUNK_REFS * sizeof (struct ref_map))
1098 #define REF_MAP_SIZE(ref_chunk) ((ref_chunk) * REF_CHUNK_SIZE)
1100 static struct ref_map
*ref_map
;
1102 /* Ptr to free cell in chunk's linked list. */
1103 static int ref_count
= 0;
1105 /* Number of chunks malloced. */
1106 static int ref_chunk
= 0;
1108 /* This file maintains a cache of stabs aliases found in the symbol
1109 table. If the symbol table changes, this cache must be cleared
1110 or we are left holding onto data in invalid obstacks. */
1112 stabsread_clear_cache (void)
1118 /* Create array of pointers mapping refids to symbols and stab strings.
1119 Add pointers to reference definition symbols and/or their values as we
1120 find them, using their reference numbers as our index.
1121 These will be used later when we resolve references. */
1123 ref_add (int refnum
, struct symbol
*sym
, char *stabs
, CORE_ADDR value
)
1127 if (refnum
>= ref_count
)
1128 ref_count
= refnum
+ 1;
1129 if (ref_count
> ref_chunk
* MAX_CHUNK_REFS
)
1131 int new_slots
= ref_count
- ref_chunk
* MAX_CHUNK_REFS
;
1132 int new_chunks
= new_slots
/ MAX_CHUNK_REFS
+ 1;
1133 ref_map
= (struct ref_map
*)
1134 xrealloc (ref_map
, REF_MAP_SIZE (ref_chunk
+ new_chunks
));
1135 memset (ref_map
+ ref_chunk
* MAX_CHUNK_REFS
, 0, new_chunks
* REF_CHUNK_SIZE
);
1136 ref_chunk
+= new_chunks
;
1138 ref_map
[refnum
].stabs
= stabs
;
1139 ref_map
[refnum
].sym
= sym
;
1140 ref_map
[refnum
].value
= value
;
1143 /* Return defined sym for the reference REFNUM. */
1145 ref_search (int refnum
)
1147 if (refnum
< 0 || refnum
> ref_count
)
1149 return ref_map
[refnum
].sym
;
1152 /* Return value for the reference REFNUM. */
1155 ref_search_value (int refnum
)
1157 if (refnum
< 0 || refnum
> ref_count
)
1159 return ref_map
[refnum
].value
;
1162 /* Parse a reference id in STRING and return the resulting
1163 reference number. Move STRING beyond the reference id. */
1166 process_reference (char **string
)
1171 if (**string
!= '#')
1174 /* Advance beyond the initial '#'. */
1177 /* Read number as reference id. */
1178 while (*p
&& isdigit (*p
))
1180 refnum
= refnum
* 10 + *p
- '0';
1187 /* If STRING defines a reference, store away a pointer to the reference
1188 definition for later use. Return the reference number. */
1191 symbol_reference_defined (char **string
)
1196 refnum
= process_reference (&p
);
1198 /* Defining symbols end in '=' */
1201 /* Symbol is being defined here. */
1207 /* Must be a reference. Either the symbol has already been defined,
1208 or this is a forward reference to it. */
1216 define_symbol (CORE_ADDR valu
, char *string
, int desc
, int type
,
1217 struct objfile
*objfile
)
1219 register struct symbol
*sym
;
1220 char *p
= (char *) find_name_end (string
);
1225 /* We would like to eliminate nameless symbols, but keep their types.
1226 E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
1227 to type 2, but, should not create a symbol to address that type. Since
1228 the symbol will be nameless, there is no way any user can refer to it. */
1232 /* Ignore syms with empty names. */
1236 /* Ignore old-style symbols from cc -go */
1243 p
= strchr (p
, ':');
1246 /* If a nameless stab entry, all we need is the type, not the symbol.
1247 e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
1248 nameless
= (p
== string
|| ((string
[0] == ' ') && (string
[1] == ':')));
1250 current_symbol
= sym
= (struct symbol
*)
1251 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
1252 memset (sym
, 0, sizeof (struct symbol
));
1254 switch (type
& N_TYPE
)
1257 SYMBOL_SECTION (sym
) = SECT_OFF_TEXT (objfile
);
1260 SYMBOL_SECTION (sym
) = SECT_OFF_DATA (objfile
);
1263 SYMBOL_SECTION (sym
) = SECT_OFF_BSS (objfile
);
1267 if (processing_gcc_compilation
)
1269 /* GCC 2.x puts the line number in desc. SunOS apparently puts in the
1270 number of bytes occupied by a type or object, which we ignore. */
1271 SYMBOL_LINE (sym
) = desc
;
1275 SYMBOL_LINE (sym
) = 0; /* unknown */
1278 if (is_cplus_marker (string
[0]))
1280 /* Special GNU C++ names. */
1284 DEPRECATED_SYMBOL_NAME (sym
) = obsavestring ("this", strlen ("this"),
1285 &objfile
->symbol_obstack
);
1288 case 'v': /* $vtbl_ptr_type */
1289 /* Was: DEPRECATED_SYMBOL_NAME (sym) = "vptr"; */
1293 DEPRECATED_SYMBOL_NAME (sym
) = obsavestring ("eh_throw", strlen ("eh_throw"),
1294 &objfile
->symbol_obstack
);
1298 /* This was an anonymous type that was never fixed up. */
1301 #ifdef STATIC_TRANSFORM_NAME
1303 /* SunPRO (3.0 at least) static variable encoding. */
1308 complaint (&symfile_complaints
, "Unknown C++ symbol name `%s'",
1310 goto normal
; /* Do *something* with it */
1313 else if (string
[0] == '#')
1315 /* Special GNU C extension for referencing symbols. */
1319 /* If STRING defines a new reference id, then add it to the
1320 reference map. Else it must be referring to a previously
1321 defined symbol, so add it to the alias list of the previously
1324 refnum
= symbol_reference_defined (&s
);
1326 ref_add (refnum
, sym
, string
, SYMBOL_VALUE (sym
));
1327 else if (!resolve_symbol_reference (objfile
, sym
, string
))
1330 /* S..P contains the name of the symbol. We need to store
1331 the correct name into DEPRECATED_SYMBOL_NAME. */
1336 SYMBOL_SET_NAMES (sym
, s
, nlen
, objfile
);
1338 /* FIXME! Want DEPRECATED_SYMBOL_NAME (sym) = 0;
1339 Get error if leave name 0. So give it something. */
1342 SYMBOL_SET_NAMES (sym
, string
, nlen
, objfile
);
1345 /* Advance STRING beyond the reference id. */
1351 SYMBOL_LANGUAGE (sym
) = current_subfile
->language
;
1352 SYMBOL_SET_NAMES (sym
, string
, p
- string
, objfile
);
1356 /* Determine the type of name being defined. */
1358 /* Getting GDB to correctly skip the symbol on an undefined symbol
1359 descriptor and not ever dump core is a very dodgy proposition if
1360 we do things this way. I say the acorn RISC machine can just
1361 fix their compiler. */
1362 /* The Acorn RISC machine's compiler can put out locals that don't
1363 start with "234=" or "(3,4)=", so assume anything other than the
1364 deftypes we know how to handle is a local. */
1365 if (!strchr ("cfFGpPrStTvVXCR", *p
))
1367 if (isdigit (*p
) || *p
== '(' || *p
== '-')
1376 /* c is a special case, not followed by a type-number.
1377 SYMBOL:c=iVALUE for an integer constant symbol.
1378 SYMBOL:c=rVALUE for a floating constant symbol.
1379 SYMBOL:c=eTYPE,INTVALUE for an enum constant symbol.
1380 e.g. "b:c=e6,0" for "const b = blob1"
1381 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1384 SYMBOL_CLASS (sym
) = LOC_CONST
;
1385 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1386 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1387 add_symbol_to_list (sym
, &file_symbols
);
1395 double d
= atof (p
);
1398 /* FIXME-if-picky-about-floating-accuracy: Should be using
1399 target arithmetic to get the value. real.c in GCC
1400 probably has the necessary code. */
1402 /* FIXME: lookup_fundamental_type is a hack. We should be
1403 creating a type especially for the type of float constants.
1404 Problem is, what type should it be?
1406 Also, what should the name of this type be? Should we
1407 be using 'S' constants (see stabs.texinfo) instead? */
1409 SYMBOL_TYPE (sym
) = lookup_fundamental_type (objfile
,
1412 obstack_alloc (&objfile
->symbol_obstack
,
1413 TYPE_LENGTH (SYMBOL_TYPE (sym
)));
1414 store_typed_floating (dbl_valu
, SYMBOL_TYPE (sym
), d
);
1415 SYMBOL_VALUE_BYTES (sym
) = dbl_valu
;
1416 SYMBOL_CLASS (sym
) = LOC_CONST_BYTES
;
1421 /* Defining integer constants this way is kind of silly,
1422 since 'e' constants allows the compiler to give not
1423 only the value, but the type as well. C has at least
1424 int, long, unsigned int, and long long as constant
1425 types; other languages probably should have at least
1426 unsigned as well as signed constants. */
1428 /* We just need one int constant type for all objfiles.
1429 It doesn't depend on languages or anything (arguably its
1430 name should be a language-specific name for a type of
1431 that size, but I'm inclined to say that if the compiler
1432 wants a nice name for the type, it can use 'e'). */
1433 static struct type
*int_const_type
;
1435 /* Yes, this is as long as a *host* int. That is because we
1437 if (int_const_type
== NULL
)
1439 init_type (TYPE_CODE_INT
,
1440 sizeof (int) * HOST_CHAR_BIT
/ TARGET_CHAR_BIT
, 0,
1442 (struct objfile
*) NULL
);
1443 SYMBOL_TYPE (sym
) = int_const_type
;
1444 SYMBOL_VALUE (sym
) = atoi (p
);
1445 SYMBOL_CLASS (sym
) = LOC_CONST
;
1449 /* SYMBOL:c=eTYPE,INTVALUE for a constant symbol whose value
1450 can be represented as integral.
1451 e.g. "b:c=e6,0" for "const b = blob1"
1452 (where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
1454 SYMBOL_CLASS (sym
) = LOC_CONST
;
1455 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1459 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1464 /* If the value is too big to fit in an int (perhaps because
1465 it is unsigned), or something like that, we silently get
1466 a bogus value. The type and everything else about it is
1467 correct. Ideally, we should be using whatever we have
1468 available for parsing unsigned and long long values,
1470 SYMBOL_VALUE (sym
) = atoi (p
);
1475 SYMBOL_CLASS (sym
) = LOC_CONST
;
1476 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
1479 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1480 add_symbol_to_list (sym
, &file_symbols
);
1484 /* The name of a caught exception. */
1485 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1486 SYMBOL_CLASS (sym
) = LOC_LABEL
;
1487 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1488 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
1489 add_symbol_to_list (sym
, &local_symbols
);
1493 /* A static function definition. */
1494 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1495 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
1496 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1497 add_symbol_to_list (sym
, &file_symbols
);
1498 /* fall into process_function_types. */
1500 process_function_types
:
1501 /* Function result types are described as the result type in stabs.
1502 We need to convert this to the function-returning-type-X type
1503 in GDB. E.g. "int" is converted to "function returning int". */
1504 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_FUNC
)
1505 SYMBOL_TYPE (sym
) = lookup_function_type (SYMBOL_TYPE (sym
));
1507 /* All functions in C++ have prototypes. Stabs does not offer an
1508 explicit way to identify prototyped or unprototyped functions,
1509 but both GCC and Sun CC emit stabs for the "call-as" type rather
1510 than the "declared-as" type for unprototyped functions, so
1511 we treat all functions as if they were prototyped. This is used
1512 primarily for promotion when calling the function from GDB. */
1513 TYPE_FLAGS (SYMBOL_TYPE (sym
)) |= TYPE_FLAG_PROTOTYPED
;
1515 /* fall into process_prototype_types */
1517 process_prototype_types
:
1518 /* Sun acc puts declared types of arguments here. */
1521 struct type
*ftype
= SYMBOL_TYPE (sym
);
1526 /* Obtain a worst case guess for the number of arguments
1527 by counting the semicolons. */
1534 /* Allocate parameter information fields and fill them in. */
1535 TYPE_FIELDS (ftype
) = (struct field
*)
1536 TYPE_ALLOC (ftype
, nsemi
* sizeof (struct field
));
1541 /* A type number of zero indicates the start of varargs.
1542 FIXME: GDB currently ignores vararg functions. */
1543 if (p
[0] == '0' && p
[1] == '\0')
1545 ptype
= read_type (&p
, objfile
);
1547 /* The Sun compilers mark integer arguments, which should
1548 be promoted to the width of the calling conventions, with
1549 a type which references itself. This type is turned into
1550 a TYPE_CODE_VOID type by read_type, and we have to turn
1551 it back into builtin_type_int here.
1552 FIXME: Do we need a new builtin_type_promoted_int_arg ? */
1553 if (TYPE_CODE (ptype
) == TYPE_CODE_VOID
)
1554 ptype
= builtin_type_int
;
1555 TYPE_FIELD_TYPE (ftype
, nparams
) = ptype
;
1556 TYPE_FIELD_ARTIFICIAL (ftype
, nparams
++) = 0;
1558 TYPE_NFIELDS (ftype
) = nparams
;
1559 TYPE_FLAGS (ftype
) |= TYPE_FLAG_PROTOTYPED
;
1564 /* A global function definition. */
1565 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1566 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
1567 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1568 add_symbol_to_list (sym
, &global_symbols
);
1569 goto process_function_types
;
1572 /* For a class G (global) symbol, it appears that the
1573 value is not correct. It is necessary to search for the
1574 corresponding linker definition to find the value.
1575 These definitions appear at the end of the namelist. */
1576 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1577 SYMBOL_CLASS (sym
) = LOC_STATIC
;
1578 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1579 /* Don't add symbol references to global_sym_chain.
1580 Symbol references don't have valid names and wont't match up with
1581 minimal symbols when the global_sym_chain is relocated.
1582 We'll fixup symbol references when we fixup the defining symbol. */
1583 if (DEPRECATED_SYMBOL_NAME (sym
) && DEPRECATED_SYMBOL_NAME (sym
)[0] != '#')
1585 i
= hashname (DEPRECATED_SYMBOL_NAME (sym
));
1586 SYMBOL_VALUE_CHAIN (sym
) = global_sym_chain
[i
];
1587 global_sym_chain
[i
] = sym
;
1589 add_symbol_to_list (sym
, &global_symbols
);
1592 /* This case is faked by a conditional above,
1593 when there is no code letter in the dbx data.
1594 Dbx data never actually contains 'l'. */
1597 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1598 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
1599 SYMBOL_VALUE (sym
) = valu
;
1600 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1601 add_symbol_to_list (sym
, &local_symbols
);
1606 /* pF is a two-letter code that means a function parameter in Fortran.
1607 The type-number specifies the type of the return value.
1608 Translate it into a pointer-to-function type. */
1612 = lookup_pointer_type
1613 (lookup_function_type (read_type (&p
, objfile
)));
1616 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1618 SYMBOL_CLASS (sym
) = LOC_ARG
;
1619 SYMBOL_VALUE (sym
) = valu
;
1620 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1621 add_symbol_to_list (sym
, &local_symbols
);
1623 if (TARGET_BYTE_ORDER
!= BFD_ENDIAN_BIG
)
1625 /* On little-endian machines, this crud is never necessary,
1626 and, if the extra bytes contain garbage, is harmful. */
1630 /* If it's gcc-compiled, if it says `short', believe it. */
1631 if (processing_gcc_compilation
|| BELIEVE_PCC_PROMOTION
)
1634 if (!BELIEVE_PCC_PROMOTION
)
1636 /* This is the signed type which arguments get promoted to. */
1637 static struct type
*pcc_promotion_type
;
1638 /* This is the unsigned type which arguments get promoted to. */
1639 static struct type
*pcc_unsigned_promotion_type
;
1641 /* Call it "int" because this is mainly C lossage. */
1642 if (pcc_promotion_type
== NULL
)
1643 pcc_promotion_type
=
1644 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
1647 if (pcc_unsigned_promotion_type
== NULL
)
1648 pcc_unsigned_promotion_type
=
1649 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
1650 TYPE_FLAG_UNSIGNED
, "unsigned int", NULL
);
1652 if (BELIEVE_PCC_PROMOTION_TYPE
)
1654 /* This is defined on machines (e.g. sparc) where we
1655 should believe the type of a PCC 'short' argument,
1656 but shouldn't believe the address (the address is the
1657 address of the corresponding int).
1659 My guess is that this correction, as opposed to
1660 changing the parameter to an 'int' (as done below,
1661 for PCC on most machines), is the right thing to do
1662 on all machines, but I don't want to risk breaking
1663 something that already works. On most PCC machines,
1664 the sparc problem doesn't come up because the calling
1665 function has to zero the top bytes (not knowing
1666 whether the called function wants an int or a short),
1667 so there is little practical difference between an
1668 int and a short (except perhaps what happens when the
1669 GDB user types "print short_arg = 0x10000;").
1671 Hacked for SunOS 4.1 by gnu@cygnus.com. In 4.1, the
1672 compiler actually produces the correct address (we
1673 don't need to fix it up). I made this code adapt so
1674 that it will offset the symbol if it was pointing at
1675 an int-aligned location and not otherwise. This way
1676 you can use the same gdb for 4.0.x and 4.1 systems.
1678 If the parameter is shorter than an int, and is
1679 integral (e.g. char, short, or unsigned equivalent),
1680 and is claimed to be passed on an integer boundary,
1681 don't believe it! Offset the parameter's address to
1682 the tail-end of that integer. */
1684 if (TYPE_LENGTH (SYMBOL_TYPE (sym
)) < TYPE_LENGTH (pcc_promotion_type
)
1685 && TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_INT
1686 && 0 == SYMBOL_VALUE (sym
) % TYPE_LENGTH (pcc_promotion_type
))
1688 SYMBOL_VALUE (sym
) += TYPE_LENGTH (pcc_promotion_type
)
1689 - TYPE_LENGTH (SYMBOL_TYPE (sym
));
1695 /* If PCC says a parameter is a short or a char,
1696 it is really an int. */
1697 if (TYPE_LENGTH (SYMBOL_TYPE (sym
)) < TYPE_LENGTH (pcc_promotion_type
)
1698 && TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_INT
)
1701 TYPE_UNSIGNED (SYMBOL_TYPE (sym
))
1702 ? pcc_unsigned_promotion_type
1703 : pcc_promotion_type
;
1710 /* acc seems to use P to declare the prototypes of functions that
1711 are referenced by this file. gdb is not prepared to deal
1712 with this extra information. FIXME, it ought to. */
1715 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1716 goto process_prototype_types
;
1721 /* Parameter which is in a register. */
1722 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1723 SYMBOL_CLASS (sym
) = LOC_REGPARM
;
1724 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
1725 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
1727 reg_value_complaint (SYMBOL_VALUE (sym
),
1728 NUM_REGS
+ NUM_PSEUDO_REGS
,
1729 SYMBOL_PRINT_NAME (sym
));
1730 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
1732 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1733 add_symbol_to_list (sym
, &local_symbols
);
1737 /* Register variable (either global or local). */
1738 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1739 SYMBOL_CLASS (sym
) = LOC_REGISTER
;
1740 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
1741 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
1743 reg_value_complaint (SYMBOL_VALUE (sym
),
1744 NUM_REGS
+ NUM_PSEUDO_REGS
,
1745 SYMBOL_PRINT_NAME (sym
));
1746 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
1748 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1749 if (within_function
)
1751 /* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
1752 name to represent an argument passed in a register.
1753 GCC uses 'P' for the same case. So if we find such a symbol pair
1754 we combine it into one 'P' symbol. For Sun cc we need to do this
1755 regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
1756 the 'p' symbol even if it never saves the argument onto the stack.
1758 On most machines, we want to preserve both symbols, so that
1759 we can still get information about what is going on with the
1760 stack (VAX for computing args_printed, using stack slots instead
1761 of saved registers in backtraces, etc.).
1763 Note that this code illegally combines
1764 main(argc) struct foo argc; { register struct foo argc; }
1765 but this case is considered pathological and causes a warning
1766 from a decent compiler. */
1769 && local_symbols
->nsyms
> 0
1770 #ifndef USE_REGISTER_NOT_ARG
1771 && REG_STRUCT_HAS_ADDR_P ()
1772 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation
,
1774 && (TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_STRUCT
1775 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_UNION
1776 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_SET
1777 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_BITSTRING
)
1781 struct symbol
*prev_sym
;
1782 prev_sym
= local_symbols
->symbol
[local_symbols
->nsyms
- 1];
1783 if ((SYMBOL_CLASS (prev_sym
) == LOC_REF_ARG
1784 || SYMBOL_CLASS (prev_sym
) == LOC_ARG
)
1785 && STREQ (DEPRECATED_SYMBOL_NAME (prev_sym
), DEPRECATED_SYMBOL_NAME (sym
)))
1787 SYMBOL_CLASS (prev_sym
) = LOC_REGPARM
;
1788 /* Use the type from the LOC_REGISTER; that is the type
1789 that is actually in that register. */
1790 SYMBOL_TYPE (prev_sym
) = SYMBOL_TYPE (sym
);
1791 SYMBOL_VALUE (prev_sym
) = SYMBOL_VALUE (sym
);
1796 add_symbol_to_list (sym
, &local_symbols
);
1799 add_symbol_to_list (sym
, &file_symbols
);
1803 /* Static symbol at top level of file */
1804 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1805 SYMBOL_CLASS (sym
) = LOC_STATIC
;
1806 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
1807 #ifdef STATIC_TRANSFORM_NAME
1808 if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym
)))
1810 struct minimal_symbol
*msym
;
1811 msym
= lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym
), NULL
, objfile
);
1814 DEPRECATED_SYMBOL_NAME (sym
) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym
));
1815 SYMBOL_VALUE_ADDRESS (sym
) = SYMBOL_VALUE_ADDRESS (msym
);
1819 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1820 add_symbol_to_list (sym
, &file_symbols
);
1825 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1827 /* For a nameless type, we don't want a create a symbol, thus we
1828 did not use `sym'. Return without further processing. */
1832 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
1833 SYMBOL_VALUE (sym
) = valu
;
1834 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1835 /* C++ vagaries: we may have a type which is derived from
1836 a base type which did not have its name defined when the
1837 derived class was output. We fill in the derived class's
1838 base part member's name here in that case. */
1839 if (TYPE_NAME (SYMBOL_TYPE (sym
)) != NULL
)
1840 if ((TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_STRUCT
1841 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_UNION
)
1842 && TYPE_N_BASECLASSES (SYMBOL_TYPE (sym
)))
1845 for (j
= TYPE_N_BASECLASSES (SYMBOL_TYPE (sym
)) - 1; j
>= 0; j
--)
1846 if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym
), j
) == 0)
1847 TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym
), j
) =
1848 type_name_no_tag (TYPE_BASECLASS (SYMBOL_TYPE (sym
), j
));
1851 if (TYPE_NAME (SYMBOL_TYPE (sym
)) == NULL
)
1853 /* gcc-2.6 or later (when using -fvtable-thunks)
1854 emits a unique named type for a vtable entry.
1855 Some gdb code depends on that specific name. */
1856 extern const char vtbl_ptr_name
[];
1858 if ((TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_PTR
1859 && strcmp (DEPRECATED_SYMBOL_NAME (sym
), vtbl_ptr_name
))
1860 || TYPE_CODE (SYMBOL_TYPE (sym
)) == TYPE_CODE_FUNC
)
1862 /* If we are giving a name to a type such as "pointer to
1863 foo" or "function returning foo", we better not set
1864 the TYPE_NAME. If the program contains "typedef char
1865 *caddr_t;", we don't want all variables of type char
1866 * to print as caddr_t. This is not just a
1867 consequence of GDB's type management; PCC and GCC (at
1868 least through version 2.4) both output variables of
1869 either type char * or caddr_t with the type number
1870 defined in the 't' symbol for caddr_t. If a future
1871 compiler cleans this up it GDB is not ready for it
1872 yet, but if it becomes ready we somehow need to
1873 disable this check (without breaking the PCC/GCC2.4
1878 Fortunately, this check seems not to be necessary
1879 for anything except pointers or functions. */
1880 /* ezannoni: 2000-10-26. This seems to apply for
1881 versions of gcc older than 2.8. This was the original
1882 problem: with the following code gdb would tell that
1883 the type for name1 is caddr_t, and func is char()
1884 typedef char *caddr_t;
1896 /* Pascal accepts names for pointer types. */
1897 if (current_subfile
->language
== language_pascal
)
1899 TYPE_NAME (SYMBOL_TYPE (sym
)) = DEPRECATED_SYMBOL_NAME (sym
);
1903 TYPE_NAME (SYMBOL_TYPE (sym
)) = DEPRECATED_SYMBOL_NAME (sym
);
1906 add_symbol_to_list (sym
, &file_symbols
);
1910 /* Struct, union, or enum tag. For GNU C++, this can be be followed
1911 by 't' which means we are typedef'ing it as well. */
1912 synonym
= *p
== 't';
1916 #if 0 /* OBSOLETE CFront */
1917 // OBSOLETE /* The semantics of C++ state that "struct foo { ... }" also defines
1918 // OBSOLETE a typedef for "foo". Unfortunately, cfront never makes the typedef
1919 // OBSOLETE when translating C++ into C. We make the typedef here so that
1920 // OBSOLETE "ptype foo" works as expected for cfront translated code. */
1921 // OBSOLETE else if ((current_subfile->language == language_cplus)
1922 // OBSOLETE || (current_subfile->language == language_objc))
1923 // OBSOLETE synonym = 1;
1924 #endif /* OBSOLETE CFront */
1926 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1928 /* For a nameless type, we don't want a create a symbol, thus we
1929 did not use `sym'. Return without further processing. */
1933 SYMBOL_CLASS (sym
) = LOC_TYPEDEF
;
1934 SYMBOL_VALUE (sym
) = valu
;
1935 SYMBOL_DOMAIN (sym
) = STRUCT_DOMAIN
;
1936 if (TYPE_TAG_NAME (SYMBOL_TYPE (sym
)) == 0)
1937 TYPE_TAG_NAME (SYMBOL_TYPE (sym
))
1938 = obconcat (&objfile
->type_obstack
, "", "", DEPRECATED_SYMBOL_NAME (sym
));
1939 add_symbol_to_list (sym
, &file_symbols
);
1943 /* Clone the sym and then modify it. */
1944 register struct symbol
*typedef_sym
= (struct symbol
*)
1945 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
1946 *typedef_sym
= *sym
;
1947 SYMBOL_CLASS (typedef_sym
) = LOC_TYPEDEF
;
1948 SYMBOL_VALUE (typedef_sym
) = valu
;
1949 SYMBOL_DOMAIN (typedef_sym
) = VAR_DOMAIN
;
1950 if (TYPE_NAME (SYMBOL_TYPE (sym
)) == 0)
1951 TYPE_NAME (SYMBOL_TYPE (sym
))
1952 = obconcat (&objfile
->type_obstack
, "", "", DEPRECATED_SYMBOL_NAME (sym
));
1953 add_symbol_to_list (typedef_sym
, &file_symbols
);
1958 /* Static symbol of local scope */
1959 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1960 SYMBOL_CLASS (sym
) = LOC_STATIC
;
1961 SYMBOL_VALUE_ADDRESS (sym
) = valu
;
1962 #ifdef STATIC_TRANSFORM_NAME
1963 if (IS_STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym
)))
1965 struct minimal_symbol
*msym
;
1966 msym
= lookup_minimal_symbol (DEPRECATED_SYMBOL_NAME (sym
), NULL
, objfile
);
1969 DEPRECATED_SYMBOL_NAME (sym
) = STATIC_TRANSFORM_NAME (DEPRECATED_SYMBOL_NAME (sym
));
1970 SYMBOL_VALUE_ADDRESS (sym
) = SYMBOL_VALUE_ADDRESS (msym
);
1974 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1975 add_symbol_to_list (sym
, &local_symbols
);
1979 /* Reference parameter */
1980 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1981 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
1982 SYMBOL_VALUE (sym
) = valu
;
1983 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
1984 add_symbol_to_list (sym
, &local_symbols
);
1988 /* Reference parameter which is in a register. */
1989 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
1990 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
1991 SYMBOL_VALUE (sym
) = STAB_REG_TO_REGNUM (valu
);
1992 if (SYMBOL_VALUE (sym
) >= NUM_REGS
+ NUM_PSEUDO_REGS
)
1994 reg_value_complaint (SYMBOL_VALUE (sym
),
1995 NUM_REGS
+ NUM_PSEUDO_REGS
,
1996 SYMBOL_PRINT_NAME (sym
));
1997 SYMBOL_VALUE (sym
) = SP_REGNUM
; /* Known safe, though useless */
1999 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
2000 add_symbol_to_list (sym
, &local_symbols
);
2004 /* This is used by Sun FORTRAN for "function result value".
2005 Sun claims ("dbx and dbxtool interfaces", 2nd ed)
2006 that Pascal uses it too, but when I tried it Pascal used
2007 "x:3" (local symbol) instead. */
2008 SYMBOL_TYPE (sym
) = read_type (&p
, objfile
);
2009 SYMBOL_CLASS (sym
) = LOC_LOCAL
;
2010 SYMBOL_VALUE (sym
) = valu
;
2011 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
2012 add_symbol_to_list (sym
, &local_symbols
);
2014 #if 0 /* OBSOLETE CFront */
2015 // OBSOLETE /* New code added to support cfront stabs strings.
2016 // OBSOLETE Note: case 'P' already handled above */
2017 // OBSOLETE case 'Z':
2018 // OBSOLETE /* Cfront type continuation coming up!
2019 // OBSOLETE Find the original definition and add to it.
2020 // OBSOLETE We'll have to do this for the typedef too,
2021 // OBSOLETE since we cloned the symbol to define a type in read_type.
2022 // OBSOLETE Stabs info examples:
2023 // OBSOLETE __1C :Ztl
2024 // OBSOLETE foo__1CFv :ZtF (first def foo__1CFv:F(0,3);(0,24))
2025 // OBSOLETE C:ZsC;;__ct__1CFv func1__1CFv func2__1CFv ... ;;;
2026 // OBSOLETE where C is the name of the class.
2027 // OBSOLETE Unfortunately, we can't lookup the original symbol yet 'cuz
2028 // OBSOLETE we haven't finished reading all the symbols.
2029 // OBSOLETE Instead, we save it for processing later */
2030 // OBSOLETE process_later (sym, p, resolve_cfront_continuation);
2031 // OBSOLETE SYMBOL_TYPE (sym) = error_type (&p, objfile); /* FIXME! change later */
2032 // OBSOLETE SYMBOL_CLASS (sym) = LOC_CONST;
2033 // OBSOLETE SYMBOL_VALUE (sym) = 0;
2034 // OBSOLETE SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
2035 // OBSOLETE /* Don't add to list - we'll delete it later when
2036 // OBSOLETE we add the continuation to the real sym */
2037 // OBSOLETE return sym;
2038 // OBSOLETE /* End of new code added to support cfront stabs strings */
2039 #endif /* OBSOLETE CFront */
2042 SYMBOL_TYPE (sym
) = error_type (&p
, objfile
);
2043 SYMBOL_CLASS (sym
) = LOC_CONST
;
2044 SYMBOL_VALUE (sym
) = 0;
2045 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
2046 add_symbol_to_list (sym
, &file_symbols
);
2050 /* When passing structures to a function, some systems sometimes pass
2051 the address in a register, not the structure itself. */
2053 if (REG_STRUCT_HAS_ADDR_P ()
2054 && REG_STRUCT_HAS_ADDR (processing_gcc_compilation
, SYMBOL_TYPE (sym
))
2055 && (SYMBOL_CLASS (sym
) == LOC_REGPARM
|| SYMBOL_CLASS (sym
) == LOC_ARG
))
2057 struct type
*symbol_type
= check_typedef (SYMBOL_TYPE (sym
));
2059 if ((TYPE_CODE (symbol_type
) == TYPE_CODE_STRUCT
)
2060 || (TYPE_CODE (symbol_type
) == TYPE_CODE_UNION
)
2061 || (TYPE_CODE (symbol_type
) == TYPE_CODE_BITSTRING
)
2062 || (TYPE_CODE (symbol_type
) == TYPE_CODE_SET
))
2064 /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
2065 LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
2066 if (SYMBOL_CLASS (sym
) == LOC_REGPARM
)
2067 SYMBOL_CLASS (sym
) = LOC_REGPARM_ADDR
;
2068 /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
2069 and subsequent arguments on the sparc, for example). */
2070 else if (SYMBOL_CLASS (sym
) == LOC_ARG
)
2071 SYMBOL_CLASS (sym
) = LOC_REF_ARG
;
2075 /* Is there more to parse? For example LRS/alias information? */
2076 while (*p
&& *p
== ';')
2079 if (*p
&& p
[0] == 'l' && p
[1] == '(')
2081 /* GNU extensions for live range splitting may be appended to
2082 the end of the stab string. eg. "l(#1,#2);l(#3,#5)" */
2084 /* Resolve the live range and add it to SYM's live range list. */
2085 if (!resolve_live_range (objfile
, sym
, p
))
2088 /* Find end of live range info. */
2089 p
= strchr (p
, ')');
2090 if (!*p
|| *p
!= ')')
2092 lrs_general_complaint ("live range format not recognized");
2101 /* Add the live range found in P to the symbol SYM in objfile OBJFILE. Returns
2102 non-zero on success, zero otherwise. */
2105 resolve_live_range (struct objfile
*objfile
, struct symbol
*sym
, char *p
)
2108 CORE_ADDR start
, end
;
2110 /* Sanity check the beginning of the stabs string. */
2111 if (!*p
|| *p
!= 'l')
2113 lrs_general_complaint ("live range string 1");
2118 if (!*p
|| *p
!= '(')
2120 lrs_general_complaint ("live range string 2");
2125 /* Get starting value of range and advance P past the reference id.
2127 ?!? In theory, the process_reference should never fail, but we should
2128 catch that case just in case the compiler scrogged the stabs. */
2129 refnum
= process_reference (&p
);
2130 start
= ref_search_value (refnum
);
2133 lrs_general_complaint ("Live range symbol not found 1");
2137 if (!*p
|| *p
!= ',')
2139 lrs_general_complaint ("live range string 3");
2144 /* Get ending value of range and advance P past the reference id.
2146 ?!? In theory, the process_reference should never fail, but we should
2147 catch that case just in case the compiler scrogged the stabs. */
2148 refnum
= process_reference (&p
);
2149 end
= ref_search_value (refnum
);
2152 lrs_general_complaint ("Live range symbol not found 2");
2156 if (!*p
|| *p
!= ')')
2158 lrs_general_complaint ("live range string 4");
2162 /* Now that we know the bounds of the range, add it to the
2164 add_live_range (objfile
, sym
, start
, end
);
2169 /* Add a new live range defined by START and END to the symbol SYM
2170 in objfile OBJFILE. */
2173 add_live_range (struct objfile
*objfile
, struct symbol
*sym
, CORE_ADDR start
,
2176 struct range_list
*r
, *rs
;
2180 lrs_general_complaint ("end of live range follows start");
2184 /* Alloc new live range structure. */
2185 r
= (struct range_list
*)
2186 obstack_alloc (&objfile
->type_obstack
,
2187 sizeof (struct range_list
));
2192 /* Append this range to the symbol's range list. */
2193 if (!SYMBOL_RANGES (sym
))
2194 SYMBOL_RANGES (sym
) = r
;
2197 /* Get the last range for the symbol. */
2198 for (rs
= SYMBOL_RANGES (sym
); rs
->next
; rs
= rs
->next
)
2205 /* Skip rest of this symbol and return an error type.
2207 General notes on error recovery: error_type always skips to the
2208 end of the symbol (modulo cretinous dbx symbol name continuation).
2209 Thus code like this:
2211 if (*(*pp)++ != ';')
2212 return error_type (pp, objfile);
2214 is wrong because if *pp starts out pointing at '\0' (typically as the
2215 result of an earlier error), it will be incremented to point to the
2216 start of the next symbol, which might produce strange results, at least
2217 if you run off the end of the string table. Instead use
2220 return error_type (pp, objfile);
2226 foo = error_type (pp, objfile);
2230 And in case it isn't obvious, the point of all this hair is so the compiler
2231 can define new types and new syntaxes, and old versions of the
2232 debugger will be able to read the new symbol tables. */
2234 static struct type
*
2235 error_type (char **pp
, struct objfile
*objfile
)
2237 complaint (&symfile_complaints
, "couldn't parse type; debugger out of date?");
2240 /* Skip to end of symbol. */
2241 while (**pp
!= '\0')
2246 /* Check for and handle cretinous dbx symbol name continuation! */
2247 if ((*pp
)[-1] == '\\' || (*pp
)[-1] == '?')
2249 *pp
= next_symbol_text (objfile
);
2256 return (builtin_type_error
);
2260 /* Read type information or a type definition; return the type. Even
2261 though this routine accepts either type information or a type
2262 definition, the distinction is relevant--some parts of stabsread.c
2263 assume that type information starts with a digit, '-', or '(' in
2264 deciding whether to call read_type. */
2266 static struct type
*
2267 read_type (register char **pp
, struct objfile
*objfile
)
2269 register struct type
*type
= 0;
2272 char type_descriptor
;
2274 /* Size in bits of type if specified by a type attribute, or -1 if
2275 there is no size attribute. */
2278 /* Used to distinguish string and bitstring from char-array and set. */
2281 /* Used to distinguish vector from array. */
2284 /* Read type number if present. The type number may be omitted.
2285 for instance in a two-dimensional array declared with type
2286 "ar1;1;10;ar1;1;10;4". */
2287 if ((**pp
>= '0' && **pp
<= '9')
2291 if (read_type_number (pp
, typenums
) != 0)
2292 return error_type (pp
, objfile
);
2294 /* Type is not being defined here. Either it already exists,
2295 or this is a forward reference to it. dbx_alloc_type handles
2298 return dbx_alloc_type (typenums
, objfile
);
2300 /* Type is being defined here. */
2302 Also skip the type descriptor - we get it below with (*pp)[-1]. */
2307 /* 'typenums=' not present, type is anonymous. Read and return
2308 the definition, but don't put it in the type vector. */
2309 typenums
[0] = typenums
[1] = -1;
2314 type_descriptor
= (*pp
)[-1];
2315 switch (type_descriptor
)
2319 enum type_code code
;
2321 /* Used to index through file_symbols. */
2322 struct pending
*ppt
;
2325 /* Name including "struct", etc. */
2329 char *from
, *to
, *p
, *q1
, *q2
;
2331 /* Set the type code according to the following letter. */
2335 code
= TYPE_CODE_STRUCT
;
2338 code
= TYPE_CODE_UNION
;
2341 code
= TYPE_CODE_ENUM
;
2345 /* Complain and keep going, so compilers can invent new
2346 cross-reference types. */
2347 complaint (&symfile_complaints
,
2348 "Unrecognized cross-reference type `%c'", (*pp
)[0]);
2349 code
= TYPE_CODE_STRUCT
;
2354 q1
= strchr (*pp
, '<');
2355 p
= strchr (*pp
, ':');
2357 return error_type (pp
, objfile
);
2358 if (q1
&& p
> q1
&& p
[1] == ':')
2360 int nesting_level
= 0;
2361 for (q2
= q1
; *q2
; q2
++)
2365 else if (*q2
== '>')
2367 else if (*q2
== ':' && nesting_level
== 0)
2372 return error_type (pp
, objfile
);
2375 (char *) obstack_alloc (&objfile
->type_obstack
, p
- *pp
+ 1);
2377 /* Copy the name. */
2383 /* Set the pointer ahead of the name which we just read, and
2388 /* Now check to see whether the type has already been
2389 declared. This was written for arrays of cross-referenced
2390 types before we had TYPE_CODE_TARGET_STUBBED, so I'm pretty
2391 sure it is not necessary anymore. But it might be a good
2392 idea, to save a little memory. */
2394 for (ppt
= file_symbols
; ppt
; ppt
= ppt
->next
)
2395 for (i
= 0; i
< ppt
->nsyms
; i
++)
2397 struct symbol
*sym
= ppt
->symbol
[i
];
2399 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
2400 && SYMBOL_DOMAIN (sym
) == STRUCT_DOMAIN
2401 && (TYPE_CODE (SYMBOL_TYPE (sym
)) == code
)
2402 && STREQ (DEPRECATED_SYMBOL_NAME (sym
), type_name
))
2404 obstack_free (&objfile
->type_obstack
, type_name
);
2405 type
= SYMBOL_TYPE (sym
);
2410 /* Didn't find the type to which this refers, so we must
2411 be dealing with a forward reference. Allocate a type
2412 structure for it, and keep track of it so we can
2413 fill in the rest of the fields when we get the full
2415 type
= dbx_alloc_type (typenums
, objfile
);
2416 TYPE_CODE (type
) = code
;
2417 TYPE_TAG_NAME (type
) = type_name
;
2418 INIT_CPLUS_SPECIFIC (type
);
2419 TYPE_FLAGS (type
) |= TYPE_FLAG_STUB
;
2421 add_undefined_type (type
);
2425 case '-': /* RS/6000 built-in type */
2439 /* We deal with something like t(1,2)=(3,4)=... which
2440 the Lucid compiler and recent gcc versions (post 2.7.3) use. */
2442 /* Allocate and enter the typedef type first.
2443 This handles recursive types. */
2444 type
= dbx_alloc_type (typenums
, objfile
);
2445 TYPE_CODE (type
) = TYPE_CODE_TYPEDEF
;
2447 struct type
*xtype
= read_type (pp
, objfile
);
2450 /* It's being defined as itself. That means it is "void". */
2451 TYPE_CODE (type
) = TYPE_CODE_VOID
;
2452 TYPE_LENGTH (type
) = 1;
2454 else if (type_size
>= 0 || is_string
)
2456 /* This is the absolute wrong way to construct types. Every
2457 other debug format has found a way around this problem and
2458 the related problems with unnecessarily stubbed types;
2459 someone motivated should attempt to clean up the issue
2460 here as well. Once a type pointed to has been created it
2461 should not be modified.
2463 Well, it's not *absolutely* wrong. Constructing recursive
2464 types (trees, linked lists) necessarily entails modifying
2465 types after creating them. Constructing any loop structure
2466 entails side effects. The Dwarf 2 reader does handle this
2467 more gracefully (it never constructs more than once
2468 instance of a type object, so it doesn't have to copy type
2469 objects wholesale), but it still mutates type objects after
2470 other folks have references to them.
2472 Keep in mind that this circularity/mutation issue shows up
2473 at the source language level, too: C's "incomplete types",
2474 for example. So the proper cleanup, I think, would be to
2475 limit GDB's type smashing to match exactly those required
2476 by the source language. So GDB could have a
2477 "complete_this_type" function, but never create unnecessary
2478 copies of a type otherwise. */
2479 replace_type (type
, xtype
);
2480 TYPE_NAME (type
) = NULL
;
2481 TYPE_TAG_NAME (type
) = NULL
;
2485 TYPE_FLAGS (type
) |= TYPE_FLAG_TARGET_STUB
;
2486 TYPE_TARGET_TYPE (type
) = xtype
;
2491 /* In the following types, we must be sure to overwrite any existing
2492 type that the typenums refer to, rather than allocating a new one
2493 and making the typenums point to the new one. This is because there
2494 may already be pointers to the existing type (if it had been
2495 forward-referenced), and we must change it to a pointer, function,
2496 reference, or whatever, *in-place*. */
2498 case '*': /* Pointer to another type */
2499 type1
= read_type (pp
, objfile
);
2500 type
= make_pointer_type (type1
, dbx_lookup_type (typenums
));
2503 case '&': /* Reference to another type */
2504 type1
= read_type (pp
, objfile
);
2505 type
= make_reference_type (type1
, dbx_lookup_type (typenums
));
2508 case 'f': /* Function returning another type */
2509 type1
= read_type (pp
, objfile
);
2510 type
= make_function_type (type1
, dbx_lookup_type (typenums
));
2513 case 'g': /* Prototyped function. (Sun) */
2515 /* Unresolved questions:
2517 - According to Sun's ``STABS Interface Manual'', for 'f'
2518 and 'F' symbol descriptors, a `0' in the argument type list
2519 indicates a varargs function. But it doesn't say how 'g'
2520 type descriptors represent that info. Someone with access
2521 to Sun's toolchain should try it out.
2523 - According to the comment in define_symbol (search for
2524 `process_prototype_types:'), Sun emits integer arguments as
2525 types which ref themselves --- like `void' types. Do we
2526 have to deal with that here, too? Again, someone with
2527 access to Sun's toolchain should try it out and let us
2530 const char *type_start
= (*pp
) - 1;
2531 struct type
*return_type
= read_type (pp
, objfile
);
2532 struct type
*func_type
2533 = make_function_type (return_type
, dbx_lookup_type (typenums
));
2536 struct type_list
*next
;
2540 while (**pp
&& **pp
!= '#')
2542 struct type
*arg_type
= read_type (pp
, objfile
);
2543 struct type_list
*new = alloca (sizeof (*new));
2544 new->type
= arg_type
;
2545 new->next
= arg_types
;
2553 complaint (&symfile_complaints
,
2554 "Prototyped function type didn't end arguments with `#':\n%s",
2558 /* If there is just one argument whose type is `void', then
2559 that's just an empty argument list. */
2561 && ! arg_types
->next
2562 && TYPE_CODE (arg_types
->type
) == TYPE_CODE_VOID
)
2565 TYPE_FIELDS (func_type
)
2566 = (struct field
*) TYPE_ALLOC (func_type
,
2567 num_args
* sizeof (struct field
));
2568 memset (TYPE_FIELDS (func_type
), 0, num_args
* sizeof (struct field
));
2571 struct type_list
*t
;
2573 /* We stuck each argument type onto the front of the list
2574 when we read it, so the list is reversed. Build the
2575 fields array right-to-left. */
2576 for (t
= arg_types
, i
= num_args
- 1; t
; t
= t
->next
, i
--)
2577 TYPE_FIELD_TYPE (func_type
, i
) = t
->type
;
2579 TYPE_NFIELDS (func_type
) = num_args
;
2580 TYPE_FLAGS (func_type
) |= TYPE_FLAG_PROTOTYPED
;
2586 case 'k': /* Const qualifier on some type (Sun) */
2587 type
= read_type (pp
, objfile
);
2588 type
= make_cv_type (1, TYPE_VOLATILE (type
), type
,
2589 dbx_lookup_type (typenums
));
2592 case 'B': /* Volatile qual on some type (Sun) */
2593 type
= read_type (pp
, objfile
);
2594 type
= make_cv_type (TYPE_CONST (type
), 1, type
,
2595 dbx_lookup_type (typenums
));
2599 if (isdigit (**pp
) || **pp
== '(' || **pp
== '-')
2600 { /* Member (class & variable) type */
2601 /* FIXME -- we should be doing smash_to_XXX types here. */
2603 struct type
*domain
= read_type (pp
, objfile
);
2604 struct type
*memtype
;
2607 /* Invalid member type data format. */
2608 return error_type (pp
, objfile
);
2611 memtype
= read_type (pp
, objfile
);
2612 type
= dbx_alloc_type (typenums
, objfile
);
2613 smash_to_member_type (type
, domain
, memtype
);
2616 /* type attribute */
2619 /* Skip to the semicolon. */
2620 while (**pp
!= ';' && **pp
!= '\0')
2623 return error_type (pp
, objfile
);
2625 ++ * pp
; /* Skip the semicolon. */
2629 case 's': /* Size attribute */
2630 type_size
= atoi (attr
+ 1);
2635 case 'S': /* String attribute */
2636 /* FIXME: check to see if following type is array? */
2640 case 'V': /* Vector attribute */
2641 /* FIXME: check to see if following type is array? */
2646 /* Ignore unrecognized type attributes, so future compilers
2647 can invent new ones. */
2655 case '#': /* Method (class & fn) type */
2656 if ((*pp
)[0] == '#')
2658 /* We'll get the parameter types from the name. */
2659 struct type
*return_type
;
2662 return_type
= read_type (pp
, objfile
);
2663 if (*(*pp
)++ != ';')
2664 complaint (&symfile_complaints
,
2665 "invalid (minimal) member type data format at symtab pos %d.",
2667 type
= allocate_stub_method (return_type
);
2668 if (typenums
[0] != -1)
2669 *dbx_lookup_type (typenums
) = type
;
2673 struct type
*domain
= read_type (pp
, objfile
);
2674 struct type
*return_type
;
2679 /* Invalid member type data format. */
2680 return error_type (pp
, objfile
);
2684 return_type
= read_type (pp
, objfile
);
2685 args
= read_args (pp
, ';', objfile
, &nargs
, &varargs
);
2686 type
= dbx_alloc_type (typenums
, objfile
);
2687 smash_to_method_type (type
, domain
, return_type
, args
,
2692 case 'r': /* Range type */
2693 type
= read_range_type (pp
, typenums
, objfile
);
2694 if (typenums
[0] != -1)
2695 *dbx_lookup_type (typenums
) = type
;
2700 /* Sun ACC builtin int type */
2701 type
= read_sun_builtin_type (pp
, typenums
, objfile
);
2702 if (typenums
[0] != -1)
2703 *dbx_lookup_type (typenums
) = type
;
2707 case 'R': /* Sun ACC builtin float type */
2708 type
= read_sun_floating_type (pp
, typenums
, objfile
);
2709 if (typenums
[0] != -1)
2710 *dbx_lookup_type (typenums
) = type
;
2713 case 'e': /* Enumeration type */
2714 type
= dbx_alloc_type (typenums
, objfile
);
2715 type
= read_enum_type (pp
, type
, objfile
);
2716 if (typenums
[0] != -1)
2717 *dbx_lookup_type (typenums
) = type
;
2720 case 's': /* Struct type */
2721 case 'u': /* Union type */
2723 enum type_code type_code
= TYPE_CODE_UNDEF
;
2724 type
= dbx_alloc_type (typenums
, objfile
);
2725 switch (type_descriptor
)
2728 type_code
= TYPE_CODE_STRUCT
;
2731 type_code
= TYPE_CODE_UNION
;
2734 type
= read_struct_type (pp
, type
, type_code
, objfile
);
2738 case 'a': /* Array type */
2740 return error_type (pp
, objfile
);
2743 type
= dbx_alloc_type (typenums
, objfile
);
2744 type
= read_array_type (pp
, type
, objfile
);
2746 TYPE_CODE (type
) = TYPE_CODE_STRING
;
2748 TYPE_FLAGS (type
) |= TYPE_FLAG_VECTOR
;
2751 case 'S': /* Set or bitstring type */
2752 type1
= read_type (pp
, objfile
);
2753 type
= create_set_type ((struct type
*) NULL
, type1
);
2755 TYPE_CODE (type
) = TYPE_CODE_BITSTRING
;
2756 if (typenums
[0] != -1)
2757 *dbx_lookup_type (typenums
) = type
;
2761 --*pp
; /* Go back to the symbol in error */
2762 /* Particularly important if it was \0! */
2763 return error_type (pp
, objfile
);
2768 warning ("GDB internal error, type is NULL in stabsread.c\n");
2769 return error_type (pp
, objfile
);
2772 /* Size specified in a type attribute overrides any other size. */
2773 if (type_size
!= -1)
2774 TYPE_LENGTH (type
) = (type_size
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
2779 /* RS/6000 xlc/dbx combination uses a set of builtin types, starting from -1.
2780 Return the proper type node for a given builtin type number. */
2782 static struct type
*
2783 rs6000_builtin_type (int typenum
)
2785 /* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
2786 #define NUMBER_RECOGNIZED 34
2787 /* This includes an empty slot for type number -0. */
2788 static struct type
*negative_types
[NUMBER_RECOGNIZED
+ 1];
2789 struct type
*rettype
= NULL
;
2791 if (typenum
>= 0 || typenum
< -NUMBER_RECOGNIZED
)
2793 complaint (&symfile_complaints
, "Unknown builtin type %d", typenum
);
2794 return builtin_type_error
;
2796 if (negative_types
[-typenum
] != NULL
)
2797 return negative_types
[-typenum
];
2799 #if TARGET_CHAR_BIT != 8
2800 #error This code wrong for TARGET_CHAR_BIT not 8
2801 /* These definitions all assume that TARGET_CHAR_BIT is 8. I think
2802 that if that ever becomes not true, the correct fix will be to
2803 make the size in the struct type to be in bits, not in units of
2810 /* The size of this and all the other types are fixed, defined
2811 by the debugging format. If there is a type called "int" which
2812 is other than 32 bits, then it should use a new negative type
2813 number (or avoid negative type numbers for that case).
2814 See stabs.texinfo. */
2815 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "int", NULL
);
2818 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "char", NULL
);
2821 rettype
= init_type (TYPE_CODE_INT
, 2, 0, "short", NULL
);
2824 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "long", NULL
);
2827 rettype
= init_type (TYPE_CODE_INT
, 1, TYPE_FLAG_UNSIGNED
,
2828 "unsigned char", NULL
);
2831 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "signed char", NULL
);
2834 rettype
= init_type (TYPE_CODE_INT
, 2, TYPE_FLAG_UNSIGNED
,
2835 "unsigned short", NULL
);
2838 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2839 "unsigned int", NULL
);
2842 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2845 rettype
= init_type (TYPE_CODE_INT
, 4, TYPE_FLAG_UNSIGNED
,
2846 "unsigned long", NULL
);
2849 rettype
= init_type (TYPE_CODE_VOID
, 1, 0, "void", NULL
);
2852 /* IEEE single precision (32 bit). */
2853 rettype
= init_type (TYPE_CODE_FLT
, 4, 0, "float", NULL
);
2856 /* IEEE double precision (64 bit). */
2857 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "double", NULL
);
2860 /* This is an IEEE double on the RS/6000, and different machines with
2861 different sizes for "long double" should use different negative
2862 type numbers. See stabs.texinfo. */
2863 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "long double", NULL
);
2866 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "integer", NULL
);
2869 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
2873 rettype
= init_type (TYPE_CODE_FLT
, 4, 0, "short real", NULL
);
2876 rettype
= init_type (TYPE_CODE_FLT
, 8, 0, "real", NULL
);
2879 rettype
= init_type (TYPE_CODE_ERROR
, 0, 0, "stringptr", NULL
);
2882 rettype
= init_type (TYPE_CODE_CHAR
, 1, TYPE_FLAG_UNSIGNED
,
2886 rettype
= init_type (TYPE_CODE_BOOL
, 1, TYPE_FLAG_UNSIGNED
,
2890 rettype
= init_type (TYPE_CODE_BOOL
, 2, TYPE_FLAG_UNSIGNED
,
2894 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
2898 rettype
= init_type (TYPE_CODE_BOOL
, 4, TYPE_FLAG_UNSIGNED
,
2902 /* Complex type consisting of two IEEE single precision values. */
2903 rettype
= init_type (TYPE_CODE_COMPLEX
, 8, 0, "complex", NULL
);
2904 TYPE_TARGET_TYPE (rettype
) = init_type (TYPE_CODE_FLT
, 4, 0, "float",
2908 /* Complex type consisting of two IEEE double precision values. */
2909 rettype
= init_type (TYPE_CODE_COMPLEX
, 16, 0, "double complex", NULL
);
2910 TYPE_TARGET_TYPE (rettype
) = init_type (TYPE_CODE_FLT
, 8, 0, "double",
2914 rettype
= init_type (TYPE_CODE_INT
, 1, 0, "integer*1", NULL
);
2917 rettype
= init_type (TYPE_CODE_INT
, 2, 0, "integer*2", NULL
);
2920 rettype
= init_type (TYPE_CODE_INT
, 4, 0, "integer*4", NULL
);
2923 rettype
= init_type (TYPE_CODE_CHAR
, 2, 0, "wchar", NULL
);
2926 rettype
= init_type (TYPE_CODE_INT
, 8, 0, "long long", NULL
);
2929 rettype
= init_type (TYPE_CODE_INT
, 8, TYPE_FLAG_UNSIGNED
,
2930 "unsigned long long", NULL
);
2933 rettype
= init_type (TYPE_CODE_INT
, 8, TYPE_FLAG_UNSIGNED
,
2937 rettype
= init_type (TYPE_CODE_INT
, 8, 0, "integer*8", NULL
);
2940 negative_types
[-typenum
] = rettype
;
2944 /* This page contains subroutines of read_type. */
2946 /* Replace *OLD_NAME with the method name portion of PHYSNAME. */
2949 update_method_name_from_physname (char **old_name
, char *physname
)
2953 method_name
= method_name_from_physname (physname
);
2955 if (method_name
== NULL
)
2957 complaint (&symfile_complaints
,
2958 "Method has bad physname %s\n", physname
);
2962 if (strcmp (*old_name
, method_name
) != 0)
2965 *old_name
= method_name
;
2968 xfree (method_name
);
2971 /* Read member function stabs info for C++ classes. The form of each member
2974 NAME :: TYPENUM[=type definition] ARGS : PHYSNAME ;
2976 An example with two member functions is:
2978 afunc1::20=##15;:i;2A.;afunc2::20:i;2A.;
2980 For the case of overloaded operators, the format is op$::*.funcs, where
2981 $ is the CPLUS_MARKER (usually '$'), `*' holds the place for an operator
2982 name (such as `+=') and `.' marks the end of the operator name.
2984 Returns 1 for success, 0 for failure. */
2987 read_member_functions (struct field_info
*fip
, char **pp
, struct type
*type
,
2988 struct objfile
*objfile
)
2992 /* Total number of member functions defined in this class. If the class
2993 defines two `f' functions, and one `g' function, then this will have
2995 int total_length
= 0;
2999 struct next_fnfield
*next
;
3000 struct fn_field fn_field
;
3003 struct type
*look_ahead_type
;
3004 struct next_fnfieldlist
*new_fnlist
;
3005 struct next_fnfield
*new_sublist
;
3009 /* Process each list until we find something that is not a member function
3010 or find the end of the functions. */
3014 /* We should be positioned at the start of the function name.
3015 Scan forward to find the first ':' and if it is not the
3016 first of a "::" delimiter, then this is not a member function. */
3028 look_ahead_type
= NULL
;
3031 new_fnlist
= (struct next_fnfieldlist
*)
3032 xmalloc (sizeof (struct next_fnfieldlist
));
3033 make_cleanup (xfree
, new_fnlist
);
3034 memset (new_fnlist
, 0, sizeof (struct next_fnfieldlist
));
3036 if ((*pp
)[0] == 'o' && (*pp
)[1] == 'p' && is_cplus_marker ((*pp
)[2]))
3038 /* This is a completely wierd case. In order to stuff in the
3039 names that might contain colons (the usual name delimiter),
3040 Mike Tiemann defined a different name format which is
3041 signalled if the identifier is "op$". In that case, the
3042 format is "op$::XXXX." where XXXX is the name. This is
3043 used for names like "+" or "=". YUUUUUUUK! FIXME! */
3044 /* This lets the user type "break operator+".
3045 We could just put in "+" as the name, but that wouldn't
3047 static char opname
[32] = "op$";
3048 char *o
= opname
+ 3;
3050 /* Skip past '::'. */
3053 STABS_CONTINUE (pp
, objfile
);
3059 main_fn_name
= savestring (opname
, o
- opname
);
3065 main_fn_name
= savestring (*pp
, p
- *pp
);
3066 /* Skip past '::'. */
3069 new_fnlist
->fn_fieldlist
.name
= main_fn_name
;
3074 (struct next_fnfield
*) xmalloc (sizeof (struct next_fnfield
));
3075 make_cleanup (xfree
, new_sublist
);
3076 memset (new_sublist
, 0, sizeof (struct next_fnfield
));
3078 /* Check for and handle cretinous dbx symbol name continuation! */
3079 if (look_ahead_type
== NULL
)
3082 STABS_CONTINUE (pp
, objfile
);
3084 new_sublist
->fn_field
.type
= read_type (pp
, objfile
);
3087 /* Invalid symtab info for member function. */
3093 /* g++ version 1 kludge */
3094 new_sublist
->fn_field
.type
= look_ahead_type
;
3095 look_ahead_type
= NULL
;
3105 /* If this is just a stub, then we don't have the real name here. */
3107 if (TYPE_STUB (new_sublist
->fn_field
.type
))
3109 if (!TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
))
3110 TYPE_DOMAIN_TYPE (new_sublist
->fn_field
.type
) = type
;
3111 new_sublist
->fn_field
.is_stub
= 1;
3113 new_sublist
->fn_field
.physname
= savestring (*pp
, p
- *pp
);
3116 /* Set this member function's visibility fields. */
3119 case VISIBILITY_PRIVATE
:
3120 new_sublist
->fn_field
.is_private
= 1;
3122 case VISIBILITY_PROTECTED
:
3123 new_sublist
->fn_field
.is_protected
= 1;
3127 STABS_CONTINUE (pp
, objfile
);
3130 case 'A': /* Normal functions. */
3131 new_sublist
->fn_field
.is_const
= 0;
3132 new_sublist
->fn_field
.is_volatile
= 0;
3135 case 'B': /* `const' member functions. */
3136 new_sublist
->fn_field
.is_const
= 1;
3137 new_sublist
->fn_field
.is_volatile
= 0;
3140 case 'C': /* `volatile' member function. */
3141 new_sublist
->fn_field
.is_const
= 0;
3142 new_sublist
->fn_field
.is_volatile
= 1;
3145 case 'D': /* `const volatile' member function. */
3146 new_sublist
->fn_field
.is_const
= 1;
3147 new_sublist
->fn_field
.is_volatile
= 1;
3150 case '*': /* File compiled with g++ version 1 -- no info */
3155 complaint (&symfile_complaints
,
3156 "const/volatile indicator missing, got '%c'", **pp
);
3165 /* virtual member function, followed by index.
3166 The sign bit is set to distinguish pointers-to-methods
3167 from virtual function indicies. Since the array is
3168 in words, the quantity must be shifted left by 1
3169 on 16 bit machine, and by 2 on 32 bit machine, forcing
3170 the sign bit out, and usable as a valid index into
3171 the array. Remove the sign bit here. */
3172 new_sublist
->fn_field
.voffset
=
3173 (0x7fffffff & read_huge_number (pp
, ';', &nbits
)) + 2;
3177 STABS_CONTINUE (pp
, objfile
);
3178 if (**pp
== ';' || **pp
== '\0')
3180 /* Must be g++ version 1. */
3181 new_sublist
->fn_field
.fcontext
= 0;
3185 /* Figure out from whence this virtual function came.
3186 It may belong to virtual function table of
3187 one of its baseclasses. */
3188 look_ahead_type
= read_type (pp
, objfile
);
3191 /* g++ version 1 overloaded methods. */
3195 new_sublist
->fn_field
.fcontext
= look_ahead_type
;
3204 look_ahead_type
= NULL
;
3210 /* static member function. */
3212 int slen
= strlen (main_fn_name
);
3214 new_sublist
->fn_field
.voffset
= VOFFSET_STATIC
;
3216 /* For static member functions, we can't tell if they
3217 are stubbed, as they are put out as functions, and not as
3219 GCC v2 emits the fully mangled name if
3220 dbxout.c:flag_minimal_debug is not set, so we have to
3221 detect a fully mangled physname here and set is_stub
3222 accordingly. Fully mangled physnames in v2 start with
3223 the member function name, followed by two underscores.
3224 GCC v3 currently always emits stubbed member functions,
3225 but with fully mangled physnames, which start with _Z. */
3226 if (!(strncmp (new_sublist
->fn_field
.physname
,
3227 main_fn_name
, slen
) == 0
3228 && new_sublist
->fn_field
.physname
[slen
] == '_'
3229 && new_sublist
->fn_field
.physname
[slen
+ 1] == '_'))
3231 new_sublist
->fn_field
.is_stub
= 1;
3238 complaint (&symfile_complaints
,
3239 "member function type missing, got '%c'", (*pp
)[-1]);
3240 /* Fall through into normal member function. */
3243 /* normal member function. */
3244 new_sublist
->fn_field
.voffset
= 0;
3245 new_sublist
->fn_field
.fcontext
= 0;
3249 new_sublist
->next
= sublist
;
3250 sublist
= new_sublist
;
3252 STABS_CONTINUE (pp
, objfile
);
3254 while (**pp
!= ';' && **pp
!= '\0');
3257 STABS_CONTINUE (pp
, objfile
);
3259 /* Skip GCC 3.X member functions which are duplicates of the callable
3260 constructor/destructor. */
3261 if (strcmp (main_fn_name
, "__base_ctor") == 0
3262 || strcmp (main_fn_name
, "__base_dtor") == 0
3263 || strcmp (main_fn_name
, "__deleting_dtor") == 0)
3265 xfree (main_fn_name
);
3270 int has_destructor
= 0, has_other
= 0;
3272 struct next_fnfield
*tmp_sublist
;
3274 /* Various versions of GCC emit various mostly-useless
3275 strings in the name field for special member functions.
3277 For stub methods, we need to defer correcting the name
3278 until we are ready to unstub the method, because the current
3279 name string is used by gdb_mangle_name. The only stub methods
3280 of concern here are GNU v2 operators; other methods have their
3281 names correct (see caveat below).
3283 For non-stub methods, in GNU v3, we have a complete physname.
3284 Therefore we can safely correct the name now. This primarily
3285 affects constructors and destructors, whose name will be
3286 __comp_ctor or __comp_dtor instead of Foo or ~Foo. Cast
3287 operators will also have incorrect names; for instance,
3288 "operator int" will be named "operator i" (i.e. the type is
3291 For non-stub methods in GNU v2, we have no easy way to
3292 know if we have a complete physname or not. For most
3293 methods the result depends on the platform (if CPLUS_MARKER
3294 can be `$' or `.', it will use minimal debug information, or
3295 otherwise the full physname will be included).
3297 Rather than dealing with this, we take a different approach.
3298 For v3 mangled names, we can use the full physname; for v2,
3299 we use cplus_demangle_opname (which is actually v2 specific),
3300 because the only interesting names are all operators - once again
3301 barring the caveat below. Skip this process if any method in the
3302 group is a stub, to prevent our fouling up the workings of
3305 The caveat: GCC 2.95.x (and earlier?) put constructors and
3306 destructors in the same method group. We need to split this
3307 into two groups, because they should have different names.
3308 So for each method group we check whether it contains both
3309 routines whose physname appears to be a destructor (the physnames
3310 for and destructors are always provided, due to quirks in v2
3311 mangling) and routines whose physname does not appear to be a
3312 destructor. If so then we break up the list into two halves.
3313 Even if the constructors and destructors aren't in the same group
3314 the destructor will still lack the leading tilde, so that also
3317 So, to summarize what we expect and handle here:
3319 Given Given Real Real Action
3320 method name physname physname method name
3322 __opi [none] __opi__3Foo operator int opname
3324 Foo _._3Foo _._3Foo ~Foo separate and
3326 operator i _ZN3FoocviEv _ZN3FoocviEv operator int demangle
3327 __comp_ctor _ZN3FooC1ERKS_ _ZN3FooC1ERKS_ Foo demangle
3330 tmp_sublist
= sublist
;
3331 while (tmp_sublist
!= NULL
)
3333 if (tmp_sublist
->fn_field
.is_stub
)
3335 if (tmp_sublist
->fn_field
.physname
[0] == '_'
3336 && tmp_sublist
->fn_field
.physname
[1] == 'Z')
3339 if (is_destructor_name (tmp_sublist
->fn_field
.physname
))
3344 tmp_sublist
= tmp_sublist
->next
;
3347 if (has_destructor
&& has_other
)
3349 struct next_fnfieldlist
*destr_fnlist
;
3350 struct next_fnfield
*last_sublist
;
3352 /* Create a new fn_fieldlist for the destructors. */
3354 destr_fnlist
= (struct next_fnfieldlist
*)
3355 xmalloc (sizeof (struct next_fnfieldlist
));
3356 make_cleanup (xfree
, destr_fnlist
);
3357 memset (destr_fnlist
, 0, sizeof (struct next_fnfieldlist
));
3358 destr_fnlist
->fn_fieldlist
.name
3359 = obconcat (&objfile
->type_obstack
, "", "~",
3360 new_fnlist
->fn_fieldlist
.name
);
3362 destr_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
3363 obstack_alloc (&objfile
->type_obstack
,
3364 sizeof (struct fn_field
) * has_destructor
);
3365 memset (destr_fnlist
->fn_fieldlist
.fn_fields
, 0,
3366 sizeof (struct fn_field
) * has_destructor
);
3367 tmp_sublist
= sublist
;
3368 last_sublist
= NULL
;
3370 while (tmp_sublist
!= NULL
)
3372 if (!is_destructor_name (tmp_sublist
->fn_field
.physname
))
3374 tmp_sublist
= tmp_sublist
->next
;
3378 destr_fnlist
->fn_fieldlist
.fn_fields
[i
++]
3379 = tmp_sublist
->fn_field
;
3381 last_sublist
->next
= tmp_sublist
->next
;
3383 sublist
= tmp_sublist
->next
;
3384 last_sublist
= tmp_sublist
;
3385 tmp_sublist
= tmp_sublist
->next
;
3388 destr_fnlist
->fn_fieldlist
.length
= has_destructor
;
3389 destr_fnlist
->next
= fip
->fnlist
;
3390 fip
->fnlist
= destr_fnlist
;
3392 total_length
+= has_destructor
;
3393 length
-= has_destructor
;
3397 /* v3 mangling prevents the use of abbreviated physnames,
3398 so we can do this here. There are stubbed methods in v3
3400 - in -gstabs instead of -gstabs+
3401 - or for static methods, which are output as a function type
3402 instead of a method type. */
3404 update_method_name_from_physname (&new_fnlist
->fn_fieldlist
.name
,
3405 sublist
->fn_field
.physname
);
3407 else if (has_destructor
&& new_fnlist
->fn_fieldlist
.name
[0] != '~')
3409 new_fnlist
->fn_fieldlist
.name
= concat ("~", main_fn_name
, NULL
);
3410 xfree (main_fn_name
);
3414 char dem_opname
[256];
3416 ret
= cplus_demangle_opname (new_fnlist
->fn_fieldlist
.name
,
3417 dem_opname
, DMGL_ANSI
);
3419 ret
= cplus_demangle_opname (new_fnlist
->fn_fieldlist
.name
,
3422 new_fnlist
->fn_fieldlist
.name
3423 = obsavestring (dem_opname
, strlen (dem_opname
),
3424 &objfile
->type_obstack
);
3427 new_fnlist
->fn_fieldlist
.fn_fields
= (struct fn_field
*)
3428 obstack_alloc (&objfile
->type_obstack
,
3429 sizeof (struct fn_field
) * length
);
3430 memset (new_fnlist
->fn_fieldlist
.fn_fields
, 0,
3431 sizeof (struct fn_field
) * length
);
3432 for (i
= length
; (i
--, sublist
); sublist
= sublist
->next
)
3434 new_fnlist
->fn_fieldlist
.fn_fields
[i
] = sublist
->fn_field
;
3437 new_fnlist
->fn_fieldlist
.length
= length
;
3438 new_fnlist
->next
= fip
->fnlist
;
3439 fip
->fnlist
= new_fnlist
;
3441 total_length
+= length
;
3447 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
3448 TYPE_FN_FIELDLISTS (type
) = (struct fn_fieldlist
*)
3449 TYPE_ALLOC (type
, sizeof (struct fn_fieldlist
) * nfn_fields
);
3450 memset (TYPE_FN_FIELDLISTS (type
), 0,
3451 sizeof (struct fn_fieldlist
) * nfn_fields
);
3452 TYPE_NFN_FIELDS (type
) = nfn_fields
;
3453 TYPE_NFN_FIELDS_TOTAL (type
) = total_length
;
3459 /* Special GNU C++ name.
3461 Returns 1 for success, 0 for failure. "failure" means that we can't
3462 keep parsing and it's time for error_type(). */
3465 read_cpp_abbrev (struct field_info
*fip
, char **pp
, struct type
*type
,
3466 struct objfile
*objfile
)
3471 struct type
*context
;
3481 /* At this point, *pp points to something like "22:23=*22...",
3482 where the type number before the ':' is the "context" and
3483 everything after is a regular type definition. Lookup the
3484 type, find it's name, and construct the field name. */
3486 context
= read_type (pp
, objfile
);
3490 case 'f': /* $vf -- a virtual function table pointer */
3491 name
= type_name_no_tag (context
);
3496 fip
->list
->field
.name
=
3497 obconcat (&objfile
->type_obstack
, vptr_name
, name
, "");
3500 case 'b': /* $vb -- a virtual bsomethingorother */
3501 name
= type_name_no_tag (context
);
3504 complaint (&symfile_complaints
,
3505 "C++ abbreviated type name unknown at symtab pos %d",
3509 fip
->list
->field
.name
=
3510 obconcat (&objfile
->type_obstack
, vb_name
, name
, "");
3514 invalid_cpp_abbrev_complaint (*pp
);
3515 fip
->list
->field
.name
=
3516 obconcat (&objfile
->type_obstack
,
3517 "INVALID_CPLUSPLUS_ABBREV", "", "");
3521 /* At this point, *pp points to the ':'. Skip it and read the
3527 invalid_cpp_abbrev_complaint (*pp
);
3530 fip
->list
->field
.type
= read_type (pp
, objfile
);
3532 (*pp
)++; /* Skip the comma. */
3538 FIELD_BITPOS (fip
->list
->field
) = read_huge_number (pp
, ';', &nbits
);
3542 /* This field is unpacked. */
3543 FIELD_BITSIZE (fip
->list
->field
) = 0;
3544 fip
->list
->visibility
= VISIBILITY_PRIVATE
;
3548 invalid_cpp_abbrev_complaint (*pp
);
3549 /* We have no idea what syntax an unrecognized abbrev would have, so
3550 better return 0. If we returned 1, we would need to at least advance
3551 *pp to avoid an infinite loop. */
3558 read_one_struct_field (struct field_info
*fip
, char **pp
, char *p
,
3559 struct type
*type
, struct objfile
*objfile
)
3561 #if 0 /* OBSOLETE CFront */
3562 // OBSOLETE /* The following is code to work around cfront generated stabs.
3563 // OBSOLETE The stabs contains full mangled name for each field.
3564 // OBSOLETE We try to demangle the name and extract the field name out of it.
3566 // OBSOLETE if (ARM_DEMANGLING && current_subfile->language == language_cplus)
3568 // OBSOLETE char save_p;
3569 // OBSOLETE char *dem, *dem_p;
3570 // OBSOLETE save_p = *p;
3571 // OBSOLETE *p = '\0';
3572 // OBSOLETE dem = cplus_demangle (*pp, DMGL_ANSI | DMGL_PARAMS);
3573 // OBSOLETE if (dem != NULL)
3575 // OBSOLETE dem_p = strrchr (dem, ':');
3576 // OBSOLETE if (dem_p != 0 && *(dem_p - 1) == ':')
3577 // OBSOLETE dem_p++;
3578 // OBSOLETE FIELD_NAME (fip->list->field) =
3579 // OBSOLETE obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
3583 // OBSOLETE FIELD_NAME (fip->list->field) =
3584 // OBSOLETE obsavestring (*pp, p - *pp, &objfile->type_obstack);
3586 // OBSOLETE *p = save_p;
3588 // OBSOLETE /* end of code for cfront work around */
3591 #endif /* OBSOLETE CFront */
3592 fip
->list
->field
.name
=
3593 obsavestring (*pp
, p
- *pp
, &objfile
->type_obstack
);
3596 /* This means we have a visibility for a field coming. */
3600 fip
->list
->visibility
= *(*pp
)++;
3604 /* normal dbx-style format, no explicit visibility */
3605 fip
->list
->visibility
= VISIBILITY_PUBLIC
;
3608 fip
->list
->field
.type
= read_type (pp
, objfile
);
3613 /* Possible future hook for nested types. */
3616 fip
->list
->field
.bitpos
= (long) -2; /* nested type */
3626 /* Static class member. */
3627 SET_FIELD_PHYSNAME (fip
->list
->field
, savestring (*pp
, p
- *pp
));
3631 else if (**pp
!= ',')
3633 /* Bad structure-type format. */
3634 stabs_general_complaint ("bad structure-type format");
3638 (*pp
)++; /* Skip the comma. */
3642 FIELD_BITPOS (fip
->list
->field
) = read_huge_number (pp
, ',', &nbits
);
3645 stabs_general_complaint ("bad structure-type format");
3648 FIELD_BITSIZE (fip
->list
->field
) = read_huge_number (pp
, ';', &nbits
);
3651 stabs_general_complaint ("bad structure-type format");
3656 if (FIELD_BITPOS (fip
->list
->field
) == 0
3657 && FIELD_BITSIZE (fip
->list
->field
) == 0)
3659 /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
3660 it is a field which has been optimized out. The correct stab for
3661 this case is to use VISIBILITY_IGNORE, but that is a recent
3662 invention. (2) It is a 0-size array. For example
3663 union { int num; char str[0]; } foo. Printing "<no value>" for
3664 str in "p foo" is OK, since foo.str (and thus foo.str[3])
3665 will continue to work, and a 0-size array as a whole doesn't
3666 have any contents to print.
3668 I suspect this probably could also happen with gcc -gstabs (not
3669 -gstabs+) for static fields, and perhaps other C++ extensions.
3670 Hopefully few people use -gstabs with gdb, since it is intended
3671 for dbx compatibility. */
3673 /* Ignore this field. */
3674 fip
->list
->visibility
= VISIBILITY_IGNORE
;
3678 /* Detect an unpacked field and mark it as such.
3679 dbx gives a bit size for all fields.
3680 Note that forward refs cannot be packed,
3681 and treat enums as if they had the width of ints. */
3683 struct type
*field_type
= check_typedef (FIELD_TYPE (fip
->list
->field
));
3685 if (TYPE_CODE (field_type
) != TYPE_CODE_INT
3686 && TYPE_CODE (field_type
) != TYPE_CODE_RANGE
3687 && TYPE_CODE (field_type
) != TYPE_CODE_BOOL
3688 && TYPE_CODE (field_type
) != TYPE_CODE_ENUM
)
3690 FIELD_BITSIZE (fip
->list
->field
) = 0;
3692 if ((FIELD_BITSIZE (fip
->list
->field
)
3693 == TARGET_CHAR_BIT
* TYPE_LENGTH (field_type
)
3694 || (TYPE_CODE (field_type
) == TYPE_CODE_ENUM
3695 && FIELD_BITSIZE (fip
->list
->field
) == TARGET_INT_BIT
)
3698 FIELD_BITPOS (fip
->list
->field
) % 8 == 0)
3700 FIELD_BITSIZE (fip
->list
->field
) = 0;
3706 /* Read struct or class data fields. They have the form:
3708 NAME : [VISIBILITY] TYPENUM , BITPOS , BITSIZE ;
3710 At the end, we see a semicolon instead of a field.
3712 In C++, this may wind up being NAME:?TYPENUM:PHYSNAME; for
3715 The optional VISIBILITY is one of:
3717 '/0' (VISIBILITY_PRIVATE)
3718 '/1' (VISIBILITY_PROTECTED)
3719 '/2' (VISIBILITY_PUBLIC)
3720 '/9' (VISIBILITY_IGNORE)
3722 or nothing, for C style fields with public visibility.
3724 Returns 1 for success, 0 for failure. */
3727 read_struct_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
3728 struct objfile
*objfile
)
3731 struct nextfield
*new;
3733 /* We better set p right now, in case there are no fields at all... */
3737 /* Read each data member type until we find the terminating ';' at the end of
3738 the data member list, or break for some other reason such as finding the
3739 start of the member function list. */
3740 /* Stab string for structure/union does not end with two ';' in
3741 SUN C compiler 5.3 i.e. F6U2, hence check for end of string. */
3743 while (**pp
!= ';' && **pp
!= '\0')
3745 STABS_CONTINUE (pp
, objfile
);
3746 /* Get space to record the next field's data. */
3747 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
3748 make_cleanup (xfree
, new);
3749 memset (new, 0, sizeof (struct nextfield
));
3750 new->next
= fip
->list
;
3753 /* Get the field name. */
3756 /* If is starts with CPLUS_MARKER it is a special abbreviation,
3757 unless the CPLUS_MARKER is followed by an underscore, in
3758 which case it is just the name of an anonymous type, which we
3759 should handle like any other type name. */
3761 if (is_cplus_marker (p
[0]) && p
[1] != '_')
3763 if (!read_cpp_abbrev (fip
, pp
, type
, objfile
))
3768 /* Look for the ':' that separates the field name from the field
3769 values. Data members are delimited by a single ':', while member
3770 functions are delimited by a pair of ':'s. When we hit the member
3771 functions (if any), terminate scan loop and return. */
3773 while (*p
!= ':' && *p
!= '\0')
3780 /* Check to see if we have hit the member functions yet. */
3785 read_one_struct_field (fip
, pp
, p
, type
, objfile
);
3787 if (p
[0] == ':' && p
[1] == ':')
3789 /* (the deleted) chill the list of fields: the last entry (at
3790 the head) is a partially constructed entry which we now
3792 fip
->list
= fip
->list
->next
;
3797 /* The stabs for C++ derived classes contain baseclass information which
3798 is marked by a '!' character after the total size. This function is
3799 called when we encounter the baseclass marker, and slurps up all the
3800 baseclass information.
3802 Immediately following the '!' marker is the number of base classes that
3803 the class is derived from, followed by information for each base class.
3804 For each base class, there are two visibility specifiers, a bit offset
3805 to the base class information within the derived class, a reference to
3806 the type for the base class, and a terminating semicolon.
3808 A typical example, with two base classes, would be "!2,020,19;0264,21;".
3810 Baseclass information marker __________________|| | | | | | |
3811 Number of baseclasses __________________________| | | | | | |
3812 Visibility specifiers (2) ________________________| | | | | |
3813 Offset in bits from start of class _________________| | | | |
3814 Type number for base class ___________________________| | | |
3815 Visibility specifiers (2) _______________________________| | |
3816 Offset in bits from start of class ________________________| |
3817 Type number of base class ____________________________________|
3819 Return 1 for success, 0 for (error-type-inducing) failure. */
3825 read_baseclasses (struct field_info
*fip
, char **pp
, struct type
*type
,
3826 struct objfile
*objfile
)
3829 struct nextfield
*new;
3837 /* Skip the '!' baseclass information marker. */
3841 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
3844 TYPE_N_BASECLASSES (type
) = read_huge_number (pp
, ',', &nbits
);
3850 /* Some stupid compilers have trouble with the following, so break
3851 it up into simpler expressions. */
3852 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*)
3853 TYPE_ALLOC (type
, B_BYTES (TYPE_N_BASECLASSES (type
)));
3856 int num_bytes
= B_BYTES (TYPE_N_BASECLASSES (type
));
3859 pointer
= (char *) TYPE_ALLOC (type
, num_bytes
);
3860 TYPE_FIELD_VIRTUAL_BITS (type
) = (B_TYPE
*) pointer
;
3864 B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type
), TYPE_N_BASECLASSES (type
));
3866 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
3868 new = (struct nextfield
*) xmalloc (sizeof (struct nextfield
));
3869 make_cleanup (xfree
, new);
3870 memset (new, 0, sizeof (struct nextfield
));
3871 new->next
= fip
->list
;
3873 FIELD_BITSIZE (new->field
) = 0; /* this should be an unpacked field! */
3875 STABS_CONTINUE (pp
, objfile
);
3879 /* Nothing to do. */
3882 SET_TYPE_FIELD_VIRTUAL (type
, i
);
3885 /* Unknown character. Complain and treat it as non-virtual. */
3887 complaint (&symfile_complaints
,
3888 "Unknown virtual character `%c' for baseclass", **pp
);
3893 new->visibility
= *(*pp
)++;
3894 switch (new->visibility
)
3896 case VISIBILITY_PRIVATE
:
3897 case VISIBILITY_PROTECTED
:
3898 case VISIBILITY_PUBLIC
:
3901 /* Bad visibility format. Complain and treat it as
3904 complaint (&symfile_complaints
,
3905 "Unknown visibility `%c' for baseclass",
3907 new->visibility
= VISIBILITY_PUBLIC
;
3914 /* The remaining value is the bit offset of the portion of the object
3915 corresponding to this baseclass. Always zero in the absence of
3916 multiple inheritance. */
3918 FIELD_BITPOS (new->field
) = read_huge_number (pp
, ',', &nbits
);
3923 /* The last piece of baseclass information is the type of the
3924 base class. Read it, and remember it's type name as this
3927 new->field
.type
= read_type (pp
, objfile
);
3928 new->field
.name
= type_name_no_tag (new->field
.type
);
3930 /* skip trailing ';' and bump count of number of fields seen */
3939 /* The tail end of stabs for C++ classes that contain a virtual function
3940 pointer contains a tilde, a %, and a type number.
3941 The type number refers to the base class (possibly this class itself) which
3942 contains the vtable pointer for the current class.
3944 This function is called when we have parsed all the method declarations,
3945 so we can look for the vptr base class info. */
3948 read_tilde_fields (struct field_info
*fip
, char **pp
, struct type
*type
,
3949 struct objfile
*objfile
)
3953 STABS_CONTINUE (pp
, objfile
);
3955 /* If we are positioned at a ';', then skip it. */
3965 if (**pp
== '=' || **pp
== '+' || **pp
== '-')
3967 /* Obsolete flags that used to indicate the presence
3968 of constructors and/or destructors. */
3972 /* Read either a '%' or the final ';'. */
3973 if (*(*pp
)++ == '%')
3975 /* The next number is the type number of the base class
3976 (possibly our own class) which supplies the vtable for
3977 this class. Parse it out, and search that class to find
3978 its vtable pointer, and install those into TYPE_VPTR_BASETYPE
3979 and TYPE_VPTR_FIELDNO. */
3984 t
= read_type (pp
, objfile
);
3986 while (*p
!= '\0' && *p
!= ';')
3992 /* Premature end of symbol. */
3996 TYPE_VPTR_BASETYPE (type
) = t
;
3997 if (type
== t
) /* Our own class provides vtbl ptr */
3999 for (i
= TYPE_NFIELDS (t
) - 1;
4000 i
>= TYPE_N_BASECLASSES (t
);
4003 char *name
= TYPE_FIELD_NAME (t
, i
);
4004 if (!strncmp (name
, vptr_name
, sizeof (vptr_name
) - 2)
4005 && is_cplus_marker (name
[sizeof (vptr_name
) - 2]))
4007 TYPE_VPTR_FIELDNO (type
) = i
;
4011 /* Virtual function table field not found. */
4012 complaint (&symfile_complaints
,
4013 "virtual function table pointer not found when defining class `%s'",
4019 TYPE_VPTR_FIELDNO (type
) = TYPE_VPTR_FIELDNO (t
);
4030 attach_fn_fields_to_type (struct field_info
*fip
, register struct type
*type
)
4034 for (n
= TYPE_NFN_FIELDS (type
);
4035 fip
->fnlist
!= NULL
;
4036 fip
->fnlist
= fip
->fnlist
->next
)
4038 --n
; /* Circumvent Sun3 compiler bug */
4039 TYPE_FN_FIELDLISTS (type
)[n
] = fip
->fnlist
->fn_fieldlist
;
4044 #if 0 /* OBSOLETE CFront */
4045 // OBSOLETE /* read cfront class static data.
4046 // OBSOLETE pp points to string starting with the list of static data
4047 // OBSOLETE eg: A:ZcA;1@Bpub v2@Bvirpri;__ct__1AFv func__1AFv *sfunc__1AFv ;as__1A ;;
4048 // OBSOLETE ^^^^^^^^
4050 // OBSOLETE A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
4054 // OBSOLETE static int
4055 // OBSOLETE read_cfront_static_fields (struct field_info *fip, char **pp, struct type *type,
4056 // OBSOLETE struct objfile *objfile)
4058 // OBSOLETE struct nextfield *new;
4059 // OBSOLETE struct type *stype;
4060 // OBSOLETE char *sname;
4061 // OBSOLETE struct symbol *ref_static = 0;
4063 // OBSOLETE if (**pp == ';') /* no static data; return */
4065 // OBSOLETE ++(*pp);
4066 // OBSOLETE return 1;
4069 // OBSOLETE /* Process each field in the list until we find the terminating ";" */
4071 // OBSOLETE /* eg: p = "as__1A ;;;" */
4072 // OBSOLETE STABS_CONTINUE (pp, objfile); /* handle \\ */
4073 // OBSOLETE while (**pp != ';' && (sname = get_substring (pp, ' '), sname))
4075 // OBSOLETE ref_static = lookup_symbol (sname, 0, VAR_DOMAIN, 0, 0); /*demangled_name */
4076 // OBSOLETE if (!ref_static)
4078 // OBSOLETE complaint (&symfile_complaints,
4079 // OBSOLETE "Unable to find symbol for static data field %s", sname);
4080 // OBSOLETE continue;
4082 // OBSOLETE stype = SYMBOL_TYPE (ref_static);
4084 // OBSOLETE /* allocate a new fip */
4085 // OBSOLETE new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
4086 // OBSOLETE make_cleanup (xfree, new);
4087 // OBSOLETE memset (new, 0, sizeof (struct nextfield));
4088 // OBSOLETE new->next = fip->list;
4089 // OBSOLETE fip->list = new;
4091 // OBSOLETE /* set visibility */
4092 // OBSOLETE /* FIXME! no way to tell visibility from stabs??? */
4093 // OBSOLETE new->visibility = VISIBILITY_PUBLIC;
4095 // OBSOLETE /* set field info into fip */
4096 // OBSOLETE fip->list->field.type = stype;
4098 // OBSOLETE /* set bitpos & bitsize */
4099 // OBSOLETE SET_FIELD_PHYSNAME (fip->list->field, savestring (sname, strlen (sname)));
4101 // OBSOLETE /* set name field */
4102 // OBSOLETE /* The following is code to work around cfront generated stabs.
4103 // OBSOLETE The stabs contains full mangled name for each field.
4104 // OBSOLETE We try to demangle the name and extract the field name out of it.
4106 // OBSOLETE if (ARM_DEMANGLING)
4108 // OBSOLETE char *dem, *dem_p;
4109 // OBSOLETE dem = cplus_demangle (sname, DMGL_ANSI | DMGL_PARAMS);
4110 // OBSOLETE if (dem != NULL)
4112 // OBSOLETE dem_p = strrchr (dem, ':');
4113 // OBSOLETE if (dem_p != 0 && *(dem_p - 1) == ':')
4114 // OBSOLETE dem_p++;
4115 // OBSOLETE fip->list->field.name =
4116 // OBSOLETE obsavestring (dem_p, strlen (dem_p), &objfile->type_obstack);
4120 // OBSOLETE fip->list->field.name =
4121 // OBSOLETE obsavestring (sname, strlen (sname), &objfile->type_obstack);
4123 // OBSOLETE } /* end of code for cfront work around */
4124 // OBSOLETE } /* loop again for next static field */
4125 // OBSOLETE return 1;
4128 // OBSOLETE /* Copy structure fields to fip so attach_fields_to_type will work.
4129 // OBSOLETE type has already been created with the initial instance data fields.
4130 // OBSOLETE Now we want to be able to add the other members to the class,
4131 // OBSOLETE so we want to add them back to the fip and reattach them again
4132 // OBSOLETE once we have collected all the class members. */
4134 // OBSOLETE static int
4135 // OBSOLETE copy_cfront_struct_fields (struct field_info *fip, struct type *type,
4136 // OBSOLETE struct objfile *objfile)
4138 // OBSOLETE int nfields = TYPE_NFIELDS (type);
4140 // OBSOLETE struct nextfield *new;
4142 // OBSOLETE /* Copy the fields into the list of fips and reset the types
4143 // OBSOLETE to remove the old fields */
4145 // OBSOLETE for (i = 0; i < nfields; i++)
4147 // OBSOLETE /* allocate a new fip */
4148 // OBSOLETE new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
4149 // OBSOLETE make_cleanup (xfree, new);
4150 // OBSOLETE memset (new, 0, sizeof (struct nextfield));
4151 // OBSOLETE new->next = fip->list;
4152 // OBSOLETE fip->list = new;
4154 // OBSOLETE /* copy field info into fip */
4155 // OBSOLETE new->field = TYPE_FIELD (type, i);
4156 // OBSOLETE /* set visibility */
4157 // OBSOLETE if (TYPE_FIELD_PROTECTED (type, i))
4158 // OBSOLETE new->visibility = VISIBILITY_PROTECTED;
4159 // OBSOLETE else if (TYPE_FIELD_PRIVATE (type, i))
4160 // OBSOLETE new->visibility = VISIBILITY_PRIVATE;
4162 // OBSOLETE new->visibility = VISIBILITY_PUBLIC;
4164 // OBSOLETE /* Now delete the fields from the type since we will be
4165 // OBSOLETE allocing new space once we get the rest of the fields
4166 // OBSOLETE in attach_fields_to_type.
4167 // OBSOLETE The pointer TYPE_FIELDS(type) is left dangling but should
4168 // OBSOLETE be freed later by objstack_free */
4169 // OBSOLETE TYPE_FIELDS (type) = 0;
4170 // OBSOLETE TYPE_NFIELDS (type) = 0;
4172 // OBSOLETE return 1;
4174 #endif /* OBSOLETE CFront */
4176 /* Create the vector of fields, and record how big it is.
4177 We need this info to record proper virtual function table information
4178 for this class's virtual functions. */
4181 attach_fields_to_type (struct field_info
*fip
, register struct type
*type
,
4182 struct objfile
*objfile
)
4184 register int nfields
= 0;
4185 register int non_public_fields
= 0;
4186 register struct nextfield
*scan
;
4188 /* Count up the number of fields that we have, as well as taking note of
4189 whether or not there are any non-public fields, which requires us to
4190 allocate and build the private_field_bits and protected_field_bits
4193 for (scan
= fip
->list
; scan
!= NULL
; scan
= scan
->next
)
4196 if (scan
->visibility
!= VISIBILITY_PUBLIC
)
4198 non_public_fields
++;
4202 /* Now we know how many fields there are, and whether or not there are any
4203 non-public fields. Record the field count, allocate space for the
4204 array of fields, and create blank visibility bitfields if necessary. */
4206 TYPE_NFIELDS (type
) = nfields
;
4207 TYPE_FIELDS (type
) = (struct field
*)
4208 TYPE_ALLOC (type
, sizeof (struct field
) * nfields
);
4209 memset (TYPE_FIELDS (type
), 0, sizeof (struct field
) * nfields
);
4211 if (non_public_fields
)
4213 ALLOCATE_CPLUS_STRUCT_TYPE (type
);
4215 TYPE_FIELD_PRIVATE_BITS (type
) =
4216 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4217 B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type
), nfields
);
4219 TYPE_FIELD_PROTECTED_BITS (type
) =
4220 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4221 B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type
), nfields
);
4223 TYPE_FIELD_IGNORE_BITS (type
) =
4224 (B_TYPE
*) TYPE_ALLOC (type
, B_BYTES (nfields
));
4225 B_CLRALL (TYPE_FIELD_IGNORE_BITS (type
), nfields
);
4228 /* Copy the saved-up fields into the field vector. Start from the head
4229 of the list, adding to the tail of the field array, so that they end
4230 up in the same order in the array in which they were added to the list. */
4232 while (nfields
-- > 0)
4234 TYPE_FIELD (type
, nfields
) = fip
->list
->field
;
4235 switch (fip
->list
->visibility
)
4237 case VISIBILITY_PRIVATE
:
4238 SET_TYPE_FIELD_PRIVATE (type
, nfields
);
4241 case VISIBILITY_PROTECTED
:
4242 SET_TYPE_FIELD_PROTECTED (type
, nfields
);
4245 case VISIBILITY_IGNORE
:
4246 SET_TYPE_FIELD_IGNORE (type
, nfields
);
4249 case VISIBILITY_PUBLIC
:
4253 /* Unknown visibility. Complain and treat it as public. */
4255 complaint (&symfile_complaints
, "Unknown visibility `%c' for field",
4256 fip
->list
->visibility
);
4260 fip
->list
= fip
->list
->next
;
4266 /* Complain that the compiler has emitted more than one definition for the
4267 structure type TYPE. */
4269 complain_about_struct_wipeout (struct type
*type
)
4274 if (TYPE_TAG_NAME (type
))
4276 name
= TYPE_TAG_NAME (type
);
4277 switch (TYPE_CODE (type
))
4279 case TYPE_CODE_STRUCT
: kind
= "struct "; break;
4280 case TYPE_CODE_UNION
: kind
= "union "; break;
4281 case TYPE_CODE_ENUM
: kind
= "enum "; break;
4285 else if (TYPE_NAME (type
))
4287 name
= TYPE_NAME (type
);
4296 complaint (&symfile_complaints
,
4297 "struct/union type gets multiply defined: %s%s", kind
, name
);
4301 /* Read the description of a structure (or union type) and return an object
4302 describing the type.
4304 PP points to a character pointer that points to the next unconsumed token
4305 in the the stabs string. For example, given stabs "A:T4=s4a:1,0,32;;",
4306 *PP will point to "4a:1,0,32;;".
4308 TYPE points to an incomplete type that needs to be filled in.
4310 OBJFILE points to the current objfile from which the stabs information is
4311 being read. (Note that it is redundant in that TYPE also contains a pointer
4312 to this same objfile, so it might be a good idea to eliminate it. FIXME).
4315 static struct type
*
4316 read_struct_type (char **pp
, struct type
*type
, enum type_code type_code
,
4317 struct objfile
*objfile
)
4319 struct cleanup
*back_to
;
4320 struct field_info fi
;
4325 /* When describing struct/union/class types in stabs, G++ always drops
4326 all qualifications from the name. So if you've got:
4327 struct A { ... struct B { ... }; ... };
4328 then G++ will emit stabs for `struct A::B' that call it simply
4329 `struct B'. Obviously, if you've got a real top-level definition for
4330 `struct B', or other nested definitions, this is going to cause
4333 Obviously, GDB can't fix this by itself, but it can at least avoid
4334 scribbling on existing structure type objects when new definitions
4336 if (! (TYPE_CODE (type
) == TYPE_CODE_UNDEF
4337 || TYPE_STUB (type
)))
4339 complain_about_struct_wipeout (type
);
4341 /* It's probably best to return the type unchanged. */
4345 back_to
= make_cleanup (null_cleanup
, 0);
4347 INIT_CPLUS_SPECIFIC (type
);
4348 TYPE_CODE (type
) = type_code
;
4349 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
4351 /* First comes the total size in bytes. */
4355 TYPE_LENGTH (type
) = read_huge_number (pp
, 0, &nbits
);
4357 return error_type (pp
, objfile
);
4360 /* Now read the baseclasses, if any, read the regular C struct or C++
4361 class member fields, attach the fields to the type, read the C++
4362 member functions, attach them to the type, and then read any tilde
4363 field (baseclass specifier for the class holding the main vtable). */
4365 if (!read_baseclasses (&fi
, pp
, type
, objfile
)
4366 || !read_struct_fields (&fi
, pp
, type
, objfile
)
4367 || !attach_fields_to_type (&fi
, type
, objfile
)
4368 || !read_member_functions (&fi
, pp
, type
, objfile
)
4369 || !attach_fn_fields_to_type (&fi
, type
)
4370 || !read_tilde_fields (&fi
, pp
, type
, objfile
))
4372 type
= error_type (pp
, objfile
);
4375 do_cleanups (back_to
);
4379 /* Read a definition of an array type,
4380 and create and return a suitable type object.
4381 Also creates a range type which represents the bounds of that
4384 static struct type
*
4385 read_array_type (register char **pp
, register struct type
*type
,
4386 struct objfile
*objfile
)
4388 struct type
*index_type
, *element_type
, *range_type
;
4393 /* Format of an array type:
4394 "ar<index type>;lower;upper;<array_contents_type>".
4395 OS9000: "arlower,upper;<array_contents_type>".
4397 Fortran adjustable arrays use Adigits or Tdigits for lower or upper;
4398 for these, produce a type like float[][]. */
4401 index_type
= read_type (pp
, objfile
);
4403 /* Improper format of array type decl. */
4404 return error_type (pp
, objfile
);
4408 if (!(**pp
>= '0' && **pp
<= '9') && **pp
!= '-')
4413 lower
= read_huge_number (pp
, ';', &nbits
);
4416 return error_type (pp
, objfile
);
4418 if (!(**pp
>= '0' && **pp
<= '9') && **pp
!= '-')
4423 upper
= read_huge_number (pp
, ';', &nbits
);
4425 return error_type (pp
, objfile
);
4427 element_type
= read_type (pp
, objfile
);
4436 create_range_type ((struct type
*) NULL
, index_type
, lower
, upper
);
4437 type
= create_array_type (type
, element_type
, range_type
);
4443 /* Read a definition of an enumeration type,
4444 and create and return a suitable type object.
4445 Also defines the symbols that represent the values of the type. */
4447 static struct type
*
4448 read_enum_type (register char **pp
, register struct type
*type
,
4449 struct objfile
*objfile
)
4454 register struct symbol
*sym
;
4456 struct pending
**symlist
;
4457 struct pending
*osyms
, *syms
;
4460 int unsigned_enum
= 1;
4463 /* FIXME! The stabs produced by Sun CC merrily define things that ought
4464 to be file-scope, between N_FN entries, using N_LSYM. What's a mother
4465 to do? For now, force all enum values to file scope. */
4466 if (within_function
)
4467 symlist
= &local_symbols
;
4470 symlist
= &file_symbols
;
4472 o_nsyms
= osyms
? osyms
->nsyms
: 0;
4474 /* The aix4 compiler emits an extra field before the enum members;
4475 my guess is it's a type of some sort. Just ignore it. */
4478 /* Skip over the type. */
4482 /* Skip over the colon. */
4486 /* Read the value-names and their values.
4487 The input syntax is NAME:VALUE,NAME:VALUE, and so on.
4488 A semicolon or comma instead of a NAME means the end. */
4489 while (**pp
&& **pp
!= ';' && **pp
!= ',')
4491 STABS_CONTINUE (pp
, objfile
);
4495 name
= obsavestring (*pp
, p
- *pp
, &objfile
->symbol_obstack
);
4497 n
= read_huge_number (pp
, ',', &nbits
);
4499 return error_type (pp
, objfile
);
4501 sym
= (struct symbol
*)
4502 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
4503 memset (sym
, 0, sizeof (struct symbol
));
4504 DEPRECATED_SYMBOL_NAME (sym
) = name
;
4505 SYMBOL_LANGUAGE (sym
) = current_subfile
->language
;
4506 SYMBOL_CLASS (sym
) = LOC_CONST
;
4507 SYMBOL_DOMAIN (sym
) = VAR_DOMAIN
;
4508 SYMBOL_VALUE (sym
) = n
;
4511 add_symbol_to_list (sym
, symlist
);
4516 (*pp
)++; /* Skip the semicolon. */
4518 /* Now fill in the fields of the type-structure. */
4520 TYPE_LENGTH (type
) = TARGET_INT_BIT
/ HOST_CHAR_BIT
;
4521 TYPE_CODE (type
) = TYPE_CODE_ENUM
;
4522 TYPE_FLAGS (type
) &= ~TYPE_FLAG_STUB
;
4524 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
4525 TYPE_NFIELDS (type
) = nsyms
;
4526 TYPE_FIELDS (type
) = (struct field
*)
4527 TYPE_ALLOC (type
, sizeof (struct field
) * nsyms
);
4528 memset (TYPE_FIELDS (type
), 0, sizeof (struct field
) * nsyms
);
4530 /* Find the symbols for the values and put them into the type.
4531 The symbols can be found in the symlist that we put them on
4532 to cause them to be defined. osyms contains the old value
4533 of that symlist; everything up to there was defined by us. */
4534 /* Note that we preserve the order of the enum constants, so
4535 that in something like "enum {FOO, LAST_THING=FOO}" we print
4536 FOO, not LAST_THING. */
4538 for (syms
= *symlist
, n
= nsyms
- 1; syms
; syms
= syms
->next
)
4540 int last
= syms
== osyms
? o_nsyms
: 0;
4541 int j
= syms
->nsyms
;
4542 for (; --j
>= last
; --n
)
4544 struct symbol
*xsym
= syms
->symbol
[j
];
4545 SYMBOL_TYPE (xsym
) = type
;
4546 TYPE_FIELD_NAME (type
, n
) = DEPRECATED_SYMBOL_NAME (xsym
);
4547 TYPE_FIELD_BITPOS (type
, n
) = SYMBOL_VALUE (xsym
);
4548 TYPE_FIELD_BITSIZE (type
, n
) = 0;
4557 /* Sun's ACC uses a somewhat saner method for specifying the builtin
4558 typedefs in every file (for int, long, etc):
4560 type = b <signed> <width> <format type>; <offset>; <nbits>
4562 optional format type = c or b for char or boolean.
4563 offset = offset from high order bit to start bit of type.
4564 width is # bytes in object of this type, nbits is # bits in type.
4566 The width/offset stuff appears to be for small objects stored in
4567 larger ones (e.g. `shorts' in `int' registers). We ignore it for now,
4570 static struct type
*
4571 read_sun_builtin_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4576 enum type_code code
= TYPE_CODE_INT
;
4587 return error_type (pp
, objfile
);
4591 /* For some odd reason, all forms of char put a c here. This is strange
4592 because no other type has this honor. We can safely ignore this because
4593 we actually determine 'char'acterness by the number of bits specified in
4595 Boolean forms, e.g Fortran logical*X, put a b here. */
4599 else if (**pp
== 'b')
4601 code
= TYPE_CODE_BOOL
;
4605 /* The first number appears to be the number of bytes occupied
4606 by this type, except that unsigned short is 4 instead of 2.
4607 Since this information is redundant with the third number,
4608 we will ignore it. */
4609 read_huge_number (pp
, ';', &nbits
);
4611 return error_type (pp
, objfile
);
4613 /* The second number is always 0, so ignore it too. */
4614 read_huge_number (pp
, ';', &nbits
);
4616 return error_type (pp
, objfile
);
4618 /* The third number is the number of bits for this type. */
4619 type_bits
= read_huge_number (pp
, 0, &nbits
);
4621 return error_type (pp
, objfile
);
4622 /* The type *should* end with a semicolon. If it are embedded
4623 in a larger type the semicolon may be the only way to know where
4624 the type ends. If this type is at the end of the stabstring we
4625 can deal with the omitted semicolon (but we don't have to like
4626 it). Don't bother to complain(), Sun's compiler omits the semicolon
4632 return init_type (TYPE_CODE_VOID
, 1,
4633 signed_type
? 0 : TYPE_FLAG_UNSIGNED
, (char *) NULL
,
4636 return init_type (code
,
4637 type_bits
/ TARGET_CHAR_BIT
,
4638 signed_type
? 0 : TYPE_FLAG_UNSIGNED
, (char *) NULL
,
4642 static struct type
*
4643 read_sun_floating_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4648 struct type
*rettype
;
4650 /* The first number has more details about the type, for example
4652 details
= read_huge_number (pp
, ';', &nbits
);
4654 return error_type (pp
, objfile
);
4656 /* The second number is the number of bytes occupied by this type */
4657 nbytes
= read_huge_number (pp
, ';', &nbits
);
4659 return error_type (pp
, objfile
);
4661 if (details
== NF_COMPLEX
|| details
== NF_COMPLEX16
4662 || details
== NF_COMPLEX32
)
4664 rettype
= init_type (TYPE_CODE_COMPLEX
, nbytes
, 0, NULL
, objfile
);
4665 TYPE_TARGET_TYPE (rettype
)
4666 = init_type (TYPE_CODE_FLT
, nbytes
/ 2, 0, NULL
, objfile
);
4670 return init_type (TYPE_CODE_FLT
, nbytes
, 0, NULL
, objfile
);
4673 /* Read a number from the string pointed to by *PP.
4674 The value of *PP is advanced over the number.
4675 If END is nonzero, the character that ends the
4676 number must match END, or an error happens;
4677 and that character is skipped if it does match.
4678 If END is zero, *PP is left pointing to that character.
4680 If the number fits in a long, set *BITS to 0 and return the value.
4681 If not, set *BITS to be the number of bits in the number and return 0.
4683 If encounter garbage, set *BITS to -1 and return 0. */
4686 read_huge_number (char **pp
, int end
, int *bits
)
4703 /* Leading zero means octal. GCC uses this to output values larger
4704 than an int (because that would be hard in decimal). */
4711 upper_limit
= LONG_MAX
/ radix
;
4713 while ((c
= *p
++) >= '0' && c
< ('0' + radix
))
4715 if (n
<= upper_limit
)
4718 n
+= c
- '0'; /* FIXME this overflows anyway */
4723 /* This depends on large values being output in octal, which is
4730 /* Ignore leading zeroes. */
4734 else if (c
== '2' || c
== '3')
4760 /* Large decimal constants are an error (because it is hard to
4761 count how many bits are in them). */
4767 /* -0x7f is the same as 0x80. So deal with it by adding one to
4768 the number of bits. */
4780 /* It's *BITS which has the interesting information. */
4784 static struct type
*
4785 read_range_type (char **pp
, int typenums
[2], struct objfile
*objfile
)
4787 char *orig_pp
= *pp
;
4792 struct type
*result_type
;
4793 struct type
*index_type
= NULL
;
4795 /* First comes a type we are a subrange of.
4796 In C it is usually 0, 1 or the type being defined. */
4797 if (read_type_number (pp
, rangenums
) != 0)
4798 return error_type (pp
, objfile
);
4799 self_subrange
= (rangenums
[0] == typenums
[0] &&
4800 rangenums
[1] == typenums
[1]);
4805 index_type
= read_type (pp
, objfile
);
4808 /* A semicolon should now follow; skip it. */
4812 /* The remaining two operands are usually lower and upper bounds
4813 of the range. But in some special cases they mean something else. */
4814 n2
= read_huge_number (pp
, ';', &n2bits
);
4815 n3
= read_huge_number (pp
, ';', &n3bits
);
4817 if (n2bits
== -1 || n3bits
== -1)
4818 return error_type (pp
, objfile
);
4821 goto handle_true_range
;
4823 /* If limits are huge, must be large integral type. */
4824 if (n2bits
!= 0 || n3bits
!= 0)
4826 char got_signed
= 0;
4827 char got_unsigned
= 0;
4828 /* Number of bits in the type. */
4831 /* Range from 0 to <large number> is an unsigned large integral type. */
4832 if ((n2bits
== 0 && n2
== 0) && n3bits
!= 0)
4837 /* Range from <large number> to <large number>-1 is a large signed
4838 integral type. Take care of the case where <large number> doesn't
4839 fit in a long but <large number>-1 does. */
4840 else if ((n2bits
!= 0 && n3bits
!= 0 && n2bits
== n3bits
+ 1)
4841 || (n2bits
!= 0 && n3bits
== 0
4842 && (n2bits
== sizeof (long) * HOST_CHAR_BIT
)
4849 if (got_signed
|| got_unsigned
)
4851 return init_type (TYPE_CODE_INT
, nbits
/ TARGET_CHAR_BIT
,
4852 got_unsigned
? TYPE_FLAG_UNSIGNED
: 0, NULL
,
4856 return error_type (pp
, objfile
);
4859 /* A type defined as a subrange of itself, with bounds both 0, is void. */
4860 if (self_subrange
&& n2
== 0 && n3
== 0)
4861 return init_type (TYPE_CODE_VOID
, 1, 0, NULL
, objfile
);
4863 /* If n3 is zero and n2 is positive, we want a floating type, and n2
4864 is the width in bytes.
4866 Fortran programs appear to use this for complex types also. To
4867 distinguish between floats and complex, g77 (and others?) seem
4868 to use self-subranges for the complexes, and subranges of int for
4871 Also note that for complexes, g77 sets n2 to the size of one of
4872 the member floats, not the whole complex beast. My guess is that
4873 this was to work well with pre-COMPLEX versions of gdb. */
4875 if (n3
== 0 && n2
> 0)
4877 struct type
*float_type
4878 = init_type (TYPE_CODE_FLT
, n2
, 0, NULL
, objfile
);
4882 struct type
*complex_type
=
4883 init_type (TYPE_CODE_COMPLEX
, 2 * n2
, 0, NULL
, objfile
);
4884 TYPE_TARGET_TYPE (complex_type
) = float_type
;
4885 return complex_type
;
4891 /* If the upper bound is -1, it must really be an unsigned int. */
4893 else if (n2
== 0 && n3
== -1)
4895 /* It is unsigned int or unsigned long. */
4896 /* GCC 2.3.3 uses this for long long too, but that is just a GDB 3.5
4897 compatibility hack. */
4898 return init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
4899 TYPE_FLAG_UNSIGNED
, NULL
, objfile
);
4902 /* Special case: char is defined (Who knows why) as a subrange of
4903 itself with range 0-127. */
4904 else if (self_subrange
&& n2
== 0 && n3
== 127)
4905 return init_type (TYPE_CODE_INT
, 1, TYPE_FLAG_NOSIGN
, NULL
, objfile
);
4907 /* We used to do this only for subrange of self or subrange of int. */
4910 /* -1 is used for the upper bound of (4 byte) "unsigned int" and
4911 "unsigned long", and we already checked for that,
4912 so don't need to test for it here. */
4915 /* n3 actually gives the size. */
4916 return init_type (TYPE_CODE_INT
, -n3
, TYPE_FLAG_UNSIGNED
,
4919 /* Is n3 == 2**(8n)-1 for some integer n? Then it's an
4920 unsigned n-byte integer. But do require n to be a power of
4921 two; we don't want 3- and 5-byte integers flying around. */
4927 for (bytes
= 0; (bits
& 0xff) == 0xff; bytes
++)
4930 && ((bytes
- 1) & bytes
) == 0) /* "bytes is a power of two" */
4931 return init_type (TYPE_CODE_INT
, bytes
, TYPE_FLAG_UNSIGNED
, NULL
,
4935 /* I think this is for Convex "long long". Since I don't know whether
4936 Convex sets self_subrange, I also accept that particular size regardless
4937 of self_subrange. */
4938 else if (n3
== 0 && n2
< 0
4940 || n2
== -TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
))
4941 return init_type (TYPE_CODE_INT
, -n2
, 0, NULL
, objfile
);
4942 else if (n2
== -n3
- 1)
4945 return init_type (TYPE_CODE_INT
, 1, 0, NULL
, objfile
);
4947 return init_type (TYPE_CODE_INT
, 2, 0, NULL
, objfile
);
4948 if (n3
== 0x7fffffff)
4949 return init_type (TYPE_CODE_INT
, 4, 0, NULL
, objfile
);
4952 /* We have a real range type on our hands. Allocate space and
4953 return a real pointer. */
4957 index_type
= builtin_type_int
;
4959 index_type
= *dbx_lookup_type (rangenums
);
4960 if (index_type
== NULL
)
4962 /* Does this actually ever happen? Is that why we are worrying
4963 about dealing with it rather than just calling error_type? */
4965 static struct type
*range_type_index
;
4967 complaint (&symfile_complaints
,
4968 "base type %d of range type is not defined", rangenums
[1]);
4969 if (range_type_index
== NULL
)
4971 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
4972 0, "range type index type", NULL
);
4973 index_type
= range_type_index
;
4976 result_type
= create_range_type ((struct type
*) NULL
, index_type
, n2
, n3
);
4977 return (result_type
);
4980 /* Read in an argument list. This is a list of types, separated by commas
4981 and terminated with END. Return the list of types read in, or (struct type
4982 **)-1 if there is an error. */
4984 static struct field
*
4985 read_args (char **pp
, int end
, struct objfile
*objfile
, int *nargsp
,
4988 /* FIXME! Remove this arbitrary limit! */
4989 struct type
*types
[1024]; /* allow for fns of 1023 parameters */
4996 /* Invalid argument list: no ','. */
4997 return (struct field
*) -1;
4999 STABS_CONTINUE (pp
, objfile
);
5000 types
[n
++] = read_type (pp
, objfile
);
5002 (*pp
)++; /* get past `end' (the ':' character) */
5004 if (TYPE_CODE (types
[n
- 1]) != TYPE_CODE_VOID
)
5012 rval
= (struct field
*) xmalloc (n
* sizeof (struct field
));
5013 memset (rval
, 0, n
* sizeof (struct field
));
5014 for (i
= 0; i
< n
; i
++)
5015 rval
[i
].type
= types
[i
];
5020 /* Common block handling. */
5022 /* List of symbols declared since the last BCOMM. This list is a tail
5023 of local_symbols. When ECOMM is seen, the symbols on the list
5024 are noted so their proper addresses can be filled in later,
5025 using the common block base address gotten from the assembler
5028 static struct pending
*common_block
;
5029 static int common_block_i
;
5031 /* Name of the current common block. We get it from the BCOMM instead of the
5032 ECOMM to match IBM documentation (even though IBM puts the name both places
5033 like everyone else). */
5034 static char *common_block_name
;
5036 /* Process a N_BCOMM symbol. The storage for NAME is not guaranteed
5037 to remain after this function returns. */
5040 common_block_start (char *name
, struct objfile
*objfile
)
5042 if (common_block_name
!= NULL
)
5044 complaint (&symfile_complaints
,
5045 "Invalid symbol data: common block within common block");
5047 common_block
= local_symbols
;
5048 common_block_i
= local_symbols
? local_symbols
->nsyms
: 0;
5049 common_block_name
= obsavestring (name
, strlen (name
),
5050 &objfile
->symbol_obstack
);
5053 /* Process a N_ECOMM symbol. */
5056 common_block_end (struct objfile
*objfile
)
5058 /* Symbols declared since the BCOMM are to have the common block
5059 start address added in when we know it. common_block and
5060 common_block_i point to the first symbol after the BCOMM in
5061 the local_symbols list; copy the list and hang it off the
5062 symbol for the common block name for later fixup. */
5065 struct pending
*new = 0;
5066 struct pending
*next
;
5069 if (common_block_name
== NULL
)
5071 complaint (&symfile_complaints
, "ECOMM symbol unmatched by BCOMM");
5075 sym
= (struct symbol
*)
5076 obstack_alloc (&objfile
->symbol_obstack
, sizeof (struct symbol
));
5077 memset (sym
, 0, sizeof (struct symbol
));
5078 /* Note: common_block_name already saved on symbol_obstack */
5079 DEPRECATED_SYMBOL_NAME (sym
) = common_block_name
;
5080 SYMBOL_CLASS (sym
) = LOC_BLOCK
;
5082 /* Now we copy all the symbols which have been defined since the BCOMM. */
5084 /* Copy all the struct pendings before common_block. */
5085 for (next
= local_symbols
;
5086 next
!= NULL
&& next
!= common_block
;
5089 for (j
= 0; j
< next
->nsyms
; j
++)
5090 add_symbol_to_list (next
->symbol
[j
], &new);
5093 /* Copy however much of COMMON_BLOCK we need. If COMMON_BLOCK is
5094 NULL, it means copy all the local symbols (which we already did
5097 if (common_block
!= NULL
)
5098 for (j
= common_block_i
; j
< common_block
->nsyms
; j
++)
5099 add_symbol_to_list (common_block
->symbol
[j
], &new);
5101 SYMBOL_TYPE (sym
) = (struct type
*) new;
5103 /* Should we be putting local_symbols back to what it was?
5106 i
= hashname (DEPRECATED_SYMBOL_NAME (sym
));
5107 SYMBOL_VALUE_CHAIN (sym
) = global_sym_chain
[i
];
5108 global_sym_chain
[i
] = sym
;
5109 common_block_name
= NULL
;
5112 /* Add a common block's start address to the offset of each symbol
5113 declared to be in it (by being between a BCOMM/ECOMM pair that uses
5114 the common block name). */
5117 fix_common_block (struct symbol
*sym
, int valu
)
5119 struct pending
*next
= (struct pending
*) SYMBOL_TYPE (sym
);
5120 for (; next
; next
= next
->next
)
5123 for (j
= next
->nsyms
- 1; j
>= 0; j
--)
5124 SYMBOL_VALUE_ADDRESS (next
->symbol
[j
]) += valu
;
5130 /* What about types defined as forward references inside of a small lexical
5132 /* Add a type to the list of undefined types to be checked through
5133 once this file has been read in. */
5136 add_undefined_type (struct type
*type
)
5138 if (undef_types_length
== undef_types_allocated
)
5140 undef_types_allocated
*= 2;
5141 undef_types
= (struct type
**)
5142 xrealloc ((char *) undef_types
,
5143 undef_types_allocated
* sizeof (struct type
*));
5145 undef_types
[undef_types_length
++] = type
;
5148 /* Go through each undefined type, see if it's still undefined, and fix it
5149 up if possible. We have two kinds of undefined types:
5151 TYPE_CODE_ARRAY: Array whose target type wasn't defined yet.
5152 Fix: update array length using the element bounds
5153 and the target type's length.
5154 TYPE_CODE_STRUCT, TYPE_CODE_UNION: Structure whose fields were not
5155 yet defined at the time a pointer to it was made.
5156 Fix: Do a full lookup on the struct/union tag. */
5158 cleanup_undefined_types (void)
5162 for (type
= undef_types
; type
< undef_types
+ undef_types_length
; type
++)
5164 switch (TYPE_CODE (*type
))
5167 case TYPE_CODE_STRUCT
:
5168 case TYPE_CODE_UNION
:
5169 case TYPE_CODE_ENUM
:
5171 /* Check if it has been defined since. Need to do this here
5172 as well as in check_typedef to deal with the (legitimate in
5173 C though not C++) case of several types with the same name
5174 in different source files. */
5175 if (TYPE_STUB (*type
))
5177 struct pending
*ppt
;
5179 /* Name of the type, without "struct" or "union" */
5180 char *typename
= TYPE_TAG_NAME (*type
);
5182 if (typename
== NULL
)
5184 complaint (&symfile_complaints
, "need a type name");
5187 for (ppt
= file_symbols
; ppt
; ppt
= ppt
->next
)
5189 for (i
= 0; i
< ppt
->nsyms
; i
++)
5191 struct symbol
*sym
= ppt
->symbol
[i
];
5193 if (SYMBOL_CLASS (sym
) == LOC_TYPEDEF
5194 && SYMBOL_DOMAIN (sym
) == STRUCT_DOMAIN
5195 && (TYPE_CODE (SYMBOL_TYPE (sym
)) ==
5197 && STREQ (DEPRECATED_SYMBOL_NAME (sym
), typename
))
5198 replace_type (*type
, SYMBOL_TYPE (sym
));
5207 complaint (&symfile_complaints
,
5208 "GDB internal error. cleanup_undefined_types with bad type %d.",
5215 undef_types_length
= 0;
5218 /* Scan through all of the global symbols defined in the object file,
5219 assigning values to the debugging symbols that need to be assigned
5220 to. Get these symbols from the minimal symbol table. */
5223 scan_file_globals (struct objfile
*objfile
)
5226 struct minimal_symbol
*msymbol
;
5227 struct symbol
*sym
, *prev
, *rsym
;
5228 struct objfile
*resolve_objfile
;
5230 /* SVR4 based linkers copy referenced global symbols from shared
5231 libraries to the main executable.
5232 If we are scanning the symbols for a shared library, try to resolve
5233 them from the minimal symbols of the main executable first. */
5235 if (symfile_objfile
&& objfile
!= symfile_objfile
)
5236 resolve_objfile
= symfile_objfile
;
5238 resolve_objfile
= objfile
;
5242 /* Avoid expensive loop through all minimal symbols if there are
5243 no unresolved symbols. */
5244 for (hash
= 0; hash
< HASHSIZE
; hash
++)
5246 if (global_sym_chain
[hash
])
5249 if (hash
>= HASHSIZE
)
5252 for (msymbol
= resolve_objfile
->msymbols
;
5253 msymbol
&& DEPRECATED_SYMBOL_NAME (msymbol
) != NULL
;
5258 /* Skip static symbols. */
5259 switch (MSYMBOL_TYPE (msymbol
))
5271 /* Get the hash index and check all the symbols
5272 under that hash index. */
5274 hash
= hashname (DEPRECATED_SYMBOL_NAME (msymbol
));
5276 for (sym
= global_sym_chain
[hash
]; sym
;)
5278 if (DEPRECATED_SYMBOL_NAME (msymbol
)[0] == DEPRECATED_SYMBOL_NAME (sym
)[0] &&
5279 STREQ (DEPRECATED_SYMBOL_NAME (msymbol
) + 1, DEPRECATED_SYMBOL_NAME (sym
) + 1))
5282 struct alias_list
*aliases
;
5284 /* Splice this symbol out of the hash chain and
5285 assign the value we have to it. */
5288 SYMBOL_VALUE_CHAIN (prev
) = SYMBOL_VALUE_CHAIN (sym
);
5292 global_sym_chain
[hash
] = SYMBOL_VALUE_CHAIN (sym
);
5295 /* Check to see whether we need to fix up a common block. */
5296 /* Note: this code might be executed several times for
5297 the same symbol if there are multiple references. */
5299 /* If symbol has aliases, do minimal symbol fixups for each.
5300 These live aliases/references weren't added to
5301 global_sym_chain hash but may also need to be fixed up. */
5302 /* FIXME: Maybe should have added aliases to the global chain, resolved symbol name, then treated aliases as normal
5303 symbols? Still, we wouldn't want to add_to_list. */
5304 /* Now do the same for each alias of this symbol */
5306 aliases
= SYMBOL_ALIASES (sym
);
5309 if (SYMBOL_CLASS (rsym
) == LOC_BLOCK
)
5311 fix_common_block (rsym
,
5312 SYMBOL_VALUE_ADDRESS (msymbol
));
5316 SYMBOL_VALUE_ADDRESS (rsym
)
5317 = SYMBOL_VALUE_ADDRESS (msymbol
);
5319 SYMBOL_SECTION (rsym
) = SYMBOL_SECTION (msymbol
);
5322 rsym
= aliases
->sym
;
5323 aliases
= aliases
->next
;
5332 sym
= SYMBOL_VALUE_CHAIN (prev
);
5336 sym
= global_sym_chain
[hash
];
5342 sym
= SYMBOL_VALUE_CHAIN (sym
);
5346 if (resolve_objfile
== objfile
)
5348 resolve_objfile
= objfile
;
5351 /* Change the storage class of any remaining unresolved globals to
5352 LOC_UNRESOLVED and remove them from the chain. */
5353 for (hash
= 0; hash
< HASHSIZE
; hash
++)
5355 sym
= global_sym_chain
[hash
];
5359 sym
= SYMBOL_VALUE_CHAIN (sym
);
5361 /* Change the symbol address from the misleading chain value
5363 SYMBOL_VALUE_ADDRESS (prev
) = 0;
5365 /* Complain about unresolved common block symbols. */
5366 if (SYMBOL_CLASS (prev
) == LOC_STATIC
)
5367 SYMBOL_CLASS (prev
) = LOC_UNRESOLVED
;
5369 complaint (&symfile_complaints
,
5370 "%s: common block `%s' from global_sym_chain unresolved",
5371 objfile
->name
, DEPRECATED_SYMBOL_NAME (prev
));
5374 memset (global_sym_chain
, 0, sizeof (global_sym_chain
));
5377 /* Initialize anything that needs initializing when starting to read
5378 a fresh piece of a symbol file, e.g. reading in the stuff corresponding
5382 stabsread_init (void)
5386 /* Initialize anything that needs initializing when a completely new
5387 symbol file is specified (not just adding some symbols from another
5388 file, e.g. a shared library). */
5391 stabsread_new_init (void)
5393 /* Empty the hash table of global syms looking for values. */
5394 memset (global_sym_chain
, 0, sizeof (global_sym_chain
));
5397 /* Initialize anything that needs initializing at the same time as
5398 start_symtab() is called. */
5403 global_stabs
= NULL
; /* AIX COFF */
5404 /* Leave FILENUM of 0 free for builtin types and this file's types. */
5405 n_this_object_header_files
= 1;
5406 type_vector_length
= 0;
5407 type_vector
= (struct type
**) 0;
5409 /* FIXME: If common_block_name is not already NULL, we should complain(). */
5410 common_block_name
= NULL
;
5413 /* Call after end_symtab() */
5420 xfree (type_vector
);
5423 type_vector_length
= 0;
5424 previous_stab_code
= 0;
5428 finish_global_stabs (struct objfile
*objfile
)
5432 patch_block_stabs (global_symbols
, global_stabs
, objfile
);
5433 xfree (global_stabs
);
5434 global_stabs
= NULL
;
5438 /* Find the end of the name, delimited by a ':', but don't match
5439 ObjC symbols which look like -[Foo bar::]:bla. */
5441 find_name_end (char *name
)
5444 if (s
[0] == '-' || *s
== '+')
5446 /* Must be an ObjC method symbol. */
5449 error ("invalid symbol name \"%s\"", name
);
5451 s
= strchr (s
, ']');
5454 error ("invalid symbol name \"%s\"", name
);
5456 return strchr (s
, ':');
5460 return strchr (s
, ':');
5464 /* Initializer for this module */
5467 _initialize_stabsread (void)
5469 undef_types_allocated
= 20;
5470 undef_types_length
= 0;
5471 undef_types
= (struct type
**)
5472 xmalloc (undef_types_allocated
* sizeof (struct type
*));