gdbserver/linux-low: turn 'sw_breakpoint_from_kind' into a method
[deliverable/binutils-gdb.git] / gdbserver / linux-low.cc
index f93d66a41bd66c0dcd3f6e381878c715c73c66de..14a4dbf0866a2c4bf27d58dcf2087e5e7cc1a597 100644 (file)
@@ -267,25 +267,15 @@ int using_threads = 1;
    jump pads).  */
 static int stabilizing_threads;
 
-static void linux_resume_one_lwp (struct lwp_info *lwp,
-                                 int step, int signal, siginfo_t *info);
-static void stop_all_lwps (int suspend, struct lwp_info *except);
-static void unstop_all_lwps (int unsuspend, struct lwp_info *except);
 static void unsuspend_all_lwps (struct lwp_info *except);
-static int linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
-                                         int *wstat, int options);
-static int linux_wait_for_event (ptid_t ptid, int *wstat, int options);
 static struct lwp_info *add_lwp (ptid_t ptid);
 static void mark_lwp_dead (struct lwp_info *lwp, int wstat);
 static int lwp_is_marked_dead (struct lwp_info *lwp);
-static void proceed_all_lwps (void);
 static int finish_step_over (struct lwp_info *lwp);
 static int kill_lwp (unsigned long lwpid, int signo);
 static void enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info);
-static void complete_ongoing_step_over (void);
 static int linux_low_ptrace_options (int attached);
 static int check_ptrace_stopped_lwp_gone (struct lwp_info *lp);
-static void proceed_one_lwp (thread_info *thread, lwp_info *except);
 
 /* When the event-loop is doing a step-over, this points at the thread
    being stepped.  */
@@ -311,13 +301,22 @@ can_software_single_step (void)
   return (the_low_target.get_next_pcs != NULL);
 }
 
-/* True if the low target supports memory breakpoints.  If so, we'll
-   have a GET_PC implementation.  */
+bool
+linux_process_target::low_supports_breakpoints ()
+{
+  return false;
+}
 
-static int
-supports_breakpoints (void)
+CORE_ADDR
+linux_process_target::low_get_pc (regcache *regcache)
+{
+  return 0;
+}
+
+void
+linux_process_target::low_set_pc (regcache *regcache, CORE_ADDR newpc)
 {
-  return (the_low_target.get_pc != NULL);
+  gdb_assert_not_reached ("linux target op low_set_pc is not implemented");
 }
 
 /* Returns true if this target can support fast tracepoints.  This
@@ -355,7 +354,6 @@ static int linux_event_pipe[2] = { -1, -1 };
 #define target_is_async_p() (linux_event_pipe[0] != -1)
 
 static void send_sigstop (struct lwp_info *lwp);
-static void wait_for_sigstop (void);
 
 /* Return non-zero if HEADER is a 64-bit ELF file.  */
 
@@ -446,39 +444,22 @@ linux_add_process (int pid, int attached)
   return proc;
 }
 
-static CORE_ADDR get_pc (struct lwp_info *lwp);
-
-/* Call the target arch_setup function on the current thread.  */
-
-static void
-linux_arch_setup (void)
-{
-  the_low_target.arch_setup ();
-}
-
-/* Call the target arch_setup function on THREAD.  */
-
-static void
-linux_arch_setup_thread (struct thread_info *thread)
+void
+linux_process_target::arch_setup_thread (thread_info *thread)
 {
   struct thread_info *saved_thread;
 
   saved_thread = current_thread;
   current_thread = thread;
 
-  linux_arch_setup ();
+  low_arch_setup ();
 
   current_thread = saved_thread;
 }
 
-/* Handle a GNU/Linux extended wait response.  If we see a clone,
-   fork, or vfork event, we need to add the new LWP to our list
-   (and return 0 so as not to report the trap to higher layers).
-   If we see an exec event, we will modify ORIG_EVENT_LWP to point
-   to a new LWP representing the new program.  */
-
-static int
-handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
+int
+linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
+                                           int wstat)
 {
   client_state &cs = get_client_state ();
   struct lwp_info *event_lwp = *orig_event_lwp;
@@ -639,9 +620,9 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
       new_lwp = add_lwp (ptid);
 
       /* Either we're going to immediately resume the new thread
-        or leave it stopped.  linux_resume_one_lwp is a nop if it
+        or leave it stopped.  resume_one_lwp is a nop if it
         thinks the thread is currently running, so set this first
-        before calling linux_resume_one_lwp.  */
+        before calling resume_one_lwp.  */
       new_lwp->stopped = 1;
 
       /* If we're suspending all threads, leave this one suspended
@@ -711,7 +692,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
       syscalls_to_catch = std::move (proc->syscalls_to_catch);
 
       /* Delete the execing process and all its threads.  */
-      the_target->pt->mourn (proc);
+      mourn (proc);
       current_thread = NULL;
 
       /* Create a new process/lwp/thread.  */
@@ -719,7 +700,7 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
       event_lwp = add_lwp (event_ptid);
       event_thr = get_lwp_thread (event_lwp);
       gdb_assert (current_thread == event_thr);
-      linux_arch_setup_thread (event_thr);
+      arch_setup_thread (event_thr);
 
       /* Set the event status.  */
       event_lwp->waitstatus.kind = TARGET_WAITKIND_EXECD;
@@ -749,24 +730,21 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat)
   internal_error (__FILE__, __LINE__, _("unknown ptrace event %d"), event);
 }
 
