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] Delete generic_target_read_sp


Hello,

Like generic_target_read_pc, this deletes generic_target_read_sp.

Again the intent is to get the global depedand SP read code down to a single function.

Note that for the mn10300 and ia64 I created a new function XXX_read_fp() (copy of the old generic_target_read_sp). Those architectures were setting deprecated_read_fp to generic_target_read_sp. Ulgh!

committed,
Andrew
2003-06-07  Andrew Cagney  <cagney@redhat.com>

	* gdbarch.sh (TARGET_READ_SP): Add predicate, delete default.
	* gdbarch.h, gdbarch.c: Regenerate.
	* mn10300-tdep.c: Include "gdb_assert.h".
	(mn10300_read_fp): New function.
	(mn10300_gdbarch_init): Set deprecated_target_read_fp to
	mn10300_read_fp.  Do not set read_sp to generic_target_read_sp.
	* ia64-tdep.c: Include "gdb_assert.h".
	(ia64_read_fp): New function.
	(ia64_gdbarch_init): Set deprecated_target_read_fp to
	ia64_read_sp.  Do not set read_sp to generic_target_read_sp.
	* regcache.c (generic_target_read_sp): Delete function.
	(read_sp): Try TARGET_READ_SP and SP_REGNUM for the SP register.
	* inferior.h (generic_target_read_sp): Delete declaration.
	* frv-tdep.c (frv_gdbarch_init): Do not set read_sp to
	generic_target_read_sp.
	* m68hc11-tdep.c (m68hc11_gdbarch_init): Ditto.
	* sparc-tdep.c (sparc_gdbarch_init): Ditto
	* sh-tdep.c (sh_gdbarch_init): Ditto.
	* rs6000-tdep.c (rs6000_gdbarch_init): Ditto.
	* Makefile.in (mn10300-tdep.o, ia64-tdep.o): Update dependencies.

Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.391
diff -u -r1.391 Makefile.in
--- Makefile.in	5 Jun 2003 20:59:15 -0000	1.391
+++ Makefile.in	7 Jun 2003 18:00:51 -0000
@@ -1844,7 +1844,7 @@
 ia64-linux-tdep.o: ia64-linux-tdep.c $(defs_h) $(arch_utils_h)
 ia64-tdep.o: ia64-tdep.c $(defs_h) $(inferior_h) $(symfile_h) $(gdbcore_h) \
 	$(arch_utils_h) $(floatformat_h) $(regcache_h) $(doublest_h) \
-	$(value_h) $(objfiles_h) $(elf_common_h) $(elf_bfd_h)
+	$(value_h) $(gdb_assert_h) $(objfiles_h) $(elf_common_h) $(elf_bfd_h)
 inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
 	$(event_top_h) $(inf_loop_h) $(remote_h)
 infcall.o: infcall.c $(defs_h) $(breakpoint_h) $(target_h) $(regcache_h) \
@@ -1998,9 +1998,9 @@
 mn10200-tdep.o: mn10200-tdep.c $(defs_h) $(frame_h) $(inferior_h) \
 	$(target_h) $(value_h) $(bfd_h) $(gdb_string_h) $(gdbcore_h) \
 	$(symfile_h) $(regcache_h)
-mn10300-tdep.o: mn10300-tdep.c $(defs_h) $(frame_h) $(inferior_h) \
-	$(target_h) $(value_h) $(bfd_h) $(gdb_string_h) $(gdbcore_h) \
-	$(symfile_h) $(regcache_h) $(arch_utils_h)
+mn10300-tdep.o: mn10300-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \
+	$(value_h) $(bfd_h) $(gdb_string_h) $(gdbcore_h) $(symfile_h) \
+	$(regcache_h) $(arch_utils_h) $(gdb_assert_h)
 monitor.o: monitor.c $(defs_h) $(gdbcore_h) $(target_h) $(gdb_string_h) \
 	$(command_h) $(serial_h) $(monitor_h) $(gdbcmd_h) $(inferior_h) \
 	$(gdb_regex_h) $(srec_h) $(regcache_h)
Index: frv-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/frv-tdep.c,v
retrieving revision 1.40
diff -u -r1.40 frv-tdep.c
--- frv-tdep.c	7 Jun 2003 16:23:10 -0000	1.40
+++ frv-tdep.c	7 Jun 2003 18:00:51 -0000
@@ -1100,7 +1100,6 @@
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
-  set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
 
   set_gdbarch_deprecated_pc_in_call_dummy (gdbarch, deprecated_pc_in_call_dummy_at_entry_point);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.242
