This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix memory leaks in libunwind unwinder, part 2


On Fri, Jun 08, 2007 at 05:09:41PM +0200, Andreas Schwab wrote:
> This is the second part of the memory leak fix for the libunwind
> unwinder.  There is no significant increase in gdb's memory any more.
> 
> Andreas.
> 
> 2007-06-08  Andreas Schwab  <schwab@suse.de>
> 
> 	* frame-unwind.h (frame_dealloc_cache_ftype): Define.
> 	(struct frame_unwind): Add dealloc_cache.
> 	* frame.c (reinit_frame_cache): Call dealloc_cache on all caches.
> 
> 	* libunwind-frame.h (libunwind_frame_dealloc_cache): Declare.
> 	* libunwind-frame.c (libunwind_frame_dealloc_cache): Define.
> 	(libunwind_frame_unwind): Set dealloc_cache.
> 	* ia64-tdep.c (ia64_libunwind_frame_unwind): Set dealloc_cache.

Thanks, this is OK with one fix.
> +  /* Tear down all frame caches.  */
> +  for (fi = current_frame; fi != NULL; fi = fi->prev)
> +    {
> +      if (fi->prologue_cache && fi->unwind->dealloc_cache)
> +	fi->unwind->dealloc_cache (fi, fi->prologue_cache);
> +      if (fi->base_cache && fi->base->unwind->dealloc_cache)
> +	fi->base->unwind->dealloc_cache (fi, fi->base_cache);
> +    }

Compare with:

  /* Sneaky: If the low-level unwind and high-level base code share a
     common unwinder, let them share the prologue cache.  */
  if (fi->base->unwind == fi->unwind)
    return fi->base->this_base (fi->next, &fi->prologue_cache);
  return fi->base->this_base (fi->next, &fi->base_cache);

I think you shouldn't dealloc the base cache if the two unwinders are
the same, right?

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]