gdbserver/linux-low: turn 'supports_software_single_step' and 'get_next_pcs' into...
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 2 Apr 2020 13:11:26 +0000 (15:11 +0200)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Thu, 2 Apr 2020 13:11:26 +0000 (15:11 +0200)
gdbserver/ChangeLog:
2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

Remove the 'supports_software_single_step' linux target op and let
the concrete linux target define it by overriding the op in
process_stratum_target.
Turn the 'get_next_pcs' linux target op into a method of
linux_process_target.

* linux-low.h (struct linux_target_ops): Remove the ops.
(class linux_process_target) <supports_software_single_step>:
Remove.
<low_get_next_pcs>: Declare.
* linux-low.cc (can_software_single_step): Remove.
(linux_process_target::low_get_next_pcs): Define.
(linux_process_target::supports_software_single_step): Remove.

Update the callers below.

(linux_process_target::handle_extended_wait)
(linux_process_target::wait_1)
(linux_process_target::install_software_single_step_breakpoints)
(linux_process_target::single_step)
(linux_process_target::thread_needs_step_over)
(linux_process_target::proceed_one_lwp)
(linux_process_target::supports_range_stepping)

* linux-x86-low.cc (the_low_target): Remove the op field.
* linux-aarch64-low.cc (the_low_target): Ditto.
* linux-bfin-low.cc (the_low_target): Ditto.
* linux-cris-low.cc (the_low_target): Ditto.
* linux-crisv32-low.cc (the_low_target): Ditto.
* linux-m32r-low.cc (the_low_target): Ditto.
* linux-m68k-low.cc (the_low_target): Ditto.
* linux-mips-low.cc (the_low_target): Ditto.
* linux-nios2-low.cc (the_low_target): Ditto.
* linux-ppc-low.cc (the_low_target): Ditto.
* linux-riscv-low.cc (the_low_target): Ditto.
* linux-s390-low.cc (the_low_target): Ditto.
* linux-sh-low.cc (the_low_target): Ditto.
* linux-sparc-low.cc (the_low_target): Ditto.
* linux-tic6x-low.cc (the_low_target): Ditto.
* linux-tile-low.cc (the_low_target): Ditto.
* linux-xtensa-low.cc (the_low_target): Ditto.
* linux-arm-low.cc (class arm_target) <low_get_next_pcs>
<supports_software_single_step>: Declare.
(arm_target::supports_software_single_step): Define.
(arm_gdbserver_get_next_pcs): Turn into...
(arm_target::low_get_next_pcs): ...this.
(the_low_target): Remove the op field.

21 files changed:
gdbserver/ChangeLog
gdbserver/linux-aarch64-low.cc
gdbserver/linux-arm-low.cc
gdbserver/linux-bfin-low.cc
gdbserver/linux-cris-low.cc
gdbserver/linux-crisv32-low.cc
gdbserver/linux-low.cc
gdbserver/linux-low.h
gdbserver/linux-m32r-low.cc
gdbserver/linux-m68k-low.cc
gdbserver/linux-mips-low.cc
gdbserver/linux-nios2-low.cc
gdbserver/linux-ppc-low.cc
gdbserver/linux-riscv-low.cc
gdbserver/linux-s390-low.cc
gdbserver/linux-sh-low.cc
gdbserver/linux-sparc-low.cc
gdbserver/linux-tic6x-low.cc
gdbserver/linux-tile-low.cc
gdbserver/linux-x86-low.cc
gdbserver/linux-xtensa-low.cc

