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]

[commit] Remove frame_map_... routines


Hello,

in working on per-frame architecture, I noticed that on some occasions,
get_frame_arch () was called with a NULL frame argument.

That works with the current dummy implementation of get_frame_arch,
but breaks as soon as this is replaced with a real implementation
that actually looks at its argument ...

Most of these occasions come from calls to the frame_map_regnum_to_name
and frame_map_name_to_regnum routines, which in turn are called in many
places using deprecated_safe_get_selected_frame () as argument.  Not
only will this routine sometimes return NULL, it's deprecated anyway.

Therefore, the following patch simply removes the frame_map_ routines
completely, and updates the callers to use the user_reg_map_ routines
directly.  This is generally easier to do anyway.

Unfortunately this patch re-introduces uses of current_gdbarch at some
of those call sites.  However, those are places that already use
current_gdbarch nearby, so they need to be fixed anyway.

Tested on powerpc-linux and powerpc64-linux.
Committed to mainline.

Bye,
Ulrich


ChangeLog:

	* frame.h (frame_map_regnum_to_name): Remove prototype.
	(frame_map_name_to_regnum): Remove prototype.
	* frame.c (frame_map_regnum_to_name): Remove.
	(frame_map_name_to_regnum): Remove.
	(frame_unwind_register_value): Use user_reg_map_regnum_to_name
	instead of frame_map_regnum_to_name.
	* ax-gdb.c: Include "user-regs.h".
	(gen_expr): Use user_reg_map_name_to_regnum instead of
	frame_map_name_to_regnum.
	* eval.c:  Include "user-regs.h".
	(evaluate_subexp_standard): Use user_reg_map_name_to_regnum
	instead of frame_map_name_to_regnum.
	* infcmd.c (registers_info): Likewise.
	* parse.c: Include "user-regs.h".
	(write_dollar_variable): Use user_reg_map_name_to_regnum
	instead of frame_map_name_to_regnum.
	* tracepoint.c: Include "user-regs.h".
	(encode_actions): Use user_reg_map_name_to_regnum
	instead of frame_map_name_to_regnum.
	* valops.c: Include "user-regs.h".
	(value_fetch_lazy): Use user_reg_map_regnum_to_name instead
	of frame_map_regnum_to_name.

diff -urNp gdb-orig/gdb/ax-gdb.c gdb-head/gdb/ax-gdb.c
--- gdb-orig/gdb/ax-gdb.c	2008-05-28 16:24:24.000000000 +0200
+++ gdb-head/gdb/ax-gdb.c	2008-08-18 20:43:30.664584338 +0200
@@ -33,6 +33,7 @@
 #include "gdb_string.h"
 #include "block.h"
 #include "regcache.h"
+#include "user-regs.h"
 
 /* To make sense of this file, you should read doc/agentexpr.texi.
    Then look at the types and enums in ax-gdb.h.  For the code itself,
@@ -1592,8 +1593,8 @@ gen_expr (union exp_element **pc, struct
 	const char *name = &(*pc)[2].string;
 	int reg;
 	(*pc) += 4 + BYTES_TO_EXP_ELEM ((*pc)[1].longconst + 1);
-	reg = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
-					name, strlen (name));
+	reg = user_reg_map_name_to_regnum (current_gdbarch,
+					   name, strlen (name));
 	if (reg == -1)
 	  internal_error (__FILE__, __LINE__,
 			  _("Register $%s not available"), name);
diff -urNp gdb-orig/gdb/eval.c gdb-head/gdb/eval.c
--- gdb-orig/gdb/eval.c	2008-07-12 22:00:17.000000000 +0200
+++ gdb-head/gdb/eval.c	2008-08-18 20:43:03.341375679 +0200
@@ -38,6 +38,7 @@
 #include "ui-out.h"
 #include "exceptions.h"
 #include "regcache.h"
+#include "user-regs.h"
 
 #include "gdb_assert.h"
 
@@ -538,8 +539,8 @@ evaluate_subexp_standard (struct type *e
 	struct value *val;
 
 	(*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
-	regno = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
-					  name, strlen (name));
+	regno = user_reg_map_name_to_regnum (current_gdbarch,
+					     name, strlen (name));
 	if (regno == -1)
 	  error (_("Register $%s not available."), name);
 
diff -urNp gdb-orig/gdb/frame.c gdb-head/gdb/frame.c
--- gdb-orig/gdb/frame.c	2008-08-05 22:16:25.000000000 +0200
+++ gdb-head/gdb/frame.c	2008-08-18 20:44:47.001220007 +0200
@@ -619,7 +619,8 @@ frame_unwind_register_value (struct fram
       fprintf_unfiltered (gdb_stdlog, "\
 { frame_unwind_register_value (frame=%d,regnum=%d(%s),...) ",
 			  frame->level, regnum,
-			  frame_map_regnum_to_name (frame, regnum));
+			  user_reg_map_regnum_to_name
+			    (get_frame_arch (frame), regnum));
     }
 
   /* Find the unwinder.  */
@@ -834,22 +835,6 @@ put_frame_register_bytes (struct frame_i
     }
 }
 
-/* Map between a frame register number and its name.  A frame register
-   space is a superset of the cooked register space --- it also
-   includes builtin registers.  */
-
-int
-frame_map_name_to_regnum (struct frame_info *frame, const char *name, int len)
-{
-  return user_reg_map_name_to_regnum (get_frame_arch (frame), name, len);
-}
-
-const char *
-frame_map_regnum_to_name (struct frame_info *frame, int regnum)
-{
-  return user_reg_map_regnum_to_name (get_frame_arch (frame), regnum);
-}
-
 /* Create a sentinel frame.  */
 
 static struct frame_info *