-/* Return the PC as read from the regcache of LWP, without any
-   adjustment.  */
-
-static CORE_ADDR
-get_pc (struct lwp_info *lwp)
+CORE_ADDR
+linux_process_target::get_pc (lwp_info *lwp)
 {
   struct thread_info *saved_thread;
   struct regcache *regcache;
   CORE_ADDR pc;
 
-  if (the_low_target.get_pc == NULL)
+  if (!low_supports_breakpoints ())
     return 0;
 
   saved_thread = current_thread;
   current_thread = get_lwp_thread (lwp);
 
   regcache = get_thread_regcache (current_thread, 1);
-  pc = (*the_low_target.get_pc) (regcache);
+  pc = low_get_pc (regcache);
 
   if (debug_threads)
     debug_printf ("pc is 0x%lx\n", (long) pc);
@@ -806,14 +784,8 @@ get_syscall_trapinfo (struct lwp_info *lwp, int *sysno)
 
 static int check_stopped_by_watchpoint (struct lwp_info *child);
 
-/* Called when the LWP stopped for a signal/trap.  If it stopped for a
-   trap check what caused it (breakpoint, watchpoint, trace, etc.),
-   and save the result in the LWP's stop_reason field.  If it stopped
-   for a breakpoint, decrement the PC if necessary on the lwp's
-   architecture.  Returns true if we now have the LWP's stop PC.  */
-
-static int
-save_stop_reason (struct lwp_info *lwp)
+bool
+linux_process_target::save_stop_reason (lwp_info *lwp)
 {
   CORE_ADDR pc;
   CORE_ADDR sw_breakpoint_pc;
@@ -822,8 +794,8 @@ save_stop_reason (struct lwp_info *lwp)
   siginfo_t siginfo;
 #endif
 
-  if (the_low_target.get_pc == NULL)
-    return 0;
+  if (!low_supports_breakpoints ())
+    return false;
 
   pc = get_pc (lwp);
   sw_breakpoint_pc = pc - the_low_target.decr_pc_after_break;
@@ -905,7 +877,7 @@ save_stop_reason (struct lwp_info *lwp)
        {
          struct regcache *regcache
            = get_thread_regcache (current_thread, 1);
-         (*the_low_target.set_pc) (regcache, sw_breakpoint_pc);
+         low_set_pc (regcache, sw_breakpoint_pc);
        }
 
       /* Update this so we record the correct stop PC below.  */
@@ -944,7 +916,7 @@ save_stop_reason (struct lwp_info *lwp)
 
   lwp->stop_pc = pc;
   current_thread = saved_thread;
-  return 1;
+  return true;
 }
 
 static struct lwp_info *
@@ -1038,7 +1010,7 @@ linux_process_target::post_create_inferior ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
 
-  linux_arch_setup ();
+  low_arch_setup ();
 
   if (lwp->must_set_ptrace_flags)
     {
@@ -1234,8 +1206,7 @@ linux_process_target::attach (unsigned long pid)
       int wstat, lwpid;
       ptid_t pid_ptid = ptid_t (pid);
 
-      lwpid = linux_wait_for_event_filtered (pid_ptid, pid_ptid,
-                                            &wstat, __WALL);
+      lwpid = wait_for_event_filtered (pid_ptid, pid_ptid, &wstat, __WALL);
       gdb_assert (lwpid > 0);
 
       lwp = find_lwp_pid (ptid_t (lwpid));
@@ -1345,7 +1316,7 @@ kill_wait_lwp (struct lwp_info *lwp)
 
         - The loop is most likely unnecessary.
 
-        - We don't use linux_wait_for_event as that could delete lwps
+        - We don't use wait_for_event as that could delete lwps
           while we're iterating over them.  We're not interested in
           any pending status at this point, only in making sure all
           wait status on the kernel side are collected until the
@@ -1702,12 +1673,8 @@ linux_process_target::thread_alive (ptid_t ptid)
     return 0;
 }
 
-/* Return 1 if this lwp still has an interesting status pending.  If
-   not (e.g., it had stopped for a breakpoint that is gone), return
-   false.  */
-
-static int
-thread_still_has_status_pending_p (struct thread_info *thread)
+bool
+linux_process_target::thread_still_has_status_pending (thread_info *thread)
 {
   struct lwp_info *lp = get_thread_lwp (thread);
 
@@ -1790,9 +1757,9 @@ lwp_resumed (struct lwp_info *lwp)
   return 0;
 }
 
-/* Return true if this lwp has an interesting status pending.  */
-static bool
-status_pending_p_callback (thread_info *thread, ptid_t ptid)
+bool
+linux_process_target::status_pending_p_callback (thread_info *thread,
+                                                ptid_t ptid)
 {
   struct lwp_info *lp = get_thread_lwp (thread);
 
@@ -1805,9 +1772,9 @@ status_pending_p_callback (thread_info *thread, ptid_t ptid)
     return 0;
 
   if (lp->status_pending_p
-      && !thread_still_has_status_pending_p (thread))
+      && !thread_still_has_status_pending (thread))
     {
-      linux_resume_one_lwp (lp, lp->stepping, GDB_SIGNAL_0, NULL);
+      resume_one_lwp (lp, lp->stepping, GDB_SIGNAL_0, NULL);
       return 0;
     }
 
@@ -2045,13 +2012,8 @@ linux_fast_tracepoint_collecting (struct lwp_info *lwp,
   return fast_tracepoint_collecting (thread_area, lwp->stop_pc, status);
 }
 
-/* The reason we resume in the caller, is because we want to be able
-   to pass lwp->status_pending as WSTAT, and we need to clear
-   status_pending_p before resuming, otherwise, linux_resume_one_lwp
-   refuses to resume.  */
-
-static int
-maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
+bool
+linux_process_target::maybe_move_out_of_jump_pad (lwp_info *lwp, int *wstat)
 {
   struct thread_info *saved_thread;
 
@@ -2099,7 +2061,7 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
                              lwpid_of (current_thread));
              current_thread = saved_thread;
 
-             return 1;
+             return true;
            }
        }
       else
@@ -2139,7 +2101,7 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
                }
 
              regcache = get_thread_regcache (current_thread, 1);
-             (*the_low_target.set_pc) (regcache, status.tpoint_addr);
+             low_set_pc (regcache, status.tpoint_addr);
              lwp->stop_pc = status.tpoint_addr;
 
              /* Cancel any fast tracepoint lock this thread was
@@ -2171,7 +2133,7 @@ maybe_move_out_of_jump_pad (struct lwp_info *lwp, int *wstat)
                  lwpid_of (current_thread));
 
   current_thread = saved_thread;
-  return 0;
+  return false;
 }
 
 /* Enqueue one signal in the "signals to report later when out of the
@@ -2346,12 +2308,8 @@ linux_low_ptrace_options (int attached)
   return options;
 }
 
-/* Do low-level handling of the event, and check if we should go on
-   and pass it to caller code.  Return the affected lwp if we are, or
-   NULL otherwise.  */
-
-static struct lwp_info *
-linux_low_filter_event (int lwpid, int wstat)
+lwp_info *
+linux_process_target::filter_event (int lwpid, int wstat)
 {
   client_state &cs = get_client_state ();
   struct lwp_info *child;
@@ -2456,7 +2414,7 @@ linux_low_filter_event (int lwpid, int wstat)
              /* This needs to happen after we have attached to the
                 inferior and it is stopped for the first time, but
                 before we access any inferior registers.  */
-             linux_arch_setup_thread (thread);
+             arch_setup_thread (thread);
            }
          else
            {
@@ -2550,7 +2508,7 @@ linux_low_filter_event (int lwpid, int wstat)
                          child->stepping ? "step" : "continue",
                          target_pid_to_str (ptid_of (thread)));
 
-         linux_resume_one_lwp (child, child->stepping, 0, NULL);
+         resume_one_lwp (child, child->stepping, 0, NULL);
          return NULL;
        }
     }
@@ -2576,11 +2534,8 @@ maybe_hw_step (struct thread_info *thread)
     }
 }
 
-/* Resume LWPs that are currently stopped without any pending status
-   to report, but are resumed from the core's perspective.  */
-
-static void
-resume_stopped_resumed_lwps (thread_info *thread)
+void
+linux_process_target::resume_stopped_resumed_lwps (thread_info *thread)
 {
   struct lwp_info *lp = get_thread_lwp (thread);
 
@@ -2600,22 +2555,14 @@ resume_stopped_resumed_lwps (thread_info *thread)
                      paddress (lp->stop_pc),
                      step);
 
-      linux_resume_one_lwp (lp, step, GDB_SIGNAL_0, NULL);
+      resume_one_lwp (lp, step, GDB_SIGNAL_0, NULL);
     }
 }
 
