This is the mail archive of the gdb-patches@sources.redhat.com 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]

[commit] Add function frame_save_as_regcache ()


Both pop_frame, and dummy-frame were saving registers from the current_frame. This adds a function that both can use.

committed,
Andrew
2004-08-01  Andrew Cagney  <cagney@gnu.org>

	* 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.

Index: dummy-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dummy-frame.c,v
retrieving revision 1.36
diff -p -u -r1.36 dummy-frame.c
--- dummy-frame.c	1 Aug 2004 23:13:41 -0000	1.36
+++ dummy-frame.c	2 Aug 2004 03:23:11 -0000
@@ -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;
 }
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.189
diff -p -u -r1.189 frame.c
--- frame.c	1 Aug 2004 21:47:18 -0000	1.189
+++ frame.c	2 Aug 2004 03:23:11 -0000
@@ -456,12 +456,20 @@ 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);
+  regcache_save (regcache, do_frame_register_read, this_frame);
+  return regcache;
+}
+
 void
 frame_pop (struct frame_info *this_frame)
 {
@@ -469,9 +477,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
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.139
diff -p -u -r1.139 frame.h
--- frame.h	1 Aug 2004 23:13:41 -0000	1.139
+++ frame.h	2 Aug 2004 03:23:11 -0000
@@ -518,6 +518,9 @@ extern void *frame_obstack_zalloc (unsig
 #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 *,

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