* coffread.c (coff_symfile_finish): Call dwarf2_free_objfile.
authorDaniel Jacobowitz <drow@false.org>
Mon, 22 Oct 2007 01:16:34 +0000 (01:16 +0000)
committerDaniel Jacobowitz <drow@false.org>
Mon, 22 Oct 2007 01:16:34 +0000 (01:16 +0000)
* dwarf2read.c (dwarf2_free_objfile): New.
* elfread.c (elf_symfile_finish): Call dwarf2_free_objfile.
* symfile.h (dwarf2_free_objfile): Declare.

gdb/ChangeLog
gdb/coffread.c
gdb/dwarf2read.c
gdb/elfread.c
gdb/symfile.h

index 2ad5ec2..6ce0ef9 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-21  Daniel Jacobowitz  <dan@codesourcery.com>
+
+       * 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  <brobecker@adacore.com>
 
        * hppa-hpux-nat.c (hppa_hpux_store_register): Add missing semi-colon.
index c492749..d1a4246 100644 (file)
@@ -665,6 +665,8 @@ coff_symfile_finish (struct objfile *objfile)
 
   /* Let stabs reader clean up */
   stabsread_clear_cache ();
+
+  dwarf2_free_objfile (objfile);
 }
 \f
 
index e5e8aa4..dbbe019 100644 (file)
@@ -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.  */
index 7b317b8..e479a76 100644 (file)
@@ -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.
index fd14215..8876df2 100644 (file)
@@ -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.  */