From e35bb30cf0b747898abcc3e9689349e6929a6648 Mon Sep 17 00:00:00 2001 From: uweigand Date: Sun, 13 May 2007 12:27:29 +0000 Subject: [PATCH] * 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. --- gdb/ChangeLog | 10 ++++++++++ gdb/gcore.c | 4 ++-- gdb/infcall.c | 2 +- gdb/inferior.h | 2 -- gdb/ppc-sysv-tdep.c | 14 +++++++++----- gdb/regcache.c | 18 +----------------- gdb/rs6000-tdep.c | 4 ++-- 7 files changed, 25 insertions(+), 29 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a3762f56a8..7827d9dffb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2007-05-13 Ulrich Weigand + + * 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. + 2007-05-11 Ulrich Weigand * i386-linux-nat.c (i386_linux_resume): Use regcache functions diff --git a/gdb/gcore.c b/gdb/gcore.c index 00b8ebaaa5..46d2aac403 100644 --- a/gdb/gcore.c +++ b/gdb/gcore.c @@ -187,8 +187,8 @@ derive_stack_segment (bfd_vma *bottom, bfd_vma *top) /* 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 --git a/gdb/infcall.c b/gdb/infcall.c index c4435e5822..5eb9ca3f94 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -368,7 +368,7 @@ call_function_by_hand (struct value *function, int nargs, struct value **args) /* 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 --git a/gdb/inferior.h b/gdb/inferior.h index 5efbf1e133..6e1c42c30d 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -174,8 +174,6 @@ extern void write_pc_pid (CORE_ADDR, ptid_t); 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 --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index ca465e2e0e..51f9c0a06b 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -51,10 +51,12 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, 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 gdbarch *gdbarch, struct value *function, { 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 gdbarch *gdbarch, struct value *function, 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 --git a/gdb/regcache.c b/gdb/regcache.c index daa412f554..bb9cfde89b 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -867,8 +867,7 @@ regcache_raw_collect (const struct regcache *regcache, int regnum, void *buf) } -/* 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 --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index e9f8a86c4f..afd901e08f 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -1591,7 +1591,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function, 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 *gdbarch, struct value *function, 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; -- 2.11.0