/* Support routines for decoding "stabs" debugging information format.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996
+ Copyright 1986, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 1997
Free Software Foundation, Inc.
This file is part of GDB.
} *fnlist;
};
+static void
+read_one_struct_field PARAMS ((struct field_info *, char **, char *,
+ struct type *, struct objfile *));
+
+static char *
+get_substring PARAMS ((char **, int));
+
static struct type *
dbx_alloc_type PARAMS ((int [2], struct objfile *));
/* new functions added for cfront support */
-extern void
-resolve_cfront_continuation PARAMS ((struct objfile *, struct symbol *,
- char * p));
-
static int
copy_cfront_struct_fields PARAMS ((struct field_info *, struct type *,
struct objfile *));
{
real_filenum = this_object_header_files[filenum];
- if (real_filenum >= n_header_files)
+ if (real_filenum >= N_HEADER_FILES (current_objfile))
{
struct type *temp_type;
struct type **temp_type_p;
return temp_type_p;
}
- f = &header_files[real_filenum];
+ f = HEADER_FILES (current_objfile) + real_filenum;
f_orig_length = f->length;
if (index >= f_orig_length)
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
SYMBOL_NAME (sym) =
- obstack_copy0 (&objfile->symbol_obstack, name, pp - name);
+ obsavestring (name, pp - name, &objfile->symbol_obstack);
pp += 2;
if (*(pp-1) == 'F' || *(pp-1) == 'f')
{
/* This code added to support parsing of ARM/Cfront stabs strings */
-/* get substring from string up to char c
- advance string pointer past suibstring */
+/* Get substring from string up to char c, advance string pointer past
+ suibstring. */
+
static char *
-get_substring(p, c)
+get_substring (p, c)
char ** p;
- char c;
+ int c;
{
- char * str;
+ char *str;
str = *p;
- *p = strchr(*p,c);
+ *p = strchr (*p, c);
if (*p)
{
**p = 0;
return str;
}
-/* Physname gets strcat'd onto sname in order to recreate the mangled name
- (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make the physname
- look like that of g++ - take out the initial mangling
+/* Physname gets strcat'd onto sname in order to recreate the mangled
+ name (see funtion gdb_mangle_name in gdbtypes.c). For cfront, make
+ the physname look like that of g++ - take out the initial mangling
eg: for sname="a" and fname="foo__1aFPFs_i" return "FPFs_i" */
+
static char *
-get_cfront_method_physname(fname)
- char * fname;
+get_cfront_method_physname (fname)
+ char *fname;
{
- int len=0;
+ int len = 0;
/* FIXME would like to make this generic for g++ too, but
that is already handled in read_member_funcctions */
char * p = fname;
/* search ahead to find the start of the mangled suffix */
if (*p == '_' && *(p+1)=='_') /* compiler generated; probably a ctor/dtor */
- p+=2;
- while (p && ((p+1) - fname) < strlen(fname) && *(p+1)!='_')
- p = strchr(p,'_');
- if (!(p && *p=='_' && *(p+1)=='_'))
- error("Invalid mangled function name %s",fname);
- p+=2; /* advance past '__' */
+ p += 2;
+ while (p && ((p+1) - fname) < strlen (fname) && *(p+1) != '_')
+ p = strchr (p, '_');
+ if (!(p && *p == '_' && *(p+1) == '_'))
+ error ("Invalid mangled function name %s",fname);
+ p += 2; /* advance past '__' */
/* struct name length and name of type should come next; advance past it */
- while (isdigit(*p))
+ while (isdigit (*p))
{
- len = len*10 + (*p - '0');
+ len = len * 10 + (*p - '0');
p++;
}
- p+=len;
+ p += len;
return p;
}
A:ZcA;;foopri__1AFv foopro__1AFv __ct__1AFv __ct__1AFRC1A foopub__1AFv ;;;
^
*/
+
static int
-read_cfront_baseclasses(fip, pp, type, objfile)
+read_cfront_baseclasses (fip, pp, type, objfile)
struct field_info *fip;
- struct objfile * objfile;
+ struct objfile *objfile;
char ** pp;
- struct type * type;
+ struct type *type;
{
- static struct complaint msg_noterm = {"\
- Base classes not terminated while reading stabs string %s.\n",
- 0, 0};
static struct complaint msg_unknown = {"\
Unsupported token in stabs string %s.\n",
0, 0};
static struct complaint msg_notfound = {"\
Unable to find base type for %s.\n",
0, 0};
- int bnum=0;
+ int bnum = 0;
char * p;
int i;
struct nextfield *new;
- if (**pp==';') /* no base classes; return */
+ if (**pp == ';') /* no base classes; return */
{
++(*pp);
- return;
+ return 1;
}
/* first count base classes so we can allocate space before parsing */
- for (p = *pp; p && *p && *p!=';'; p++)
+ for (p = *pp; p && *p && *p != ';'; p++)
{
- if (*p==' ') bnum++;
+ if (*p == ' ')
+ bnum++;
}
bnum++; /* add one more for last one */
{
int num_bytes = B_BYTES (TYPE_N_BASECLASSES (type));
char *pointer;
+
pointer = (char *) TYPE_ALLOC (type, num_bytes);
TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *) pointer;
}
B_CLRALL (TYPE_FIELD_VIRTUAL_BITS (type), TYPE_N_BASECLASSES (type));
-
for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
{
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
if (**pp!='@')
{
complain (&msg_unknown, *pp);
- return;
+ return 1;
}
++(*pp);
if (!bname || !*bname)
{
complain (&msg_unknown, *pp);
- return;
+ return 1;
}
/* FIXME! attach base info to type */
bsym = lookup_symbol (bname, 0, STRUCT_NAMESPACE, 0, 0); /*demangled_name*/
else
{
complain (&msg_notfound, *pp);
- return;
+ return 1;
}
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
+static int
read_cfront_member_functions(fip, pp, type, objfile)
struct field_info *fip;
char **pp;
for public, set new_sublist->fn_field.is_protected = 1) */
/* Unable to distinguish const/volatile from stabs definition!
- Assuming normal for now. FIXME!
+ Assuming normal for now. FIXME! */
+
new_sublist -> fn_field.is_const = 0;
new_sublist -> fn_field.is_volatile = 0; /* volatile not implemented in cfront */
char * sname;
/* snarfed from read_struct_type */
struct field_info fi;
- struct field_info * fip = &fi;
struct type *type;
struct cleanup *back_to;
/* When passing structures to a function, some systems sometimes pass
the address in a register, not the structure itself. */
- if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation,
- SYMBOL_TYPE (sym))
- && ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
- || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_UNION)
- || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_BITSTRING)
- || (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_SET)))
+ if (REG_STRUCT_HAS_ADDR (processing_gcc_compilation, SYMBOL_TYPE (sym))
+ && (SYMBOL_CLASS (sym) == LOC_REGPARM || SYMBOL_CLASS (sym) == LOC_ARG))
{
- /* If REG_STRUCT_HAS_ADDR yields non-zero we have to
- convert LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
- if (SYMBOL_CLASS (sym) == LOC_REGPARM)
- SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
- /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th and
- subsequent arguments on the sparc, for example). */
- else if (SYMBOL_CLASS (sym) == LOC_ARG)
- SYMBOL_CLASS (sym) = LOC_REF_ARG;
+ struct type *symbol_type = check_typedef (SYMBOL_TYPE (sym));
+
+ if ((TYPE_CODE (symbol_type) == TYPE_CODE_STRUCT)
+ || (TYPE_CODE (symbol_type) == TYPE_CODE_UNION)
+ || (TYPE_CODE (symbol_type) == TYPE_CODE_BITSTRING)
+ || (TYPE_CODE (symbol_type) == TYPE_CODE_SET))
+ {
+ /* If REG_STRUCT_HAS_ADDR yields non-zero we have to convert
+ LOC_REGPARM to LOC_REGPARM_ADDR for structures and unions. */
+ if (SYMBOL_CLASS (sym) == LOC_REGPARM)
+ SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+ /* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
+ and subsequent arguments on the sparc, for example). */
+ else if (SYMBOL_CLASS (sym) == LOC_ARG)
+ SYMBOL_CLASS (sym) = LOC_REF_ARG;
+ }
}
return sym;
register struct type *type = 0;
struct type *type1;
int typenums[2];
- int xtypenums[2];
char type_descriptor;
/* Size in bits of type if specified by a type attribute, or -1 if
p = strchr(*pp, ':');
if (p == NULL)
return error_type (pp, objfile);
- while (q1 && p > q1 && p[1] == ':')
+ if (q1 && p > q1 && p[1] == ':')
{
- q2 = strchr(q1, '>');
- if (!q2 || q2 < p)
- break;
- p += 2;
- p = strchr(p, ':');
- if (p == NULL)
- return error_type (pp, objfile);
+ int nesting_level = 0;
+ for (q2 = q1; *q2; q2++)
+ {
+ if (*q2 == '<')
+ nesting_level++;
+ else if (*q2 == '>')
+ nesting_level--;
+ else if (*q2 == ':' && nesting_level == 0)
+ break;
+ }
+ p = q2;
+ if (*p != ':')
+ return error_type (pp, objfile);
}
to = type_name =
(char *)obstack_alloc (&objfile->type_obstack, p - *pp + 1);
struct type *type;
struct objfile *objfile;
{
- int nfields = TYPE_NFIELDS(type);
- int i;
struct nextfield * new;
struct type *stype;
char * sname;
if (**pp==';') /* no static data; return */
{
++(*pp);
- return;
+ return 1;
}
/* Process each field in the list until we find the terminating ";" */
sym = (struct symbol *)
obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
+ /* Note: common_block_name already saved on symbol_obstack */
SYMBOL_NAME (sym) = common_block_name;
SYMBOL_CLASS (sym) = LOC_BLOCK;
int hash;
struct minimal_symbol *msymbol;
struct symbol *sym, *prev;
+ struct objfile *resolve_objfile;
- /* Avoid expensive loop through all minimal symbols if there are
- no unresolved symbols. */
- for (hash = 0; hash < HASHSIZE; hash++)
- {
- if (global_sym_chain[hash])
- break;
- }
- if (hash >= HASHSIZE)
- return;
+ /* SVR4 based linkers copy referenced global symbols from shared
+ libraries to the main executable.
+ If we are scanning the symbols for a shared library, try to resolve
+ them from the minimal symbols of the main executable first. */
- for (msymbol = objfile -> msymbols;
- msymbol && SYMBOL_NAME (msymbol) != NULL;
- msymbol++)
- {
- QUIT;
+ if (symfile_objfile && objfile != symfile_objfile)
+ resolve_objfile = symfile_objfile;
+ else
+ resolve_objfile = objfile;
- /* Skip static symbols. */
- switch (MSYMBOL_TYPE (msymbol))
+ while (1)
+ {
+ /* Avoid expensive loop through all minimal symbols if there are
+ no unresolved symbols. */
+ for (hash = 0; hash < HASHSIZE; hash++)
{
- case mst_file_text:
- case mst_file_data:
- case mst_file_bss:
- continue;
- default:
- break;
+ if (global_sym_chain[hash])
+ break;
}
+ if (hash >= HASHSIZE)
+ return;
+
+ for (msymbol = resolve_objfile -> msymbols;
+ msymbol && SYMBOL_NAME (msymbol) != NULL;
+ msymbol++)
+ {
+ QUIT;
- prev = NULL;
+ /* Skip static symbols. */
+ switch (MSYMBOL_TYPE (msymbol))
+ {
+ case mst_file_text:
+ case mst_file_data:
+ case mst_file_bss:
+ continue;
+ default:
+ break;
+ }
- /* Get the hash index and check all the symbols
- under that hash index. */
+ prev = NULL;
- hash = hashname (SYMBOL_NAME (msymbol));
+ /* Get the hash index and check all the symbols
+ under that hash index. */
- for (sym = global_sym_chain[hash]; sym;)
- {
- if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
- STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
+ hash = hashname (SYMBOL_NAME (msymbol));
+
+ for (sym = global_sym_chain[hash]; sym;)
{
- /* Splice this symbol out of the hash chain and
- assign the value we have to it. */
- if (prev)
+ if (SYMBOL_NAME (msymbol)[0] == SYMBOL_NAME (sym)[0] &&
+ STREQ(SYMBOL_NAME (msymbol) + 1, SYMBOL_NAME (sym) + 1))
{
- SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
- }
- else
- {
- global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
- }
-
- /* Check to see whether we need to fix up a common block. */
- /* Note: this code might be executed several times for
- the same symbol if there are multiple references. */
+ /* Splice this symbol out of the hash chain and
+ assign the value we have to it. */
+ if (prev)
+ {
+ SYMBOL_VALUE_CHAIN (prev) = SYMBOL_VALUE_CHAIN (sym);
+ }
+ else
+ {
+ global_sym_chain[hash] = SYMBOL_VALUE_CHAIN (sym);
+ }
+
+ /* Check to see whether we need to fix up a common block. */
+ /* Note: this code might be executed several times for
+ the same symbol if there are multiple references. */
- if (SYMBOL_CLASS (sym) == LOC_BLOCK)
- {
- fix_common_block (sym, SYMBOL_VALUE_ADDRESS (msymbol));
- }
- else
- {
- SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msymbol);
- }
+ if (SYMBOL_CLASS (sym) == LOC_BLOCK)
+ {
+ fix_common_block (sym, SYMBOL_VALUE_ADDRESS (msymbol));
+ }
+ else
+ {
+ SYMBOL_VALUE_ADDRESS (sym)
+ = SYMBOL_VALUE_ADDRESS (msymbol);
+ }
- SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
-
- if (prev)
- {
- sym = SYMBOL_VALUE_CHAIN (prev);
+ SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
+
+ if (prev)
+ {
+ sym = SYMBOL_VALUE_CHAIN (prev);
+ }
+ else
+ {
+ sym = global_sym_chain[hash];
+ }
}
else
{
- sym = global_sym_chain[hash];
+ prev = sym;
+ sym = SYMBOL_VALUE_CHAIN (sym);
}
}
- else
- {
- prev = sym;
- sym = SYMBOL_VALUE_CHAIN (sym);
- }
}
+ if (resolve_objfile == objfile)
+ break;
+ resolve_objfile = objfile;
}
/* Change the storage class of any remaining unresolved globals to
SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
else
complain (&unresolved_sym_chain_complaint,
- objfile->name, SYMBOL_NAME (prev));
+ objfile -> name, SYMBOL_NAME (prev));
}
}
memset (global_sym_chain, 0, sizeof (global_sym_chain));