This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Eliminate read_sp function
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Date: Sun, 13 May 2007 14:28:50 +0200 (CEST)
- Subject: [commit] Eliminate read_sp function
Hello,
this patch removes the last remaining uses of the read_sp function.
Tested on powerpc64-linux, powerpc-ibm-aix5.3.0.0, s390-ibm-linux,
and s390x-ibm-linux. Committed to mainline.
Bye,
Ulrich
ChangeLog:
* inferior.h (read_sp): Remove prototype.
* regcache.c (read_sp): Remove.
* gcore.c (derive_stack_segment): Use get_frame_sp instead of read_sp.
* infcall.c (call_function_by_hand): Likewise.
* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Use regcache instead
of calling read_sp.
* rs6000-tdep.c (rs6000_push_dummy_call): Likewise.
diff -urNp gdb-orig/gdb/gcore.c gdb-head/gdb/gcore.c
--- gdb-orig/gdb/gcore.c 2007-05-13 13:18:43.149174000 +0200
+++ gdb-head/gdb/gcore.c 2007-05-13 13:20:39.973042439 +0200
@@ -187,8 +187,8 @@ derive_stack_segment (bfd_vma *bottom, b
/* Save frame pointer of TOS frame. */
*top = get_frame_base (fi);
/* If current stack pointer is more "inner", use that instead. */
- if (INNER_THAN (read_sp (), *top))
- *top = read_sp ();
+ if (INNER_THAN (get_frame_sp (fi), *top))
+ *top = get_frame_sp (fi);
/* Find prev-most frame. */
while ((tmp_fi = get_prev_frame (fi)) != NULL)
diff -urNp gdb-orig/gdb/infcall.c gdb-head/gdb/infcall.c
--- gdb-orig/gdb/infcall.c 2007-05-09 18:18:41.000000000 +0200
+++ gdb-head/gdb/infcall.c 2007-05-13 13:20:59.971222883 +0200
@@ -368,7 +368,7 @@ call_function_by_hand (struct value *fun
/* Ensure that the initial SP is correctly aligned. */
{
- CORE_ADDR old_sp = read_sp ();
+ CORE_ADDR old_sp = get_frame_sp (get_current_frame ());
if (gdbarch_frame_align_p (current_gdbarch))
{
sp = gdbarch_frame_align (current_gdbarch, old_sp);
diff -urNp gdb-orig/gdb/inferior.h gdb-head/gdb/inferior.h
--- gdb-orig/gdb/inferior.h 2007-05-13 13:18:43.166172000 +0200
+++ gdb-head/gdb/inferior.h 2007-05-13 13:20:39.988040281 +0200
@@ -174,8 +174,6 @@ extern void write_pc_pid (CORE_ADDR, pti
extern void generic_target_write_pc (CORE_ADDR, ptid_t);
-extern CORE_ADDR read_sp (void);
-
extern CORE_ADDR unsigned_pointer_to_address (struct type *type,
const gdb_byte *buf);
extern void unsigned_address_to_pointer (struct type *type, gdb_byte *buf,
diff -urNp gdb-orig/gdb/ppc-sysv-tdep.c gdb-head/gdb/ppc-sysv-tdep.c
--- gdb-orig/gdb/ppc-sysv-tdep.c 2007-05-13 13:18:43.173171000 +0200
+++ gdb-head/gdb/ppc-sysv-tdep.c 2007-05-13 13:20:39.994039417 +0200
@@ -51,10 +51,12 @@ ppc_sysv_abi_push_dummy_call (struct gdb
int struct_return, CORE_ADDR struct_addr)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
- const CORE_ADDR saved_sp = read_sp ();
+ ULONGEST saved_sp;
int argspace = 0; /* 0 is an initial wrong guess. */
int write_pass;
+ regcache_cooked_read_unsigned (regcache, SP_REGNUM, &saved_sp);
+
/* Go through the argument list twice.
Pass 1: Figure out how much new stack space is required for
@@ -578,10 +580,7 @@ ppc64_sysv_abi_push_dummy_call (struct g
{
CORE_ADDR func_addr = find_function_addr (function, NULL);
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
- /* By this stage in the proceedings, SP has been decremented by "red
- zone size" + "struct return size". Fetch the stack-pointer from
- before this and use that as the BACK_CHAIN. */
- const CORE_ADDR back_chain = read_sp ();
+ ULONGEST back_chain;
/* See for-loop comment below. */
int write_pass;
/* Size of the Altivec's vector parameter region, the final value is
@@ -599,6 +598,11 @@ ppc64_sysv_abi_push_dummy_call (struct g
the possible values of tdep->wordsize. */
gdb_assert (tdep->wordsize == 8);
+ /* By this stage in the proceedings, SP has been decremented by "red
+ zone size" + "struct return size". Fetch the stack-pointer from
+ before this and use that as the BACK_CHAIN. */
+ regcache_cooked_read_unsigned (regcache, SP_REGNUM, &back_chain);
+
/* Go through the argument list twice.
Pass 1: Compute the function call's stack space and register
diff -urNp gdb-orig/gdb/regcache.c gdb-head/gdb/regcache.c
--- gdb-orig/gdb/regcache.c 2007-05-13 13:18:43.192168000 +0200
+++ gdb-head/gdb/regcache.c 2007-05-13 13:23:02.292234346 +0200
@@ -867,8 +867,7 @@ regcache_raw_collect (const struct regca
}
-/* read_pc, write_pc, read_sp, etc. Special handling for registers
- PC, SP, and FP. */
+/* read_pc, write_pc, etc. Special handling for register PC. */
/* NOTE: cagney/2001-02-18: The functions read_pc_pid(), read_pc() and
read_sp(), will eventually be replaced by per-frame methods.
@@ -941,21 +940,6 @@ write_pc (CORE_ADDR pc)
write_pc_pid (pc, inferior_ptid);
}
-/* Cope with strage ways of getting to the stack and frame pointers */
-
-CORE_ADDR
-read_sp (void)
-{
- if (TARGET_READ_SP_P ())
- return TARGET_READ_SP ();
- else if (gdbarch_unwind_sp_p (current_gdbarch))
- return get_frame_sp (get_current_frame ());
- else if (SP_REGNUM >= 0)
- /* Try SP_REGNUM last: this makes all sorts of [wrong] assumptions
- about the architecture so put it at the end. */
- return read_register (SP_REGNUM);
- internal_error (__FILE__, __LINE__, _("read_sp: Unable to find SP"));
-}
static void
reg_flush_command (char *command, int from_tty)
diff -urNp gdb-orig/gdb/rs6000-tdep.c gdb-head/gdb/rs6000-tdep.c
--- gdb-orig/gdb/rs6000-tdep.c 2007-05-13 13:18:43.217164000 +0200
+++ gdb-head/gdb/rs6000-tdep.c 2007-05-13 13:20:40.033033804 +0200
@@ -1591,7 +1591,7 @@ rs6000_push_dummy_call (struct gdbarch *
struct value *arg = 0;
struct type *type;
- CORE_ADDR saved_sp;
+ ULONGEST saved_sp;
/* The calling convention this function implements assumes the
processor has floating-point registers. We shouldn't be using it
@@ -1693,7 +1693,7 @@ rs6000_push_dummy_call (struct gdbarch *
ran_out_of_registers_for_arguments:
- saved_sp = read_sp ();
+ regcache_cooked_read_unsigned (regcache, SP_REGNUM, &saved_sp);
/* Location for 8 parameters are always reserved. */
sp -= wordsize * 8;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com