/* Support routines for decoding "stabs" debugging information format.
- Copyright (C) 1986-2012 Free Software Foundation, Inc.
+ Copyright (C) 1986-2013 Free Software Foundation, Inc.
This file is part of GDB.
patch_block_stabs (struct pending *, struct pending_stabs *,
struct objfile *);
-static void fix_common_block (struct symbol *, int);
+static void fix_common_block (struct symbol *, CORE_ADDR);
static int read_type_number (char **, int *);
/* 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. */
- sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct symbol));
-
- memset (sym, 0, sizeof (struct symbol));
+ sym = allocate_symbol (objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
- SYMBOL_CLASS (sym) = LOC_OPTIMIZED_OUT;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
SYMBOL_SET_LINKAGE_NAME
- (sym, obsavestring (name, pp - name,
- &objfile->objfile_obstack));
+ (sym, obstack_copy0 (&objfile->objfile_obstack,
+ name, pp - name));
pp += 2;
if (*(pp - 1) == 'F' || *(pp - 1) == 'f')
{
stab_reg_to_regnum
};
+/* The "aclass" indices for computed symbols. */
+
+static int stab_register_index;
+static int stab_regparm_index;
+
struct symbol *
define_symbol (CORE_ADDR valu, char *string, int desc, int type,
struct objfile *objfile)
e.g. ":t10=*2" or a nameless enum like " :T16=ered:0,green:1,blue:2,;" */
nameless = (p == string || ((string[0] == ' ') && (string[1] == ':')));
- current_symbol = sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
- memset (sym, 0, sizeof (struct symbol));
-
- switch (type & N_TYPE)
- {
- case N_TEXT:
- SYMBOL_SECTION (sym) = SECT_OFF_TEXT (objfile);
- break;
- case N_DATA:
- SYMBOL_SECTION (sym) = SECT_OFF_DATA (objfile);
- break;
- case N_BSS:
- SYMBOL_SECTION (sym) = SECT_OFF_BSS (objfile);
- break;
- }
+ current_symbol = sym = allocate_symbol (objfile);
if (processing_gcc_compilation)
{
else
{
normal:
- SYMBOL_SET_LANGUAGE (sym, current_subfile->language);
+ SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+ &objfile->objfile_obstack);
if (SYMBOL_LANGUAGE (sym) == language_cplus)
{
char *name = alloca (p - string + 1);
(where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
if (*p != '=')
{
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &file_symbols);
SYMBOL_TYPE (sym) = dbl_type;
SYMBOL_VALUE_BYTES (sym) = dbl_valu;
- SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST_BYTES;
}
break;
case 'i':
SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_long;
SYMBOL_VALUE (sym) = atoi (p);
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
}
break;
{
SYMBOL_TYPE (sym) = objfile_type (objfile)->builtin_char;
SYMBOL_VALUE (sym) = atoi (p);
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
}
break;
if (quote != '\'' && quote != '"')
{
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &file_symbols);
}
if (*p != quote)
{
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = error_type (&p, objfile);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &file_symbols);
p++;
SYMBOL_VALUE_BYTES (sym) = string_value;
- SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST_BYTES;
}
break;
e.g. "b:c=e6,0" for "const b = blob1"
(where type 6 is defined by "blobs:t6=eblob1:0,blob2:1,;"). */
{
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = read_type (&p, objfile);
if (*p != ',')
break;
default:
{
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_TYPE (sym) = error_type (&p, objfile);
}
}
case 'C':
/* The name of a caught exception. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_LABEL;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_LABEL;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_VALUE_ADDRESS (sym) = valu;
add_symbol_to_list (sym, &local_symbols);
case 'f':
/* A static function definition. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_BLOCK;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &file_symbols);
/* fall into process_function_types. */
case 'F':
/* A global function definition. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_BLOCK;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &global_symbols);
goto process_function_types;
corresponding linker definition to find the value.
These definitions appear at the end of the namelist. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_STATIC;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
/* Don't add symbol references to global_sym_chain.
Symbol references don't have valid names and wont't match up with
case 's':
case 'l':
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_LOCAL;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &local_symbols);
else
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_ARG;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_ARG;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_IS_ARGUMENT (sym) = 1;
case 'R':
/* 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_ACLASS_INDEX (sym) = stab_register_index;
SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
case 'r':
/* Register variable (either global or local). */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_REGISTER;
- SYMBOL_REGISTER_OPS (sym) = &stab_register_funcs;
+ SYMBOL_ACLASS_INDEX (sym) = stab_register_index;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
if (within_function)
&& strcmp (SYMBOL_LINKAGE_NAME (prev_sym),
SYMBOL_LINKAGE_NAME (sym)) == 0)
{
- SYMBOL_CLASS (prev_sym) = LOC_REGISTER;
- SYMBOL_REGISTER_OPS (prev_sym) = &stab_register_funcs;
+ SYMBOL_ACLASS_INDEX (prev_sym) = stab_register_index;
/* Use the type from the LOC_REGISTER; that is the type
that is actually in that register. */
SYMBOL_TYPE (prev_sym) = SYMBOL_TYPE (sym);
case 'S':
/* Static symbol at top level of file. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_STATIC;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
if (gdbarch_static_transform_name_p (gdbarch)
&& gdbarch_static_transform_name (gdbarch,
if (nameless)
return NULL;
- SYMBOL_CLASS (sym) = LOC_TYPEDEF;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
/* C++ vagaries: we may have a type which is derived from
if (synonym)
{
/* Create the STRUCT_DOMAIN clone. */
- struct symbol *struct_sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
+ struct symbol *struct_sym = allocate_symbol (objfile);
*struct_sym = *sym;
- SYMBOL_CLASS (struct_sym) = LOC_TYPEDEF;
+ SYMBOL_ACLASS_INDEX (struct_sym) = LOC_TYPEDEF;
SYMBOL_VALUE (struct_sym) = valu;
SYMBOL_DOMAIN (struct_sym) = STRUCT_DOMAIN;
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
if (nameless)
return NULL;
- SYMBOL_CLASS (sym) = LOC_TYPEDEF;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = STRUCT_DOMAIN;
if (TYPE_TAG_NAME (SYMBOL_TYPE (sym)) == 0)
if (synonym)
{
/* Clone the sym and then modify it. */
- struct symbol *typedef_sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
+ struct symbol *typedef_sym = allocate_symbol (objfile);
*typedef_sym = *sym;
- SYMBOL_CLASS (typedef_sym) = LOC_TYPEDEF;
+ SYMBOL_ACLASS_INDEX (typedef_sym) = LOC_TYPEDEF;
SYMBOL_VALUE (typedef_sym) = valu;
SYMBOL_DOMAIN (typedef_sym) = VAR_DOMAIN;
if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
case 'V':
/* Static symbol of local scope. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_STATIC;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_STATIC;
SYMBOL_VALUE_ADDRESS (sym) = valu;
if (gdbarch_static_transform_name_p (gdbarch)
&& gdbarch_static_transform_name (gdbarch,
case 'v':
/* Reference parameter */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_REF_ARG;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_REF_ARG;
SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
case 'a':
/* 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_ACLASS_INDEX (sym) = stab_regparm_index;
SYMBOL_IS_ARGUMENT (sym) = 1;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
that Pascal uses it too, but when I tried it Pascal used
"x:3" (local symbol) instead. */
SYMBOL_TYPE (sym) = read_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_LOCAL;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_LOCAL;
SYMBOL_VALUE (sym) = valu;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &local_symbols);
default:
SYMBOL_TYPE (sym) = error_type (&p, objfile);
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_VALUE (sym) = 0;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
add_symbol_to_list (sym, &file_symbols);
/* We have to convert LOC_REGISTER to LOC_REGPARM_ADDR (for
variables passed in a register). */
if (SYMBOL_CLASS (sym) == LOC_REGISTER)
- SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_REGPARM_ADDR;
/* Likewise for converting LOC_ARG to LOC_REF_ARG (for the 7th
and subsequent arguments on SPARC, for example). */
else if (SYMBOL_CLASS (sym) == LOC_ARG)
- SYMBOL_CLASS (sym) = LOC_REF_ARG;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_REF_ARG;
}
return sym;
new_name = cp_canonicalize_string (name);
if (new_name != NULL)
{
- type_name = obsavestring (new_name, strlen (new_name),
- &objfile->objfile_obstack);
+ type_name = obstack_copy0 (&objfile->objfile_obstack,
+ new_name, strlen (new_name));
xfree (new_name);
}
}
make_vector_type (type);
break;
- case 'S': /* Set or bitstring type */
+ case 'S': /* Set type */
type1 = read_type (pp, objfile);
type = create_set_type ((struct type *) NULL, type1);
- if (is_string)
- TYPE_CODE (type) = TYPE_CODE_BITSTRING;
if (typenums[0] != -1)
*dbx_lookup_type (typenums, objfile) = type;
break;
dem_opname, 0);
if (ret)
new_fnlist->fn_fieldlist.name
- = obsavestring (dem_opname, strlen (dem_opname),
- &objfile->objfile_obstack);
+ = obstack_copy0 (&objfile->objfile_obstack,
+ dem_opname, strlen (dem_opname));
xfree (main_fn_name);
}
{
int nbits;
- FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ';', &nbits,
- 0);
+ SET_FIELD_BITPOS (fip->list->field,
+ read_huge_number (pp, ';', &nbits, 0));
if (nbits != 0)
return 0;
}
struct gdbarch *gdbarch = get_objfile_arch (objfile);
fip->list->field.name =
- obsavestring (*pp, p - *pp, &objfile->objfile_obstack);
+ obstack_copy0 (&objfile->objfile_obstack, *pp, p - *pp);
*pp = p + 1;
/* This means we have a visibility for a field coming. */
{
int nbits;
- FIELD_BITPOS (fip->list->field) = read_huge_number (pp, ',', &nbits, 0);
+ SET_FIELD_BITPOS (fip->list->field,
+ read_huge_number (pp, ',', &nbits, 0));
if (nbits != 0)
{
stabs_general_complaint ("bad structure-type format");
corresponding to this baseclass. Always zero in the absence of
multiple inheritance. */
- FIELD_BITPOS (new->field) = read_huge_number (pp, ',', &nbits, 0);
+ SET_FIELD_BITPOS (new->field, read_huge_number (pp, ',', &nbits, 0));
if (nbits != 0)
return 0;
}
p = *pp;
while (*p != ':')
p++;
- name = obsavestring (*pp, p - *pp, &objfile->objfile_obstack);
+ name = obstack_copy0 (&objfile->objfile_obstack, *pp, p - *pp);
*pp = p + 1;
n = read_huge_number (pp, ',', &nbits, 0);
if (nbits != 0)
return error_type (pp, objfile);
- sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
- memset (sym, 0, sizeof (struct symbol));
+ sym = allocate_symbol (objfile);
SYMBOL_SET_LINKAGE_NAME (sym, name);
- SYMBOL_SET_LANGUAGE (sym, current_subfile->language);
- SYMBOL_CLASS (sym) = LOC_CONST;
+ SYMBOL_SET_LANGUAGE (sym, current_subfile->language,
+ &objfile->objfile_obstack);
+ SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
SYMBOL_VALUE (sym) = n;
if (n < 0)
SYMBOL_TYPE (xsym) = type;
TYPE_FIELD_NAME (type, n) = SYMBOL_LINKAGE_NAME (xsym);
- TYPE_FIELD_BITPOS (type, n) = SYMBOL_VALUE (xsym);
+ SET_FIELD_ENUMVAL (TYPE_FIELD (type, n), SYMBOL_VALUE (xsym));
TYPE_FIELD_BITSIZE (type, n) = 0;
}
if (syms == osyms)
}
common_block = local_symbols;
common_block_i = local_symbols ? local_symbols->nsyms : 0;
- common_block_name = obsavestring (name, strlen (name),
- &objfile->objfile_obstack);
+ common_block_name = obstack_copy0 (&objfile->objfile_obstack,
+ name, strlen (name));
}
/* Process a N_ECOMM symbol. */
return;
}
- sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
- memset (sym, 0, sizeof (struct symbol));
+ sym = allocate_symbol (objfile);
/* Note: common_block_name already saved on objfile_obstack. */
SYMBOL_SET_LINKAGE_NAME (sym, common_block_name);
- SYMBOL_CLASS (sym) = LOC_BLOCK;
+ SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK;
/* Now we copy all the symbols which have been defined since the BCOMM. */
the common block name). */
static void
-fix_common_block (struct symbol *sym, int valu)
+fix_common_block (struct symbol *sym, CORE_ADDR valu)
{
struct pending *next = (struct pending *) SYMBOL_TYPE (sym);
this unit. */
void
-cleanup_undefined_types (struct objfile *objfile)
+cleanup_undefined_stabs_types (struct objfile *objfile)
{
cleanup_undefined_types_1 ();
cleanup_undefined_types_noname (objfile);
/* Complain about unresolved common block symbols. */
if (SYMBOL_CLASS (prev) == LOC_STATIC)
- SYMBOL_CLASS (prev) = LOC_UNRESOLVED;
+ SYMBOL_ACLASS_INDEX (prev) = LOC_UNRESOLVED;
else
complaint (&symfile_complaints,
_("%s: common block `%s' from "
noname_undefs_length = 0;
noname_undefs = (struct nat *)
xmalloc (noname_undefs_allocated * sizeof (struct nat));
+
+ stab_register_index = register_symbol_register_impl (LOC_REGISTER,
+ &stab_register_funcs);
+ stab_regparm_index = register_symbol_register_impl (LOC_REGPARM_ADDR,
+ &stab_register_funcs);
}