index 77c766d8052a2d5034deb442ba5b1374447af659..f9a3df22d0256eb4e948e7b19f2cfecc31214185 100644 (file)
@@ -1,3 +1,53 @@
+2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       Remove the 'supports_software_single_step' linux target op and let
+       the concrete linux target define it by overriding the op in
+       process_stratum_target.
+       Turn the 'get_next_pcs' linux target op into a method of
+       linux_process_target.
+
+       * linux-low.h (struct linux_target_ops): Remove the ops.
+       (class linux_process_target) <supports_software_single_step>:
+       Remove.
+       <low_get_next_pcs>: Declare.
+       * linux-low.cc (can_software_single_step): Remove.
+       (linux_process_target::low_get_next_pcs): Define.
+       (linux_process_target::supports_software_single_step): Remove.
+
+       Update the callers below.
+
+       (linux_process_target::handle_extended_wait)
+       (linux_process_target::wait_1)
+       (linux_process_target::install_software_single_step_breakpoints)
+       (linux_process_target::single_step)
+       (linux_process_target::thread_needs_step_over)
+       (linux_process_target::proceed_one_lwp)
+       (linux_process_target::supports_range_stepping)
+
+       * linux-x86-low.cc (the_low_target): Remove the op field.
+       * linux-aarch64-low.cc (the_low_target): Ditto.
+       * linux-bfin-low.cc (the_low_target): Ditto.
+       * linux-cris-low.cc (the_low_target): Ditto.
+       * linux-crisv32-low.cc (the_low_target): Ditto.
+       * linux-m32r-low.cc (the_low_target): Ditto.
+       * linux-m68k-low.cc (the_low_target): Ditto.
+       * linux-mips-low.cc (the_low_target): Ditto.
+       * linux-nios2-low.cc (the_low_target): Ditto.
+       * linux-ppc-low.cc (the_low_target): Ditto.
+       * linux-riscv-low.cc (the_low_target): Ditto.
+       * linux-s390-low.cc (the_low_target): Ditto.
+       * linux-sh-low.cc (the_low_target): Ditto.
+       * linux-sparc-low.cc (the_low_target): Ditto.
+       * linux-tic6x-low.cc (the_low_target): Ditto.
+       * linux-tile-low.cc (the_low_target): Ditto.
+       * linux-xtensa-low.cc (the_low_target): Ditto.
+       * linux-arm-low.cc (class arm_target) <low_get_next_pcs>
+       <supports_software_single_step>: Declare.
+       (arm_target::supports_software_single_step): Define.
+       (arm_gdbserver_get_next_pcs): Turn into...
+       (arm_target::low_get_next_pcs): ...this.
+       (the_low_target): Remove the op field.
+
 2020-04-02  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        Remove the 'sw_breakpoint_from_kind' linux target op, and let
index 23c9c3e25184ce83ae42d911ccecdb964f537766..11c3296eb6b90fe7306fc16a14ab0a223b910b1a 100644 (file)
@@ -3103,7 +3103,6 @@ aarch64_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL, /* get_next_pcs */
   0,    /* decr_pc_after_break */
   aarch64_breakpoint_at,
   aarch64_supports_z_point_type,
index aab2c427f5abd4b446de5b0d3a6862ddf3c7319c..bd42feba1c4724bc20a421f2b52e840a66342bc5 100644 (file)
@@ -68,6 +68,8 @@ public:
 
   const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
 
+  bool supports_software_single_step () override;
+
 protected:
 
   void low_arch_setup () override;
@@ -81,6 +83,8 @@ protected:
   CORE_ADDR low_get_pc (regcache *regcache) override;
 
   void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
+
+  std::vector<CORE_ADDR> low_get_next_pcs (regcache *regcache) override;
 };
 
 /* The singleton target ops object.  */
@@ -968,10 +972,16 @@ arm_target::low_arch_setup ()
     have_ptrace_getregset = 0;
 }
 
+bool
+arm_target::supports_software_single_step ()
+{
+  return true;
+}
+
 /* Fetch the next possible PCs after the current instruction executes.  */
 
