New class allocate_on_obstack
This patch adds a new class allocate_on_obstack, and let dwarf2_per_objfile inherit it, so that dwarf2_per_objfile is automatically allocated on obstack, and "delete dwarf2_per_objfile" doesn't de-allocate any space. gdb: 2018-02-16 Yao Qi <yao.qi@linaro.org> * block.c (block_namespace_info): Inherit allocate_on_obstack. (block_initialize_namespace): Use new. * dwarf2read.c (dwarf2_per_objfile): Inherit allocate_on_obstack. (dwarf2_free_objfile): Use delete. * gdbtypes.c (type_pair): Inherit allocate_on_obstack. (copy_type_recursive): Use new. * gdb_obstack.h (allocate_on_obstack): New.
This commit is contained in:
parent
75cdede099
commit
fd90ace4c1
5 changed files with 50 additions and 24 deletions
|
@ -380,7 +380,7 @@ struct tu_stats
|
|||
/* Collection of data recorded per objfile.
|
||||
This hangs off of dwarf2_objfile_data_key. */
|
||||
|
||||
struct dwarf2_per_objfile
|
||||
struct dwarf2_per_objfile : public allocate_on_obstack
|
||||
{
|
||||
/* Construct a dwarf2_per_objfile for OBJFILE. NAMES points to the
|
||||
dwarf2 section names, or is NULL if the standard ELF names are
|
||||
|
@ -2525,10 +2525,9 @@ dwarf2_has_info (struct objfile *objfile,
|
|||
if (dwarf2_per_objfile == NULL)
|
||||
{
|
||||
/* Initialize per-objfile state. */
|
||||
struct dwarf2_per_objfile *data
|
||||
= XOBNEW (&objfile->objfile_obstack, struct dwarf2_per_objfile);
|
||||
|
||||
dwarf2_per_objfile = new (data) struct dwarf2_per_objfile (objfile, names);
|
||||
dwarf2_per_objfile
|
||||
= new (&objfile->objfile_obstack) struct dwarf2_per_objfile (objfile,
|
||||
names);
|
||||
set_dwarf2_per_objfile (objfile, dwarf2_per_objfile);
|
||||
}
|
||||
return (!dwarf2_per_objfile->info.is_virtual
|
||||
|
@ -25202,10 +25201,7 @@ dwarf2_free_objfile (struct objfile *objfile)
|
|||
struct dwarf2_per_objfile *dwarf2_per_objfile
|
||||
= get_dwarf2_per_objfile (objfile);
|
||||
|
||||
if (dwarf2_per_objfile == NULL)
|
||||
return;
|
||||
|
||||
dwarf2_per_objfile->~dwarf2_per_objfile ();
|
||||
delete dwarf2_per_objfile;
|
||||
}
|
||||
|
||||
/* A set of CU "per_cu" pointer, DIE offset, and GDB type pointer.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue