/* Support routines for decoding "stabs" debugging information format.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995
Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Support routines for reading and decoding debugging information in
the "stabs" format. This format is used with many systems that use
Avoid placing any object file format specific code in this file. */
#include "defs.h"
-#include <string.h>
+#include "gdb_string.h"
#include "bfd.h"
#include "obstack.h"
#include "symtab.h"
#include "gdbtypes.h"
+#include "expression.h"
#include "symfile.h"
#include "objfiles.h"
#include "aout/stab_gnu.h" /* We always use GNU stabs, not native */
+#include "libaout.h"
+#include "aout/aout64.h"
+#include "gdb-stabs.h"
#include "buildsym.h"
#include "complaints.h"
#include "demangle.h"
+#include "language.h"
#include <ctype.h>
static long read_huge_number PARAMS ((char **, int, int *));
-static struct type *error_type PARAMS ((char **));
+static struct type *error_type PARAMS ((char **, struct objfile *));
static void
patch_block_stabs PARAMS ((struct pending *, struct pending_stabs *,
struct complaint rs6000_builtin_complaint =
{"Unknown builtin type %d", 0, 0};
+struct complaint unresolved_sym_chain_complaint =
+ {"%s: common block `%s' from global_sym_chain unresolved", 0, 0};
+
struct complaint stabs_general_complaint =
{"%s", 0, 0};
static struct type **undef_types;
static int undef_types_allocated;
static int undef_types_length;
+static struct symbol *current_symbol = NULL;
/* Check for and handle cretinous stabs symbol name continuation! */
-#define STABS_CONTINUE(pp) \
+#define STABS_CONTINUE(pp,objfile) \
do { \
if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \
- *(pp) = next_symbol_text (); \
+ *(pp) = next_symbol_text (objfile); \
} while (0)
\f
/* FIXME: These probably should be our own types (like rs6000_builtin_type
sym = find_symbol_in_list (symbols, name, pp-name);
if (!sym)
{
+ /* FIXME-maybe: it would be nice if we noticed whether
+ the variable was defined *anywhere*, not just whether
+ it is defined in this compilation unit. But neither
+ xlc or GCC seem to need such a definition, and until
+ we do psymtabs (so that the minimal symbols from all
+ compilation units are available now), I'm not sure
+ how to get the information. */
+
/* On xcoff, if a global is defined and never referenced,
ld will remove it from the executable. There is then
a N_GSYM stab for it, but no regular (C_EXT) symbol. */
}
\f
-/* To handle GNU C++ typename abbreviation, we need to be able to
- fill in a type's name as soon as space for that type is allocated.
- `type_synonym_name' is the name of the type being allocated.
- It is cleared as soon as it is used (lest all allocated types
- get this name). */
-
-static char *type_synonym_name;
-
#if !defined (REG_STRUCT_HAS_ADDR)
-#define REG_STRUCT_HAS_ADDR(gcc_p) 0
+#define REG_STRUCT_HAS_ADDR(gcc_p,type) 0
#endif
/* ARGSUSED */
e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
nameless = (p == string || ((string[0] == ' ') && (string[1] == ':')));
- sym = (struct symbol *)
+ current_symbol = sym = (struct symbol *)
obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
memset (sym, 0, sizeof (struct symbol));
+ switch (type & N_TYPE)
+ {
+ case N_TEXT:
+ SYMBOL_SECTION(sym) = SECT_OFF_TEXT;
+ break;
+ case N_DATA:
+ SYMBOL_SECTION(sym) = SECT_OFF_DATA;
+ break;
+ case N_BSS:
+ SYMBOL_SECTION(sym) = SECT_OFF_BSS;
+ break;
+ }
+
if (processing_gcc_compilation)
{
/* GCC 2.x puts the line number in desc. SunOS apparently puts in the
/* This was an anonymous type that was never fixed up. */
goto normal;
+#ifdef STATIC_TRANSFORM_NAME
+ case 'X':
+ /* SunPRO (3.0 at least) static variable encoding. */
+ goto normal;
+#endif
+
default:
complain (&unrecognized_cplus_name_complaint, string);
goto normal; /* Do *something* with it */
if (*p != '=')
{
SYMBOL_CLASS (sym) = LOC_CONST;
- SYMBOL_TYPE (sym) = error_type (&p);
+ SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
add_symbol_to_list (sym, &file_symbols);
return sym;
if (*p != ',')
{
- SYMBOL_TYPE (sym) = error_type (&p);
+ SYMBOL_TYPE (sym) = error_type (&p, objfile);
break;
}
++p;
default:
{
SYMBOL_CLASS (sym) = LOC_CONST;
- SYMBOL_TYPE (sym) = error_type (&p);
+ SYMBOL_TYPE (sym) = error_type (&p, objfile);
}
}
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
We need to convert this to the function-returning-type-X type
in GDB. E.g. "int" is converted to "function returning int". */
if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_FUNC)
- {
-#if 0
- /* This code doesn't work -- it needs to realloc and can't. */
- /* Attempt to set up to record a function prototype... */
- struct type *new = alloc_type (objfile);
-
- /* Generate a template for the type of this function. The
- types of the arguments will be added as we read the symbol
- table. */
- *new = *lookup_function_type (SYMBOL_TYPE(sym));
- SYMBOL_TYPE(sym) = new;
- TYPE_OBJFILE (new) = objfile;
- in_function_type = new;
-#else
- SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
-#endif
- }
+ SYMBOL_TYPE (sym) = lookup_function_type (SYMBOL_TYPE (sym));
/* fall into process_prototype_types */
process_prototype_types:
SYMBOL_CLASS (sym) = DBX_PARM_SYMBOL_CLASS (type);
SYMBOL_VALUE (sym) = valu;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
-#if 0
- /* This doesn't work yet. */
- add_param_to_type (&in_function_type, sym);
-#endif
add_symbol_to_list (sym, &local_symbols);
-#if TARGET_BYTE_ORDER == LITTLE_ENDIAN
- /* On little-endian machines, this crud is never necessary, and,
- if the extra bytes contain garbage, is harmful. */
- break;
-#else /* Big endian. */
+ if (TARGET_BYTE_ORDER != BIG_ENDIAN)
+ {
+ /* On little-endian machines, this crud is never necessary,
+ and, if the extra bytes contain garbage, is harmful. */
+ break;
+ }
+
/* If it's gcc-compiled, if it says `short', believe it. */
if (processing_gcc_compilation || BELIEVE_PCC_PROMOTION)
break;
#endif /* no BELIEVE_PCC_PROMOTION_TYPE. */
}
#endif /* !BELIEVE_PCC_PROMOTION. */
-#endif /* Big endian. */
case 'P':
/* acc seems to use P to delare the prototypes of functions that
/* Sun cc uses a pair of symbols, one 'p' and one 'r' with the same
name to represent an argument passed in a register.
GCC uses 'P' for the same case. So if we find such a symbol pair
- we combine it into one 'P' symbol.
+ we combine it into one 'P' symbol. For Sun cc we need to do this
+ regardless of REG_STRUCT_HAS_ADDR, because the compiler puts out
+ the 'p' symbol even if it never saves the argument onto the stack.
- But we only do this in the REG_STRUCT_HAS_ADDR case, so that
+ On most machines, we want to preserve both symbols, so that
we can still get information about what is going on with the
stack (VAX for computing args_printed, using stack slots instead
of saved registers in backtraces, etc.).
if (local_symbols
&& local_symbols->nsyms > 0
- && REG_STRUCT_HAS_ADDR (processing_gcc_compilation)
+#ifndef USE_REGISTER_NOT_ARG
+ && 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_UNION)
+#endif
+ )
{
struct symbol *prev_sym;
prev_sym = local_symbols->symbol[local_symbols->nsyms - 1];
- if (SYMBOL_CLASS (prev_sym) == LOC_ARG
+ if ((SYMBOL_CLASS (prev_sym) == LOC_REF_ARG
+ || SYMBOL_CLASS (prev_sym) == LOC_ARG)
&& STREQ (SYMBOL_NAME (prev_sym), SYMBOL_NAME(sym)))
{
SYMBOL_CLASS (prev_sym) = LOC_REGPARM;
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
+#ifdef STATIC_TRANSFORM_NAME
+ if (SYMBOL_NAME (sym)[0] == '$')
+ {
+ struct minimal_symbol *msym;
+ msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
+ if (msym != NULL)
+ {
+ SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
+ SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
+ }
+ }
+#endif
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
add_symbol_to_list (sym, &file_symbols);
break;
if (TYPE_NAME (SYMBOL_TYPE (sym)) == NULL)
{
- if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
+ /* gcc-2.6 or later (when using -fvtable-thunks)
+ emits a unique named type for a vtable entry.
+ Some gdb code depends on that specific name. */
+ extern const char vtbl_ptr_name[];
+
+ if ((TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_PTR
+ && strcmp (SYMBOL_NAME (sym), vtbl_ptr_name))
|| TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_FUNC)
{
/* If we are giving a name to a type such as "pointer to
synonym = *p == 't';
if (synonym)
- {
- p++;
- type_synonym_name = obsavestring (SYMBOL_NAME (sym),
- strlen (SYMBOL_NAME (sym)),
- &objfile -> symbol_obstack);
- }
+ p++;
/* The semantics of C++ state that "struct foo { ... }" also defines
a typedef for "foo". Unfortunately, cfront never makes the typedef
when translating C++ into C. We make the typedef here so that
"ptype foo" works as expected for cfront translated code. */
else if (current_subfile->language == language_cplus)
- {
- synonym = 1;
- type_synonym_name = obsavestring (SYMBOL_NAME (sym),
- strlen (SYMBOL_NAME (sym)),
- &objfile -> symbol_obstack);
- }
+ synonym = 1;
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
+#ifdef STATIC_TRANSFORM_NAME
+ if (SYMBOL_NAME (sym)[0] == '$')
+ {
+ struct minimal_symbol *msym;
+ msym = lookup_minimal_symbol (SYMBOL_NAME (sym), NULL, objfile);
+ if (msym != NULL)
+ {
+ SYMBOL_NAME (sym) = STATIC_TRANSFORM_NAME (SYMBOL_NAME (sym));
+ SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msym);
+ }
+ }
+#endif
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
if (os9k_stabs)
add_symbol_to_list (sym, &global_symbols);
add_symbol_to_list (sym, &local_symbols);
break;
+ case 'a':
+ /* Reference parameter which is in a register. */
+ SYMBOL_TYPE (sym) = read_type (&p, objfile);
+ SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+ SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
+ if (SYMBOL_VALUE (sym) >= NUM_REGS)
+ {
+ complain (®_value_complaint, SYMBOL_SOURCE_NAME (sym));
+ SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
+ }
+ SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
+ add_symbol_to_list (sym, &local_symbols);
+ break;
+
case 'X':
/* This is used by Sun FORTRAN for "function result value".
Sun claims ("dbx and dbxtool interfaces", 2nd ed)
break;
default:
- SYMBOL_TYPE (sym) = error_type (&p);
+ SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_VALUE (sym) = 0;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
to LOC_REGPARM_ADDR for structures and unions. */
if (SYMBOL_CLASS (sym) == LOC_REGPARM
- && REG_STRUCT_HAS_ADDR (processing_gcc_compilation)
+ && 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)))
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). */
+ if (SYMBOL_CLASS (sym) == LOC_ARG
+ && 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)))
+ SYMBOL_CLASS (sym) = LOC_REF_ARG;
+
return sym;
}
Thus code like this:
if (*(*pp)++ != ';')
- return error_type (pp);
+ return error_type (pp, objfile);
is wrong because if *pp starts out pointing at '\0' (typically as the
result of an earlier error), it will be incremented to point to the
if you run off the end of the string table. Instead use
if (**pp != ';')
- return error_type (pp);
+ return error_type (pp, objfile);
++*pp;
or
if (**pp != ';')
- foo = error_type (pp);
+ foo = error_type (pp, objfile);
else
++*pp;
debugger will be able to read the new symbol tables. */
static struct type *
-error_type (pp)
+error_type (pp, objfile)
char **pp;
+ struct objfile *objfile;
{
complain (&error_type_complaint);
while (1)
/* Check for and handle cretinous dbx symbol name continuation! */
if ((*pp)[-1] == '\\' || (*pp)[-1] == '?')
{
- *pp = next_symbol_text ();
+ *pp = next_symbol_text (objfile);
}
else
{
|| **pp == '-')
{
if (read_type_number (pp, typenums) != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
/* Type is not being defined here. Either it already exists,
or this is a forward reference to it. dbx_alloc_type handles
++p;
*pp = p;
if (*p == '\0')
- return error_type (pp);
+ return error_type (pp, objfile);
else
/* Skip the semicolon. */
++*pp;
q1 = strchr(*pp, '<');
p = strchr(*pp, ':');
if (p == NULL)
- return error_type (pp);
+ return error_type (pp, objfile);
while (q1 && p > q1 && p[1] == ':')
{
q2 = strchr(q1, '>');
p += 2;
p = strchr(p, ':');
if (p == NULL)
- return error_type (pp);
+ return error_type (pp, objfile);
}
to = type_name =
(char *)obstack_alloc (&objfile->type_obstack, p - *pp + 1);
/* Peek ahead at the number to detect void. */
if (read_type_number (pp, xtypenums) != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
if (typenums[0] == xtypenums[0] && typenums[1] == xtypenums[1])
/* It's being defined as itself. That means it is "void". */
- type = init_type (TYPE_CODE_VOID, 0, 0, NULL, objfile);
+ type = init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
else
{
struct type *xtype;
now anyway). */
type = alloc_type (objfile);
- memcpy (type, xtype, sizeof (struct type));
-
- /* The idea behind clearing the names is that the only purpose
- for defining a type to another type is so that the name of
- one can be different. So we probably don't need to worry much
- about the case where the compiler doesn't give a name to the
- new type. */
- TYPE_NAME (type) = NULL;
- TYPE_TAG_NAME (type) = NULL;
+ if (SYMBOL_LINE (current_symbol) == 0)
+ {
+ *type = *xtype;
+ /* The idea behind clearing the names is that the only purpose
+ for defining a type to another type is so that the name of
+ one can be different. So we probably don't need to worry
+ much about the case where the compiler doesn't give a name
+ to the new type. */
+ TYPE_NAME (type) = NULL;
+ TYPE_TAG_NAME (type) = NULL;
+ }
+ else
+ {
+ TYPE_CODE (type) = TYPE_CODE_TYPEDEF;
+ TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
+ TYPE_TARGET_TYPE (type) = xtype;
+ }
}
if (typenums[0] != -1)
*dbx_lookup_type (typenums) = type;
case 'f': /* Function returning another type */
if (os9k_stabs && **pp == '(')
{
- /* Function prototype; skip it.
+ /* Function prototype; parse it.
We must conditionalize this on os9k_stabs because otherwise
it could be confused with a Sun-style (1,3) typenumber
(I think). */
- while (**pp != ')')
- ++*pp;
+ struct type *t;
++*pp;
+ while (**pp != ')')
+ {
+ t = read_type(pp, objfile);
+ if (**pp == ',') ++*pp;
+ }
}
type1 = read_type (pp, objfile);
type = make_function_type (type1, dbx_lookup_type (typenums));
/* Because 'c' means other things to AIX and 'k' is perfectly good,
only accept 'c' in the os9k_stabs case. */
if (type_descriptor == 'c' && !os9k_stabs)
- return error_type (pp);
+ return error_type (pp, objfile);
type = read_type (pp, objfile);
/* FIXME! For now, we ignore const and volatile qualifiers. */
break;
/* Because 'i' means other things to AIX and 'B' is perfectly good,
only accept 'i' in the os9k_stabs case. */
if (type_descriptor == 'i' && !os9k_stabs)
- return error_type (pp);
+ return error_type (pp, objfile);
type = read_type (pp, objfile);
/* FIXME! For now, we ignore const and volatile qualifiers. */
break;
if (**pp != ',')
/* Invalid member type data format. */
- return error_type (pp);
+ return error_type (pp, objfile);
++*pp;
memtype = read_type (pp, objfile);
if (**pp != ',')
/* Invalid member type data format. */
- return error_type (pp);
+ return error_type (pp, objfile);
else
++(*pp);
case 's': /* Struct type */
case 'u': /* Union type */
type = dbx_alloc_type (typenums, objfile);
- if (!TYPE_NAME (type))
- {
- TYPE_NAME (type) = type_synonym_name;
- }
- type_synonym_name = NULL;
switch (type_descriptor)
{
case 's':
case 'a': /* Array type */
if (**pp != 'r')
- return error_type (pp);
+ return error_type (pp, objfile);
++*pp;
type = dbx_alloc_type (typenums, objfile);
default:
--*pp; /* Go back to the symbol in error */
/* Particularly important if it was \0! */
- return error_type (pp);
+ return error_type (pp, objfile);
}
if (type == 0)
{
warning ("GDB internal error, type is NULL in stabsread.c\n");
- return error_type (pp);
+ return error_type (pp, objfile);
}
/* Size specified in a type attribute overrides any other size. */
if (type_size != -1)
- TYPE_LENGTH (type) = type_size / TARGET_CHAR_BIT;
+ TYPE_LENGTH (type) = (type_size + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
return type;
}
int typenum;
{
/* We recognize types numbered from -NUMBER_RECOGNIZED to -1. */
-#define NUMBER_RECOGNIZED 30
+#define NUMBER_RECOGNIZED 34
/* This includes an empty slot for type number -0. */
static struct type *negative_types[NUMBER_RECOGNIZED + 1];
struct type *rettype = NULL;
"unsigned long", NULL);
break;
case 11:
- rettype = init_type (TYPE_CODE_VOID, 0, 0, "void", NULL);
+ rettype = init_type (TYPE_CODE_VOID, 1, 0, "void", NULL);
break;
case 12:
/* IEEE single precision (32 bit). */
case 30:
rettype = init_type (TYPE_CODE_CHAR, 2, 0, "wchar", NULL);
break;
+ case 31:
+ rettype = init_type (TYPE_CODE_INT, 8, 0, "long long", NULL);
+ break;
+ case 32:
+ rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
+ "unsigned long long", NULL);
+ break;
+ case 33:
+ rettype = init_type (TYPE_CODE_INT, 8, TYPE_FLAG_UNSIGNED,
+ "logical*8", NULL);
+ break;
+ case 34:
+ rettype = init_type (TYPE_CODE_INT, 8, 0, "integer*8", NULL);
+ break;
}
negative_types[-typenum] = rettype;
return rettype;
/* Skip past '::'. */
*pp = p + 2;
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
p = *pp;
while (*p != '.')
{
if (look_ahead_type == NULL)
{
/* Normal case. */
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
new_sublist -> fn_field.type = read_type (pp, objfile);
if (**pp != ':')
break;
}
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
switch (**pp)
{
case 'A': /* Normal functions. */
if (nbits != 0)
return 0;
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
if (**pp == ';' || **pp == '\0')
{
/* Must be g++ version 1. */
new_sublist -> next = sublist;
sublist = new_sublist;
length++;
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
}
while (**pp != ';' && **pp != '\0');
fip -> fnlist = new_fnlist;
nfn_fields++;
total_length += length;
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
}
if (nfn_fields)
struct type *type;
struct objfile *objfile;
{
- fip -> list -> field.name =
+ /* The following is code to work around cfront generated stabs.
+ The stabs contains full mangled name for each field.
+ We try to demangle the name and extract the field name out of it.
+ */
+ if (ARM_DEMANGLING && current_subfile->language == language_cplus)
+ {
+ char save_p;
+ char *dem, *dem_p;
+ save_p = *p;
+ *p = '\0';
+ dem = cplus_demangle (*pp, DMGL_ANSI | DMGL_PARAMS);
+ if (dem != NULL)
+ {
+ dem_p = strrchr (dem, ':');
+ if (dem_p != 0 && *(dem_p-1)==':')
+ dem_p++;
+ fip->list->field.name =
+ obsavestring (dem_p, strlen(dem_p), &objfile -> type_obstack);
+ }
+ else
+ {
+ fip->list->field.name =
+ obsavestring (*pp, p - *pp, &objfile -> type_obstack);
+ }
+ *p = save_p;
+ }
+ /* end of code for cfront work around */
+
+ else
+ fip -> list -> field.name =
obsavestring (*pp, p - *pp, &objfile -> type_obstack);
*pp = p + 1;
while (**pp != ';')
{
- STABS_CONTINUE (pp);
+ if (os9k_stabs && **pp == ',') break;
+ STABS_CONTINUE (pp, objfile);
/* Get space to record the next field's data. */
new = (struct nextfield *) xmalloc (sizeof (struct nextfield));
make_cleanup (free, new);
fip -> list = new;
new -> field.bitsize = 0; /* this should be an unpacked field! */
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
switch (**pp)
{
case '0':
{
register char *p;
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
/* If we are positioned at a ';', then skip it. */
if (**pp == ';')
{
register int n;
- for (n = 0; n < TYPE_N_BASECLASSES (type); n++)
- {
- if (TYPE_CODE (TYPE_BASECLASS (type, n)) == TYPE_CODE_UNDEF)
- {
- /* @@ Memory leak on objfile -> type_obstack? */
- return 0;
- }
- TYPE_NFN_FIELDS_TOTAL (type) +=
- TYPE_NFN_FIELDS_TOTAL (TYPE_BASECLASS (type, n));
- }
-
for (n = TYPE_NFN_FIELDS (type);
fip -> fnlist != NULL;
fip -> fnlist = fip -> fnlist -> next)
int nbits;
TYPE_LENGTH (type) = read_huge_number (pp, 0, &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
}
/* Now read the baseclasses, if any, read the regular C struct or C++
|| !read_tilde_fields (&fi, pp, type, objfile))
{
do_cleanups (back_to);
- return (error_type (pp));
+ return (error_type (pp, objfile));
}
do_cleanups (back_to);
index_type = read_type (pp, objfile);
if (**pp != ';')
/* Improper format of array type decl. */
- return error_type (pp);
+ return error_type (pp, objfile);
++*pp;
}
}
lower = read_huge_number (pp, os9k_stabs ? ',' : ';', &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
if (!(**pp >= '0' && **pp <= '9') && **pp != '-')
{
}
upper = read_huge_number (pp, ';', &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
element_type = read_type (pp, objfile);
create_range_type ((struct type *) NULL, index_type, lower, upper);
type = create_array_type (type, element_type, range_type);
- /* If we have an array whose element type is not yet known, but whose
- bounds *are* known, record it to be adjusted at the end of the file. */
- /* FIXME: Why check for zero length rather than TYPE_FLAG_STUB? I think
- the two have the same effect except that the latter is cleaner and the
- former would be wrong for types which really are zero-length (if we
- have any). */
-
- if (TYPE_LENGTH (element_type) == 0 && !adjustable)
- {
- TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
- add_undefined_type (type);
- }
-
return type;
}
struct pending *osyms, *syms;
int o_nsyms;
int nbits;
+ int unsigned_enum = 1;
#if 0
/* FIXME! The stabs produced by Sun CC merrily define things that ought
with a digit). */
read_huge_number (pp, 0, &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
+ }
+
+ /* The aix4 compiler emits an extra field before the enum members;
+ my guess is it's a type of some sort. Just ignore it. */
+ if (**pp == '-')
+ {
+ /* Skip over the type. */
+ while (**pp != ':')
+ (*pp)++;
+
+ /* Skip over the colon. */
+ (*pp)++;
}
/* Read the value-names and their values.
A semicolon or comma instead of a NAME means the end. */
while (**pp && **pp != ';' && **pp != ',')
{
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
p = *pp;
while (*p != ':') p++;
name = obsavestring (*pp, p - *pp, &objfile -> symbol_obstack);
*pp = p + 1;
n = read_huge_number (pp, ',', &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
sym = (struct symbol *)
obstack_alloc (&objfile -> symbol_obstack, sizeof (struct symbol));
SYMBOL_CLASS (sym) = LOC_CONST;
SYMBOL_NAMESPACE (sym) = VAR_NAMESPACE;
SYMBOL_VALUE (sym) = n;
+ if (n < 0)
+ unsigned_enum = 0;
add_symbol_to_list (sym, symlist);
nsyms++;
}
TYPE_LENGTH (type) = TARGET_INT_BIT / HOST_CHAR_BIT;
TYPE_CODE (type) = TYPE_CODE_ENUM;
TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
+ if (unsigned_enum)
+ TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
TYPE_ALLOC (type, sizeof (struct field) * nsyms);
that in something like "enum {FOO, LAST_THING=FOO}" we print
FOO, not LAST_THING. */
- for (syms = *symlist, n = 0; syms; syms = syms->next)
+ for (syms = *symlist, n = nsyms - 1; syms; syms = syms->next)
{
- int j = 0;
- if (syms == osyms)
- j = o_nsyms;
- for (; j < syms->nsyms; j++,n++)
+ int last = syms == osyms ? o_nsyms : 0;
+ int j = syms->nsyms;
+ for (; --j >= last; --n)
{
struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type;
signed_type = 0;
break;
default:
- return error_type (pp);
+ return error_type (pp, objfile);
}
(*pp)++;
we will ignore it. */
read_huge_number (pp, ';', &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
/* The second number is always 0, so ignore it too. */
read_huge_number (pp, ';', &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
/* The third number is the number of bits for this type. */
type_bits = read_huge_number (pp, 0, &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
/* The type *should* end with a semicolon. If it are embedded
in a larger type the semicolon may be the only way to know where
the type ends. If this type is at the end of the stabstring we
if (**pp == ';')
++(*pp);
- return init_type (type_bits == 0 ? TYPE_CODE_VOID : TYPE_CODE_INT,
- type_bits / TARGET_CHAR_BIT,
- signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *)NULL,
- objfile);
+ if (type_bits == 0)
+ return init_type (TYPE_CODE_VOID, 1,
+ signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *)NULL,
+ objfile);
+ else
+ return init_type (TYPE_CODE_INT,
+ type_bits / TARGET_CHAR_BIT,
+ signed_type ? 0 : TYPE_FLAG_UNSIGNED, (char *)NULL,
+ objfile);
}
static struct type *
FN_COMPLEX. */
details = read_huge_number (pp, ';', &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
/* The second number is the number of bytes occupied by this type */
nbytes = read_huge_number (pp, ';', &nbits);
if (nbits != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
if (details == NF_COMPLEX || details == NF_COMPLEX16
|| details == NF_COMPLEX32)
p++;
}
- upper_limit = LONG_MAX / radix;
+ if (os9k_stabs)
+ upper_limit = ULONG_MAX / radix;
+ else
+ upper_limit = LONG_MAX / radix;
+
while ((c = *p++) >= '0' && c < ('0' + radix))
{
if (n <= upper_limit)
int typenums[2];
struct objfile *objfile;
{
+ char *orig_pp = *pp;
int rangenums[2];
long n2, n3;
int n2bits, n3bits;
int self_subrange;
struct type *result_type;
- struct type *index_type;
+ struct type *index_type = NULL;
/* First comes a type we are a subrange of.
In C it is usually 0, 1 or the type being defined. */
- /* FIXME: according to stabs.texinfo and AIX doc, this can be a type-id
- not just a type number. */
if (read_type_number (pp, rangenums) != 0)
- return error_type (pp);
+ return error_type (pp, objfile);
self_subrange = (rangenums[0] == typenums[0] &&
rangenums[1] == typenums[1]);
+ if (**pp == '=')
+ {
+ *pp = orig_pp;
+ index_type = read_type (pp, objfile);
+ }
+
/* A semicolon should now follow; skip it. */
if (**pp == ';')
(*pp)++;
n3 = read_huge_number (pp, ';', &n3bits);
if (n2bits == -1 || n3bits == -1)
- return error_type (pp);
-
+ return error_type (pp, objfile);
+
+ if (index_type)
+ goto handle_true_range;
+
/* If limits are huge, must be large integral type. */
if (n2bits != 0 || n3bits != 0)
{
objfile);
}
else
- return error_type (pp);
+ return error_type (pp, objfile);
}
/* A type defined as a subrange of itself, with bounds both 0, is void. */
if (self_subrange && n2 == 0 && n3 == 0)
- return init_type (TYPE_CODE_VOID, 0, 0, NULL, objfile);
+ return init_type (TYPE_CODE_VOID, 1, 0, NULL, objfile);
- /* If n3 is zero and n2 is not, we want a floating type,
+ /* If n3 is zero and n2 is positive, we want a floating type,
and n2 is the width in bytes.
Fortran programs appear to use this for complex types also,
else if (self_subrange && n2 == 0 && n3 == 127)
return init_type (TYPE_CODE_INT, 1, 0, NULL, objfile);
+ else if (current_symbol && SYMBOL_LANGUAGE (current_symbol) == language_chill
+ && SYMBOL_LINE (current_symbol) > 0)
+ goto handle_true_range;
+
/* We used to do this only for subrange of self or subrange of int. */
else if (n2 == 0)
{
/* We have a real range type on our hands. Allocate space and
return a real pointer. */
+ handle_true_range:
/* At this point I don't have the faintest idea how to deal with
a self_subrange type; I'm going to assume that this is used
as an idiom, and that all of them are special cases. So . . . */
if (self_subrange)
- return error_type (pp);
+ return error_type (pp, objfile);
index_type = *dbx_lookup_type (rangenums);
if (index_type == NULL)
/* Invalid argument list: no ','. */
return (struct type **)-1;
(*pp)++;
- STABS_CONTINUE (pp);
+ STABS_CONTINUE (pp, objfile);
types[n++] = read_type (pp, objfile);
}
(*pp)++; /* get past `end' (the ':' character) */
case TYPE_CODE_ENUM:
{
/* Check if it has been defined since. Need to do this here
- as well as in check_stub_type to deal with the (legitimate in
+ as well as in check_typedef to deal with the (legitimate in
C though not C++) case of several types with the same name
in different source files. */
if (TYPE_FLAGS (*type) & TYPE_FLAG_STUB)
}
break;
- case TYPE_CODE_ARRAY:
- {
- /* This is a kludge which is here for historical reasons
- because I suspect that check_stub_type does not get
- called everywhere it needs to be called for arrays. Even
- with this kludge, those places are broken for the case
- where the stub type is defined in another compilation
- unit, but this kludge at least deals with it for the case
- in which it is the same compilation unit.
-
- Don't try to do this by calling check_stub_type; it might
- cause symbols to be read in lookup_symbol, and the symbol
- reader is not reentrant. */
-
- struct type *range_type;
- int lower, upper;
-
- if (TYPE_LENGTH (*type) != 0) /* Better be unknown */
- goto badtype;
- if (TYPE_NFIELDS (*type) != 1)
- goto badtype;
- range_type = TYPE_FIELD_TYPE (*type, 0);
- if (TYPE_CODE (range_type) != TYPE_CODE_RANGE)
- goto badtype;
-
- /* Now recompute the length of the array type, based on its
- number of elements and the target type's length. */
- lower = TYPE_FIELD_BITPOS (range_type, 0);
- upper = TYPE_FIELD_BITPOS (range_type, 1);
- TYPE_LENGTH (*type) = (upper - lower + 1)
- * TYPE_LENGTH (TYPE_TARGET_TYPE (*type));
-
- /* If the target type is not a stub, we could be clearing
- TYPE_FLAG_TARGET_STUB for *type. */
- }
- break;
-
default:
badtype:
{
struct minimal_symbol *msymbol;
struct symbol *sym, *prev;
- if (objfile->msymbols == 0) /* Beware the null file. */
+ /* 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;
- for (msymbol = objfile -> msymbols; SYMBOL_NAME (msymbol) != NULL; msymbol++)
+ for (msymbol = objfile -> msymbols;
+ msymbol && SYMBOL_NAME (msymbol) != NULL;
+ msymbol++)
{
QUIT;
+ /* Skip static symbols. */
+ switch (MSYMBOL_TYPE (msymbol))
+ {
+ case mst_file_text:
+ case mst_file_data:
+ case mst_file_bss:
+ continue;
+ default:
+ break;
+ }
+
prev = NULL;
/* Get the hash index and check all the symbols
{
SYMBOL_VALUE_ADDRESS (sym) = SYMBOL_VALUE_ADDRESS (msymbol);
}
+
+ SYMBOL_SECTION (sym) = SYMBOL_SECTION (msymbol);
if (prev)
{
}
}
}
+
+ /* Change the storage class of any remaining unresolved globals to
+ LOC_UNRESOLVED and remove them from the chain. */
+ for (hash = 0; hash < HASHSIZE; hash++)
+ {
+ sym = global_sym_chain[hash];
+ while (sym)
+ {
+ prev = sym;
+ sym = SYMBOL_VALUE_CHAIN (sym);
+
+ /* Change the symbol address from the misleading chain value
+ to address zero. */
+ SYMBOL_VALUE_ADDRESS (prev) = 0;
+
+ /* Complain about unresolved common block symbols. */
+ if (SYMBOL_CLASS (prev) == LOC_STATIC)
+ SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
+ else
+ complain (&unresolved_sym_chain_complaint,
+ objfile->name, SYMBOL_NAME (prev));
+ }
+ }
+ memset (global_sym_chain, 0, sizeof (global_sym_chain));
}
/* Initialize anything that needs initializing when starting to read