Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
- 2008 Free Software Foundation, Inc.
+ 2008, 2009 Free Software Foundation, Inc.
This file is part of GDB.
}
}
+static int
+stab_reg_to_regnum (struct symbol *sym, struct gdbarch *gdbarch)
+{
+ int regno = gdbarch_stab_reg_to_regnum (gdbarch, SYMBOL_VALUE (sym));
+
+ if (regno >= gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch))
+ {
+ reg_value_complaint (regno,
+ gdbarch_num_regs (gdbarch)
+ + gdbarch_num_pseudo_regs (gdbarch),
+ SYMBOL_PRINT_NAME (sym));
+
+ regno = gdbarch_sp_regnum (gdbarch); /* Known safe, though useless */
+ }
+
+ return regno;
+}
+
+static const struct symbol_register_ops stab_register_funcs = {
+ stab_reg_to_regnum
+};
+
struct symbol *
define_symbol (CORE_ADDR valu, char *string, int desc, int type,
struct objfile *objfile)
int deftype;
int synonym = 0;
int i;
+ char *new_name = NULL;
/* We would like to eliminate nameless symbols, but keep their types.
E.g. stab entry ":t10=*2" should produce a type 10, which is a pointer
{
normal:
SYMBOL_LANGUAGE (sym) = current_subfile->language;
- SYMBOL_SET_NAMES (sym, string, p - string, objfile);
+ if (SYMBOL_LANGUAGE (sym) == language_cplus)
+ {
+ char *name = alloca (p - string + 1);
+ memcpy (name, string, p - string);
+ name[p - string] = '\0';
+ new_name = cp_canonicalize_string (name);
+ cp_scan_for_anonymous_namespaces (sym);
+ }
+ if (new_name != NULL)
+ {
+ SYMBOL_SET_NAMES (sym, new_name, strlen (new_name), objfile);
+ xfree (new_name);
+ }
+ else
+ SYMBOL_SET_NAMES (sym, string, p - string, objfile);
}
p++;
than the "declared-as" type for unprototyped functions, so
we treat all functions as if they were prototyped. This is used
primarily for promotion when calling the function from GDB. */
- TYPE_FLAGS (SYMBOL_TYPE (sym)) |= TYPE_FLAG_PROTOTYPED;
+ TYPE_PROTOTYPED (SYMBOL_TYPE (sym)) = 1;
/* fall into process_prototype_types */
TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0;
}
TYPE_NFIELDS (ftype) = nparams;
- TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
+ TYPE_PROTOTYPED (ftype) = 1;
}
break;
/* Parameter which is in a register. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGISTER;
+ SYMBOL_REGISTER_OPS (sym) = &stab_register_funcs;
SYMBOL_IS_ARGUMENT (sym) = 1;
- SYMBOL_VALUE (sym) = gdbarch_stab_reg_to_regnum (current_gdbarch, valu);
- if (SYMBOL_VALUE (sym) >= gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch))
- {
- reg_value_complaint (SYMBOL_VALUE (sym),
- gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch),
- SYMBOL_PRINT_NAME (sym));
- SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch);
- /* Known safe, though useless */
- }
+ SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &local_symbols);
break;
/* Register variable (either global or local). */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGISTER;
- SYMBOL_VALUE (sym) = gdbarch_stab_reg_to_regnum (current_gdbarch, valu);
- if (SYMBOL_VALUE (sym) >= gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch))
- {
- reg_value_complaint (SYMBOL_VALUE (sym),
- gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch),
- SYMBOL_PRINT_NAME (sym));
- SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch);
- /* Known safe, though useless */
- }
+ SYMBOL_REGISTER_OPS (sym) = &stab_register_funcs;
+ SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
if (within_function)
{
SYMBOL_LINKAGE_NAME (sym)) == 0)
{
SYMBOL_CLASS (prev_sym) = LOC_REGISTER;
+ SYMBOL_REGISTER_OPS (prev_sym) = &stab_register_funcs;
/* Use the type from the LOC_REGISTER; that is the type
that is actually in that register. */
SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
/* Reference parameter which is in a register. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+ SYMBOL_REGISTER_OPS (sym) = &stab_register_funcs;
SYMBOL_IS_ARGUMENT (sym) = 1;
- SYMBOL_VALUE (sym) = gdbarch_stab_reg_to_regnum (current_gdbarch, valu);
- if (SYMBOL_VALUE (sym) >= gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch))
- {
- reg_value_complaint (SYMBOL_VALUE (sym),
- gdbarch_num_regs (current_gdbarch)
- + gdbarch_num_pseudo_regs (current_gdbarch),
- SYMBOL_PRINT_NAME (sym));
- SYMBOL_VALUE (sym) = gdbarch_sp_regnum (current_gdbarch);
- /* Known safe, though useless */
- }
+ SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &local_symbols);
break;
if (*p != ':')
return error_type (pp, objfile);
}
- to = type_name =
- (char *) obstack_alloc (&objfile->objfile_obstack, p - *pp + 1);
-
- /* Copy the name. */
- from = *pp + 1;
- while (from < p)
- *to++ = *from++;
- *to = '\0';
+ type_name = NULL;
+ if (current_subfile->language == language_cplus)
+ {
+ char *new_name, *name = alloca (p - *pp + 1);
+ memcpy (name, *pp, p - *pp);
+ name[p - *pp] = '\0';
+ new_name = cp_canonicalize_string (name);
+ if (new_name != NULL)
+ {
+ type_name = obsavestring (new_name, strlen (new_name),
+ &objfile->objfile_obstack);
+ xfree (new_name);
+ }
+ }
+ if (type_name == NULL)
+ {
+ to = type_name =
+ (char *) obstack_alloc (&objfile->objfile_obstack, p - *pp + 1);
+
+ /* Copy the name. */
+ from = *pp + 1;
+ while (from < p)
+ *to++ = *from++;
+ *to = '\0';
+ }
/* Set the pointer ahead of the name which we just read, and
the colon. */
- *pp = from + 1;
+ *pp = p + 1;
}
/* If this type has already been declared, then reuse the same
TYPE_CODE (type) = code;
TYPE_TAG_NAME (type) = type_name;
INIT_CPLUS_SPECIFIC (type);
- TYPE_FLAGS (type) |= TYPE_FLAG_STUB;
+ TYPE_STUB (type) = 1;
add_undefined_type (type, typenums);
return type;
}
else
{
- TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB;
+ TYPE_TARGET_STUB (type) = 1;
TYPE_TARGET_TYPE (type) = xtype;
}
}
case 'f': /* Function returning another type */
type1 = read_type (pp, objfile);
- type = make_function_type (type1, dbx_lookup_type (typenums));
+ type = make_function_type (type1, dbx_lookup_type (typenums), objfile);
break;
case 'g': /* Prototyped function. (Sun) */
const char *type_start = (*pp) - 1;
struct type *return_type = read_type (pp, objfile);
struct type *func_type
- = make_function_type (return_type, dbx_lookup_type (typenums));
+ = make_function_type (return_type, dbx_lookup_type (typenums),
+ objfile);
struct type_list {
struct type *type;
struct type_list *next;
TYPE_FIELD_TYPE (func_type, i) = t->type;
}
TYPE_NFIELDS (func_type) = num_args;
- TYPE_FLAGS (func_type) |= TYPE_FLAG_PROTOTYPED;
+ TYPE_PROTOTYPED (func_type) = 1;
type = func_type;
break;
/* Skip GCC 3.X member functions which are duplicates of the callable
constructor/destructor. */
- if (strcmp (main_fn_name, "__base_ctor") == 0
- || strcmp (main_fn_name, "__base_dtor") == 0
+ if (strcmp_iw (main_fn_name, "__base_ctor ") == 0
+ || strcmp_iw (main_fn_name, "__base_dtor ") == 0
|| strcmp (main_fn_name, "__deleting_dtor") == 0)
{
xfree (main_fn_name);
INIT_CPLUS_SPECIFIC (type);
TYPE_CODE (type) = type_code;
- TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
+ TYPE_STUB (type) = 0;
/* First comes the total size in bytes. */
TYPE_LENGTH (type) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT;
TYPE_CODE (type) = TYPE_CODE_ENUM;
- TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
+ TYPE_STUB (type) = 0;
if (unsigned_enum)
- TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
+ TYPE_UNSIGNED (type) = 1;
TYPE_NFIELDS (type) = nsyms;
TYPE_FIELDS (type) = (struct field *)
TYPE_ALLOC (type, sizeof (struct field) * nsyms);
/* Try to fix all undefined types pushed on the UNDEF_TYPES vector. */
-void
+static void
cleanup_undefined_types_noname (void)
{
int i;
yet defined at the time a pointer to it was made.
Fix: Do a full lookup on the struct/union tag. */
-void
+static void
cleanup_undefined_types_1 (void)
{
struct type **type;