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]

[wip] Final opaque frame changes


FYI,

Attatched is a work-in-progress snap of the final set of changes to make `struct frame_info' opaque. It does the following:

Changes INIT_EXTRA_FRAME_INFO() to a function.

Adds methods:

get_frame_extra_info()

and:

get_frame_saved_regs_p()
get_frame_saved_regs()

I'll be breaking this down and then incrementally committing it over the comming weeks.

--

In parallel I've got the following frame related changes outstanding:

- when creating the prev frame, unwind the PC before anything else
- when creating the prev frame, unwind a frame ID instead of the frame chain
- eliminate set_current_frame()

--

I guess next is `struct thread_info'? With that cleaned up, it becomes possible to pull threads, frames and registers all into one.

Andrew
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.39
diff -u -r1.39 frame.c
--- frame.c	9 Dec 2002 02:04:16 -0000	1.39
+++ frame.c	10 Dec 2002 17:06:36 -0000
@@ -1,3 +1,4 @@
+#define FRAME_C
 /* Cache and manage frames for GDB, the GNU debugger.
 
    Copyright 1986, 1987, 1989, 1991, 1994, 1995, 1996, 1998, 2000,
@@ -811,7 +812,7 @@
   fi->type = type;
 
   if (INIT_EXTRA_FRAME_INFO_P ())
-    INIT_EXTRA_FRAME_INFO (0, fi);
+    fi->extra_info = INIT_EXTRA_FRAME_INFO (0, fi);
 
   /* Select/initialize an unwind function.  */
   set_unwind_by_pc (fi->pc, fi->frame, &fi->register_unwind,
@@ -1045,7 +1046,7 @@
     prev->pc = (DEPRECATED_INIT_FRAME_PC_FIRST (fromleaf, prev));
 
   if (INIT_EXTRA_FRAME_INFO_P ())
-    INIT_EXTRA_FRAME_INFO (fromleaf, prev);
+    prev->extra_info = INIT_EXTRA_FRAME_INFO (fromleaf, prev);
 
   /* This entry is in the frame queue now, which is good since
      FRAME_SAVED_PC may use that queue to figure out its value (see
@@ -1201,6 +1202,27 @@
     }
 }
 #endif
+
+int
+get_frame_saved_regs_p (struct frame_info *fi)
+{
+  return fi->saved_regs != NULL;
+}
+
+CORE_ADDR *
+get_frame_saved_regs (struct frame_info *fi)
+{
+  if (fi->saved_regs == NULL)
+    /* Should be fi->saved_regs = ....; */
+    frame_saved_regs_zalloc (fi);
+  return fi->saved_regs;
+}
+
+struct frame_extra_info *
+get_frame_extra_info (struct frame_info *fi)
+{
+  return fi->extra_info;
+}
 
 void
 _initialize_frame (void)
Index: frame.h
===================================================================
RCS file: /cvs/src/src/gdb/frame.h,v
retrieving revision 1.44
diff -u -r1.44 frame.h
--- frame.h	4 Dec 2002 00:05:53 -0000	1.44
+++ frame.h	10 Dec 2002 17:06:36 -0000
@@ -357,6 +357,7 @@
    mips-tdep.c, or anything which reads new symbols)), we should call
    reinit_frame_cache.  */
 
+#ifdef FRAME_C
 struct frame_info
   {
     /* Nominal address of the frame described.  See comments at
@@ -430,6 +431,7 @@
     int prev_p;
     struct frame_info *prev; /* up, outer, older */
   };
+#endif
 
 /* Values for the source flag to be used in print_frame_info_base(). */
 enum print_what
@@ -457,7 +459,6 @@
         (sizeof (CORE_ADDR) * (NUM_REGS+NUM_PSEUDO_REGS))
 
 extern void *frame_obstack_alloc (unsigned long size);