-/* Wait for an event from child(ren) WAIT_PTID, and return any that
-   match FILTER_PTID (leaving others pending).  The PTIDs can be:
-   minus_one_ptid, to specify any child; a pid PTID, specifying all
-   lwps of a thread group; or a PTID representing a single lwp.  Store
-   the stop status through the status pointer WSTAT.  OPTIONS is
-   passed to the waitpid call.  Return 0 if no event was found and
-   OPTIONS contains WNOHANG.  Return -1 if no unwaited-for children
-   was found.  Return the PID of the stopped child otherwise.  */
-
-static int
-linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
-                              int *wstatp, int options)
+int
+linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
+                                              ptid_t filter_ptid,
+                                              int *wstatp, int options)
 {
   struct thread_info *event_thread;
   struct lwp_info *event_child, *requested_child;
@@ -2655,7 +2602,7 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
                                       &requested_child->status_pending);
          requested_child->status_pending_p = 0;
          requested_child->status_pending = 0;
-         linux_resume_one_lwp (requested_child, 0, 0, NULL);
+         resume_one_lwp (requested_child, 0, 0, NULL);
        }
 
       if (requested_child->suspended
@@ -2734,7 +2681,7 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
          /* Filter all events.  IOW, leave all events pending.  We'll
             randomly select an event LWP out of all that have events
             below.  */
-         linux_low_filter_event (ret, *wstatp);
+         filter_event (ret, *wstatp);
          /* Retry until nothing comes out of waitpid.  A single
             SIGCHLD can indicate more than one child stopped.  */
          continue;
@@ -2743,7 +2690,10 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
       /* Now that we've pulled all events out of the kernel, resume
         LWPs that don't have an interesting event to report.  */
       if (stopping_threads == NOT_STOPPING_THREADS)
-       for_each_thread (resume_stopped_resumed_lwps);
+       for_each_thread ([this] (thread_info *thread)
+         {
+           resume_stopped_resumed_lwps (thread);
+         });
 
       /* ... and find an LWP with a status to report to the core, if
         any.  */
@@ -2811,18 +2761,10 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid,
   return lwpid_of (event_thread);
 }
 
-/* Wait for an event from child(ren) PTID.  PTIDs can be:
-   minus_one_ptid, to specify any child; a pid PTID, specifying all
-   lwps of a thread group; or a PTID representing a single lwp.  Store
-   the stop status through the status pointer WSTAT.  OPTIONS is
-   passed to the waitpid call.  Return 0 if no event was found and
-   OPTIONS contains WNOHANG.  Return -1 if no unwaited-for children
-   was found.  Return the PID of the stopped child otherwise.  */
-
-static int
-linux_wait_for_event (ptid_t ptid, int *wstatp, int options)
+int
+linux_process_target::wait_for_event (ptid_t ptid, int *wstatp, int options)
 {
-  return linux_wait_for_event_filtered (ptid, ptid, wstatp, options);
+  return wait_for_event_filtered (ptid, ptid, wstatp, options);
 }
 
 /* Select one LWP out of those that have events pending.  */
@@ -2897,12 +2839,8 @@ unsuspend_all_lwps (struct lwp_info *except)
     });
 }
 
-static void move_out_of_jump_pad_callback (thread_info *thread);
 static bool stuck_in_jump_pad_callback (thread_info *thread);
 static bool lwp_running (thread_info *thread);
-static ptid_t linux_wait_1 (ptid_t ptid,
-                           struct target_waitstatus *ourstatus,
-                           int target_options);
 
 /* Stabilize threads (move out of jump pads).
 
@@ -2952,7 +2890,10 @@ linux_process_target::stabilize_threads ()
   stabilizing_threads = 1;
 
   /* Kick 'em all.  */
-  for_each_thread (move_out_of_jump_pad_callback);
+  for_each_thread ([this] (thread_info *thread)
+    {
+      move_out_of_jump_pad (thread);
+    });
 
   /* Loop until all are stopped out of the jump pads.  */
   while (find_thread (lwp_running) != NULL)
@@ -2964,7 +2905,7 @@ linux_process_target::stabilize_threads ()
       /* Note that we go through the full wait even loop.  While
         moving threads out of jump pad, we need to be able to step
         over internal breakpoints and such.  */
-      linux_wait_1 (minus_one_ptid, &ourstatus, 0);
+      wait_1 (minus_one_ptid, &ourstatus, 0);
 
       if (ourstatus.kind == TARGET_WAITKIND_STOPPED)
        {
@@ -3074,11 +3015,9 @@ gdb_catch_this_syscall_p (struct lwp_info *event_child)
   return 0;
 }
 
