diff options
author | Tom Tromey <tom@tromey.com> | 2020-05-15 16:11:33 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2020-05-15 16:11:34 -0600 |
commit | 8c14c3a3735d7de43e63710b2cd3a2e89cc4e243 (patch) | |
tree | 2fe8466fc509fbb3ddf291c3216c1a22aae7a129 | |
parent | 5b4a1a8dbe6b15414c586d8fc6dbaecdcf4046f3 (diff) | |
download | gdb-8c14c3a3735d7de43e63710b2cd3a2e89cc4e243.zip gdb-8c14c3a3735d7de43e63710b2cd3a2e89cc4e243.tar.gz gdb-8c14c3a3735d7de43e63710b2cd3a2e89cc4e243.tar.bz2 |
Remove allocate_symbol et al
This removes allocate_symbol, allocate_template_symbol, and
initialize_objfile_symbol in favor of changing the default values for
symbol members, and updating the one per-arch caller.
gdb/ChangeLog
2020-05-15 Tom Tromey <tom@tromey.com>
* language.c (language_alloc_type_symbol): Set
SYMBOL_SECTION.
* symtab.c (initialize_objfile_symbol): Remove.
(allocate_symbol): Remove.
(allocate_template_symbol): Remove.
* dwarf2/read.c (fixup_go_packaging): Use "new".
(new_symbol): Use "new".
(read_variable): Don't call initialize_objfile_symbol. Use
"new".
(read_func_scope): Use "new".
* xcoffread.c (process_xcoff_symbol): Don't call
initialize_objfile_symbol.
(SYMBOL_DUP): Remove.
* coffread.c (process_coff_symbol, coff_read_enum_type): Use
"new".
* symtab.h (allocate_symbol, initialize_objfile_symbol)
(allocate_template_symbol): Don't declare.
(struct symbol): Add copy constructor. Change defaults.
* jit.c (finalize_symtab): Use "new".
* ctfread.c (ctf_add_enum_member_cb, new_symbol, ctf_add_var_cb):
Use "new".
* stabsread.c (patch_block_stabs, define_symbol, read_enum_type)
(common_block_end): Use "new".
* mdebugread.c (parse_symbol): Use "new".
(new_symbol): Likewise.
-rw-r--r-- | gdb/ChangeLog | 28 | ||||
-rw-r--r-- | gdb/coffread.c | 4 | ||||
-rw-r--r-- | gdb/ctfread.c | 6 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 9 | ||||
-rw-r--r-- | gdb/jit.c | 2 | ||||
-rw-r--r-- | gdb/language.c | 1 | ||||
-rw-r--r-- | gdb/mdebugread.c | 4 | ||||
-rw-r--r-- | gdb/stabsread.c | 12 | ||||
-rw-r--r-- | gdb/symtab.c | 36 | ||||
-rw-r--r-- | gdb/symtab.h | 12 | ||||
-rw-r--r-- | gdb/xcoffread.c | 9 |
11 files changed, 52 insertions, 71 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 86499f9..4b6294f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,31 @@ +2020-05-15 Tom Tromey <tom@tromey.com> + + * language.c (language_alloc_type_symbol): Set + SYMBOL_SECTION. + * symtab.c (initialize_objfile_symbol): Remove. + (allocate_symbol): Remove. + (allocate_template_symbol): Remove. + * dwarf2/read.c (fixup_go_packaging): Use "new". + (new_symbol): Use "new". + (read_variable): Don't call initialize_objfile_symbol. Use + "new". + (read_func_scope): Use "new". + * xcoffread.c (process_xcoff_symbol): Don't call + initialize_objfile_symbol. + (SYMBOL_DUP): Remove. + * coffread.c (process_coff_symbol, coff_read_enum_type): Use + "new". + * symtab.h (allocate_symbol, initialize_objfile_symbol) + (allocate_template_symbol): Don't declare. + (struct symbol): Add copy constructor. Change defaults. + * jit.c (finalize_symtab): Use "new". + * ctfread.c (ctf_add_enum_member_cb, new_symbol, ctf_add_var_cb): + Use "new". + * stabsread.c (patch_block_stabs, define_symbol, read_enum_type) + (common_block_end): Use "new". + * mdebugread.c (parse_symbol): Use "new". + (new_symbol): Likewise. + 2020-05-15 Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS: Mention changes to help and apropos. diff --git a/gdb/coffread.c b/gdb/coffread.c index d320332..7e3cb4a 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1556,7 +1556,7 @@ process_coff_symbol (struct coff_symbol *cs, union internal_auxent *aux, struct objfile *objfile) { - struct symbol *sym = allocate_symbol (objfile); + struct symbol *sym = new (&objfile->objfile_obstack) symbol; char *name; name = cs->c_name; @@ -2095,7 +2095,7 @@ coff_read_enum_type (int index, int length, int lastsym, switch (ms->c_sclass) { case C_MOE: - sym = allocate_symbol (objfile); + sym = new (&objfile->objfile_obstack) symbol; name = obstack_strdup (&objfile->objfile_obstack, name); sym->set_linkage_name (name); diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 1efa47b..74355a0 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -407,7 +407,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg) if (name != NULL) { - struct symbol *sym = allocate_symbol (ccp->of); + struct symbol *sym = new (&ccp->of->objfile_obstack) symbol; OBJSTAT (ccp->of, n_syms++); sym->set_language (language_c, &ccp->of->objfile_obstack); @@ -436,7 +436,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid) gdb::unique_xmalloc_ptr<char> name (ctf_type_aname_raw (fp, tid)); if (name != NULL) { - sym = allocate_symbol (objfile); + sym = new (&objfile->objfile_obstack) symbol; OBJSTAT (objfile, n_syms++); sym->set_language (language_c, &objfile->objfile_obstack); @@ -1071,7 +1071,7 @@ ctf_add_var_cb (const char *name, ctf_id_t id, void *arg) complaint (_("ctf_add_var_cb: %s has NO type (%ld)"), name, id); type = objfile_type (ccp->of)->builtin_error; } - sym = allocate_symbol (ccp->of); + sym = new (&ccp->of->objfile_obstack) symbol; OBJSTAT (ccp->of, n_syms++); SYMBOL_TYPE (sym) = type; SYMBOL_DOMAIN (sym) = VAR_DOMAIN; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index ab21ab0..245ce07 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9172,7 +9172,7 @@ fixup_go_packaging (struct dwarf2_cu *cu) saved_package_name); struct symbol *sym; - sym = allocate_symbol (objfile); + sym = new (&objfile->objfile_obstack) symbol; sym->set_language (language_go, &objfile->objfile_obstack); sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd); /* This is not VAR_DOMAIN because we want a way to ensure a lookup of, @@ -12983,7 +12983,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 = allocate_template_symbol (objfile); + templ_func = new (&objfile->objfile_obstack) template_symbol; templ_func->subclass = SYMBOL_TEMPLATE; break; } @@ -13546,8 +13546,7 @@ read_variable (struct die_info *die, struct dwarf2_cu *cu) { struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; - storage = new (&objfile->objfile_obstack) rust_vtable_symbol (); - initialize_objfile_symbol (storage); + storage = new (&objfile->objfile_obstack) rust_vtable_symbol; storage->concrete_type = containing_type; storage->subclass = SYMBOL_RUST_VTABLE; } @@ -20606,7 +20605,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu, if (space) sym = space; else - sym = allocate_symbol (objfile); + sym = new (&objfile->objfile_obstack) symbol; OBJSTAT (objfile, n_syms++); /* Cache this symbol's name and the name's demangled form (if any). */ @@ -655,7 +655,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile) for (gdb_block &gdb_block_iter : stab->blocks) { struct block *new_block = allocate_block (&objfile->objfile_obstack); - struct symbol *block_name = allocate_symbol (objfile); + struct symbol *block_name = new (&objfile->objfile_obstack) symbol; struct type *block_type = arch_type (objfile->arch (), TYPE_CODE_VOID, TARGET_CHAR_BIT, diff --git a/gdb/language.c b/gdb/language.c index a7ecb79..3dc22a7 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -1041,6 +1041,7 @@ language_alloc_type_symbol (enum language lang, struct type *type) symbol->set_language (lang, nullptr); symbol->owner.arch = gdbarch; SYMBOL_OBJFILE_OWNED (symbol) = 0; + SYMBOL_SECTION (symbol) = 0; SYMBOL_TYPE (symbol) = type; SYMBOL_DOMAIN (symbol) = VAR_DOMAIN; SYMBOL_ACLASS_INDEX (symbol) = LOC_TYPEDEF; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index eab52c7..ba53512 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1056,7 +1056,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 = allocate_symbol (mdebugread_objfile); + enum_sym = new (&mdebugread_objfile->objfile_obstack) symbol; enum_sym->set_linkage_name (obstack_strdup (&mdebugread_objfile->objfile_obstack, f->name)); @@ -4721,7 +4721,7 @@ new_block (enum block_type type, enum language language) static struct symbol * new_symbol (const char *name) { - struct symbol *s = allocate_symbol (mdebugread_objfile); + struct symbol *s = new (&mdebugread_objfile->objfile_obstack) symbol; s->set_language (psymtab_language, &mdebugread_objfile->objfile_obstack); s->compute_and_set_names (name, true, mdebugread_objfile->per_bfd); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 77f105d..716b5f3 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -423,7 +423,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 = allocate_symbol (objfile); + sym = new (&objfile->objfile_obstack) symbol; SYMBOL_DOMAIN (sym) = VAR_DOMAIN; SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT; sym->set_linkage_name @@ -687,7 +687,7 @@ define_symbol (CORE_ADDR valu, const 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 = allocate_symbol (objfile); + current_symbol = sym = new (&objfile->objfile_obstack) symbol; if (processing_gcc_compilation) { @@ -1307,7 +1307,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, if (synonym) { /* Create the STRUCT_DOMAIN clone. */ - struct symbol *struct_sym = allocate_symbol (objfile); + struct symbol *struct_sym = new (&objfile->objfile_obstack) symbol; *struct_sym = *sym; SYMBOL_ACLASS_INDEX (struct_sym) = LOC_TYPEDEF; @@ -1349,7 +1349,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, if (synonym) { /* Clone the sym and then modify it. */ - struct symbol *typedef_sym = allocate_symbol (objfile); + struct symbol *typedef_sym = new (&objfile->objfile_obstack) symbol; *typedef_sym = *sym; SYMBOL_ACLASS_INDEX (typedef_sym) = LOC_TYPEDEF; @@ -3632,7 +3632,7 @@ read_enum_type (const char **pp, struct type *type, if (nbits != 0) return error_type (pp, objfile); - sym = allocate_symbol (objfile); + sym = new (&objfile->objfile_obstack) symbol; sym->set_linkage_name (name); sym->set_language (get_current_subfile ()->language, &objfile->objfile_obstack); @@ -4299,7 +4299,7 @@ common_block_end (struct objfile *objfile) return; } - sym = allocate_symbol (objfile); + sym = new (&objfile->objfile_obstack) symbol; /* Note: common_block_name already saved on objfile_obstack. */ sym->set_linkage_name (common_block_name); SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK; diff --git a/gdb/symtab.c b/gdb/symtab.c index 2043d08..16ebe4d 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6355,42 +6355,6 @@ initialize_ordinary_address_classes (void) -/* Initialize the symbol SYM, and mark it as being owned by an objfile. */ - -void -initialize_objfile_symbol (struct symbol *sym) -{ - SYMBOL_OBJFILE_OWNED (sym) = 1; - SYMBOL_SECTION (sym) = -1; -} - -/* Allocate and initialize a new 'struct symbol' on OBJFILE's - obstack. */ - -struct symbol * -allocate_symbol (struct objfile *objfile) -{ - struct symbol *result = new (&objfile->objfile_obstack) symbol (); - - initialize_objfile_symbol (result); - - 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 = new (&objfile->objfile_obstack) template_symbol (); - initialize_objfile_symbol (result); - - return result; -} - /* See symtab.h. */ struct objfile * diff --git a/gdb/symtab.h b/gdb/symtab.h index 764c567..aaf42a5 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1107,7 +1107,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack /* Class-initialization of bitfields is only allowed in C++20. */ : domain (UNDEF_DOMAIN), aclass_index (0), - is_objfile_owned (0), + is_objfile_owned (1), is_argument (0), is_inlined (0), maybe_copied (0), @@ -1120,12 +1120,14 @@ struct symbol : public general_symbol_info, public allocate_on_obstack language_specific.obstack = nullptr; m_language = language_unknown; ada_mangled = 0; - section = 0; + section = -1; /* GCC 4.8.5 (on CentOS 7) does not correctly compile class- initialization of unions, so we initialize it manually here. */ owner.symtab = nullptr; } + symbol (const symbol &) = default; + /* Data type of value */ struct type *type = nullptr; @@ -2331,12 +2333,6 @@ const char * demangle_for_lookup (const char *name, enum language lang, demangle_result_storage &storage); -struct symbol *allocate_symbol (struct objfile *); - -void initialize_objfile_symbol (struct symbol *); - -struct template_symbol *allocate_template_symbol (struct objfile *); - /* Test to see if the symbol of language SYMBOL_LANGUAGE specified by SYMNAME (which is already demangled for C++ symbols) matches SYM_TEXT in the first SYM_TEXT_LEN characters. If so, add it to diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 2c19dc8..93bdb9b 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -1521,11 +1521,6 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst) } } -#define SYMBOL_DUP(SYMBOL1, SYMBOL2) \ - (SYMBOL2) = new (&objfile->objfile_obstack) symbol (); \ - *(SYMBOL2) = *(SYMBOL1); - - #define SYMNAME_ALLOC(NAME, ALLOCED) \ ((ALLOCED) ? (NAME) : obstack_strdup (&objfile->objfile_obstack, \ (NAME))) @@ -1561,8 +1556,6 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile) if (name[0] == '.') ++name; - initialize_objfile_symbol (sym); - /* default assumptions */ SET_SYMBOL_VALUE_ADDRESS (sym, cs->c_value + off); SYMBOL_DOMAIN (sym) = VAR_DOMAIN; @@ -1578,7 +1571,7 @@ process_xcoff_symbol (struct coff_symbol *cs, struct objfile *objfile) SYMBOL_TYPE (sym) = objfile_type (objfile)->nodebug_text_symbol; SYMBOL_ACLASS_INDEX (sym) = LOC_BLOCK; - SYMBOL_DUP (sym, sym2); + sym2 = new (&objfile->objfile_obstack) symbol (*sym); if (cs->c_sclass == C_EXT || C_WEAKEXT) add_symbol_to_list (sym2, get_global_symbols ()); |