Patchwork Remove some $ARCH_read_pc and $ARCH_write_pc

login
register
mail settings
Submitter Yao Qi
Date Jan. 31, 2018, 3:41 p.m.
Message ID <1517413275-3641-1-git-send-email-yao.qi@linaro.org>
Download mbox | patch
Permalink /patch/25713/
State New
Headers show

Comments

Yao Qi - Jan. 31, 2018, 3:41 p.m.
Nowadays, gdbarch_read_pc is called in this way,

  if (gdbarch_read_pc_p (gdbarch))
    pc_val = gdbarch_read_pc (gdbarch, regcache);
  /* Else use per-frame method on get_current_frame.  */
  else if (gdbarch_pc_regnum (gdbarch) >= 0)
    {
      ULONGEST raw_val;

      if (regcache_cooked_read_unsigned (regcache,
					 gdbarch_pc_regnum (gdbarch),
					 &raw_val) == REG_UNAVAILABLE)

some ports don't have to define its own gdbarch read_pc method if the
pc value is simply a unsigned value from "pc" register.  The same rule
applies to regcache_write_pc.  This patch removes these $ARCH_read_pc
and $ARCH_write_pc functions.

gdb:

2018-01-31  Yao Qi  <yao.qi@linaro.org>

	* ft32-tdep.c (ft32_read_pc): Remove.
	(ft32_write_pc): Remove.
	(ft32_gdbarch_init): Update.
	* m32r-tdep.c (m32r_read_pc): Remove.
	(m32r_gdbarch_init): Update.
	* mep-tdep.c (mep_read_pc): Remove.
	(mep_gdbarch_init): Update.
	* microblaze-tdep.c (microblaze_write_pc): Remove.
	(microblaze_gdbarch_init): Update.
	* mn10300-tdep.c (mn10300_read_pc): Remove.
	(mn10300_write_pc): Remove.
	(mn10300_gdbarch_init): Update.
	* moxie-tdep.c (moxie_read_pc): Remove.
	(moxie_write_pc): Remove.
	(moxie_gdbarch_init): Update.
---
 gdb/ft32-tdep.c       | 22 ----------------------
 gdb/m32r-tdep.c       |  9 ---------
 gdb/mep-tdep.c        | 10 ----------
 gdb/microblaze-tdep.c |  7 -------
 gdb/mn10300-tdep.c    | 16 ----------------
 gdb/moxie-tdep.c      | 21 ---------------------
 6 files changed, 85 deletions(-)
Yao Qi - Feb. 6, 2018, 5:32 p.m.
>
> gdb:
>
> 2018-01-31  Yao Qi  <yao.qi@linaro.org>
>
>         * ft32-tdep.c (ft32_read_pc): Remove.
>         (ft32_write_pc): Remove.
>         (ft32_gdbarch_init): Update.
>         * m32r-tdep.c (m32r_read_pc): Remove.
>         (m32r_gdbarch_init): Update.
>         * mep-tdep.c (mep_read_pc): Remove.
>         (mep_gdbarch_init): Update.
>         * microblaze-tdep.c (microblaze_write_pc): Remove.
>         (microblaze_gdbarch_init): Update.
>         * mn10300-tdep.c (mn10300_read_pc): Remove.
>         (mn10300_write_pc): Remove.
>         (mn10300_gdbarch_init): Update.
>         * moxie-tdep.c (moxie_read_pc): Remove.
>         (moxie_write_pc): Remove.
>         (moxie_gdbarch_init): Update.

I pushed it in.

Patch

diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index fc4b9ef..7198b84 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -383,26 +383,6 @@  ft32_address_class_name_to_type_flags (struct gdbarch *gdbarch,
     return 0;
 }
 
-
-/* Implement the "read_pc" gdbarch method.  */
-
-static CORE_ADDR
-ft32_read_pc (struct regcache *regcache)
-{
-  ULONGEST pc;
-
-  regcache_cooked_read_unsigned (regcache, FT32_PC_REGNUM, &pc);
-  return pc;
-}
-
-/* Implement the "write_pc" gdbarch method.  */
-
-static void
-ft32_write_pc (struct regcache *regcache, CORE_ADDR val)
-{
-  regcache_cooked_write_unsigned (regcache, FT32_PC_REGNUM, val);
-}
-
 /* Implement the "unwind_sp" gdbarch method.  */
 
 static CORE_ADDR
@@ -622,8 +602,6 @@  ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 				     func_void_type);
   TYPE_INSTANCE_FLAGS (tdep->pc_type) |= TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
 
-  set_gdbarch_read_pc (gdbarch, ft32_read_pc);
-  set_gdbarch_write_pc (gdbarch, ft32_write_pc);
   set_gdbarch_unwind_sp (gdbarch, ft32_unwind_sp);
 
   set_gdbarch_num_regs (gdbarch, FT32_NUM_REGS);
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index 0fe6754..fd79f3f 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -650,14 +650,6 @@  m32r_frame_unwind_cache (struct frame_info *this_frame,
 }
 
 static CORE_ADDR
