This is the mail archive of the gdb-patches@sourceware.org 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]

[rfc] Remove deprecated_selected_frame


Does anyone object to this patch?  It's an extension of something I
have had in the Debian source package for years but never cleaned up
to submit before - this version is much more thorough.

Every reference to the global selected frame is either replaced by
get_selected_frame (if we know the program is running) or
deprecated_safe_get_selected_frame (if we're not sure).  This removes
a class of bugs caused by lazy creation of the selected frame, several
of which Debian users have reported to me.  It also simplifies some
other frame cleanups.

I've tried to preserve the same error messages everywhere.  I think
they ought to be unified and issued from just one spot, but that's a
different problem for another rainy day.

This patch will break Insight builds - you can either do the same sort
of transformation I described above, or just default to calling
deprecated_safe_get_selected_frame everywhere, and then it should keep
working.

Tested x86_64-pc-linux-gnu.  If no one objects, I will commit this
cleanup in a couple of days, and move on to the next one :-)

-- 
Daniel Jacobowitz
CodeSourcery

2007-02-22  Daniel Jacobowitz  <dan@codesourcery.com>

	* frame.c (deprecated_selected_frame): Rename to...
	(selected_frame): ...this.  Make static.
	(get_selected_frame, select_frame): Update.
	* frame.h (deprected_select_frame): Delete.
	(deprecated_safe_get_selected_frame): Update comments.

	* breakpoint.c, cli/cli-cmds.c, f-valprint.c, infcmd.c, inflow.c,
	infrun.c, stack.c, tui/tui-disasm.c, tui/tui-source.c,
	tui/tui-winsource.c, valops.c, varobj.c, findvar.c, macroscope.c,
	parse.c, regcache.h, sh64-tdep.c, tui/tui-hooks.c, tui/tui-win.c,
	tui/tui.c: Replace references to deprecated_selected_frame.

---
 gdb/breakpoint.c        |    8 ++++----
 gdb/cli/cli-cmds.c      |    5 +----
 gdb/f-valprint.c        |   24 ++++++++++++------------
 gdb/findvar.c           |    2 +-
 gdb/frame.c             |   10 +++++-----
 gdb/frame.h             |   28 ++++++++++------------------
 gdb/infcmd.c            |   41 ++++++++++++++++++-----------------------
 gdb/inflow.c            |    5 +----
 gdb/infrun.c            |    4 ++--
 gdb/macroscope.c        |   15 ++++++---------
 gdb/parse.c             |    2 +-
 gdb/regcache.h          |    2 +-
 gdb/sh64-tdep.c         |    3 +--
 gdb/stack.c             |   23 +++--------------------
 gdb/tui/tui-disasm.c    |    2 +-
 gdb/tui/tui-hooks.c     |   12 ++++++------
 gdb/tui/tui-source.c    |    2 +-
 gdb/tui/tui-win.c       |    6 +++---
 gdb/tui/tui-winsource.c |    2 +-
 gdb/tui/tui.c           |    4 ++--
 gdb/valops.c            |   16 +++++++++-------
 gdb/varobj.c            |    6 +++---
 22 files changed, 92 insertions(+), 130 deletions(-)

Index: src/gdb/breakpoint.c
===================================================================
--- src.orig/gdb/breakpoint.c	2007-02-22 14:13:26.000000000 -0500
+++ src/gdb/breakpoint.c	2007-02-22 14:23:25.000000000 -0500
@@ -1045,7 +1045,7 @@ Note: automatically using hardware break
       /* FIXME drow/2003-09-09: It would be nice if evaluate_expression
 	 took a frame parameter, so that we didn't have to change the
 	 selected frame.  */
-      saved_frame_id = get_frame_id (deprecated_selected_frame);
+      saved_frame_id = get_frame_id (get_selected_frame (NULL));
 
       /* Determine if the watchpoint is within scope.  */
       if (bpt->owner->exp_valid_block == NULL)
