[08/25] gdb/mn10300: Use default gdbarch methods where possible

Message ID 583253609ab24f0fceb744fd71da25e0cd21da17.1553721874.git.andrew.burgess@embecosm.com
State New, archived
Headers

Commit Message

Andrew Burgess March 27, 2019, 9:34 p.m. UTC
  Make use of the default gdbarch methods for gdbarch_dummy_id,
gdbarch_unwind_pc, 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.

gdb/ChangeLog:

	* mn10300-tdep.c (mn10300_dummy_id): Delete.
	(mn10300_unwind_pc): Delete.
	(mn10300_unwind_sp): Delete.
	(mn10300_frame_unwind_init): Don't register deleted functions with
	gdbarch.
---
 gdb/ChangeLog      | 10 ++++++++++
 gdb/mn10300-tdep.c | 32 +-------------------------------
 2 files changed, 11 insertions(+), 31 deletions(-)
  

Comments

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

> Make use of the default gdbarch methods for gdbarch_dummy_id,
> gdbarch_unwind_pc, 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.
> 
> gdb/ChangeLog:
> 
> 	* mn10300-tdep.c (mn10300_dummy_id): Delete.
> 	(mn10300_unwind_pc): Delete.
> 	(mn10300_unwind_sp): Delete.
> 	(mn10300_frame_unwind_init): Don't register deleted functions with
> 	gdbarch.

Please mention change to mn10300_push_dummy_call in ChangeLog entry...

>  /* Function: push_dummy_call
> @@ -1308,7 +1278,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
>    {
>      CORE_ADDR func_addr = find_function_addr (target_func, NULL);
>      CORE_ADDR unwound_sp 
> -      = mn10300_unwind_sp (gdbarch, create_new_frame (sp, func_addr));
> +      = gdbarch_unwind_sp (gdbarch, create_new_frame (sp, func_addr));
>      if (sp != unwound_sp)
>        regcache_cooked_write_unsigned (regcache, E_SP_REGNUM,
>                                        sp - (unwound_sp - sp));

Otherwise, okay.

Kevin
  

Patch

diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 583827e447d..1a08ea0cceb 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -1098,15 +1098,6 @@  mn10300_frame_base (struct frame_info *this_frame, void **this_prologue_cache)
     }
 }
 
-/* Here is a dummy implementation.  */
-static struct frame_id
-mn10300_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  CORE_ADDR sp = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
-  CORE_ADDR pc = get_frame_register_unsigned (this_frame, E_PC_REGNUM);
-  return frame_id_build (sp, pc);
-}
-
 static void
 mn10300_frame_this_id (struct frame_info *this_frame,
 		       void **this_prologue_cache,
@@ -1149,32 +1140,11 @@  static const struct frame_unwind mn10300_frame_unwind = {
   default_frame_sniffer
 };
 
-static CORE_ADDR
-mn10300_unwind_pc (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  ULONGEST pc;
-
-  pc = frame_unwind_register_unsigned (this_frame, E_PC_REGNUM);
-  return pc;
-}
-
-static CORE_ADDR
-mn10300_unwind_sp (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  ULONGEST sp;
-
-  sp = frame_unwind_register_unsigned (this_frame, E_SP_REGNUM);
-  return sp;
-}
-
 static void
 mn10300_frame_unwind_init (struct gdbarch *gdbarch)
 {
   dwarf2_append_unwinders (gdbarch);
   frame_unwind_append_unwinder (gdbarch, &mn10300_frame_unwind);
-  set_gdbarch_dummy_id (gdbarch, mn10300_dummy_id);
-  set_gdbarch_unwind_pc (gdbarch, mn10300_unwind_pc);
-  set_gdbarch_unwind_sp (gdbarch, mn10300_unwind_sp);
 }
 
 /* Function: push_dummy_call
@@ -1308,7 +1278,7 @@  mn10300_push_dummy_call (struct gdbarch *gdbarch,
   {
     CORE_ADDR func_addr = find_function_addr (target_func, NULL);
     CORE_ADDR unwound_sp 
-      = mn10300_unwind_sp (gdbarch, create_new_frame (sp, func_addr));
+      = gdbarch_unwind_sp (gdbarch, create_new_frame (sp, func_addr));
     if (sp != unwound_sp)
       regcache_cooked_write_unsigned (regcache, E_SP_REGNUM,
                                       sp - (unwound_sp - sp));