-m32r_read_pc (struct regcache *regcache)
-{
-  ULONGEST pc;
-  regcache_cooked_read_unsigned (regcache, M32R_PC_REGNUM, &pc);
-  return pc;
-}
-
-static CORE_ADDR
 m32r_unwind_sp (struct gdbarch *gdbarch, struct frame_info *next_frame)
 {
   return frame_unwind_register_unsigned (next_frame, M32R_SP_REGNUM);
@@ -912,7 +904,6 @@  m32r_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_wchar_bit (gdbarch, 16);
   set_gdbarch_wchar_signed (gdbarch, 0);
 
-  set_gdbarch_read_pc (gdbarch, m32r_read_pc);
   set_gdbarch_unwind_sp (gdbarch, m32r_unwind_sp);
 
   set_gdbarch_num_regs (gdbarch, M32R_NUM_REGS);
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index 1d0e8d3..1cda2b3 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -1112,15 +1112,6 @@  mep_register_type (struct gdbarch *gdbarch, int reg_nr)
     return builtin_type (gdbarch)->builtin_uint32;
 }
 
-
-static CORE_ADDR
-mep_read_pc (struct regcache *regcache)
-{
-  ULONGEST pc;
-  regcache_cooked_read_unsigned (regcache, MEP_PC_REGNUM, &pc);
-  return pc;
-}
-
 static enum register_status
 mep_pseudo_cr32_read (struct gdbarch *gdbarch,
 		      readable_regcache *regcache,
@@ -2446,7 +2437,6 @@  mep_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->me_module = me_module;
 
   /* Register set.  */
-  set_gdbarch_read_pc (gdbarch, mep_read_pc);
   set_gdbarch_num_regs (gdbarch, MEP_NUM_RAW_REGS);
   set_gdbarch_pc_regnum (gdbarch, MEP_PC_REGNUM);
   set_gdbarch_sp_regnum (gdbarch, MEP_SP_REGNUM);
diff --git a/gdb/microblaze-tdep.c b/gdb/microblaze-tdep.c
index 6b1c2ec..0cb9633 100644
--- a/gdb/microblaze-tdep.c
+++ b/gdb/microblaze-tdep.c
@@ -601,11 +601,6 @@  microblaze_stabs_argument_has_addr (struct gdbarch *gdbarch, struct type *type)
   return (TYPE_LENGTH (type) == 16);
 }
 
-static void
-microblaze_write_pc (struct regcache *regcache, CORE_ADDR pc)
-{
-  regcache_cooked_write_unsigned (regcache, MICROBLAZE_PC_REGNUM, pc);
-}
 
 static int dwarf2_to_reg_map[78] =
 { 0  /* r0  */,   1  /* r1  */,   2  /* r2  */,   3  /* r3  */,  /*  0- 3 */
@@ -738,8 +733,6 @@  microblaze_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   set_gdbarch_frame_args_skip (gdbarch, 8);
 
-  set_gdbarch_write_pc (gdbarch, microblaze_write_pc);
-
   set_gdbarch_unwind_pc (gdbarch, microblaze_unwind_pc);
 
   microblaze_register_g_packet_guesses (gdbarch);
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 93c02d6..e12e01d 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -307,20 +307,6 @@  mn10300_register_type (struct gdbarch *gdbarch, int reg)
   return builtin_type (gdbarch)->builtin_int;
 }
 
-static CORE_ADDR
-mn10300_read_pc (struct regcache *regcache)
-{
-  ULONGEST val;
-  regcache_cooked_read_unsigned (regcache, E_PC_REGNUM, &val);
-  return val;
-}
-
-static void
-mn10300_write_pc (struct regcache *regcache, CORE_ADDR val)
-{
-  regcache_cooked_write_unsigned (regcache, E_PC_REGNUM, val);
-}
-
 /* The breakpoint instruction must be the same size as the smallest
    instruction in the instruction set.
 
@@ -1423,8 +1409,6 @@  mn10300_gdbarch_init (struct gdbarch_info info,
   set_gdbarch_num_regs (gdbarch, num_regs);
   set_gdbarch_register_type (gdbarch, mn10300_register_type);
   set_gdbarch_skip_prologue (gdbarch, mn10300_skip_prologue);
-  set_gdbarch_read_pc (gdbarch, mn10300_read_pc);
-  set_gdbarch_write_pc (gdbarch, mn10300_write_pc);
   set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);
   set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
   set_gdbarch_dwarf2_reg_to_regnum (gdbarch, mn10300_dwarf2_reg_to_regnum);
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 5356796..50cacfe 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -448,25 +448,6 @@  moxie_software_single_step (struct regcache *regcache)
   return next_pcs;
 }
 
-/* Implement the "read_pc" gdbarch method.  */
-
-static CORE_ADDR
-moxie_read_pc (struct regcache *regcache)
-{
-  ULONGEST pc;
-
-  regcache_cooked_read_unsigned (regcache, MOXIE_PC_REGNUM, &pc);
-  return pc;
-}
-
-/* Implement the "write_pc" gdbarch method.  */
-
-static void
-moxie_write_pc (struct regcache *regcache, CORE_ADDR val)
-{
-  regcache_cooked_write_unsigned (regcache, MOXIE_PC_REGNUM, val);
-}
-
 /* Implement the "unwind_sp" gdbarch method.  */
 
 static CORE_ADDR
@@ -1109,8 +1090,6 @@  moxie_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_wchar_bit (gdbarch, 32);
   set_gdbarch_wchar_signed (gdbarch, 0);
 
-  set_gdbarch_read_pc (gdbarch, moxie_read_pc);
-  set_gdbarch_write_pc (gdbarch, moxie_write_pc);
   set_gdbarch_unwind_sp (gdbarch, moxie_unwind_sp);
 
   set_gdbarch_num_regs (gdbarch, MOXIE_NUM_REGS);