-static std::vector<CORE_ADDR>
-arm_gdbserver_get_next_pcs (struct regcache *regcache)
+std::vector<CORE_ADDR>
+arm_target::low_get_next_pcs (regcache *regcache)
 {
   struct arm_get_next_pcs next_pcs_ctx;
 
@@ -1075,7 +1085,6 @@ arm_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  arm_gdbserver_get_next_pcs,
   0,
   arm_breakpoint_at,
   arm_supports_z_point_type,
index c798c9317f26d570cca196ef4751b8b1630888d7..17948ed16f009c504836ba88cd7e05013b3f999a 100644 (file)
@@ -161,7 +161,6 @@ bfin_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_next_pcs */
   2,
   bfin_breakpoint_at,
   NULL, /* supports_z_point_type */
index a22ec3342dcae1d0976f1e517abd046c2d236c2d..99060de1765212f75a63a338b3073584e0c47d85 100644 (file)
@@ -158,7 +158,6 @@ cris_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_next_pcs */
   0,
   cris_breakpoint_at,
 };
index 965f186981d9eacc07486d56f1384cea0b8ae902..c75e428885e4722cf1e6751d6f5ea10b7a2a59e0 100644 (file)
@@ -455,7 +455,6 @@ crisv32_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_next_pcs */
   0,
   cris_breakpoint_at,
   cris_supports_z_point_type,
index 14a4dbf0866a2c4bf27d58dcf2087e5e7cc1a597..8eca077180e34dec12c1ec5bc13f3df7b3ecbaf2 100644 (file)
@@ -292,15 +292,6 @@ can_hardware_single_step (void)
     return 0;
 }
 
-/* True if the low target can software single-step.  Such targets
-   implement the GET_NEXT_PCS callback.  */
-
-static int
-can_software_single_step (void)
-{
-  return (the_low_target.get_next_pcs != NULL);
-}
-
 bool
 linux_process_target::low_supports_breakpoints ()
 {
@@ -319,6 +310,13 @@ linux_process_target::low_set_pc (regcache *regcache, CORE_ADDR newpc)
   gdb_assert_not_reached ("linux target op low_set_pc is not implemented");
 }
 
+std::vector<CORE_ADDR>
+linux_process_target::low_get_next_pcs (regcache *regcache)
+{
+  gdb_assert_not_reached ("linux target op low_get_next_pcs is not "
+                         "implemented");
+}
+
 /* Returns true if this target can support fast tracepoints.  This
    does not mean that the in-process agent has been loaded in the
    inferior.  */
