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]

[patch] dummy-frame cleanups


Hello,

The attached cleans up dummy-frame.[hc] a little:

- dummy_frame_register_unwind() now has a sensible name (it was generic_call_dummy_register_unwind).

- a number of utility functions are added (cached_find_dummy_frame and find_dummy_frame)

The function cached_find_dummy_frame() might look like overkill but it isn't. The next patch will add:

CORE_ADDR
dummy_frame_pc_unwind (struct frame_info *frame,
                       void **cache)
{
  struct dummy_frame *dummy = cached_find_dummy_frame (frame, cache);
  return dummy->pc;
}
committed,
Andrew
2002-11-08  Andrew Cagney  <ac131313@redhat.com>

	* frame.c (set_unwind_by_pc): Use dummy_frame_register_unwind.
	* dummy-frame.c (find_dummy_frame): Rename
	generic_find_dummy_frame, make static.  Return the dummy frame
	instead of the regcache.
	(generic_find_dummy_frame): Re-implement using find_dummy_frame,
	(cached_find_dummy_frame): New function.  Use find_dummy_frame.
	(dummy_frame_register_unwind): Rename
	generic_call_dummy_register_unwind.  Use cached_find_dummy_frame.
	* dummy-frame.h (dummy_frame_register_unwind): Rename
	generic_call_dummy_register_unwind.

Index: dummy-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dummy-frame.c,v
retrieving revision 1.1
diff -u -r1.1 dummy-frame.c
--- dummy-frame.c	8 Nov 2002 19:42:00 -0000	1.1
+++ dummy-frame.c	8 Nov 2002 23:10:55 -0000
@@ -58,8 +58,8 @@
    adjust for DECR_PC_AFTER_BREAK.  This is because it is only legal
    to call this function after the PC has been adjusted.  */
 
-struct regcache *
-generic_find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp)
+static struct dummy_frame *
+find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp)
 {
   struct dummy_frame *dummyframe;
 
@@ -94,10 +94,28 @@
 	    continue;
 	}
       /* The FP matches this dummy frame.  */
-      return dummyframe->regcache;
+      return dummyframe;
     }
 
-  return 0;
+  return NULL;
+}
+
+struct dummy_frame *
+cached_find_dummy_frame (struct frame_info *frame, void **cache)
+{
+  if ((*cache) == NULL)
+    (*cache) = find_dummy_frame (frame->pc, frame->frame);
+  return (*cache);
+}
+
+struct regcache *
+generic_find_dummy_frame (CORE_ADDR pc, CORE_ADDR fp)
+{
+  struct dummy_frame *dummy = find_dummy_frame (pc, fp);
+  if (dummy != NULL)
+    return dummy->regcache;
+  else
+    return NULL;
 }
 
 char *
@@ -264,13 +282,13 @@
    register value is taken from the local copy of the register buffer.  */
 
 void
-generic_call_dummy_register_unwind (struct frame_info *frame, void **cache,
-				    int regnum, int *optimized,
-				    enum lval_type *lvalp, CORE_ADDR *addrp,
-				    int *realnum, void *bufferp)
+dummy_frame_register_unwind (struct frame_info *frame, void **cache,
+			     int regnum, int *optimized,
+			     enum lval_type *lvalp, CORE_ADDR *addrp,
+			     int *realnum, void *bufferp)
 {
-  gdb_assert (frame != NULL);
-  gdb_assert (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame));
+  struct dummy_frame *dummy = cached_find_dummy_frame (frame, cache);
+  gdb_assert (dummy != NULL);
 
   /* Describe the register's location.  Generic dummy frames always
      have the register value in an ``expression''.  */
@@ -282,27 +300,11 @@
   /* If needed, find and return the value of the register.  */
   if (bufferp != NULL)
     {
-      struct regcache *registers;
-#if 1
-      /* Get the address of the register buffer that contains all the
-	 saved registers for this dummy frame.  Cache that address.  */
-      registers = (*cache);
-      if (registers == NULL)
-	{
-	  registers = generic_find_dummy_frame (frame->pc, frame->frame);
-	  (*cache) = registers;
-	}
-#else
-      /* Get the address of the register buffer that contains the
-         saved registers and then extract the value from that.  */
-      registers = generic_find_dummy_frame (frame->pc, frame->frame);
-#endif
-      gdb_assert (registers != NULL);
       /* Return the actual value.  */
       /* Use the regcache_cooked_read() method so that it, on the fly,
          constructs either a raw or pseudo register from the raw
          register cache.  */
-      regcache_cooked_read (registers, regnum, bufferp);
+      regcache_cooked_read (dummy->regcache, regnum, bufferp);
     }
 }
 
Index: dummy-frame.h
===================================================================
RCS file: /cvs/src/src/gdb/dummy-frame.h,v
retrieving revision 1.1
diff -u -r1.1 dummy-frame.h
--- dummy-frame.h	8 Nov 2002 19:42:00 -0000	1.1
+++ dummy-frame.h	8 Nov 2002 23:10:55 -0000
@@ -45,14 +45,14 @@
 /* Assuming that FRAME is a dummy, return a register value for the
    previous frame.  */
 
-extern void generic_call_dummy_register_unwind (struct frame_info *frame,
-						void **unwind_cache,
-						int regnum,
-						int *optimized,
-						enum lval_type *lvalp,
-						CORE_ADDR *addrp,
-						int *realnump,
-						void *valuep);
+extern void dummy_frame_register_unwind (struct frame_info *frame,
+					 void **unwind_cache,
+					 int regnum,
+					 int *optimized,
+					 enum lval_type *lvalp,
+					 CORE_ADDR *addrp,
+					 int *realnump,
+					 void *valuep);
 
 /* Return the regcache that belongs to the dummy-frame identifed by PC
    and FP, or NULL if no such frame exists.  */
@@ -62,5 +62,4 @@
 
 extern struct regcache *generic_find_dummy_frame (CORE_ADDR pc,
 						  CORE_ADDR fp);
-
 #endif /* !defined (DUMMY_FRAME_H)  */
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.22
diff -u -r1.22 frame.c
--- frame.c	8 Nov 2002 20:48:55 -0000	1.22
+++ frame.c	8 Nov 2002 23:10:56 -0000
@@ -636,7 +636,7 @@
        return vaguely correct values..  */
     *unwind = frame_saved_regs_register_unwind;
   else if (PC_IN_CALL_DUMMY (pc, fp, fp))
-    *unwind = generic_call_dummy_register_unwind;
+    *unwind = dummy_frame_register_unwind;
   else
     *unwind = frame_saved_regs_register_unwind;
 }

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