-extern void frame_saved_regs_zalloc (struct frame_info *);
 
 /* Define a default FRAME_CHAIN_VALID, in the form that is suitable for most
    targets.  If FRAME_CHAIN_VALID returns zero it means that the given frame
@@ -642,5 +643,11 @@
 
 extern void set_current_frame (struct frame_info *);
 extern struct frame_info *create_new_frame (CORE_ADDR, CORE_ADDR);
+
+
+/* Keep old code working.  Return the frame's `extra info'.  */
+extern struct frame_extra_info *get_frame_extra_info (struct frame_info *);
+extern int get_frame_saved_regs_p (struct frame_info *);
+extern CORE_ADDR *get_frame_saved_regs (struct frame_info *);
 
 #endif /* !defined (FRAME_H)  */
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.181
diff -u -r1.181 gdbarch.sh
--- gdbarch.sh	9 Dec 2002 02:04:16 -0000	1.181
+++ gdbarch.sh	10 Dec 2002 17:06:37 -0000
@@ -551,7 +551,7 @@
 f:2:USE_STRUCT_CONVENTION:int:use_struct_convention:int gcc_p, struct type *value_type:gcc_p, value_type:::generic_use_struct_convention::0
 #
 f:2:FRAME_INIT_SAVED_REGS:void:frame_init_saved_regs:struct frame_info *frame:frame::0:0
-F:2:INIT_EXTRA_FRAME_INFO:void:init_extra_frame_info:int fromleaf, struct frame_info *frame:fromleaf, frame:::0
+F:2:INIT_EXTRA_FRAME_INFO:struct frame_extra_info *:init_extra_frame_info:int fromleaf, struct frame_info *frame:fromleaf, frame:::0
 #
 f:2:SKIP_PROLOGUE:CORE_ADDR:skip_prologue:CORE_ADDR ip:ip::0:0
 f:2:PROLOGUE_FRAMELESS_P:int:prologue_frameless_p:CORE_ADDR ip:ip::0:generic_prologue_frameless_p::0
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.82
diff -u -r1.82 infrun.c
--- infrun.c	6 Dec 2002 07:35:55 -0000	1.82
+++ infrun.c	10 Dec 2002 17:06:37 -0000
@@ -1,3 +1,4 @@
+#define FRAME_C
 /* Target-struct-independent code to start (run) and stop an inferior
    process.
 
Index: ppc-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/ppc-tdep.h,v
retrieving revision 1.13
diff -u -r1.13 ppc-tdep.h
--- ppc-tdep.h	20 Aug 2002 22:24:29 -0000	1.13
+++ ppc-tdep.h	10 Dec 2002 17:06:37 -0000
@@ -45,7 +45,7 @@
 
 /* From rs6000-tdep.c... */
 CORE_ADDR rs6000_frame_saved_pc (struct frame_info *fi);
-void rs6000_init_extra_frame_info (int fromleaf, struct frame_info *);
+struct frame_extra_info *rs6000_init_extra_frame_info (int fromleaf, struct frame_info *);
 int rs6000_frameless_function_invocation (struct frame_info *);
 void rs6000_frame_init_saved_regs (struct frame_info *);
 CORE_ADDR rs6000_frame_chain (struct frame_info *);
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.99
diff -u -r1.99 rs6000-tdep.c
--- rs6000-tdep.c	9 Dec 2002 03:30:44 -0000	1.99
+++ rs6000-tdep.c	10 Dec 2002 17:06:38 -0000
@@ -163,12 +163,12 @@
   CORE_ADDR initial_sp;		/* initial stack pointer. */
 };
 