diff -u -r1.242 gdbarch.sh
--- gdbarch.sh	7 Jun 2003 17:09:19 -0000	1.242
+++ gdbarch.sh	7 Jun 2003 18:01:03 -0000
@@ -431,7 +431,7 @@
 # This is simply not needed.  See value_of_builtin_frame_fp_reg and
 # call_function_by_hand.
 F::DEPRECATED_TARGET_READ_FP:CORE_ADDR:deprecated_target_read_fp:void
-f:2:TARGET_READ_SP:CORE_ADDR:read_sp:void:::0:generic_target_read_sp::0
+F:2:TARGET_READ_SP:CORE_ADDR:read_sp:void
 # The dummy call frame SP should be set by push_dummy_call.
 F:2:DEPRECATED_DUMMY_WRITE_SP:void:deprecated_dummy_write_sp:CORE_ADDR val:val
 # Function for getting target's idea of a frame pointer.  FIXME: GDB's
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.80
diff -u -r1.80 ia64-tdep.c
--- ia64-tdep.c	2 Jun 2003 02:09:39 -0000	1.80
+++ ia64-tdep.c	7 Jun 2003 18:01:05 -0000
@@ -28,7 +28,7 @@
 #include "regcache.h"
 #include "doublest.h"
 #include "value.h"
-
+#include "gdb_assert.h"
 #include "objfiles.h"
 #include "elf/common.h"		/* for DT_PLTGOT value */
 #include "elf-bfd.h"
@@ -623,6 +623,18 @@
   return breakpoint;
 }
 
+static CORE_ADDR
+ia64_read_fp (void)
+{
+  /* We won't necessarily have a frame pointer and even if we do, it
+     winds up being extraordinarly messy when attempting to find the
+     frame chain.  So for the purposes of creating frames (which is
+     all deprecated_read_fp() is used for), simply use the stack
+     pointer value instead.  */
+  gdb_assert (SP_REGNUM >= 0);
+  return read_register (SP_REGNUM);
+}
+
 CORE_ADDR
 ia64_read_pc (ptid_t ptid)
 {
@@ -2296,12 +2308,11 @@
      frame chain.  So for the purposes of creating frames (which is
      all deprecated_read_fp() is used for), simply use the stack
      pointer value instead.  */
-  set_gdbarch_deprecated_target_read_fp (gdbarch, generic_target_read_sp);
+  set_gdbarch_deprecated_target_read_fp (gdbarch, ia64_read_fp);
 
   /* Settings that should be unnecessary.  */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
-  set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
 
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.56
diff -u -r1.56 inferior.h
--- inferior.h	7 Jun 2003 16:23:12 -0000	1.56
+++ inferior.h	7 Jun 2003 18:01:05 -0000
@@ -176,8 +176,6 @@
 
 extern CORE_ADDR read_sp (void);
 
-extern CORE_ADDR generic_target_read_sp (void);
-
 extern void generic_target_write_sp (CORE_ADDR);
 
 extern CORE_ADDR deprecated_read_fp (void);
Index: m68hc11-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/m68hc11-tdep.c,v
retrieving revision 1.70
diff -u -r1.70 m68hc11-tdep.c
--- m68hc11-tdep.c	7 Jun 2003 16:23:12 -0000	1.70
+++ m68hc11-tdep.c	7 Jun 2003 18:01:06 -0000
@@ -1366,7 +1366,6 @@
   set_gdbarch_frame_args_skip (gdbarch, 0);
 
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
-  set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
 
   set_gdbarch_sp_regnum (gdbarch, HARD_SP_REGNUM);
Index: mn10300-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mn10300-tdep.c,v
retrieving revision 1.78
diff -u -r1.78 mn10300-tdep.c
--- mn10300-tdep.c	2 Jun 2003 02:09:39 -0000	1.78
+++ mn10300-tdep.c	7 Jun 2003 18:01:06 -0000
@@ -31,6 +31,7 @@
 #include "symfile.h"
 #include "regcache.h"
 #include "arch-utils.h"
+#include "gdb_assert.h"
 
 #define D0_REGNUM 0
 #define D2_REGNUM 2
@@ -1091,6 +1092,14 @@
     }
 }
 
