+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.
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;
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);
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);
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);
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;
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,
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;
}
{
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;
}
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). */
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,
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;
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));
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);
/* 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
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)
{
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;
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;
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);
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;
\f
-/* 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 *
/* 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),
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;
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
}
}
-#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)))
if (name[0] == '.')
++name;
- initialize_objfile_symbol (sym);
-
/* default assumptions */
SET_SYMBOL_VALUE_ADDRESS (sym, cs->c_value + off);
SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
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 ());