From: Daniel Jacobowitz Date: Mon, 22 Oct 2007 01:16:34 +0000 (+0000) Subject: * coffread.c (coff_symfile_finish): Call dwarf2_free_objfile. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fe3e1990b3ea81a95d90721f8e86fb5a10f76ba1;p=binutils-gdb.git * coffread.c (coff_symfile_finish): Call dwarf2_free_objfile. * dwarf2read.c (dwarf2_free_objfile): New. * elfread.c (elf_symfile_finish): Call dwarf2_free_objfile. * symfile.h (dwarf2_free_objfile): Declare. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2ad5ec2f6e0..6ce0ef949e4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2007-10-21 Daniel Jacobowitz + + * coffread.c (coff_symfile_finish): Call dwarf2_free_objfile. + * dwarf2read.c (dwarf2_free_objfile): New. + * elfread.c (elf_symfile_finish): Call dwarf2_free_objfile. + * symfile.h (dwarf2_free_objfile): Declare. + 2007-10-21 Joel Brobecker * hppa-hpux-nat.c (hppa_hpux_store_register): Add missing semi-colon. diff --git a/gdb/coffread.c b/gdb/coffread.c index c4927490b99..d1a4246822f 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -665,6 +665,8 @@ coff_symfile_finish (struct objfile *objfile) /* Let stabs reader clean up */ stabsread_clear_cache (); + + dwarf2_free_objfile (objfile); } diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index e5e8aa4aa26..dbbe019d14b 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9964,6 +9964,22 @@ free_one_cached_comp_unit (void *target_cu) } } +/* Release all extra memory associated with OBJFILE. */ + +void +dwarf2_free_objfile (struct objfile *objfile) +{ + dwarf2_per_objfile = objfile_data (objfile, dwarf2_objfile_data_key); + + if (dwarf2_per_objfile == NULL) + return; + + /* Cached DIE trees use xmalloc and the comp_unit_obstack. */ + free_cached_comp_units (NULL); + + /* Everything else should be on the objfile obstack. */ +} + /* A pair of DIE offset and GDB type pointer. We store these in a hash table separate from the DIEs, and preserve them when the DIEs are flushed out of cache. */ diff --git a/gdb/elfread.c b/gdb/elfread.c index 7b317b8675e..e479a7698a7 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -709,6 +709,8 @@ elf_symfile_finish (struct objfile *objfile) { xfree (objfile->deprecated_sym_stab_info); } + + dwarf2_free_objfile (objfile); } /* ELF specific initialization routine for reading symbols. diff --git a/gdb/symfile.h b/gdb/symfile.h index fd14215c7be..8876df29dd2 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -365,6 +365,8 @@ extern int dwarf2_has_info (struct objfile *); extern void dwarf2_build_psymtabs (struct objfile *, int); extern void dwarf2_build_frame_info (struct objfile *); +void dwarf2_free_objfile (struct objfile *); + /* From mdebugread.c */ /* Hack to force structures to exist before use in parameter list. */