+static CORE_ADDR
+mn10300_read_fp (void)
+{
+  /* That's right, we're using the stack pointer as our frame pointer.  */
+  gdb_assert (SP_REGNUM >= 0);
+  return read_register (SP_REGNUM);
+}
+
 /* Dump out the mn10300 speciic architecture information. */
 
 static void
@@ -1184,7 +1193,7 @@
   set_gdbarch_frame_args_skip (gdbarch, 0);
   set_gdbarch_frame_num_args (gdbarch, frame_num_args_unknown);
   /* That's right, we're using the stack pointer as our frame pointer.  */
-  set_gdbarch_deprecated_target_read_fp (gdbarch, generic_target_read_sp);
+  set_gdbarch_deprecated_target_read_fp (gdbarch, mn10300_read_fp);
 
   /* Calling functions in the inferior from GDB.  */
   set_gdbarch_deprecated_call_dummy_words (gdbarch, mn10300_call_dummy_words);
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.83
diff -u -r1.83 regcache.c
--- regcache.c	7 Jun 2003 16:23:12 -0000	1.83
+++ regcache.c	7 Jun 2003 18:01:10 -0000
@@ -1273,9 +1273,6 @@
    they will use the contextual information provided by the FRAME.
    These functions do not belong in the register cache.  */
 
-/* NOTE: cagney/2003-06-07: The function generic_target_read_sp()
-   should be deleted.  */
-
 /* NOTE: cagney/2003-06-07: The function generic_target_write_sp()
    should be deleted.  */
 
@@ -1353,20 +1350,14 @@
 /* Cope with strage ways of getting to the stack and frame pointers */
 
 CORE_ADDR
-generic_target_read_sp (void)
-{
-#ifdef SP_REGNUM
-  if (SP_REGNUM >= 0)
-    return read_register (SP_REGNUM);
-#endif
-  internal_error (__FILE__, __LINE__,
-		  "generic_target_read_sp");
-}
-
-CORE_ADDR
 read_sp (void)
 {
-  return TARGET_READ_SP ();
+  if (TARGET_READ_SP_P ())
+    return TARGET_READ_SP ();
+  /* Else return SP from get_current_frame.  */
+  else if (SP_REGNUM >= 0)
+    return read_register (SP_REGNUM);
+  internal_error (__FILE__, __LINE__, "read_sp: Unable to find SP");
 }
 
 void
Index: rs6000-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v
retrieving revision 1.137
diff -u -r1.137 rs6000-tdep.c
--- rs6000-tdep.c	7 Jun 2003 16:23:12 -0000	1.137
+++ rs6000-tdep.c	7 Jun 2003 18:01:12 -0000
@@ -2911,7 +2911,6 @@
     set_gdbarch_print_insn (gdbarch, gdb_print_insn_powerpc);
 
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
-  set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
 
   set_gdbarch_num_regs (gdbarch, v->nregs);
Index: sh-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sh-tdep.c,v
retrieving revision 1.126
diff -u -r1.126 sh-tdep.c
--- sh-tdep.c	7 Jun 2003 16:23:12 -0000	1.126
+++ sh-tdep.c	7 Jun 2003 18:01:23 -0000
@@ -4638,7 +4638,6 @@
     }
 
   set_gdbarch_write_pc (gdbarch, generic_target_write_pc);
-  set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
   set_gdbarch_deprecated_dummy_write_sp (gdbarch, generic_target_write_sp);
 
   set_gdbarch_register_name (gdbarch, sh_register_name);
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.108
diff -u -r1.108 sparc-tdep.c
--- sparc-tdep.c	7 Jun 2003 16:23:12 -0000	1.108
+++ sparc-tdep.c	7 Jun 2003 18:01:32 -0000
@@ -3423,7 +3423,6 @@
       set_gdbarch_pc_regnum (gdbarch, SPARC32_PC_REGNUM);
       set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
       set_gdbarch_deprecated_push_arguments (gdbarch, sparc32_push_arguments);
-      set_gdbarch_read_sp (gdbarch, generic_target_read_sp);
 
       set_gdbarch_register_byte (gdbarch, sparc32_register_byte);
       set_gdbarch_register_raw_size (gdbarch, sparc32_register_size);

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