@@ -551,7 +549,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
          child_proc->attached = parent_proc->attached;
 
          if (event_lwp->bp_reinsert != 0
-             && can_software_single_step ()
+             && supports_software_single_step ()
              && event == PTRACE_EVENT_VFORK)
            {
              /* If we leave single-step breakpoints there, child will
@@ -596,7 +594,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
             In case of vfork, we'll reinsert them back once vforked
             child is done.  */
          if (event_lwp->bp_reinsert != 0
-             && can_software_single_step ())
+             && supports_software_single_step ())
            {
              /* The child process is forked and stopped, so it is safe
                 to access its memory without stopping all other threads
@@ -660,7 +658,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
     {
       event_lwp->waitstatus.kind = TARGET_WAITKIND_VFORK_DONE;
 
-      if (event_lwp->bp_reinsert != 0 && can_software_single_step ())
+      if (event_lwp->bp_reinsert != 0 && supports_software_single_step ())
        {
          reinsert_single_step_breakpoints (event_thr);
 
@@ -3508,7 +3506,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
          /* Remove the single-step breakpoints if any.  Note that
             there isn't single-step breakpoint if we finished stepping
             over.  */
-         if (can_software_single_step ()
+         if (supports_software_single_step ()
              && has_single_step_breakpoints (current_thread))
            {
              stop_all_lwps (0, event_child);
@@ -3555,7 +3553,7 @@ linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
   /* Alright, we're going to report a stop.  */
 
   /* Remove single-step breakpoints.  */
-  if (can_software_single_step ())
+  if (supports_software_single_step ())
     {
       /* Remove single-step breakpoints or not.  It it is true, stop all
         lwps, so that other threads won't hit the breakpoint in the
@@ -4116,7 +4114,7 @@ linux_process_target::install_software_single_step_breakpoints (lwp_info *lwp)
   scoped_restore save_current_thread = make_scoped_restore (&current_thread);
 
   current_thread = thread;
-  std::vector<CORE_ADDR> next_pcs = the_low_target.get_next_pcs (regcache);
+  std::vector<CORE_ADDR> next_pcs = low_get_next_pcs (regcache);
 
   for (CORE_ADDR pc : next_pcs)
     set_single_step_breakpoint (pc, current_ptid);
@@ -4131,7 +4129,7 @@ linux_process_target::single_step (lwp_info* lwp)
     {
       step = 1;
     }
-  else if (can_software_single_step ())
+  else if (supports_software_single_step ())
     {
       install_software_single_step_breakpoints (lwp);
       step = 0;
@@ -4610,7 +4608,7 @@ linux_process_target::thread_needs_step_over (thread_info *thread)
 
   /* On software single step target, resume the inferior with signal
      rather than stepping over.  */
-  if (can_software_single_step ()
+  if (supports_software_single_step ()
       && lwp->pending_signals != NULL
       && lwp_signal_can_be_delivered (lwp))
     {
@@ -5042,7 +5040,7 @@ linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
       /* If resume_step is requested by GDB, install single-step
         breakpoints when the thread is about to be actually resumed if
         the single-step breakpoints weren't removed.  */
-      if (can_software_single_step ()
+      if (supports_software_single_step ()
          && !has_single_step_breakpoints (thread))
        install_software_single_step_breakpoints (lwp);
 
@@ -5910,12 +5908,6 @@ linux_process_target::supports_hardware_single_step ()
   return can_hardware_single_step ();
 }
 
-bool
-linux_process_target::supports_software_single_step ()
-{
-  return can_software_single_step ();
-}
-
 bool
 linux_process_target::stopped_by_watchpoint ()
 {
@@ -6299,7 +6291,7 @@ linux_process_target::supports_agent ()
 bool
 linux_process_target::supports_range_stepping ()
 {
-  if (can_software_single_step ())
+  if (supports_software_single_step ())
     return true;
   if (*the_low_target.supports_range_stepping == NULL)
     return false;
index b2f779893e30fe08e4283b83744edf64311cfa66..2202a6582254ec281fa23f835898765706483d0e 100644 (file)
@@ -131,9 +131,6 @@ struct lwp_info;
 
 struct linux_target_ops
 {
-  /* Find the next possible PCs after the current instruction executes.  */
-  std::vector<CORE_ADDR> (*get_next_pcs) (struct regcache *regcache);
-
   int decr_pc_after_break;
   int (*breakpoint_at) (CORE_ADDR pc);
 
@@ -440,8 +437,6 @@ public:
                      int *handle_len) override;
 #endif
 
-  bool supports_software_single_step () override;
-
   bool supports_catch_syscall () override;
 
   int get_ipa_tdesc_idx () override;
@@ -666,6 +661,11 @@ protected:
   virtual CORE_ADDR low_get_pc (regcache *regcache);
 
   virtual void low_set_pc (regcache *regcache, CORE_ADDR newpc);
+
+  /* Find the next possible PCs after the current instruction executes.
+     Targets that override this method should also override
+     'supports_software_single_step' to return true.  */
+  virtual std::vector<CORE_ADDR> low_get_next_pcs (regcache *regcache);
 };
 
 extern linux_process_target *the_linux_target;
index 1a6771f5845c54497afea64df78915ae8337d738..78e002dfb242808ef57eec61158f40c22abcfab8 100644 (file)
@@ -160,7 +160,6 @@ m32r_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL,
   0,
   m32r_breakpoint_at,
   NULL, /* supports_z_point_type */
index 5e19ab02094d459927596bbaf667e9f426150802..00851af5f0247e5a409bc578f199ecaaa45dc6db 100644 (file)
@@ -255,7 +255,6 @@ m68k_supports_hardware_single_step (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL,
   2,
   m68k_breakpoint_at,
   NULL, /* supports_z_point_type */
index 972f431bfbd8931de61e55d716b615febd886b71..710245c1610dda9d3ce729d1b90df1a822b30933 100644 (file)
@@ -966,7 +966,6 @@ mips_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_next_pcs */
   0,
   mips_breakpoint_at,
   mips_supports_z_point_type,
index 693af71f29ec3daa416f55df4821520e640d3136..3cae8dac2859fb21a5ac11bc1ef33c47a04d50bf 100644 (file)
@@ -277,7 +277,6 @@ nios2_target::get_regs_info ()
 
 struct linux_target_ops the_low_target =
 {
-  NULL, /* get_next_pcs */
   0,
   nios2_breakpoint_at,
 };
index 9690d79f3d87360c5c3869b58885689ca7767dbb..af9dc0b2adfbb19730650657f4b7f6321d50a7bf 100644 (file)
@@ -3406,7 +3406,6 @@ ppc_get_ipa_tdesc_idx (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL,
   0,
   ppc_breakpoint_at,
   ppc_supports_z_point_type,
index d6f31b47250cd8b02b9e4b1158785aa63115182a..9e96504687e08795436760b813892ca4df7d5810 100644 (file)
@@ -309,7 +309,6 @@ riscv_breakpoint_at (CORE_ADDR pc)
 /* RISC-V/Linux target operations.  */
 struct linux_target_ops the_low_target =
 {
-  NULL, /* get_next_pcs */
   0,    /* decr_pc_after_break */
   riscv_breakpoint_at,
 };
index 164142dff6e81fddcd34c3cdc666c6ca7542f200..4c4b877bb751116c2594cfc3f670807d3bdd1bce 100644 (file)
@@ -2826,7 +2826,6 @@ s390_emit_ops (void)
 }
 
 struct linux_target_ops the_low_target = {
-  NULL,
   s390_breakpoint_len,
   s390_breakpoint_at,
   s390_supports_z_point_type,
index 10ee49a5f87118ddd5c5236c8217ee7b31510243..47242dafe946290eeb27c907a5650963fda1e1e9 100644 (file)
@@ -190,7 +190,6 @@ sh_target::low_arch_setup ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL,
   0,
   sh_breakpoint_at,
   NULL, /* supports_z_point_type */
index c94c3e3caf3b65fe02680d5724b185529916549f..f724cb88b717e0dcbe0f61df4082bef8988deb67 100644 (file)
@@ -339,7 +339,6 @@ sparc_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL, /* get_next_pcs */
   0,
   sparc_breakpoint_at,
   NULL,  /* supports_z_point_type */
index 69bb4f3d7b1e63ca985edfa85d8289de126d9bb3..347b79e6519c554a92a868030da635a815facd56 100644 (file)
@@ -421,7 +421,6 @@ tic6x_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL,
   0,
   tic6x_breakpoint_at,
   NULL, /* supports_z_point_type */
index e4565b4cfbecc86169996cc853bb5b68fbb889a6..86191b9bb1ced59a0600b3ce7c996eb755391654 100644 (file)
@@ -222,7 +222,6 @@ tile_supports_hardware_single_step (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL,
   0,
   tile_breakpoint_at,
   NULL, /* supports_z_point_type */
index a9d7ec06705d1db5c832ae2f5d8a2214c40d5207..59c6b386d11ff4bfca30b58cecb5443d1b05a22d 100644 (file)
@@ -2899,7 +2899,6 @@ x86_get_ipa_tdesc_idx (void)
 
 struct linux_target_ops the_low_target =
 {
-  NULL,
   1,
   x86_breakpoint_at,
   x86_supports_z_point_type,
index ab08227a862b28ae22dd4d8ef13245a284971abe..320ac92968d3d969632ac903ffe62c194cb6c288 100644 (file)
@@ -328,7 +328,6 @@ xtensa_target::get_regs_info ()
 }
 
 struct linux_target_ops the_low_target = {
-  NULL,
   0,
   xtensa_breakpoint_at,
   NULL, /* supports_z_point_type */