if (name != nullptr && *name != '\0')
{
objfile *objfile = ccp->per_objfile->objfile;
- struct symbol *sym = new (&objfile->objfile_obstack) symbol;
- OBJSTAT (objfile, n_syms++);
+ symbol *sym = objfile->new_symbol<symbol> ();
sym->set_language (language_c, &objfile->objfile_obstack);
sym->compute_and_set_names (name, false, objfile->per_bfd);
if (name != nullptr && *name != '\0')
{
objfile *objfile = ccp->per_objfile->objfile;
- struct symbol *sym = new (&objfile->objfile_obstack) symbol;
- OBJSTAT (objfile, n_syms++);
+ symbol *sym = objfile->new_symbol<symbol> ();
sym->set_language (language_c, &objfile->objfile_obstack);
sym->compute_and_set_names (name, false, objfile->per_bfd);
complaint (_("ctf_add_var_cb: %s has NO type (%ld)"), name, id);
type = builtin_type (objfile)->builtin_error;
}
- sym = new (&objfile->objfile_obstack) symbol;
- OBJSTAT (objfile, n_syms++);
+ sym = objfile->new_symbol<symbol> ();
sym->set_type (type);
sym->set_loc_class_index (LOC_OPTIMIZED_OUT);
sym->compute_and_set_names (name, false, objfile->per_bfd);
ctf_debug_printf ("adding %s '%s' tid=0x%lx",
functions ? "function" : "object", tname, tid);
- sym = new (&objfile->objfile_obstack) symbol;
- OBJSTAT (objfile, n_syms++);
+ sym = objfile->new_symbol<symbol> ();
sym->set_type (type);
sym->set_domain (functions ? FUNCTION_DOMAIN : VAR_DOMAIN);
sym->set_loc_class_index (LOC_STATIC);
if (child_die->tag == DW_TAG_template_type_param
|| child_die->tag == DW_TAG_template_value_param)
{
- templ_func = new (&objfile->objfile_obstack) template_symbol;
+ templ_func = objfile->new_symbol<template_symbol> ();
templ_func->subclass = SYMBOL_TEMPLATE;
break;
}
{
struct objfile *objfile = cu->per_objfile->objfile;
- storage = new (&objfile->objfile_obstack) rust_vtable_symbol;
+ storage = objfile->new_symbol<rust_vtable_symbol> ();
storage->concrete_type = containing_type;
storage->subclass = SYMBOL_RUST_VTABLE;
}
if (space)
sym = space;
else
- sym = new (&objfile->objfile_obstack) symbol;
- OBJSTAT (objfile, n_syms++);
+ sym = objfile->new_symbol<symbol> ();
/* Cache this symbol's name and the name's demangled form (if any). */
sym->set_language (cu->lang (), &objfile->objfile_obstack);
if (m_is_objfile)
{
- OBJSTAT (m_data.objfile, n_types++);
+ ++m_data.objfile->n_types;
type->set_owner (m_data.objfile);
}
else
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
-/* The "objstats" structure provides a place for gdb to record some
- interesting information about its internal state at runtime, on a
- per objfile basis, such as information about the number of symbols
- read, size of string table (if any), etc. */
-
-struct objstats
-{
- /* Number of full symbols read. */
- int n_syms = 0;
-
- /* Number of types. */
- int n_types = 0;
-
- /* Size of stringtable, (if applicable). */
- int sz_strtab = 0;
-};
-
-#define OBJSTAT(objfile, expr) (objfile -> stats.expr)
-#define OBJSTATS struct objstats stats
extern void print_objfile_statistics (void);
/* Number of entries in the minimal symbol hash table. */
section_iterator (sections_end, sections_end)));
}
+ /* Allocate a new symbol on this objfile's obstack. Normally a
+ symbol is made, but other subtypes (e.g., template_symbol) can
+ also be created. */
+ template<typename T>
+ T *new_symbol ()
+ {
+ T *result = new (&objfile_obstack) T;
+ ++n_syms;
+ return result;
+ }
+
public:
/* The object file's original name as specified by the user,
struct objfile *separate_debug_objfile_link = nullptr;
- /* Place to stash various statistics about this objfile. */
+ /* Number of full symbols read. */
+ int n_syms = 0;
- OBJSTATS;
+ /* Number of types. */
+ int n_types = 0;
/* A linked list of symbols created when reading template types or
function templates. These symbols are not stored in any symbol
if (objfile.per_bfd->n_minsyms > 0)
gdb_printf (_(" Number of \"minimal\" symbols read: %d\n"),
objfile.per_bfd->n_minsyms);
- if (OBJSTAT ((&objfile), n_syms) > 0)
+ if (objfile.n_syms > 0)
gdb_printf (_(" Number of \"full\" symbols read: %d\n"),
- OBJSTAT ((&objfile), n_syms));
- if (OBJSTAT ((&objfile), n_types) > 0)
+ objfile.n_syms);
+ if (objfile.n_types > 0)
gdb_printf (_(" Number of \"types\" defined: %d\n"),
- OBJSTAT ((&objfile), n_types));
+ objfile.n_types);
i = linetables = 0;
for (compunit_symtab &cu : objfile.compunits ())
objfile.print_stats (false);
- if (OBJSTAT ((&objfile), sz_strtab) > 0)
- gdb_printf (_(" Space used by string tables: %d\n"),
- OBJSTAT ((&objfile), sz_strtab));
gdb_printf (_(" Total memory used for objfile obstack: %s\n"),
pulongest (obstack_memory_used (&objfile
.objfile_obstack)));