* coffread.c (process_coff_symbol, coff_read_enum_type): Call
authorTom Tromey <tromey@redhat.com>
Mon, 8 Apr 2013 19:48:30 +0000 (19:48 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 8 Apr 2013 19:48:30 +0000 (19:48 +0000)
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.

gdb/ChangeLog
gdb/coffread.c
gdb/dwarf2read.c
gdb/jit.c
gdb/jv-lang.c
gdb/mdebugread.c
gdb/stabsread.c
gdb/symtab.c
gdb/symtab.h
gdb/xcoffread.c

index 89c7807e41fd5f949d5be60a8c7ce465ddc7fd36..174abc547fdbb18d91f985de422151da1b1bb5a7 100644 (file)
@@ -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>
 
index eff8d646b08f98c1871966b991b5b1b9a2970b03..b5ad8c22eb0fd6b231c212580ff6aac32d5e2817 100644 (file)
@@ -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,
index 30efacf1301a30c87361626174a13330337dc95a..76a32b68787fd865244283f3347d0f8a7dac598f 100644 (file)
@@ -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).  */
index 2bb991244c4aa3ea9794b5364522d7e6f5c37688..8225540c2d54f90a12d41d477a77364be2d356cb 100644 (file)
--- 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;
index 285aa06ea5f75d624bdb8543f053c73a2f967359..1bd862469d6ea66281d7a7de20e553b21f701c1a 100644 (file)
@@ -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;
index fd5b3130ad28266478d76160d6f06356a3ecc8e6..a943cf95b8685dce11fd9381e53df32156f049ff 100644 (file)
@@ -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;
index a490bb4f0dbd1f4bd8b299ef23d661dbabe993b6..7939d6fc571dabe742d64258730c139a3e375555 100644 (file)
@@ -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;
index 51e920ee88addd51eb7e6941e5e820f23cf1c4ba..c50e895a57c1ca38f2742b2b598f08863830657c 100644 (file)
@@ -5119,6 +5119,42 @@ initialize_ordinary_address_classes (void)
 
 \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)
 {
index 354aa26a9c86277317c079acf4a4cdba0bc93011..b86c1187578c7a5650ebdfc3b7408d0e5e9749f2 100644 (file)
@@ -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) */
index e2b569e969ab41e39785a93cf95b06afcd36c8b3..45cb8f41be808b175250c917282bf4c5a18b2862 100644 (file)
@@ -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;
This page took 0.049524 seconds and 4 git commands to generate.