aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog18
-rw-r--r--gdb/coffread.c9
-rw-r--r--gdb/dwarf2read.c7
-rw-r--r--gdb/jit.c4
-rw-r--r--gdb/jv-lang.c4
-rw-r--r--gdb/mdebugread.c10
-rw-r--r--gdb/stabsread.c24
-rw-r--r--gdb/symtab.c36
-rw-r--r--gdb/symtab.h6
-rw-r--r--gdb/xcoffread.c2
10 files changed, 76 insertions, 44 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 89c7807..174abc5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,21 @@
+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>
diff --git a/gdb/coffread.c b/gdb/coffread.c
index eff8d64..b5ad8c2 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1581,12 +1581,9 @@ process_coff_symbol (struct coff_symbol *cs,
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);
@@ -2142,9 +2139,7 @@ coff_read_enum_type (int index, int length, int lastsym,
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,
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 30efacf..76a32b6 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -6952,7 +6952,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
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);
@@ -9639,8 +9639,7 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu)
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;
}
@@ -15972,7 +15971,7 @@ new_symbol_full (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
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). */
diff --git a/gdb/jit.c b/gdb/jit.c
index 2bb9912..8225540 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -677,8 +677,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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,
@@ -691,7 +690,6 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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;
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 285aa06..1bd8624 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -185,9 +185,7 @@ add_class_symbol (struct type *type, CORE_ADDR addr)
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;
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index fd5b313..a943cf9 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -1048,10 +1048,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
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,
@@ -4879,11 +4876,8 @@ new_block (enum block_type type)
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;
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index a490bb4..7939d6f 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -379,11 +379,7 @@ patch_block_stabs (struct pending *symbols, struct pending_stabs *stabs,
/* 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
@@ -652,9 +648,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
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)
{
@@ -1292,8 +1286,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int 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;
@@ -1337,8 +1330,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
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;
@@ -3681,9 +3673,7 @@ read_enum_type (char **pp, struct type *type,
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;
@@ -4355,9 +4345,7 @@ common_block_end (struct objfile *objfile)
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;
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 51e920e..c50e895 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5119,6 +5119,42 @@ initialize_ordinary_address_classes (void)
+/* 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;
+}
+
+
+
void
_initialize_symtab (void)
{
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 354aa26..b86c118 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1363,4 +1363,10 @@ void iterate_over_symbols (const struct block *block, const char *name,
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) */
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index e2b569e..45cb8f4 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1546,7 +1546,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile)
if (name[0] == '.')
++name;
- memset (sym, '\0', sizeof (struct symbol));
+ initialize_symbol (sym);
/* default assumptions */
SYMBOL_VALUE_ADDRESS (sym) = cs->c_value + off;