@@ -6053,7 +6053,8 @@ until_break_command (char *arg, int from
 {
   struct symtabs_and_lines sals;
   struct symtab_and_line sal;
-  struct frame_info *prev_frame = get_prev_frame (deprecated_selected_frame);
+  struct frame_info *frame = get_selected_frame (NULL);
+  struct frame_info *prev_frame = get_prev_frame (frame);
   struct breakpoint *breakpoint;
   struct cleanup *old_chain;
   struct continuation_arg *arg1;
@@ -6089,8 +6090,7 @@ until_break_command (char *arg, int from
   else
     /* Otherwise, specify the current frame, because we want to stop only
        at the very same frame.  */
-    breakpoint = set_momentary_breakpoint (sal,
-					   get_frame_id (deprecated_selected_frame),
+    breakpoint = set_momentary_breakpoint (sal, get_frame_id (frame),
 					   bp_until);
 
   if (!target_can_async_p ())
Index: src/gdb/cli/cli-cmds.c
===================================================================
--- src.orig/gdb/cli/cli-cmds.c	2007-02-09 13:08:42.000000000 -0500
+++ src/gdb/cli/cli-cmds.c	2007-02-22 14:18:20.000000000 -0500
@@ -915,10 +915,7 @@ disassemble_command (char *arg, int from
   name = NULL;
   if (!arg)
     {
-      if (!deprecated_selected_frame)
-	error (_("No frame selected."));
-
-      pc = get_frame_pc (deprecated_selected_frame);
+      pc = get_frame_pc (get_selected_frame (_("No frame selected.")));
       if (find_pc_partial_function (pc, &name, &low, &high) == 0)
 	error (_("No function contains program counter for selected frame."));
 #if defined(TUI)
Index: src/gdb/f-valprint.c
===================================================================
--- src.orig/gdb/f-valprint.c	2007-01-09 13:13:20.000000000 -0500
+++ src/gdb/f-valprint.c	2007-02-22 14:29:43.000000000 -0500
@@ -65,13 +65,15 @@ int f77_array_offset_tbl[MAX_FORTRAN_DIM
 int
 f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
 {
+  struct frame_info *frame;
   CORE_ADDR current_frame_addr;
   CORE_ADDR ptr_to_lower_bound;
 
   switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type))
     {
     case BOUND_BY_VALUE_ON_STACK:
-      current_frame_addr = get_frame_base (deprecated_selected_frame);
+      frame = deprecated_safe_get_selected_frame ();
+      current_frame_addr = get_frame_base (frame);
       if (current_frame_addr > 0)
 	{
 	  *lower_bound =
@@ -95,7 +97,8 @@ f77_get_dynamic_lowerbound (struct type 
       break;
 
     case BOUND_BY_REF_ON_STACK:
-      current_frame_addr = get_frame_base (deprecated_selected_frame);
+      frame = deprecated_safe_get_selected_frame ();
+      current_frame_addr = get_frame_base (frame);
       if (current_frame_addr > 0)
 	{
 	  ptr_to_lower_bound =
@@ -123,13 +126,15 @@ f77_get_dynamic_lowerbound (struct type 
 int
 f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
 {
+  struct frame_info *frame;
   CORE_ADDR current_frame_addr = 0;
   CORE_ADDR ptr_to_upper_bound;
 
   switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type))
     {
     case BOUND_BY_VALUE_ON_STACK:
-      current_frame_addr = get_frame_base (deprecated_selected_frame);
+      frame = deprecated_safe_get_selected_frame ();
+      current_frame_addr = get_frame_base (frame);
       if (current_frame_addr > 0)
 	{
 	  *upper_bound =
@@ -158,7 +163,8 @@ f77_get_dynamic_upperbound (struct type 
       break;
 
     case BOUND_BY_REF_ON_STACK:
-      current_frame_addr = get_frame_base (deprecated_selected_frame);
+      frame = deprecated_safe_get_selected_frame ();
+      current_frame_addr = get_frame_base (frame);
       if (current_frame_addr > 0)
 	{
 	  ptr_to_upper_bound =
@@ -643,10 +649,7 @@ info_common_command (char *comname, int 
      first make sure that it is visible and if so, let 
      us display its contents */
 
-  fi = deprecated_selected_frame;
-
-  if (fi == NULL)
-    error (_("No frame selected"));
+  fi = get_selected_frame (_("No frame selected"));
 
   /* The following is generally ripped off from stack.c's routine 
      print_frame_info() */
@@ -735,10 +738,7 @@ there_is_a_visible_common_named (char *c
   if (comname == NULL)
     error (_("Cannot deal with NULL common name!"));
 
-  fi = deprecated_selected_frame;
-
-  if (fi == NULL)
-    error (_("No frame selected"));
+  fi = get_selected_frame (_("No frame selected"));
 
   /* The following is generally ripped off from stack.c's routine 
      print_frame_info() */
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2007-02-22 14:13:26.000000000 -0500
+++ src/gdb/infcmd.c	2007-02-22 15:10:26.000000000 -0500
@@ -1295,10 +1295,8 @@ finish_command (char *arg, int from_tty)
     error (_("The \"finish\" command does not take any arguments."));
   if (!target_has_execution)
     error (_("The program is not running."));
-  if (deprecated_selected_frame == NULL)
-    error (_("No selected frame."));
 
-  frame = get_prev_frame (deprecated_selected_frame);
+  frame = get_prev_frame (get_selected_frame (_("No selected frame.")));
   if (frame == 0)
     error (_("\"finish\" not meaningful in the outermost frame."));
 
@@ -1316,7 +1314,7 @@ finish_command (char *arg, int from_tty)
 
   /* Find the function we will return from.  */
 
-  function = find_pc_function (get_frame_pc (deprecated_selected_frame));
+  function = find_pc_function (get_frame_pc (get_selected_frame (NULL)));
 
   /* Print info on the selected frame, including level number but not
      source.  */
@@ -1677,18 +1675,18 @@ default_print_registers_info (struct gdb
 void
 registers_info (char *addr_exp, int fpregs)
 {
+  struct frame_info *frame;
   int regnum, numregs;
   char *end;
 
   if (!target_has_registers)
     error (_("The program has no registers now."));
-  if (deprecated_selected_frame == NULL)
-    error (_("No selected frame."));
+  frame = get_selected_frame (NULL);
 
   if (!addr_exp)
     {
       gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
-				    deprecated_selected_frame, -1, fpregs);
+				    frame, -1, fpregs);
       return;
     }
 
@@ -1721,12 +1719,12 @@ registers_info (char *addr_exp, int fpre
 
       /* A register name?  */
       {
-	int regnum = frame_map_name_to_regnum (deprecated_selected_frame,
+	int regnum = frame_map_name_to_regnum (frame,
 					       start, end - start);
 	if (regnum >= 0)
 	  {
 	    gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
-					  deprecated_selected_frame, regnum, fpregs);
+					  frame, regnum, fpregs);
 	    continue;
 	  }
       }
@@ -1740,7 +1738,7 @@ registers_info (char *addr_exp, int fpre
 	    && regnum < NUM_REGS + NUM_PSEUDO_REGS)
 	  {
 	    gdbarch_print_registers_info (current_gdbarch, gdb_stdout,
-					  deprecated_selected_frame, regnum, fpregs);
+					  frame, regnum, fpregs);
 	    continue;
 	  }
       }
@@ -1766,7 +1764,7 @@ registers_info (char *addr_exp, int fpre
 		if (gdbarch_register_reggroup_p (current_gdbarch, regnum,
 						 group))
 		  gdbarch_print_registers_info (current_gdbarch,
-						gdb_stdout, deprecated_selected_frame,
+						gdb_stdout, frame,
 						regnum, fpregs);
 	      }
 	    continue;
@@ -1794,11 +1792,6 @@ static void
 print_vector_info (struct gdbarch *gdbarch, struct ui_file *file,
 		   struct frame_info *frame, const char *args)
 {
-  if (!target_has_registers)
-    error (_("The program has no registers now."));
-  if (deprecated_selected_frame == NULL)
-    error (_("No selected frame."));
-
   if (gdbarch_print_vector_info_p (gdbarch))
     gdbarch_print_vector_info (gdbarch, file, frame, args);
   else
@@ -1822,7 +1815,11 @@ print_vector_info (struct gdbarch *gdbar
 static void
 vector_info (char *args, int from_tty)
 {
-  print_vector_info (current_gdbarch, gdb_stdout, deprecated_selected_frame, args);
+  if (!target_has_registers)
+    error (_("The program has no registers now."));
+
+  print_vector_info (current_gdbarch, gdb_stdout,
+		     get_selected_frame (NULL), args);
 }
 
 
@@ -2012,11 +2009,6 @@ static void
 print_float_info (struct gdbarch *gdbarch, struct ui_file *file,
 		  struct frame_info *frame, const char *args)
 {
-  if (!target_has_registers)
-    error (_("The program has no registers now."));
-  if (deprecated_selected_frame == NULL)
-    error (_("No selected frame."));
-
   if (gdbarch_print_float_info_p (gdbarch))
     gdbarch_print_float_info (gdbarch, file, frame, args);
   else
@@ -2041,8 +2033,11 @@ No floating-point info available for thi
 static void
 float_info (char *args, int from_tty)
 {
+  if (!target_has_registers)
+    error (_("The program has no registers now."));
+
   print_float_info (current_gdbarch, gdb_stdout, 
-		    deprecated_selected_frame, args);
+		    get_selected_frame (NULL), args);
 }
 
 static void
Index: src/gdb/inflow.c
===================================================================
--- src.orig/gdb/inflow.c	2007-01-09 13:13:23.000000000 -0500
+++ src/gdb/inflow.c	2007-02-22 15:14:09.000000000 -0500
@@ -588,10 +588,7 @@ kill_command (char *arg, int from_tty)
   if (target_has_stack)
     {
       printf_filtered (_("In %s,\n"), target_longname);
-      if (deprecated_selected_frame == NULL)
-	fputs_filtered ("No selected stack frame.\n", gdb_stdout);
-      else
-	print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+      print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
     }
   bfd_cache_close_all ();
 }
Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2007-02-22 14:13:49.000000000 -0500
+++ src/gdb/infrun.c	2007-02-22 15:22:02.000000000 -0500
@@ -3173,7 +3173,7 @@ Further execution is probably impossible
          bpstat_print() contains the logic deciding in detail
          what to print, based on the event(s) that just occurred. */
 
-      if (stop_print_frame && deprecated_selected_frame)
+      if (stop_print_frame)
 	{
 	  int bpstat_ret;
 	  int source_flag;
@@ -3692,7 +3692,7 @@ save_inferior_status (int restore_stack_
 
   inf_status->registers = regcache_dup (current_regcache);
 
-  inf_status->selected_frame_id = get_frame_id (deprecated_selected_frame);
+  inf_status->selected_frame_id = get_frame_id (get_selected_frame (NULL));
   return inf_status;
 }
 
Index: src/gdb/stack.c
===================================================================
--- src.orig/gdb/stack.c	2007-02-22 14:13:25.000000000 -0500
+++ src/gdb/stack.c	2007-02-22 15:27:08.000000000 -0500
@@ -1592,24 +1592,7 @@ get_selected_block (CORE_ADDR *addr_in_b
   if (!target_has_stack)
     return 0;
 
-  /* NOTE: cagney/2002-11-28: Why go to all this effort to not create
-     a selected/current frame?  Perhaps this function is called,
-     indirectly, by WFI in "infrun.c" where avoiding the creation of
-     an inner most frame is very important (it slows down single
-     step).  I suspect, though that this was true in the deep dark
-     past but is no longer the case.  A mindless look at all the
-     callers tends to support this theory.  I think we should be able
-     to assume that there is always a selcted frame.  */
-  /* gdb_assert (deprecated_selected_frame != NULL); So, do you feel
-     lucky? */
-  if (!deprecated_selected_frame)
-    {
-      CORE_ADDR pc = read_pc ();
-      if (addr_in_block != NULL)
-	*addr_in_block = pc;
-      return block_for_pc (pc);
-    }
-  return get_frame_block (deprecated_selected_frame, addr_in_block);
+  return get_frame_block (get_selected_frame (NULL), addr_in_block);
 }
 
 /* Find a frame a certain number of levels away from FRAME.
@@ -1933,7 +1916,7 @@ func_command (char *arg, int from_tty)
 
   if (!found)
     printf_filtered (_("'%s' not within current stack frame.\n"), arg);
-  else if (frame != deprecated_selected_frame)
+  else if (frame != get_selected_frame (NULL))
     select_and_print_frame (frame);
 }
 
@@ -1942,7 +1925,7 @@ func_command (char *arg, int from_tty)
 enum language
 get_frame_language (void)
 {
-  struct frame_info *frame = deprecated_selected_frame;
+  struct frame_info *frame = deprecated_safe_get_selected_frame ();
 
   if (frame)
     {
Index: src/gdb/tui/tui-disasm.c
===================================================================
--- src.orig/gdb/tui/tui-disasm.c	2007-01-09 13:13:46.000000000 -0500
+++ src/gdb/tui/tui-disasm.c	2007-02-22 14:18:20.000000000 -0500
@@ -386,7 +386,7 @@ tui_vertical_disassem_scroll (enum tui_s
 
       content = (tui_win_content) TUI_DISASM_WIN->generic.content;
       if (cursal.symtab == (struct symtab *) NULL)
-	s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+	s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
       else
 	s = cursal.symtab;
 
Index: src/gdb/tui/tui-source.c
===================================================================
--- src.orig/gdb/tui/tui-source.c	2007-01-09 13:13:46.000000000 -0500
+++ src/gdb/tui/tui-source.c	2007-02-22 14:18:20.000000000 -0500
@@ -338,7 +338,7 @@ tui_vertical_source_scroll (enum tui_scr
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
 
       if (cursal.symtab == (struct symtab *) NULL)
-	s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+	s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
       else
 	s = cursal.symtab;
 
Index: src/gdb/tui/tui-winsource.c
===================================================================
--- src.orig/gdb/tui/tui-winsource.c	2007-01-09 13:13:46.000000000 -0500
+++ src/gdb/tui/tui-winsource.c	2007-02-22 14:18:20.000000000 -0500
@@ -314,7 +314,7 @@ tui_horizontal_source_scroll (struct tui
       struct symtab_and_line cursal = get_current_source_symtab_and_line ();
 
       if (cursal.symtab == (struct symtab *) NULL)
-	s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+	s = find_pc_symtab (get_frame_pc (get_selected_frame (NULL)));
       else
 	s = cursal.symtab;
 
Index: src/gdb/valops.c
===================================================================
--- src.orig/gdb/valops.c	2007-02-22 14:13:49.000000000 -0500
+++ src/gdb/valops.c	2007-02-22 14:18:20.000000000 -0500
@@ -578,7 +578,7 @@ value_assign (struct value *toval, struc
   /* Since modifying a register can trash the frame chain, and modifying memory
      can trash the frame cache, we save the old frame and then restore the new
      frame afterwards.  */
-  old_frame = get_frame_id (deprecated_selected_frame);
+  old_frame = get_frame_id (deprecated_safe_get_selected_frame ());
 
   switch (VALUE_LVAL (toval))
     {
@@ -2667,16 +2667,18 @@ value_of_local (const char *name, int co
   struct symbol *func, *sym;
   struct block *b;
   struct value * ret;
+  struct frame_info *frame;
 
-  if (deprecated_selected_frame == 0)
+  if (complain)
+    frame = get_selected_frame (_("no frame selected"));
+  else
     {
-      if (complain)
-	error (_("no frame selected"));
-      else
+      frame = deprecated_safe_get_selected_frame ();
+      if (frame == 0)
 	return 0;
     }
 
-  func = get_frame_function (deprecated_selected_frame);
+  func = get_frame_function (frame);
   if (!func)
     {
       if (complain)
@@ -2705,7 +2707,7 @@ value_of_local (const char *name, int co
 	return NULL;
     }
 
-  ret = read_var_value (sym, deprecated_selected_frame);
+  ret = read_var_value (sym, frame);
   if (ret == 0 && complain)
     error (_("`%s' argument unreadable"), name);
   return ret;
Index: src/gdb/varobj.c
===================================================================
--- src.orig/gdb/varobj.c	2007-02-15 15:59:46.000000000 -0500
+++ src/gdb/varobj.c	2007-02-22 15:29:26.000000000 -0500
@@ -440,7 +440,7 @@ varobj_create (char *objname,
 
       /* Allow creator to specify context of variable */
       if ((type == USE_CURRENT_FRAME) || (type == USE_SELECTED_FRAME))
-	fi = deprecated_selected_frame;
+	fi = deprecated_safe_get_selected_frame ();
       else
 	/* FIXME: cagney/2002-11-23: This code should be doing a
 	   lookup using the frame ID and not just the frame's
@@ -487,7 +487,7 @@ varobj_create (char *objname,
       if (fi != NULL)
 	{
 	  var->root->frame = get_frame_id (fi);
-	  old_fi = deprecated_selected_frame;
+	  old_fi = get_selected_frame (NULL);
 	  select_frame (fi);
 	}
 
@@ -1064,7 +1064,7 @@ varobj_update (struct varobj **varp, str
 
   /* Save the selected stack frame, since we will need to change it
      in order to evaluate expressions.  */
-  old_fid = get_frame_id (deprecated_selected_frame);
+  old_fid = get_frame_id (deprecated_safe_get_selected_frame ());
 
   /* Update the root variable. value_of_root can return NULL
      if the variable is no longer around, i.e. we stepped out of
Index: src/gdb/findvar.c
===================================================================
--- src.orig/gdb/findvar.c	2007-02-22 15:21:19.000000000 -0500
+++ src/gdb/findvar.c	2007-02-22 15:21:30.000000000 -0500
@@ -378,7 +378,7 @@ symbol_read_needs_frame (struct symbol *
    and a stack frame id, read the value of the variable
    and return a (pointer to a) struct value containing the value. 
    If the variable cannot be found, return a zero pointer.
-   If FRAME is NULL, use the deprecated_selected_frame.  */
+   If FRAME is NULL, use the selected frame.  */
 
 struct value *
 read_var_value (struct symbol *var, struct frame_info *frame)
Index: src/gdb/frame.c
===================================================================
--- src.orig/gdb/frame.c	2007-02-22 15:39:03.000000000 -0500
+++ src/gdb/frame.c	2007-02-22 15:39:20.000000000 -0500
@@ -935,7 +935,7 @@ get_current_frame (void)
 /* The "selected" stack frame is used by default for local and arg
    access.  May be zero, for no selected frame.  */
 
-struct frame_info *deprecated_selected_frame;
+static struct frame_info *selected_frame;
 
 /* Return the selected frame.  Always non-NULL (unless there isn't an
    inferior sufficient for creating a frame) in which case an error is
@@ -944,7 +944,7 @@ struct frame_info *deprecated_selected_f
 struct frame_info *
 get_selected_frame (const char *message)
 {
-  if (deprecated_selected_frame == NULL)
+  if (selected_frame == NULL)
     {
       if (message != NULL && (!target_has_registers
 			      || !target_has_stack
@@ -956,8 +956,8 @@ get_selected_frame (const char *message)
       select_frame (get_current_frame ());
     }
   /* There is always a frame.  */
-  gdb_assert (deprecated_selected_frame != NULL);
-  return deprecated_selected_frame;
+  gdb_assert (selected_frame != NULL);
+  return selected_frame;
 }
 
 /* This is a variant of get_selected_frame() which can be called when
@@ -979,7 +979,7 @@ select_frame (struct frame_info *fi)
 {
   struct symtab *s;
 
-  deprecated_selected_frame = fi;
+  selected_frame = fi;
   /* NOTE: cagney/2002-05-04: FI can be NULL.  This occurs when the
      frame is being invalidated.  */
   if (deprecated_selected_frame_level_changed_hook)
Index: src/gdb/frame.h
===================================================================
--- src.orig/gdb/frame.h	2007-02-22 15:34:35.000000000 -0500
+++ src/gdb/frame.h	2007-02-22 15:38:59.000000000 -0500
@@ -665,10 +665,10 @@ extern void (*deprecated_selected_frame_
 extern void return_command (char *, int);
 
 
-/* NOTE: cagney/2002-11-27:
+/* Notes (cagney/2002-11-27, drow/2003-09-06):
 
-   You might think that the below global can simply be replaced by a
-   call to either get_selected_frame() or select_frame().
+   You might think that calls to this function can simply be replaced by a
+   call to get_selected_frame().
 
    Unfortunately, it isn't that easy.
 
@@ -680,25 +680,17 @@ extern void return_command (char *, int)
    The only real exceptions occur at the edge (in the CLI code) where
    user commands need to pick up the selected frame before proceeding.
 
+   There are also some functions called with a NULL frame meaning either "the
+   program is not running" or "use the selected frame".
+
    This is important.  GDB is trying to stamp out the hack:
 
-   saved_frame = deprecated_selected_frame;
-   deprecated_selected_frame = ...;
+   saved_frame = deprecated_safe_get_selected_frame ();
+   select_frame (...);
    hack_using_global_selected_frame ();
-   deprecated_selected_frame = saved_frame;
-
-   Take care!  */
-
-extern struct frame_info *deprecated_selected_frame;
-
-/* NOTE: drow/2003-09-06:
+   select_frame (saved_frame);
 
-   This function is "a step sideways" for uses of deprecated_selected_frame.
-   They should be fixed as above, but meanwhile, we needed a solution for
-   cases where functions are called with a NULL frame meaning either "the
-   program is not running" or "use the selected frame".  Lazy building of
-   deprecated_selected_frame confuses the situation, because now
-   deprecated_selected_frame can be NULL even when the inferior is running.
+   Take care!
 
    This function calls get_selected_frame if the inferior should have a
    frame, or returns NULL otherwise.  */
Index: src/gdb/macroscope.c
===================================================================
--- src.orig/gdb/macroscope.c	2007-02-22 15:22:55.000000000 -0500
+++ src/gdb/macroscope.c	2007-02-22 15:23:53.000000000 -0500
@@ -84,17 +84,14 @@ default_macro_scope (void)
 {
   struct symtab_and_line sal;
   struct macro_scope *ms;
+  struct frame_info *frame;
 
-  /* If there's a selected frame, use its PC.  */ 
-  if (deprecated_selected_frame)
-    sal = find_pc_line (get_frame_pc (deprecated_selected_frame), 0);
+  /* If there's a selected frame, use its PC.  */
+  frame = deprecated_safe_get_selected_frame ();
+  if (frame)
+    sal = find_pc_line (get_frame_pc (frame), 0);
   
-  /* If the target has any registers at all, then use its PC.  Why we
-     would have registers but no stack, I'm not sure.  */
-  else if (target_has_registers)
-    sal = find_pc_line (read_pc (), 0);
-
-  /* If all else fails, fall back to the current listing position.  */
+  /* Fall back to the current listing position.  */
   else
     {
       /* Don't call select_source_symtab here.  That can raise an
Index: src/gdb/parse.c
===================================================================
--- src.orig/gdb/parse.c	2007-02-22 15:24:23.000000000 -0500
+++ src/gdb/parse.c	2007-02-22 15:24:28.000000000 -0500
@@ -509,7 +509,7 @@ write_dollar_variable (struct stoken str
 
   /* Handle tokens that refer to machine registers:
      $ followed by a register name.  */
-  i = frame_map_name_to_regnum (deprecated_selected_frame,
+  i = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
 				str.ptr + 1, str.length - 1);
   if (i >= 0)
     goto handle_register;
Index: src/gdb/regcache.h
===================================================================
--- src.orig/gdb/regcache.h	2007-02-22 15:24:52.000000000 -0500
+++ src/gdb/regcache.h	2007-02-22 15:24:57.000000000 -0500
@@ -163,7 +163,7 @@ extern void regcache_cpy_no_passthrough 
    simple substitution is required when updating the code.  The
    change, as far as practical, should avoid adding references to
    global variables (e.g., current_regcache, current_frame,
-   current_gdbarch or deprecated_selected_frame) and instead refer to
+   current_gdbarch or the selected frame) and instead refer to
    the FRAME or REGCACHE that has been passed into the containing
    function as parameters.  Consequently, the change typically
    involves modifying the containing function so that it takes a FRAME
Index: src/gdb/sh64-tdep.c
===================================================================
--- src.orig/gdb/sh64-tdep.c	2007-02-22 15:25:32.000000000 -0500
+++ src/gdb/sh64-tdep.c	2007-02-22 15:25:43.000000000 -0500
@@ -1408,8 +1408,7 @@ sh64_show_compact_regs (void)
 void
 sh64_show_regs (void)
 {
-  if (deprecated_selected_frame
-      && pc_is_isa32 (get_frame_pc (deprecated_selected_frame)))
+  if (pc_is_isa32 (get_frame_pc (get_selected_frame (NULL))))
     sh64_show_media_regs ();
   else
     sh64_show_compact_regs ();
Index: src/gdb/tui/tui-hooks.c
===================================================================
--- src.orig/gdb/tui/tui-hooks.c	2007-02-22 15:30:27.000000000 -0500
+++ src/gdb/tui/tui-hooks.c	2007-02-22 15:31:31.000000000 -0500
@@ -132,8 +132,8 @@ tui_registers_changed_hook (void)
 {
   struct frame_info *fi;
 
-  fi = deprecated_selected_frame;
-  if (fi && tui_refreshing_registers == 0)
+  fi = get_selected_frame (NULL);
+  if (tui_refreshing_registers == 0)
     {
       tui_refreshing_registers = 1;
 #if 0
@@ -148,8 +148,8 @@ tui_register_changed_hook (int regno)
 {
   struct frame_info *fi;
 
-  fi = deprecated_selected_frame;
-  if (fi && tui_refreshing_registers == 0)
+  fi = get_selected_frame (NULL);
+  if (tui_refreshing_registers == 0)
     {
       tui_refreshing_registers = 1;
       tui_check_data_values (fi);
@@ -230,7 +230,7 @@ tui_selected_frame_level_changed_hook (i
 {
   struct frame_info *fi;
 
-  fi = deprecated_selected_frame;
+  fi = get_selected_frame (NULL);
   /* Ensure that symbols for this frame are read in.  Also, determine the
      source language of this frame, and switch to it if desired.  */
   if (fi)
@@ -264,7 +264,7 @@ tui_print_frame_info_listing_hook (struc
                                    int stopline, int noerror)
 {
   select_source_symtab (s);
-  tui_show_frame_info (deprecated_selected_frame);
+  tui_show_frame_info (get_selected_frame (NULL));
 }
 
 /* Called when the target process died or is detached.
Index: src/gdb/tui/tui-win.c
===================================================================
--- src.orig/gdb/tui/tui-win.c	2007-02-22 15:32:33.000000000 -0500
+++ src/gdb/tui/tui-win.c	2007-02-22 15:33:04.000000000 -0500
@@ -1328,13 +1328,13 @@ make_visible_with_new_height (struct tui
 	  tui_free_win_content (&win_info->generic);
 	  tui_update_source_window (win_info, cursal.symtab, line_or_addr, TRUE);
 	}
-      else if (deprecated_selected_frame != (struct frame_info *) NULL)
+      else if (deprecated_safe_get_selected_frame () != NULL)
 	{
 	  struct tui_line_or_address line;
 	  struct symtab_and_line cursal = get_current_source_symtab_and_line ();
+	  struct frame_info *frame = deprecated_safe_get_selected_frame ();
 
-
-	  s = find_pc_symtab (get_frame_pc (deprecated_selected_frame));
+	  s = find_pc_symtab (get_frame_pc (frame));
 	  if (win_info->generic.type == SRC_WIN)
 	    {
 	      line.loa = LOA_LINE;
Index: src/gdb/tui/tui.c
===================================================================
--- src.orig/gdb/tui/tui.c	2007-02-22 15:33:17.000000000 -0500
+++ src/gdb/tui/tui.c	2007-02-22 15:33:27.000000000 -0500
@@ -408,8 +408,8 @@ tui_enable (void)
   tui_setup_io (1);
 
   tui_active = 1;
-  if (deprecated_selected_frame)
-     tui_show_frame_info (deprecated_selected_frame);
+  if (deprecated_safe_get_selected_frame ())
+     tui_show_frame_info (deprecated_safe_get_selected_frame ());
 
   /* Restore TUI keymap.  */
   tui_set_key_mode (tui_current_key_mode);


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