diff -urNp gdb-orig/gdb/frame.h gdb-head/gdb/frame.h
--- gdb-orig/gdb/frame.h	2008-08-05 22:16:25.000000000 +0200
+++ gdb-head/gdb/frame.h	2008-08-18 20:44:59.459296800 +0200
@@ -501,16 +501,6 @@ extern void put_frame_register_bytes (st
 				      CORE_ADDR offset, int len,
 				      const gdb_byte *myaddr);
 
-/* Map between a frame register number and its name.  A frame register
-   space is a superset of the cooked register space --- it also
-   includes builtin registers.  If NAMELEN is negative, use the NAME's
-   length when doing the comparison.  */
-
-extern int frame_map_name_to_regnum (struct frame_info *frame,
-				     const char *name, int namelen);
-extern const char *frame_map_regnum_to_name (struct frame_info *frame,
-					     int regnum);
-
 /* Unwind the PC.  Strictly speaking return the resume address of the
    calling frame.  For GDB, `pc' is the resume address and not a
    specific register.  */
diff -urNp gdb-orig/gdb/infcmd.c gdb-head/gdb/infcmd.c
--- gdb-orig/gdb/infcmd.c	2008-08-08 19:09:23.000000000 +0200
+++ gdb-head/gdb/infcmd.c	2008-08-18 20:42:19.839957870 +0200
@@ -1778,7 +1778,7 @@ registers_info (char *addr_exp, int fpre
 
       /* A register name?  */
       {
-	int regnum = frame_map_name_to_regnum (frame, start, end - start);
+	int regnum = user_reg_map_name_to_regnum (gdbarch, start, end - start);
 	if (regnum >= 0)
 	  {
 	    /* User registers lie completely outside of the range of
diff -urNp gdb-orig/gdb/parse.c gdb-head/gdb/parse.c
--- gdb-orig/gdb/parse.c	2008-07-12 22:00:19.000000000 +0200
+++ gdb-head/gdb/parse.c	2008-08-18 20:43:40.422649583 +0200
@@ -53,6 +53,7 @@
 #include "source.h"
 #include "objfiles.h"
 #include "exceptions.h"
+#include "user-regs.h"
 
 /* Standard set of definitions for printing, dumping, prefixifying,
  * and evaluating expressions.  */
@@ -543,8 +544,8 @@ 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_safe_get_selected_frame (),
-				str.ptr + 1, str.length - 1);
+  i = user_reg_map_name_to_regnum (current_gdbarch,
+				   str.ptr + 1, str.length - 1);
   if (i >= 0)
     goto handle_register;
 
diff -urNp gdb-orig/gdb/tracepoint.c gdb-head/gdb/tracepoint.c
--- gdb-orig/gdb/tracepoint.c	2008-08-05 22:16:26.000000000 +0200
+++ gdb-head/gdb/tracepoint.c	2008-08-18 20:43:18.753429080 +0200
@@ -37,6 +37,7 @@
 #include "block.h"
 #include "dictionary.h"
 #include "observer.h"
+#include "user-regs.h"
 
 #include "ax.h"
 #include "ax-gdb.h"
@@ -1574,8 +1575,8 @@ encode_actions (struct tracepoint *t, ch
 		      {
 			const char *name = &exp->elts[2].string;
 
-			i = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
-						      name, strlen (name));
+			i = user_reg_map_name_to_regnum (current_gdbarch,
+							 name, strlen (name));
 			if (i == -1)
 			  internal_error (__FILE__, __LINE__,
 					  _("Register $%s not available"),
diff -urNp gdb-orig/gdb/valops.c gdb-head/gdb/valops.c
--- gdb-orig/gdb/valops.c	2008-08-05 22:16:26.000000000 +0200
+++ gdb-head/gdb/valops.c	2008-08-18 20:43:59.483845795 +0200
@@ -37,6 +37,7 @@
 #include "dictionary.h"
 #include "cp-support.h"
 #include "dfp.h"
+#include "user-regs.h"
 
 #include <errno.h>
 #include "gdb_string.h"
@@ -663,13 +664,15 @@ value_fetch_lazy (struct value *val)
 
       if (frame_debug)
 	{
+	  struct gdbarch *gdbarch;
 	  frame = frame_find_by_id (VALUE_FRAME_ID (val));
 	  regnum = VALUE_REGNUM (val);
+	  gdbarch = get_frame_arch (frame);
 
 	  fprintf_unfiltered (gdb_stdlog, "\
 { value_fetch_lazy (frame=%d,regnum=%d(%s),...) ",
 			      frame_relative_level (frame), regnum,
-			      frame_map_regnum_to_name (frame, regnum));
+			      user_reg_map_regnum_to_name (gdbarch, regnum));
 
 	  fprintf_unfiltered (gdb_stdlog, "->");
 	  if (value_optimized_out (new_val))
@@ -690,9 +693,7 @@ value_fetch_lazy (struct value *val)
 
 	      fprintf_unfiltered (gdb_stdlog, " bytes=");
 	      fprintf_unfiltered (gdb_stdlog, "[");
-	      for (i = 0;
-		   i < register_size (get_frame_arch (frame), regnum);
-		   i++)
+	      for (i = 0; i < register_size (gdbarch, regnum); i++)
 		fprintf_unfiltered (gdb_stdlog, "%02x", buf[i]);
 	      fprintf_unfiltered (gdb_stdlog, "]");
 	    }
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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