* 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.
This commit is contained in:
Andreas Schwab 2007-06-12 15:21:27 +00:00
parent 4339e69e64
commit 272dfcfd78
6 changed files with 48 additions and 2 deletions

View File

@ -1,3 +1,14 @@
2007-06-12 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.
2007-06-12 Ulrich Weigand <uweigand@de.ibm.com> 2007-06-12 Ulrich Weigand <uweigand@de.ibm.com>
Markus Deuling <deuling@de.ibm.com> Markus Deuling <deuling@de.ibm.com>

View File

@ -125,6 +125,10 @@ typedef void (frame_prev_register_ftype) (struct frame_info *next_frame,
typedef CORE_ADDR (frame_prev_pc_ftype) (struct frame_info *next_frame, typedef CORE_ADDR (frame_prev_pc_ftype) (struct frame_info *next_frame,
void **this_prologue_cache); void **this_prologue_cache);
/* Deallocate extra memory associated with the frame cache if any. */
typedef void (frame_dealloc_cache_ftype) (struct frame_info *self,
void *this_cache);
struct frame_unwind struct frame_unwind
{ {
@ -138,6 +142,7 @@ struct frame_unwind
const struct frame_data *unwind_data; const struct frame_data *unwind_data;
frame_sniffer_ftype *sniffer; frame_sniffer_ftype *sniffer;
frame_prev_pc_ftype *prev_pc; frame_prev_pc_ftype *prev_pc;
frame_dealloc_cache_ftype *dealloc_cache;
}; };
/* Register a frame unwinder, _prepending_ it to the front of the /* Register a frame unwinder, _prepending_ it to the front of the

View File

@ -1077,6 +1077,17 @@ frame_observer_target_changed (struct target_ops *target)
void void
reinit_frame_cache (void) reinit_frame_cache (void)
{ {
struct frame_info *fi;
/* 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);
}
/* Since we can't really be sure what the first object allocated was */ /* Since we can't really be sure what the first object allocated was */
obstack_free (&frame_cache_obstack, 0); obstack_free (&frame_cache_obstack, 0);
obstack_init (&frame_cache_obstack); obstack_init (&frame_cache_obstack);

View File

@ -2778,7 +2778,11 @@ static const struct frame_unwind ia64_libunwind_frame_unwind =
{ {
NORMAL_FRAME, NORMAL_FRAME,
ia64_libunwind_frame_this_id, ia64_libunwind_frame_this_id,
ia64_libunwind_frame_prev_register ia64_libunwind_frame_prev_register,
NULL,
NULL,
NULL,
libunwind_frame_dealloc_cache
}; };
static const struct frame_unwind * static const struct frame_unwind *

View File

@ -65,6 +65,7 @@ struct libunwind_frame_cache
CORE_ADDR base; CORE_ADDR base;
CORE_ADDR func_addr; CORE_ADDR func_addr;
unw_cursor_t cursor; unw_cursor_t cursor;
unw_addr_space_t as;
}; };
/* We need to qualify the function names with a platform-specific prefix to match /* We need to qualify the function names with a platform-specific prefix to match
@ -187,11 +188,20 @@ libunwind_frame_cache (struct frame_info *next_frame, void **this_cache)
} }
cache->base = (CORE_ADDR)fp; cache->base = (CORE_ADDR)fp;
cache->as = as;
*this_cache = cache; *this_cache = cache;
return cache; return cache;
} }
void
libunwind_frame_dealloc_cache (struct frame_info *self, void *this_cache)
{
struct libunwind_frame_cache *cache = this_cache;
if (cache->as)
unw_destroy_addr_space_p (cache->as);
}
unw_word_t unw_word_t
libunwind_find_dyn_list (unw_addr_space_t as, unw_dyn_info_t *di, void *arg) libunwind_find_dyn_list (unw_addr_space_t as, unw_dyn_info_t *di, void *arg)
{ {
@ -202,7 +212,11 @@ static const struct frame_unwind libunwind_frame_unwind =
{ {
NORMAL_FRAME, NORMAL_FRAME,
libunwind_frame_this_id, libunwind_frame_this_id,
libunwind_frame_prev_register libunwind_frame_prev_register,
NULL,
NULL,
NULL,
libunwind_frame_dealloc_cache
}; };
/* Verify if there is sufficient libunwind information for the frame to use /* Verify if there is sufficient libunwind information for the frame to use

View File

@ -53,6 +53,7 @@ void libunwind_frame_prev_register (struct frame_info *next_frame, void **this_c
int regnum, int *optimizedp, int regnum, int *optimizedp,
enum lval_type *lvalp, CORE_ADDR *addrp, enum lval_type *lvalp, CORE_ADDR *addrp,
int *realnump, gdb_byte *valuep); int *realnump, gdb_byte *valuep);
void libunwind_frame_dealloc_cache (struct frame_info *self, void *cache);
CORE_ADDR libunwind_frame_base_address (struct frame_info *next_frame, void **this_cache); CORE_ADDR libunwind_frame_base_address (struct frame_info *next_frame, void **this_cache);
int libunwind_is_initialized (void); int libunwind_is_initialized (void);