allocate_symbol.
* dwarf2read.c (fixup_go_packaging): Call allocate_symbol.
(read_func_scope): Call allocate_template_symbol.
(new_symbol_full): Call allocate_symbol.
* jit.c (finalize_symtab): Call allocate_symbol.
* jv-lang.c (add_class_symbol): Call allocate_symbol.
* mdebugread.c (parse_symbol, new_block): Call allocate_symbol.
* stabsread.c (patch_block_stabs, define_symbol, read_enum_type)
(common_block_end): Call allocate_symbol.
* symtab.c (allocate_symbol, initialize_symbol)
(allocate_template_symbol): New functions.
* symtab.c (allocate_symbol, initialize_symbol)
(allocate_template_symbol): Declare.
* xcoffread.c (process_xcoff_symbol): Call initialize_symbol.
+2013-04-08 Tom Tromey <tromey@redhat.com>
+
+ * coffread.c (process_coff_symbol, coff_read_enum_type): Call
+ allocate_symbol.
+ * dwarf2read.c (fixup_go_packaging): Call allocate_symbol.
+ (read_func_scope): Call allocate_template_symbol.
+ (new_symbol_full): Call allocate_symbol.
+ * jit.c (finalize_symtab): Call allocate_symbol.
+ * jv-lang.c (add_class_symbol): Call allocate_symbol.
+ * mdebugread.c (parse_symbol, new_block): Call allocate_symbol.
+ * stabsread.c (patch_block_stabs, define_symbol, read_enum_type)
+ (common_block_end): Call allocate_symbol.
+ * symtab.c (allocate_symbol, initialize_symbol)
+ (allocate_template_symbol): New functions.
+ * symtab.c (allocate_symbol, initialize_symbol)
+ (allocate_template_symbol): Declare.
+ * xcoffread.c (process_xcoff_symbol): Call initialize_symbol.
+
2013-04-08 Pedro Alves <palves@redhat.com>
Keith Seitz <keiths@redhat.com>
union internal_auxent *aux,
struct objfile *objfile)
{
- struct symbol *sym
- = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct symbol));
+ struct symbol *sym = allocate_symbol (objfile);
char *name;
- memset (sym, 0, sizeof (struct symbol));
name = cs->c_name;
name = EXTERNAL_NAME (name, objfile->obfd);
SYMBOL_SET_LANGUAGE (sym, current_subfile->language);
switch (ms->c_sclass)
{
case C_MOE:
- 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,
obstack_copy0 (&objfile->objfile_obstack,
TYPE_TAG_NAME (type) = TYPE_NAME (type);
- sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
+ sym = allocate_symbol (objfile);
SYMBOL_SET_LANGUAGE (sym, language_go);
SYMBOL_SET_NAMES (sym, saved_package_name,
strlen (saved_package_name), 0, objfile);
if (child_die->tag == DW_TAG_template_type_param
|| child_die->tag == DW_TAG_template_value_param)
{
- templ_func = OBSTACK_ZALLOC (&objfile->objfile_obstack,
- struct template_symbol);
+ templ_func = allocate_template_symbol (objfile);
templ_func->base.is_cplus_template_function = 1;
break;
}
if (space)
sym = space;
else
- sym = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
+ sym = allocate_symbol (objfile);
OBJSTAT (objfile, n_syms++);
/* Cache this symbol's name and the name's demangled form (if any). */
i--, gdb_block_iter = gdb_block_iter->next)
{
struct block *new_block = allocate_block (&objfile->objfile_obstack);
- struct symbol *block_name = obstack_alloc (&objfile->objfile_obstack,
- sizeof (struct symbol));
+ struct symbol *block_name = allocate_symbol (objfile);
struct type *block_type = arch_type (get_objfile_arch (objfile),
TYPE_CODE_VOID,
1,
BLOCK_END (new_block) = (CORE_ADDR) gdb_block_iter->end;
/* The name. */
- memset (block_name, 0, sizeof (struct symbol));
SYMBOL_DOMAIN (block_name) = VAR_DOMAIN;
SYMBOL_ACLASS_INDEX (block_name) = LOC_BLOCK;
SYMBOL_SYMTAB (block_name) = symtab;
struct symbol *sym;
struct objfile *objfile = get_dynamics_objfile (get_type_arch (type));
- sym = (struct symbol *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (struct symbol));
- memset (sym, 0, sizeof (struct symbol));
+ sym = allocate_symbol (objfile);
SYMBOL_SET_LANGUAGE (sym, language_java);
SYMBOL_SET_LINKAGE_NAME (sym, TYPE_TAG_NAME (type));
SYMBOL_ACLASS_INDEX (sym) = LOC_TYPEDEF;
FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss;
FIELD_BITSIZE (*f) = 0;
- enum_sym = ((struct symbol *)
- obstack_alloc (&mdebugread_objfile->objfile_obstack,
- sizeof (struct symbol)));
- memset (enum_sym, 0, sizeof (struct symbol));
+ enum_sym = allocate_symbol (mdebugread_objfile);
SYMBOL_SET_LINKAGE_NAME
(enum_sym,
obstack_copy0 (&mdebugread_objfile->objfile_obstack,
static struct symbol *
new_symbol (char *name)
{
- struct symbol *s = ((struct symbol *)
- obstack_alloc (&mdebugread_objfile->objfile_obstack,
- sizeof (struct symbol)));
+ struct symbol *s = allocate_symbol (mdebugread_objfile);
- memset (s, 0, sizeof (*s));
SYMBOL_SET_LANGUAGE (s, psymtab_language);
SYMBOL_SET_NAMES (s, name, strlen (name), 1, mdebugread_objfile);
return s;
/* 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_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
SYMBOL_SET_LINKAGE_NAME
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));
+ current_symbol = sym = allocate_symbol (objfile);
switch (type & N_TYPE)
{
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_ACLASS_INDEX (struct_sym) = LOC_TYPEDEF;
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_ACLASS_INDEX (typedef_sym) = LOC_TYPEDEF;
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_ACLASS_INDEX (sym) = LOC_CONST;
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_ACLASS_INDEX (sym) = LOC_BLOCK;
\f
+/* Initialize the symbol SYM. */
+
+void
+initialize_symbol (struct symbol *sym)
+{
+ memset (sym, 0, sizeof (*sym));
+}
+
+/* Allocate and initialize a new 'struct symbol' on OBJFILE's
+ obstack. */
+
+struct symbol *
+allocate_symbol (struct objfile *objfile)
+{
+ struct symbol *result;
+
+ result = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symbol);
+
+ return result;
+}
+
+/* Allocate and initialize a new 'struct template_symbol' on OBJFILE's
+ obstack. */
+
+struct template_symbol *
+allocate_template_symbol (struct objfile *objfile)
+{
+ struct template_symbol *result;
+
+ result = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct template_symbol);
+
+ return result;
+}
+
+\f
+
void
_initialize_symtab (void)
{
struct cleanup *demangle_for_lookup (const char *name, enum language lang,
const char **result_name);
+struct symbol *allocate_symbol (struct objfile *);
+
+void initialize_symbol (struct symbol *);
+
+struct template_symbol *allocate_template_symbol (struct objfile *);
+
#endif /* !defined(SYMTAB_H) */
if (name[0] == '.')
++name;
- memset (sym, '\0', sizeof (struct symbol));
+ initialize_symbol (sym);
/* default assumptions */
SYMBOL_VALUE_ADDRESS (sym) = cs->c_value + off;