From b76fc32f8a134508d49b6a5e0feefeec988a532c Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Mon, 2 Aug 2004 03:36:24 +0000 Subject: [PATCH] 2004-08-01 Andrew Cagney * frame.h (frame_save_as_regcache): Declare. * frame.c (frame_save_as_regcache): New function. (do_frame_read_register): Replace do_frame_unwind_register. (frame_pop): Use frame_save_as_regcache. * dummy-frame.c (generic_push_dummy_frame): Use frame_save_as_regcache. --- gdb/ChangeLog | 9 +++++++++ gdb/dummy-frame.c | 3 +-- gdb/frame.c | 18 ++++++++++++++---- gdb/frame.h | 3 +++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8728ff45be..6d6ce0e4b8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2004-08-01 Andrew Cagney + + * frame.h (frame_save_as_regcache): Declare. + * frame.c (frame_save_as_regcache): New function. + (do_frame_read_register): Replace do_frame_unwind_register. + (frame_pop): Use frame_save_as_regcache. + * dummy-frame.c (generic_push_dummy_frame): Use + frame_save_as_regcache. + 2004-08-01 Joel Brobecker * dwarf2read.c (dwarf_decode_lines): Do not consider the current diff --git a/gdb/dummy-frame.c b/gdb/dummy-frame.c index 635c835dc2..d901214c37 100644 --- a/gdb/dummy-frame.c +++ b/gdb/dummy-frame.c @@ -161,12 +161,11 @@ generic_push_dummy_frame (void) dummy_frame = dummy_frame->next; dummy_frame = xmalloc (sizeof (struct dummy_frame)); - dummy_frame->regcache = regcache_xmalloc (current_gdbarch); + dummy_frame->regcache = frame_save_as_regcache (get_current_frame ()); dummy_frame->pc = read_pc (); dummy_frame->top = 0; dummy_frame->id = get_frame_id (get_current_frame ()); - regcache_cpy (dummy_frame->regcache, current_regcache); dummy_frame->next = dummy_frame_stack; dummy_frame_stack = dummy_frame; } diff --git a/gdb/frame.c b/gdb/frame.c index 6df8b87b4e..a723b32111 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -456,12 +456,22 @@ get_frame_func (struct frame_info *fi) } static int -do_frame_unwind_register (void *src, int regnum, void *buf) +do_frame_register_read (void *src, int regnum, void *buf) { - frame_unwind_register (src, regnum, buf); + frame_register_read (src, regnum, buf); return 1; } +struct regcache * +frame_save_as_regcache (struct frame_info *this_frame) +{ + struct regcache *regcache = regcache_xmalloc (current_gdbarch); + struct cleanup *cleanups = make_cleanup_regcache_xfree (regcache); + regcache_save (regcache, do_frame_register_read, this_frame); + discard_cleanups (cleanups); + return regcache; +} + void frame_pop (struct frame_info *this_frame) { @@ -469,9 +479,9 @@ frame_pop (struct frame_info *this_frame) Save them in a scratch buffer so that there isn't a race between trying to extract the old values from the current_regcache while at the same time writing new values into that same cache. */ - struct regcache *scratch = regcache_xmalloc (current_gdbarch); + struct regcache *scratch + = frame_save_as_regcache (get_prev_frame_1 (this_frame)); struct cleanup *cleanups = make_cleanup_regcache_xfree (scratch); - regcache_save (scratch, do_frame_unwind_register, this_frame); /* FIXME: cagney/2003-03-16: It should be possible to tell the target's register cache that it is about to be hit with a burst diff --git a/gdb/frame.h b/gdb/frame.h index 347b27a99e..75b0c9e00f 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -518,6 +518,9 @@ extern void *frame_obstack_zalloc (unsigned long size); #define FRAME_OBSTACK_ZALLOC(TYPE) ((TYPE *) frame_obstack_zalloc (sizeof (TYPE))) #define FRAME_OBSTACK_CALLOC(NUMBER,TYPE) ((TYPE *) frame_obstack_zalloc ((NUMBER) * sizeof (TYPE))) +/* Create a regcache, and copy the frame's registers into it. */ +struct regcache *frame_save_as_regcache (struct frame_info *this_frame); + extern void generic_save_dummy_frame_tos (CORE_ADDR sp); extern struct block *get_frame_block (struct frame_info *, -- 2.11.0