-void
+struct frame_extra_info *
 rs6000_init_extra_frame_info (int fromleaf, struct frame_info *fi)
 {
-  fi->extra_info = (struct frame_extra_info *)
+  struct frame_extra_info *extra_info = (struct frame_extra_info *)
     frame_obstack_alloc (sizeof (struct frame_extra_info));
-  fi->extra_info->initial_sp = 0;
+  extra_info->initial_sp = 0;
   if (get_next_frame (fi) != NULL
       && get_frame_pc (fi) < TEXT_SEGMENT_BASE)
     /* We're in get_prev_frame */
@@ -176,6 +176,7 @@
     /* (fi->pc will be some low address in the kernel, */
     /*  to which the signal handler returns).  */
     deprecated_set_frame_type (fi, SIGTRAMP_FRAME);
+  return extra_info;
 }
 
 /* Put here the code to store, into a struct frame_saved_regs,
@@ -197,8 +198,9 @@
 static CORE_ADDR
 rs6000_frame_args_address (struct frame_info *fi)
 {
-  if (fi->extra_info->initial_sp != 0)
-    return fi->extra_info->initial_sp;
+  struct frame_extra_info *extra_info = get_frame_extra_info (fi);
+  if (extra_info->initial_sp != 0)
+    return extra_info->initial_sp;
   else
     return frame_initial_stack_address (fi);
 }
@@ -1568,11 +1570,12 @@
 frame_get_saved_regs (struct frame_info *fi, struct rs6000_framedata *fdatap)
 {
   CORE_ADDR frame_addr;
+  CORE_ADDR *saved_regs;
   struct rs6000_framedata work_fdata;
   struct gdbarch_tdep * tdep = gdbarch_tdep (current_gdbarch);
   int wordsize = tdep->wordsize;
 
-  if (fi->saved_regs)
+  if (get_frame_saved_regs_p (fi))
     return;
 
   if (fdatap == NULL)
@@ -1582,7 +1585,7 @@
 			    get_frame_pc (fi), fdatap);
     }
 
-  frame_saved_regs_zalloc (fi);
+  saved_regs = get_frame_saved_regs (fi);
 
   /* If there were any saved registers, figure out parent's stack
      pointer.  */
@@ -1615,7 +1618,7 @@
       CORE_ADDR fpr_addr = frame_addr + fdatap->fpr_offset;
       for (i = fdatap->saved_fpr; i < 32; i++)
 	{
-	  fi->saved_regs[FP0_REGNUM + i] = fpr_addr;
+	  saved_regs[FP0_REGNUM + i] = fpr_addr;
 	  fpr_addr += 8;
 	}
     }
@@ -1629,7 +1632,7 @@
       CORE_ADDR gpr_addr = frame_addr + fdatap->gpr_offset;
       for (i = fdatap->saved_gpr; i < 32; i++)
 	{
-	  fi->saved_regs[i] = gpr_addr;
+	  saved_regs[i] = gpr_addr;
 	  gpr_addr += wordsize;
 	}
     }
@@ -1644,7 +1647,7 @@
 	  CORE_ADDR vr_addr = frame_addr + fdatap->vr_offset;
 	  for (i = fdatap->saved_vr; i < 32; i++)
 	    {
-	      fi->saved_regs[tdep->ppc_vr0_regnum + i] = vr_addr;
+	      saved_regs[tdep->ppc_vr0_regnum + i] = vr_addr;
 	      vr_addr += REGISTER_RAW_SIZE (tdep->ppc_vr0_regnum);
 	    }
 	}
@@ -1660,8 +1663,8 @@
 	  CORE_ADDR ev_addr = frame_addr + fdatap->ev_offset;
 	  for (i = fdatap->saved_ev; i < 32; i++)
 	    {
-	      fi->saved_regs[tdep->ppc_ev0_regnum + i] = ev_addr;
-              fi->saved_regs[tdep->ppc_gp0_regnum + i] = ev_addr + 4;
+	      saved_regs[tdep->ppc_ev0_regnum + i] = ev_addr;
+              saved_regs[tdep->ppc_gp0_regnum + i] = ev_addr + 4;
 	      ev_addr += REGISTER_RAW_SIZE (tdep->ppc_ev0_regnum);
             }
 	}
@@ -1670,17 +1673,17 @@
   /* If != 0, fdatap->cr_offset is the offset from the frame that holds
      the CR.  */
   if (fdatap->cr_offset != 0)
