[01/12] gdb/aarch64: Use default gdbarch methods where possible

Message ID a6a9ac1f65edf843e722a60d0ee7c3473858f00f.1545918068.git.andrew.burgess@embecosm.com
State New, archived
Headers

Commit Message

Andrew Burgess Dec. 27, 2018, 2:08 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:

	* gdb/aarch64-tdep.c (aarch64_dummy_id): Delete.
	(aarch64_unwind_pc): Delete.
	(aarch64_unwind_sp): Delete.
	(aarch64_gdbarch_init): Don't register deleted functions with
	gdbarch.
---
 gdb/ChangeLog      |  8 ++++++++
 gdb/aarch64-tdep.c | 38 --------------------------------------
 2 files changed, 8 insertions(+), 38 deletions(-)
  

Comments

Alan Hayward Jan. 7, 2019, 11:38 a.m. UTC | #1
> On 27 Dec 2018, at 14:08, 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:
> 
> 	* gdb/aarch64-tdep.c (aarch64_dummy_id): Delete.
> 	(aarch64_unwind_pc): Delete.
> 	(aarch64_unwind_sp): Delete.
> 	(aarch64_gdbarch_init): Don't register deleted functions with
> 	gdbarch.
> ---
> gdb/ChangeLog      |  8 ++++++++
> gdb/aarch64-tdep.c | 38 --------------------------------------
> 2 files changed, 8 insertions(+), 38 deletions(-)
> 
> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
> index ae56c9ca34c..34ee41b0a50 100644
> --- a/gdb/aarch64-tdep.c
> +++ b/gdb/aarch64-tdep.c
> @@ -998,39 +998,6 @@ struct frame_base aarch64_normal_base =
>   aarch64_normal_frame_base
> };
> 
> -/* 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 returned from
> -   aarch64_push_dummy_call, and the PC needs to match the dummy
> -   frame's breakpoint.  */
> -
> -static struct frame_id
> -aarch64_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
> -{
> -  return frame_id_build (get_frame_register_unsigned (this_frame,
> -						      AARCH64_SP_REGNUM),
> -			 get_frame_pc (this_frame));
> -}
> -
> -/* Implement the "unwind_pc" gdbarch method.  */
> -
> -static CORE_ADDR
> -aarch64_unwind_pc (struct gdbarch *gdbarch, struct frame_info *this_frame)
> -{
> -  CORE_ADDR pc
> -    = frame_unwind_register_unsigned (this_frame, AARCH64_PC_REGNUM);
> -
> -  return pc;
> -}
> -
> -/* Implement the "unwind_sp" gdbarch method.  */
> -
> -static CORE_ADDR
> -aarch64_unwind_sp (struct gdbarch *gdbarch, struct frame_info *this_frame)
> -{
> -  return frame_unwind_register_unsigned (this_frame, AARCH64_SP_REGNUM);
> -}
> -
> /* Return the value of the REGNUM register in the previous frame of
>    *THIS_FRAME.  */
> 
> @@ -3062,11 +3029,6 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
>   set_gdbarch_push_dummy_call (gdbarch, aarch64_push_dummy_call);
>   set_gdbarch_frame_align (gdbarch, aarch64_frame_align);
> 
> -  /* Frame handling.  */
> -  set_gdbarch_dummy_id (gdbarch, aarch64_dummy_id);
> -  set_gdbarch_unwind_pc (gdbarch, aarch64_unwind_pc);
> -  set_gdbarch_unwind_sp (gdbarch, aarch64_unwind_sp);
> -
>   /* Advance PC across function entry code.  */
>   set_gdbarch_skip_prologue (gdbarch, aarch64_skip_prologue);
> 


Updating to latest HEAD really helped to review this (given the default funcs
are new). :)

Code changes LGTM.
Make check on Aarch64 looks good too.



Alan.

> -- 
> 2.14.5
>
  

Patch

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index ae56c9ca34c..34ee41b0a50 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -998,39 +998,6 @@  struct frame_base aarch64_normal_base =
   aarch64_normal_frame_base
 };
 
-/* 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 returned from
-   aarch64_push_dummy_call, and the PC needs to match the dummy
-   frame's breakpoint.  */
-
-static struct frame_id
-aarch64_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  return frame_id_build (get_frame_register_unsigned (this_frame,
-						      AARCH64_SP_REGNUM),
-			 get_frame_pc (this_frame));
-}
-
-/* Implement the "unwind_pc" gdbarch method.  */
-
-static CORE_ADDR
-aarch64_unwind_pc (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  CORE_ADDR pc
-    = frame_unwind_register_unsigned (this_frame, AARCH64_PC_REGNUM);
-
-  return pc;
-}
-
-/* Implement the "unwind_sp" gdbarch method.  */
-
-static CORE_ADDR
-aarch64_unwind_sp (struct gdbarch *gdbarch, struct frame_info *this_frame)
-{
-  return frame_unwind_register_unsigned (this_frame, AARCH64_SP_REGNUM);
-}
-
 /* Return the value of the REGNUM register in the previous frame of
    *THIS_FRAME.  */
 
@@ -3062,11 +3029,6 @@  aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_push_dummy_call (gdbarch, aarch64_push_dummy_call);
   set_gdbarch_frame_align (gdbarch, aarch64_frame_align);
 
-  /* Frame handling.  */
-  set_gdbarch_dummy_id (gdbarch, aarch64_dummy_id);
-  set_gdbarch_unwind_pc (gdbarch, aarch64_unwind_pc);
-  set_gdbarch_unwind_sp (gdbarch, aarch64_unwind_sp);
-
   /* Advance PC across function entry code.  */
   set_gdbarch_skip_prologue (gdbarch, aarch64_skip_prologue);