X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fstabsread.c;h=ed670968963410078b8d9259a5ec36d275d12ff9;hb=768a979c31bbe51154e3363c1061c45aa9cd937f;hp=110f9373b3477c5e9e71611ffccbe1f838c1e0de;hpb=3567439cdefa9f2340bae3fbb068780923934865;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 110f9373b3..ed67096896 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2,7 +2,7 @@ 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. @@ -579,6 +579,29 @@ symbol_reference_defined (char **string) } } +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) @@ -589,6 +612,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, 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 @@ -683,7 +707,21 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, { 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++; @@ -824,7 +862,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, 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 */ @@ -870,7 +908,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0; } TYPE_NFIELDS (ftype) = nparams; - TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED; + TYPE_PROTOTYPED (ftype) = 1; } break; @@ -978,18 +1016,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, /* 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; @@ -998,17 +1027,8 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, /* 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) { @@ -1044,6 +1064,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, 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); @@ -1281,18 +1302,9 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type, /* 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; @@ -1517,18 +1529,35 @@ again: 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 @@ -1562,7 +1591,7 @@ again: 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; @@ -1628,7 +1657,7 @@ again: } else { - TYPE_FLAGS (type) |= TYPE_FLAG_TARGET_STUB; + TYPE_TARGET_STUB (type) = 1; TYPE_TARGET_TYPE (type) = xtype; } } @@ -1653,7 +1682,7 @@ again: 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) */ @@ -1676,7 +1705,8 @@ again: 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; @@ -1723,7 +1753,7 @@ again: 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; @@ -2406,8 +2436,8 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type, /* 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); @@ -3336,7 +3366,7 @@ read_struct_type (char **pp, struct type *type, enum type_code type_code, 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. */ @@ -3510,9 +3540,9 @@ read_enum_type (char **pp, struct type *type, 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); @@ -4262,7 +4292,7 @@ add_undefined_type (struct type *type, int typenums[2]) /* Try to fix all undefined types pushed on the UNDEF_TYPES vector. */ -void +static void cleanup_undefined_types_noname (void) { int i; @@ -4297,7 +4327,7 @@ cleanup_undefined_types_noname (void) 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;