-    fi->saved_regs[tdep->ppc_cr_regnum] = frame_addr + fdatap->cr_offset;
+    saved_regs[tdep->ppc_cr_regnum] = frame_addr + fdatap->cr_offset;
 
   /* If != 0, fdatap->lr_offset is the offset from the frame that holds
      the LR.  */
   if (fdatap->lr_offset != 0)
-    fi->saved_regs[tdep->ppc_lr_regnum] = frame_addr + fdatap->lr_offset;
+    saved_regs[tdep->ppc_lr_regnum] = frame_addr + fdatap->lr_offset;
 
   /* If != 0, fdatap->vrsave_offset is the offset from the frame that holds
      the VRSAVE.  */
   if (fdatap->vrsave_offset != 0)
-    fi->saved_regs[tdep->ppc_vrsave_regnum] = frame_addr + fdatap->vrsave_offset;
+    saved_regs[tdep->ppc_vrsave_regnum] = frame_addr + fdatap->vrsave_offset;
 }
 
 /* Return the address of a frame. This is the inital %sp value when the frame
@@ -1690,6 +1693,7 @@
 static CORE_ADDR
 frame_initial_stack_address (struct frame_info *fi)
 {
+  struct frame_extra_info *extra_info = get_frame_extra_info (fi);
   CORE_ADDR tmpaddr;
   struct rs6000_framedata fdata;
   struct frame_info *callee_fi;
@@ -1697,8 +1701,8 @@
   /* If the initial stack pointer (frame address) of this frame is known,
      just return it.  */
 
-  if (fi->extra_info->initial_sp)
-    return fi->extra_info->initial_sp;
+  if (extra_info->initial_sp)
+    return extra_info->initial_sp;
 
   /* Find out if this function is using an alloca register.  */
 
@@ -1708,7 +1712,7 @@
   /* If saved registers of this frame are not known yet, read and
      cache them.  */
 
-  if (!fi->saved_regs)
+  if (!get_frame_saved_regs_p (fi))
     frame_get_saved_regs (fi, &fdata);
 
   /* If no alloca register used, then fi->frame is the value of the %sp for
@@ -1716,8 +1720,8 @@
 
   if (fdata.alloca_reg < 0)
     {
-      fi->extra_info->initial_sp = get_frame_base (fi);
-      return fi->extra_info->initial_sp;
+      extra_info->initial_sp = get_frame_base (fi);
+      return extra_info->initial_sp;
     }
 
   /* There is an alloca register, use its value, in the current frame,
@@ -1726,7 +1730,7 @@
     char *tmpbuf = alloca (MAX_REGISTER_RAW_SIZE);
     if (frame_register_read (fi, fdata.alloca_reg, tmpbuf))
       {
-	fi->extra_info->initial_sp
+	extra_info->initial_sp
 	  = extract_unsigned_integer (tmpbuf,
 				      REGISTER_RAW_SIZE (fdata.alloca_reg));
       }
@@ -1734,9 +1738,9 @@
       /* NOTE: cagney/2002-04-17: At present the only time
          frame_register_read will fail is when the register isn't
          available.  If that does happen, use the frame.  */
-      fi->extra_info->initial_sp = get_frame_base (fi);
+      extra_info->initial_sp = get_frame_base (fi);
   }
-  return fi->extra_info->initial_sp;
+  return extra_info->initial_sp;
 }
 
 /* Describe the pointer in each stack frame to the previous stack frame
Index: stack.c
===================================================================
RCS file: /cvs/src/src/gdb/stack.c,v
retrieving revision 1.58
diff -u -r1.58 stack.c
--- stack.c	9 Dec 2002 03:30:44 -0000	1.58
+++ stack.c	10 Dec 2002 17:06:41 -0000
@@ -900,8 +900,6 @@
       }
   }
 
-  if (fi->saved_regs == NULL)
-    FRAME_INIT_SAVED_REGS (fi);
   /* Print as much information as possible on the location of all the
      registers.  */
   {

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