[07/25] gdb/mips: Use default gdbarch methods where possible

Message ID 37e90315a0fe012845a405a273903ada24edc88d.1553721874.git.andrew.burgess@embecosm.com
State New
Headers show
Series
  • Make use of default gdbarch methods for some more targets
Related show

Commit Message

Andrew Burgess March 27, 2019, 9:34 p.m.
Make use of the default gdbarch methods for gdbarch_dummy_id, and
gdbarch_unwind_sp where possible.

I have not tested this change but, by inspecting the code, I believe
the default methods are equivalent to the code being deleted.

One thing worth noting in this commit is that the accesses to the
stack pointer register changes from being signed to unsigned, however,
in all cases the register is immediately converted to a CORE_ADDR, so
I don't think this will cause any problems.

gdb/ChangeLog:

	* mips-tdep.c (mips_unwind_sp): Delete.
	(mips_dummy_id): Delete.
	(mips_gdbarch_init): Don't register deleted functions with
	gdbarch.
---
 gdb/ChangeLog   |  7 +++++++
 gdb/mips-tdep.c | 24 ------------------------
 2 files changed, 7 insertions(+), 24 deletions(-)

-- 
2.14.5

Comments

Kevin Buettner March 27, 2019, 10:31 p.m. | #1
On Wed, 27 Mar 2019 21:34:03 +0000
Andrew Burgess <andrew.burgess@embecosm.com> wrote:

> -static CORE_ADDR

> -mips_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)

> -{

> -  return frame_unwind_register_signed

> -	   (next_frame, gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM);

> -}


I don't think this one is equivalent to the default method since it's
using frame_unwind_register_signed (instead of _unsigned).

> -/* Assuming THIS_FRAME is a dummy, return the frame ID of that

> -   dummy frame.  The frame ID's base needs to match the TOS value

> -   saved by save_dummy_frame_tos(), and the PC match the dummy frame's

> -   breakpoint.  */

> -

> -static struct frame_id

> -mips_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)

> -{

> -  return frame_id_build

> -	   (get_frame_register_signed (this_frame,

> -				       gdbarch_num_regs (gdbarch)

> -				       + MIPS_SP_REGNUM),

> -	    get_frame_pc (this_frame));

> -}

> -


I'm not confident that this one is equivalent either due to calling
get_frame_register_signed.  However, I don't really know because I
haven't traced the calls to see whether a signed or unsigned version
ultimately gets called.

Kevin
Andrew Burgess March 28, 2019, 9:30 p.m. | #2
* Kevin Buettner <kevinb@redhat.com> [2019-03-27 15:31:40 -0700]:

> On Wed, 27 Mar 2019 21:34:03 +0000

> Andrew Burgess <andrew.burgess@embecosm.com> wrote:

> 

> > -static CORE_ADDR

> > -mips_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)

> > -{

> > -  return frame_unwind_register_signed

> > -	   (next_frame, gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM);

> > -}

> 

> I don't think this one is equivalent to the default method since it's

> using frame_unwind_register_signed (instead of _unsigned).

> 

> > -/* Assuming THIS_FRAME is a dummy, return the frame ID of that

> > -   dummy frame.  The frame ID's base needs to match the TOS value

> > -   saved by save_dummy_frame_tos(), and the PC match the dummy frame's

> > -   breakpoint.  */

> > -

> > -static struct frame_id

> > -mips_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)

> > -{

> > -  return frame_id_build

> > -	   (get_frame_register_signed (this_frame,

> > -				       gdbarch_num_regs (gdbarch)

> > -				       + MIPS_SP_REGNUM),

> > -	    get_frame_pc (this_frame));

> > -}

> > -

> 

> I'm not confident that this one is equivalent either due to calling

> get_frame_register_signed.  However, I don't really know because I

> haven't traced the calls to see whether a signed or unsigned version

> ultimately gets called.


I agree with your concerns.  I think this patch only should be dropped
from this series.

Thanks,
Andrew

Patch

diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index f3361388225..91cc188bdda 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -1403,28 +1403,6 @@  mips_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
   return pc;
 }
 
-static CORE_ADDR
-mips_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
-{
-  return frame_unwind_register_signed
-	   (next_frame, gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM);
-}
-
-/* Assuming THIS_FRAME is a dummy, return the frame ID of that
-   dummy frame.  The frame ID's base needs to match the TOS value
-   saved by save_dummy_frame_tos(), and the PC match the dummy frame's
-   breakpoint.  */
-
-static struct frame_id
-mips_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  return frame_id_build
-	   (get_frame_register_signed (this_frame,
-				       gdbarch_num_regs (gdbarch)
-				       + MIPS_SP_REGNUM),
-	    get_frame_pc (this_frame));
-}
-
 /* Implement the "write_pc" gdbarch method.  */
 
 void
@@ -8689,8 +8667,6 @@  mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Unwind the frame.  */
   set_gdbarch_unwind_pc (gdbarch, mips_unwind_pc);
-  set_gdbarch_unwind_sp (gdbarch, mips_unwind_sp);
-  set_gdbarch_dummy_id (gdbarch, mips_dummy_id);
 
   /* Map debug register numbers onto internal register numbers.  */
   set_gdbarch_stab_reg_to_regnum (gdbarch, mips_stab_reg_to_regnum);