-/* Wait for process, returns status.  */
-
-static ptid_t
-linux_wait_1 (ptid_t ptid,
-             struct target_waitstatus *ourstatus, int target_options)
+ptid_t
+linux_process_target::wait_1 (ptid_t ptid, target_waitstatus *ourstatus,
+                             int target_options)
 {
   client_state &cs = get_client_state ();
   int w;
@@ -3096,7 +3035,7 @@ linux_wait_1 (ptid_t ptid,
   if (debug_threads)
     {
       debug_enter ();
-      debug_printf ("linux_wait_1: [%s]\n", target_pid_to_str (ptid));
+      debug_printf ("wait_1: [%s]\n", target_pid_to_str (ptid));
     }
 
   /* Translate generic target options into linux options.  */
@@ -3128,13 +3067,13 @@ linux_wait_1 (ptid_t ptid,
     any_resumed = 0;
 
   if (step_over_bkpt == null_ptid)
-    pid = linux_wait_for_event (ptid, &w, options);
+    pid = wait_for_event (ptid, &w, options);
   else
     {
       if (debug_threads)
        debug_printf ("step_over_bkpt set [%s], doing a blocking wait\n",
                      target_pid_to_str (step_over_bkpt));
-      pid = linux_wait_for_event (step_over_bkpt, &w, options & ~WNOHANG);
+      pid = wait_for_event (step_over_bkpt, &w, options & ~WNOHANG);
     }
 
   if (pid == 0 || (pid == -1 && !any_resumed))
@@ -3143,7 +3082,7 @@ linux_wait_1 (ptid_t ptid,
 
       if (debug_threads)
        {
-         debug_printf ("linux_wait_1 ret = null_ptid, "
+         debug_printf ("wait_1 ret = null_ptid, "
                        "TARGET_WAITKIND_IGNORE\n");
          debug_exit ();
        }
@@ -3155,7 +3094,7 @@ linux_wait_1 (ptid_t ptid,
     {
       if (debug_threads)
        {
-         debug_printf ("linux_wait_1 ret = null_ptid, "
+         debug_printf ("wait_1 ret = null_ptid, "
                        "TARGET_WAITKIND_NO_RESUMED\n");
          debug_exit ();
        }
@@ -3166,7 +3105,7 @@ linux_wait_1 (ptid_t ptid,
 
   event_child = get_thread_lwp (current_thread);
 
-  /* linux_wait_for_event only returns an exit status for the last
+  /* wait_for_event only returns an exit status for the last
      child of a process.  Report it.  */
   if (WIFEXITED (w) || WIFSIGNALED (w))
     {
@@ -3177,7 +3116,7 @@ linux_wait_1 (ptid_t ptid,
 
          if (debug_threads)
            {
-             debug_printf ("linux_wait_1 ret = %s, exited with "
+             debug_printf ("wait_1 ret = %s, exited with "
                            "retcode %d\n",
                            target_pid_to_str (ptid_of (current_thread)),
                            WEXITSTATUS (w));
@@ -3191,7 +3130,7 @@ linux_wait_1 (ptid_t ptid,
 
          if (debug_threads)
            {
-             debug_printf ("linux_wait_1 ret = %s, terminated with "
+             debug_printf ("wait_1 ret = %s, terminated with "
                            "signal %d\n",
                            target_pid_to_str (ptid_of (current_thread)),
                            WTERMSIG (w));
@@ -3225,9 +3164,8 @@ linux_wait_1 (ptid_t ptid,
       int breakpoint_kind = 0;
       CORE_ADDR stop_pc = event_child->stop_pc;
 
-      breakpoint_kind =
-       the_target->breakpoint_kind_from_current_state (&stop_pc);
-      the_target->sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
+      breakpoint_kind = breakpoint_kind_from_current_state (&stop_pc);
+      sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
 
       if (debug_threads)
        {
@@ -3241,7 +3179,7 @@ linux_wait_1 (ptid_t ptid,
            = get_thread_regcache (current_thread, 1);
 
          event_child->stop_pc += increment_pc;
-         (*the_low_target.set_pc) (regcache, event_child->stop_pc);
+         low_set_pc (regcache, event_child->stop_pc);
 
          if (!(*the_low_target.breakpoint_at) (event_child->stop_pc))
            event_child->stop_reason = TARGET_STOPPED_BY_NO_REASON;
@@ -3254,7 +3192,7 @@ linux_wait_1 (ptid_t ptid,
      not support internal breakpoints at all, we also report the
      SIGTRAP without further processing; it's of no concern to us.  */
   maybe_internal_trap
-    = (supports_breakpoints ()
+    = (low_supports_breakpoints ()
        && (WSTOPSIG (w) == SIGTRAP
           || ((WSTOPSIG (w) == SIGILL
                || WSTOPSIG (w) == SIGSEGV)
@@ -3325,7 +3263,7 @@ linux_wait_1 (ptid_t ptid,
            debug_printf ("Signal %d for LWP %ld deferred (in jump pad)\n",
                          WSTOPSIG (w), lwpid_of (current_thread));
 
-         linux_resume_one_lwp (event_child, 0, 0, NULL);
+         resume_one_lwp (event_child, 0, 0, NULL);
 
          if (debug_threads)
            debug_exit ();
@@ -3400,7 +3338,7 @@ linux_wait_1 (ptid_t ptid,
 
                  if (debug_threads)
                    {
-                     debug_printf ("linux_wait_1 ret = %s, stopped "
+                     debug_printf ("wait_1 ret = %s, stopped "
                                    "while stabilizing threads\n",
                                    target_pid_to_str (ptid_of (current_thread)));
                      debug_exit ();
@@ -3425,8 +3363,7 @@ linux_wait_1 (ptid_t ptid,
                        lwpid_of (current_thread));
        }
 
-      linux_resume_one_lwp (event_child, event_child->stepping,
-                           0, NULL);
+      resume_one_lwp (event_child, event_child->stepping, 0, NULL);
 
       if (debug_threads)
        debug_exit ();
@@ -3482,8 +3419,8 @@ linux_wait_1 (ptid_t ptid,
        }
       else
        {
-         linux_resume_one_lwp (event_child, event_child->stepping,
-                               WSTOPSIG (w), info_p);
+         resume_one_lwp (event_child, event_child->stepping,
+                         WSTOPSIG (w), info_p);
        }
 
       if (debug_threads)
@@ -3550,11 +3487,11 @@ linux_wait_1 (ptid_t ptid,
         decr_pc_after_break adjustment to the inferior's regcache
         ourselves.  */
 
-      if (the_low_target.set_pc != NULL)
+      if (low_supports_breakpoints ())
        {
          struct regcache *regcache
            = get_thread_regcache (current_thread, 1);
-         (*the_low_target.set_pc) (regcache, event_child->stop_pc);
+         low_set_pc (regcache, event_child->stop_pc);
        }
 
       if (step_over_finished)
@@ -3765,7 +3702,7 @@ linux_wait_1 (ptid_t ptid,
        {
          struct regcache *regcache
            = get_thread_regcache (current_thread, 1);
-         (*the_low_target.set_pc) (regcache, event_child->stop_pc + decr_pc);
+         low_set_pc (regcache, event_child->stop_pc + decr_pc);
        }
     }
 
@@ -3799,7 +3736,7 @@ linux_wait_1 (ptid_t ptid,
 
   if (debug_threads)
     {
-      debug_printf ("linux_wait_1 ret = %s, %d, %d\n",
+      debug_printf ("wait_1 ret = %s, %d, %d\n",
                    target_pid_to_str (ptid_of (current_thread)),
                    ourstatus->kind, ourstatus->value.sig);
       debug_exit ();
@@ -3852,7 +3789,7 @@ linux_process_target::wait (ptid_t ptid,
 
   do
     {
-      event_ptid = linux_wait_1 (ptid, ourstatus, target_options);
+      event_ptid = wait_1 (ptid, ourstatus, target_options);
     }
   while ((target_options & TARGET_WNOHANG) == 0
         && event_ptid == null_ptid
@@ -3985,10 +3922,8 @@ lwp_is_marked_dead (struct lwp_info *lwp)
              || WIFSIGNALED (lwp->status_pending)));
 }
 
-/* Wait for all children to stop for the SIGSTOPs we just queued.  */
-
-static void
-wait_for_sigstop (void)
+void
+linux_process_target::wait_for_sigstop ()
 {
   struct thread_info *saved_thread;
   ptid_t saved_tid;
@@ -4007,8 +3942,7 @@ wait_for_sigstop (void)
   /* Passing NULL_PTID as filter indicates we want all events to be
      left pending.  Eventually this returns when there are no
      unwaited-for children left.  */
-  ret = linux_wait_for_event_filtered (minus_one_ptid, null_ptid,
-                                      &wstat, __WALL);
+  ret = wait_for_event_filtered (minus_one_ptid, null_ptid, &wstat, __WALL);
   gdb_assert (ret == -1);
 
   if (saved_thread == NULL || mythread_alive (saved_tid))
@@ -4053,8 +3987,8 @@ stuck_in_jump_pad_callback (thread_info *thread)
              != fast_tpoint_collect_result::not_collecting));
 }
 
-static void
-move_out_of_jump_pad_callback (thread_info *thread)
+void
+linux_process_target::move_out_of_jump_pad (thread_info *thread)
 {
   struct thread_info *saved_thread;
   struct lwp_info *lwp = get_thread_lwp (thread);
@@ -4095,7 +4029,7 @@ move_out_of_jump_pad_callback (thread_info *thread)
                          WSTOPSIG (*wstat), lwpid_of (thread));
        }
 
-      linux_resume_one_lwp (lwp, 0, 0, NULL);
+      resume_one_lwp (lwp, 0, 0, NULL);
     }
   else
     lwp_suspended_inc (lwp);
@@ -4114,12 +4048,8 @@ lwp_running (thread_info *thread)
   return !lwp->stopped;
 }
 
-/* Stop all lwps that aren't stopped yet, except EXCEPT, if not NULL.
-   If SUSPEND, then also increase the suspend count of every LWP,
-   except EXCEPT.  */
-
-static void
-stop_all_lwps (int suspend, struct lwp_info *except)
+void
+linux_process_target::stop_all_lwps (int suspend, lwp_info *except)
 {
   /* Should not be called recursively.  */
   gdb_assert (stopping_threads == NOT_STOPPING_THREADS);
@@ -4177,10 +4107,8 @@ enqueue_pending_signal (struct lwp_info *lwp, int signal, siginfo_t *info)
   lwp->pending_signals = p_sig;
 }
 
-/* Install breakpoints for software single stepping.  */
-
-static void
-install_software_single_step_breakpoints (struct lwp_info *lwp)
+void
+linux_process_target::install_software_single_step_breakpoints (lwp_info *lwp)
 {
   struct thread_info *thread = get_lwp_thread (lwp);
   struct regcache *regcache = get_thread_regcache (thread, 1);
@@ -4194,12 +4122,8 @@ install_software_single_step_breakpoints (struct lwp_info *lwp)
     set_single_step_breakpoint (pc, current_ptid);
 }
 
-/* Single step via hardware or software single step.
-   Return 1 if hardware single stepping, 0 if software single stepping
-   or can't single step.  */
-
-static int
-single_step (struct lwp_info* lwp)
+int
+linux_process_target::single_step (lwp_info* lwp)
 {
   int step = 0;
 
@@ -4234,12 +4158,9 @@ lwp_signal_can_be_delivered (struct lwp_info *lwp)
          == fast_tpoint_collect_result::not_collecting);
 }
 
-/* Resume execution of LWP.  If STEP is nonzero, single-step it.  If
-   SIGNAL is nonzero, give it that signal.  */
-
-static void
-linux_resume_one_lwp_throw (struct lwp_info *lwp,
-                           int step, int signal, siginfo_t *info)
+void
+linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step,
+                                           int signal, siginfo_t *info)
 {
   struct thread_info *thread = get_lwp_thread (lwp);
   struct thread_info *saved_thread;
@@ -4373,11 +4294,11 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp,
       step = single_step (lwp);
     }
 
-  if (proc->tdesc != NULL && the_low_target.get_pc != NULL)
+  if (proc->tdesc != NULL && low_supports_breakpoints ())
     {
       struct regcache *regcache = get_thread_regcache (current_thread, 1);
 
-      lwp->stop_pc = (*the_low_target.get_pc) (regcache);
+      lwp->stop_pc = low_get_pc (regcache);
 
       if (debug_threads)
        {
@@ -4476,16 +4397,13 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp)
   return 0;
 }
 
-/* Like linux_resume_one_lwp_throw, but no error is thrown if the LWP
-   disappears while we try to resume it.  */
-
-static void
-linux_resume_one_lwp (struct lwp_info *lwp,
-                     int step, int signal, siginfo_t *info)
+void
+linux_process_target::resume_one_lwp (lwp_info *lwp, int step, int signal,
+                                     siginfo_t *info)
 {
   try
     {
-      linux_resume_one_lwp_throw (lwp, step, signal, info);
+      resume_one_lwp_throw (lwp, step, signal, info);
     }
   catch (const gdb_exception_error &ex)
     {
@@ -4606,11 +4524,8 @@ linux_set_resume_request (thread_info *thread, thread_resume *resume, size_t n)
   lwp->resume = NULL;
 }
 
-/* find_thread callback for linux_resume.  Return true if this lwp has an
-   interesting status pending.  */
-
-static bool
-resume_status_pending_p (thread_info *thread)
+bool
+linux_process_target::resume_status_pending (thread_info *thread)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
 
@@ -4619,16 +4534,11 @@ resume_status_pending_p (thread_info *thread)
   if (lwp->resume == NULL)
     return false;
 
-  return thread_still_has_status_pending_p (thread);
+  return thread_still_has_status_pending (thread);
 }
 
-/* Return 1 if this lwp that GDB wants running is stopped at an
-   internal breakpoint that we need to step over.  It assumes that any
-   required STOP_PC adjustment has already been propagated to the
-   inferior's regcache.  */
-
-static bool
-need_step_over_p (thread_info *thread)
+bool
+linux_process_target::thread_needs_step_over (thread_info *thread)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
   struct thread_info *saved_thread;
@@ -4758,18 +4668,8 @@ need_step_over_p (thread_info *thread)
   return false;
 }
 
-/* Start a step-over operation on LWP.  When LWP stopped at a
-   breakpoint, to make progress, we need to remove the breakpoint out
-   of the way.  If we let other threads run while we do that, they may
-   pass by the breakpoint location and miss hitting it.  To avoid
-   that, a step-over momentarily stops all threads while LWP is
-   single-stepped by either hardware or software while the breakpoint
-   is temporarily uninserted from the inferior.  When the single-step
-   finishes, we reinsert the breakpoint, and let all threads that are
-   supposed to be running, run again.  */
-
-static int
-start_step_over (struct lwp_info *lwp)
+void
+linux_process_target::start_step_over (lwp_info *lwp)
 {
   struct thread_info *thread = get_lwp_thread (lwp);
   struct thread_info *saved_thread;
@@ -4809,11 +4709,10 @@ start_step_over (struct lwp_info *lwp)
 
   current_thread = saved_thread;
 
-  linux_resume_one_lwp (lwp, step, 0, NULL);
+  resume_one_lwp (lwp, step, 0, NULL);
 
   /* Require next event from this LWP.  */
   step_over_bkpt = thread->id;
-  return 1;
 }
 
 /* Finish a step-over.  Reinsert the breakpoint we had uninserted in
@@ -4858,14 +4757,8 @@ finish_step_over (struct lwp_info *lwp)
     return 0;
 }
 
-/* If there's a step over in progress, wait until all threads stop
-   (that is, until the stepping thread finishes its step), and
-   unsuspend all lwps.  The stepping thread ends with its status
-   pending, which is processed later when we get back to processing
-   events.  */
-
-static void
-complete_ongoing_step_over (void)
+void
+linux_process_target::complete_ongoing_step_over ()
 {
   if (step_over_bkpt != null_ptid)
     {
@@ -4879,8 +4772,8 @@ complete_ongoing_step_over (void)
       /* Passing NULL_PTID as filter indicates we want all events to
         be left pending.  Eventually this returns when there are no
         unwaited-for children left.  */
-      ret = linux_wait_for_event_filtered (minus_one_ptid, null_ptid,
-                                          &wstat, __WALL);
+      ret = wait_for_event_filtered (minus_one_ptid, null_ptid, &wstat,
+                                    __WALL);
       gdb_assert (ret == -1);
 
       lwp = find_lwp_pid (step_over_bkpt);
@@ -4891,21 +4784,9 @@ complete_ongoing_step_over (void)
     }
 }
 
-/* This function is called once per thread.  We check the thread's resume
-   request, which will tell us whether to resume, step, or leave the thread
-   stopped; and what signal, if any, it should be sent.
-
-   For threads which we aren't explicitly told otherwise, we preserve
-   the stepping flag; this is used for stepping over gdbserver-placed
-   breakpoints.
-
-   If pending_flags was set in any thread, we queue any needed
-   signals, since we won't actually resume.  We already have a pending
-   event to report, so we don't need to preserve any step requests;
-   they should be re-issued if necessary.  */
-
-static void
-linux_resume_one_thread (thread_info *thread, bool leave_all_stopped)
+void
+linux_process_target::resume_one_thread (thread_info *thread,
+                                        bool leave_all_stopped)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
   int leave_pending;
@@ -5032,7 +4913,10 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
      before considering to start a step-over (in all-stop).  */
   bool any_pending = false;
   if (!non_stop)
-    any_pending = find_thread (resume_status_pending_p) != NULL;
+    any_pending = find_thread ([this] (thread_info *thread)
+                   {
+                     return resume_status_pending (thread);
+                   }) != nullptr;
 
   /* If there is a thread which would otherwise be resumed, which is
      stopped at a breakpoint that needs stepping over, then don't
@@ -5040,8 +4924,11 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
      other threads stopped, then resume all threads again.  Make sure
      to queue any signals that would otherwise be delivered or
      queued.  */
-  if (!any_pending && supports_breakpoints ())
-    need_step_over = find_thread (need_step_over_p);
+  if (!any_pending && low_supports_breakpoints ())
+    need_step_over = find_thread ([this] (thread_info *thread)
+                      {
+                        return thread_needs_step_over (thread);
+                      });
 
   bool leave_all_stopped = (need_step_over != NULL || any_pending);
 
@@ -5060,7 +4947,7 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
      otherwise deliver.  */
   for_each_thread ([&] (thread_info *thread)
     {
-      linux_resume_one_thread (thread, leave_all_stopped);
+      resume_one_thread (thread, leave_all_stopped);
     });
 
   if (need_step_over)
@@ -5078,17 +4965,8 @@ linux_process_target::resume (thread_resume *resume_info, size_t n)
     async_file_mark ();
 }
 
-/* This function is called once per thread.  We check the thread's
-   last resume request, which will tell us whether to resume, step, or
-   leave the thread stopped.  Any signal the client requested to be
-   delivered has already been enqueued at this point.
-
-   If any thread that GDB wants running is stopped at an internal
-   breakpoint that needs stepping over, we start a step-over operation
-   on that particular thread, and leave all others stopped.  */
-
-static void
-proceed_one_lwp (thread_info *thread, lwp_info *except)
+void
+linux_process_target::proceed_one_lwp (thread_info *thread, lwp_info *except)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
   int step;
@@ -5181,11 +5059,12 @@ proceed_one_lwp (thread_info *thread, lwp_info *except)
   else
     step = 0;
 
-  linux_resume_one_lwp (lwp, step, 0, NULL);
+  resume_one_lwp (lwp, step, 0, NULL);
 }
 
-static void
-unsuspend_and_proceed_one_lwp (thread_info *thread, lwp_info *except)
+void
+linux_process_target::unsuspend_and_proceed_one_lwp (thread_info *thread,
+                                                    lwp_info *except)
 {
   struct lwp_info *lwp = get_thread_lwp (thread);
 
@@ -5197,12 +5076,8 @@ unsuspend_and_proceed_one_lwp (thread_info *thread, lwp_info *except)
   proceed_one_lwp (thread, except);
 }
 
-/* When we finish a step-over, set threads running again.  If there's
-   another thread that may need a step-over, now's the time to start
-   it.  Eventually, we'll move all threads past their breakpoints.  */
-
-static void
-proceed_all_lwps (void)
+void
+linux_process_target::proceed_all_lwps ()
 {
   struct thread_info *need_step_over;
 
@@ -5211,9 +5086,12 @@ proceed_all_lwps (void)
      resume any threads - have it step over the breakpoint with all
      other threads stopped, then resume all threads again.  */
 
-  if (supports_breakpoints ())
+  if (low_supports_breakpoints ())
     {
-      need_step_over = find_thread (need_step_over_p);
+      need_step_over = find_thread ([this] (thread_info *thread)
+                        {
+                          return thread_needs_step_over (thread);
+                        });
 
       if (need_step_over != NULL)
        {
@@ -5230,18 +5108,14 @@ proceed_all_lwps (void)
   if (debug_threads)
     debug_printf ("Proceeding, no step-over needed\n");
 
-  for_each_thread ([] (thread_info *thread)
+  for_each_thread ([this] (thread_info *thread)
     {
       proceed_one_lwp (thread, NULL);
     });
 }
 
-/* Stopped LWPs that the client wanted to be running, that don't have
-   pending statuses, are set to run again, except for EXCEPT, if not
-   NULL.  This undoes a stop_all_lwps call.  */
-
-static void
-unstop_all_lwps (int unsuspend, struct lwp_info *except)
+void
+linux_process_target::unstop_all_lwps (int unsuspend, lwp_info *except)
 {
   if (debug_threads)
     {
@@ -5447,7 +5321,7 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
              /* At this point, ESRCH should mean the process is
                 already gone, in which case we simply ignore attempts
                 to change its registers.  See also the related
-                comment in linux_resume_one_lwp.  */
+                comment in resume_one_lwp.  */
              free (buf);
              return 0;
            }
@@ -5503,10 +5377,10 @@ register_addr (const struct usrregs_info *usrregs, int regnum)
   return addr;
 }
 
-/* Fetch one register.  */
-static void
-fetch_register (const struct usrregs_info *usrregs,
-               struct regcache *regcache, int regno)
+
+void
+linux_process_target::fetch_register (const usrregs_info *usrregs,
+                                     regcache *regcache, int regno)
 {
   CORE_ADDR regaddr;
   int i, size;
@@ -5515,7 +5389,7 @@ fetch_register (const struct usrregs_info *usrregs,
 
   if (regno >= usrregs->num_regs)
     return;
-  if ((*the_low_target.cannot_fetch_register) (regno))
+  if (low_cannot_fetch_register (regno))
     return;
 
   regaddr = register_addr (usrregs, regno);
@@ -5551,10 +5425,9 @@ fetch_register (const struct usrregs_info *usrregs,
     supply_register (regcache, regno, buf);
 }
 
-/* Store one register.  */
-static void
-store_register (const struct usrregs_info *usrregs,
-               struct regcache *regcache, int regno)
+void
+linux_process_target::store_register (const usrregs_info *usrregs,
+                                     regcache *regcache, int regno)
 {
   CORE_ADDR regaddr;
   int i, size;
@@ -5563,7 +5436,7 @@ store_register (const struct usrregs_info *usrregs,
 
   if (regno >= usrregs->num_regs)
     return;
-  if ((*the_low_target.cannot_store_register) (regno))
+  if (low_cannot_store_register (regno))
     return;
 
   regaddr = register_addr (usrregs, regno);
@@ -5595,26 +5468,25 @@ store_register (const struct usrregs_info *usrregs,
          /* At this point, ESRCH should mean the process is
             already gone, in which case we simply ignore attempts
             to change its registers.  See also the related
-            comment in linux_resume_one_lwp.  */
+            comment in resume_one_lwp.  */
          if (errno == ESRCH)
            return;
 
-         if ((*the_low_target.cannot_store_register) (regno) == 0)
+
+         if (!low_cannot_store_register (regno))
            error ("writing register %d: %s", regno, safe_strerror (errno));
        }
       regaddr += sizeof (PTRACE_XFER_TYPE);
     }
 }
+#endif /* HAVE_LINUX_USRREGS */
 
-/* Fetch all registers, or just one, from the child process.
-   If REGNO is -1, do this for all registers, skipping any that are
-   assumed to have been retrieved by regsets_fetch_inferior_registers,
-   unless ALL is non-zero.
-   Otherwise, REGNO specifies which register (so we can save time).  */
-static void
-usr_fetch_inferior_registers (const struct regs_info *regs_info,
-                             struct regcache *regcache, int regno, int all)
+void
+linux_process_target::usr_fetch_inferior_registers (const regs_info *regs_info,
+                                                   regcache *regcache,
+                                                   int regno, int all)
 {
+#ifdef HAVE_LINUX_USRREGS
   struct usrregs_info *usr = regs_info->usrregs;
 
   if (regno == -1)
@@ -5625,17 +5497,15 @@ usr_fetch_inferior_registers (const struct regs_info *regs_info,
     }
   else
     fetch_register (usr, regcache, regno);
+#endif
 }
 
-/* Store our register values back into the inferior.
-   If REGNO is -1, do this for all registers, skipping any that are
-   assumed to have been saved by regsets_store_inferior_registers,
-   unless ALL is non-zero.
-   Otherwise, REGNO specifies which register (so we can save time).  */
-static void
-usr_store_inferior_registers (const struct regs_info *regs_info,
-                             struct regcache *regcache, int regno, int all)
+void
+linux_process_target::usr_store_inferior_registers (const regs_info *regs_info,
+                                                   regcache *regcache,
+                                                   int regno, int all)
 {
+#ifdef HAVE_LINUX_USRREGS
   struct usrregs_info *usr = regs_info->usrregs;
 
   if (regno == -1)
@@ -5646,29 +5516,21 @@ usr_store_inferior_registers (const struct regs_info *regs_info,
     }
   else
     store_register (usr, regcache, regno);
-}
-
-#else /* !HAVE_LINUX_USRREGS */
-
-#define usr_fetch_inferior_registers(regs_info, regcache, regno, all) do {} while (0)
-#define usr_store_inferior_registers(regs_info, regcache, regno, all) do {} while (0)
-
 #endif
-
+}
 
 void
 linux_process_target::fetch_registers (regcache *regcache, int regno)
 {
   int use_regsets;
   int all = 0;
-  const struct regs_info *regs_info = (*the_low_target.regs_info) ();
+  const regs_info *regs_info = get_regs_info ();
 
   if (regno == -1)
     {
-      if (the_low_target.fetch_register != NULL
-         && regs_info->usrregs != NULL)
+      if (regs_info->usrregs != NULL)
        for (regno = 0; regno < regs_info->usrregs->num_regs; regno++)
-         (*the_low_target.fetch_register) (regcache, regno);
+         low_fetch_register (regcache, regno);
 
       all = regsets_fetch_inferior_registers (regs_info->regsets_info, regcache);
       if (regs_info->usrregs != NULL)
@@ -5676,8 +5538,7 @@ linux_process_target::fetch_registers (regcache *regcache, int regno)
     }
   else
     {
-      if (the_low_target.fetch_register != NULL
-         && (*the_low_target.fetch_register) (regcache, regno))
+      if (low_fetch_register (regcache, regno))
        return;
 
       use_regsets = linux_register_in_regsets (regs_info, regno);
@@ -5694,7 +5555,7 @@ linux_process_target::store_registers (regcache *regcache, int regno)
 {
   int use_regsets;
   int all = 0;
-  const struct regs_info *regs_info = (*the_low_target.regs_info) ();
+  const regs_info *regs_info = get_regs_info ();
 
   if (regno == -1)
     {
@@ -5714,13 +5575,18 @@ linux_process_target::store_registers (regcache *regcache, int regno)
     }
 }
 
+bool
+linux_process_target::low_fetch_register (regcache *regcache, int regno)
+{
+  return false;
+}
 
 /* A wrapper for the read_memory target op.  */
 
 static int
 linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
 {
-  return the_target->pt->read_memory (memaddr, myaddr, len);
+  return the_target->read_memory (memaddr, myaddr, len);
 }
 
 /* Copy LEN bytes from inferior's memory starting at MEMADDR
@@ -6044,8 +5910,8 @@ linux_process_target::supports_hardware_single_step ()
   return can_hardware_single_step ();
 }
 
-static int
-linux_supports_software_single_step (void)
+bool
+linux_process_target::supports_software_single_step ()
 {
   return can_software_single_step ();
 }
@@ -6414,33 +6280,71 @@ linux_process_target::core_of_thread (ptid_t ptid)
   return linux_common_core_of_thread (ptid);
 }
 
-static int
-linux_supports_disable_randomization (void)
+bool
+linux_process_target::supports_disable_randomization ()
 {
 #ifdef HAVE_PERSONALITY
-  return 1;
+  return true;
 #else
-  return 0;
+  return false;
 #endif
 }
 
-static int
-linux_supports_agent (void)
+bool
+linux_process_target::supports_agent ()
 {
-  return 1;
+  return true;
 }
 
-static int
-linux_supports_range_stepping (void)
+bool
+linux_process_target::supports_range_stepping ()
 {
   if (can_software_single_step ())
-    return 1;
+    return true;
   if (*the_low_target.supports_range_stepping == NULL)
-    return 0;
+    return false;
 
   return (*the_low_target.supports_range_stepping) ();
 }
 
+bool
+linux_process_target::supports_pid_to_exec_file ()
+{
+  return true;
+}
+
+char *
+linux_process_target::pid_to_exec_file (int pid)
+{
+  return linux_proc_pid_to_exec_file (pid);
+}
+
+bool
+linux_process_target::supports_multifs ()
+{
+  return true;
+}
+
+int
+linux_process_target::multifs_open (int pid, const char *filename,
+                                   int flags, mode_t mode)
+{
+  return linux_mntns_open_cloexec (pid, filename, flags, mode);
+}
+
+int
+linux_process_target::multifs_unlink (int pid, const char *filename)
+{
+  return linux_mntns_unlink (pid, filename);
+}
+
+ssize_t
+linux_process_target::multifs_readlink (int pid, const char *filename,
+                                       char *buf, size_t bufsiz)
+{
+  return linux_mntns_readlink (pid, filename, buf, bufsiz);
+}
+
 #if defined PT_GETDSBT || defined PTRACE_GETFDPIC
 struct target_loadseg
 {
@@ -6530,15 +6434,15 @@ linux_process_target::process_qsupported (char **features, int count)
     the_low_target.process_qsupported (features, count);
 }
 
-static int
-linux_supports_catch_syscall (void)
+bool
+linux_process_target::supports_catch_syscall ()
 {
   return (the_low_target.get_syscall_trapinfo != NULL
          && linux_supports_tracesysgood ());
 }
 
-static int
-linux_get_ipa_tdesc_idx (void)
+int
+linux_process_target::get_ipa_tdesc_idx ()
 {
   if (the_low_target.get_ipa_tdesc_idx == NULL)
     return 0;
@@ -6558,18 +6462,18 @@ linux_process_target::supports_tracepoints ()
 CORE_ADDR
 linux_process_target::read_pc (regcache *regcache)
 {
-  if (the_low_target.get_pc == NULL)
+  if (!low_supports_breakpoints ())
     return 0;
 
-  return (*the_low_target.get_pc) (regcache);
+  return low_get_pc (regcache);
 }
 
 void
 linux_process_target::write_pc (regcache *regcache, CORE_ADDR pc)
 {
-  gdb_assert (the_low_target.set_pc != NULL);
+  gdb_assert (low_supports_breakpoints ());
 
-  (*the_low_target.set_pc) (regcache, pc);
+  low_set_pc (regcache, pc);
 }
 
 bool
@@ -6931,6 +6835,12 @@ read_one_ptr (CORE_ADDR memaddr, CORE_ADDR *ptr, int ptr_size)
   return ret;
 }
 
+bool
+linux_process_target::supports_qxfer_libraries_svr4 ()
+{
+  return true;
+}
+
 struct link_map_offsets
   {
     /* Offset and size of r_debug.r_version.  */
@@ -6957,10 +6867,11 @@ struct link_map_offsets
 
 /* Construct qXfer:libraries-svr4:read reply.  */
 
-static int
-linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
-                           unsigned const char *writebuf,
-                           CORE_ADDR offset, int len)
+int
+linux_process_target::qxfer_libraries_svr4 (const char *annex,
+                                           unsigned char *readbuf,
+                                           unsigned const char *writebuf,
+                                           CORE_ADDR offset, int len)
 {
   struct process_info_private *const priv = current_process ()->priv;
   char filename[PATH_MAX];
@@ -7146,10 +7057,17 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf,
 
 #ifdef HAVE_LINUX_BTRACE
 
+btrace_target_info *
+linux_process_target::enable_btrace (ptid_t ptid,
+                                    const btrace_config *conf)
+{
+  return linux_enable_btrace (ptid, conf);
+}
+
 /* See to_disable_btrace target method.  */
 
-static int
-linux_low_disable_btrace (struct btrace_target_info *tinfo)
+int
+linux_process_target::disable_btrace (btrace_target_info *tinfo)
 {
   enum btrace_error err;
 
@@ -7208,9 +7126,10 @@ linux_low_encode_raw (struct buffer *buffer, const gdb_byte *data,
 
 /* See to_read_btrace target method.  */
 
-static int
-linux_low_read_btrace (struct btrace_target_info *tinfo, struct buffer *buffer,
-                      enum btrace_read_type type)
+int
+linux_process_target::read_btrace (btrace_target_info *tinfo,
+                                  buffer *buffer,
+                                  enum btrace_read_type type)
 {
   struct btrace_data btrace;
   enum btrace_error err;
@@ -7267,9 +7186,9 @@ linux_low_read_btrace (struct btrace_target_info *tinfo, struct buffer *buffer,
 
 /* See to_btrace_conf target method.  */
 
-static int
-linux_low_btrace_conf (const struct btrace_target_info *tinfo,
-                      struct buffer *buffer)
+int
+linux_process_target::read_btrace_conf (const btrace_target_info *tinfo,
+                                       buffer *buffer)
 {
   const struct btrace_config *conf;
 
@@ -7311,38 +7230,20 @@ current_lwp_ptid (void)
   return ptid_of (current_thread);
 }
 
-/* Implementation of the target_ops method "breakpoint_kind_from_pc".  */
-
-static int
-linux_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
-{
-  if (the_low_target.breakpoint_kind_from_pc != NULL)
-    return (*the_low_target.breakpoint_kind_from_pc) (pcptr);
-  else
-    return default_breakpoint_kind_from_pc (pcptr);
-}
-
-/* Implementation of the target_ops method "sw_breakpoint_from_kind".  */
-
-static const gdb_byte *
-linux_sw_breakpoint_from_kind (int kind, int *size)
+const char *
+linux_process_target::thread_name (ptid_t thread)
 {
-  gdb_assert (the_low_target.sw_breakpoint_from_kind != NULL);
-
-  return (*the_low_target.sw_breakpoint_from_kind) (kind, size);
+  return linux_proc_tid_get_name (thread);
 }
 
-/* Implementation of the target_ops method
-   "breakpoint_kind_from_current_state".  */
-
-static int
-linux_breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
+#if USE_THREAD_DB
+bool
+linux_process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
+                                    int *handle_len)
 {
-  if (the_low_target.breakpoint_kind_from_current_state != NULL)
-    return (*the_low_target.breakpoint_kind_from_current_state) (pcptr);
-  else
-    return linux_breakpoint_kind_from_pc (pcptr);
+  return thread_db_thread_handle (ptid, handle, handle_len);
 }
+#endif
 
 /* Default implementation of linux_target_ops method "set_pc" for
    32-bit pc register which is literally named "pc".  */
@@ -7404,7 +7305,7 @@ linux_get_auxv (int wordsize, CORE_ADDR match, CORE_ADDR *valp)
 
   gdb_assert (wordsize == 4 || wordsize == 8);
 
-  while (the_target->pt->read_auxv (offset, data, 2 * wordsize) == 2 * wordsize)
+  while (the_target->read_auxv (offset, data, 2 * wordsize) == 2 * wordsize)
     {
       if (wordsize == 4)
        {
@@ -7451,45 +7352,6 @@ linux_get_hwcap2 (int wordsize)
   return hwcap2;
 }
 
-/* The linux target ops object.  */
-
-static linux_process_target the_linux_target;
-
-static process_stratum_target linux_target_ops = {
-  linux_supports_disable_randomization,
-  linux_qxfer_libraries_svr4,
-  linux_supports_agent,
-#ifdef HAVE_LINUX_BTRACE
-  linux_enable_btrace,
-  linux_low_disable_btrace,
-  linux_low_read_btrace,
-  linux_low_btrace_conf,
-#else
-  NULL,
-  NULL,
-  NULL,
-  NULL,
-#endif
-  linux_supports_range_stepping,
-  linux_proc_pid_to_exec_file,
-  linux_mntns_open_cloexec,
-  linux_mntns_unlink,
-  linux_mntns_readlink,
-  linux_breakpoint_kind_from_pc,
-  linux_sw_breakpoint_from_kind,
-  linux_proc_tid_get_name,
-  linux_breakpoint_kind_from_current_state,
-  linux_supports_software_single_step,
-  linux_supports_catch_syscall,
-  linux_get_ipa_tdesc_idx,
-#if USE_THREAD_DB
-  thread_db_thread_handle,
-#else
-  NULL,
-#endif
-  &the_linux_target,
-};
-
 #ifdef HAVE_LINUX_REGSETS
 void
 initialize_regsets_info (struct regsets_info *info)
@@ -7507,7 +7369,7 @@ initialize_low (void)
   struct sigaction sigchld_action;
 
   memset (&sigchld_action, 0, sizeof (sigchld_action));
-  set_target_ops (&linux_target_ops);
+  set_target_ops (the_linux_target);
 
   linux_ptrace_init_warnings ();
   linux_proc_init_warnings ();
This page took 0.044577 seconds and 4 git commands to generate.