gdbserver: turn target op 'get_tib_address' into a method
[deliverable/binutils-gdb.git] / gdbserver / linux-low.cc
index ee5a6c027122cfbbe1fb2d0aafe2e3c8d6d428ca..c7ebffdf708b3458cee65e51794b4c895ab7c93f 100644 (file)
@@ -45,7 +45,6 @@
 #include <sys/uio.h>
 #include "gdbsupport/filestuff.h"
 #include "tracepoint.h"
-#include "hostio.h"
 #include <inttypes.h>
 #include "gdbsupport/common-inferior.h"
 #include "nat/fork-inferior.h"
@@ -6146,10 +6145,17 @@ linux_process_target::get_tls_address (thread_info *thread,
 #endif
 }
 
-static int
-linux_qxfer_osdata (const char *annex,
-                   unsigned char *readbuf, unsigned const char *writebuf,
-                   CORE_ADDR offset, int len)
+bool
+linux_process_target::supports_qxfer_osdata ()
+{
+  return true;
+}
+
+int
+linux_process_target::qxfer_osdata (const char *annex,
+                                   unsigned char *readbuf,
+                                   unsigned const char *writebuf,
+                                   CORE_ADDR offset, int len)
 {
   return linux_common_xfer_osdata (annex, readbuf, offset, len);
 }
@@ -6176,9 +6182,17 @@ siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo, int direction)
     }
 }
 
-static int
-linux_xfer_siginfo (const char *annex, unsigned char *readbuf,
-                   unsigned const char *writebuf, CORE_ADDR offset, int len)
+bool
+linux_process_target::supports_qxfer_siginfo ()
+{
+  return true;
+}
+
+int
+linux_process_target::qxfer_siginfo (const char *annex,
+                                    unsigned char *readbuf,
+                                    unsigned const char *writebuf,
+                                    CORE_ADDR offset, int len)
 {
   int pid;
   siginfo_t siginfo;
@@ -6251,16 +6265,16 @@ sigchld_handler (int signo)
   errno = old_errno;
 }
 
-static int
-linux_supports_non_stop (void)
+bool
+linux_process_target::supports_non_stop ()
 {
-  return 1;
+  return true;
 }
 
-static int
-linux_async (int enable)
+bool
+linux_process_target::async (bool enable)
 {
-  int previous = target_is_async_p ();
+  bool previous = target_is_async_p ();
 
   if (debug_threads)
     debug_printf ("linux_async (%d), previous=%d\n",
@@ -6312,44 +6326,44 @@ linux_async (int enable)
   return previous;
 }
 
-static int
-linux_start_non_stop (int nonstop)
+int
+linux_process_target::start_non_stop (bool nonstop)
 {
   /* Register or unregister from event-loop accordingly.  */
-  linux_async (nonstop);
+  target_async (nonstop);
 
-  if (target_is_async_p () != (nonstop != 0))
+  if (target_is_async_p () != (nonstop != false))
     return -1;
 
   return 0;
 }
 
-static int
-linux_supports_multi_process (void)
+bool
+linux_process_target::supports_multi_process ()
 {
-  return 1;
+  return true;
 }
 
 /* Check if fork events are supported.  */
 
-static int
-linux_supports_fork_events (void)
+bool
+linux_process_target::supports_fork_events ()
 {
   return linux_supports_tracefork ();
 }
 
 /* Check if vfork events are supported.  */
 
-static int
-linux_supports_vfork_events (void)
+bool
+linux_process_target::supports_vfork_events ()
 {
   return linux_supports_tracefork ();
 }
 
 /* Check if exec events are supported.  */
 
-static int
-linux_supports_exec_events (void)
+bool
+linux_process_target::supports_exec_events ()
 {
   return linux_supports_traceexec ();
 }
@@ -6358,8 +6372,8 @@ linux_supports_exec_events (void)
    ptrace flags for all inferiors.  This is in case the new GDB connection
    doesn't support the same set of events that the previous one did.  */
 
-static void
-linux_handle_new_gdb_connection (void)
+void
+linux_process_target::handle_new_gdb_connection ()
 {
   /* Request that all the lwps reset their ptrace options.  */
   for_each_thread ([] (thread_info *thread)
@@ -6384,6 +6398,22 @@ linux_handle_new_gdb_connection (void)
     });
 }
 
+int
+linux_process_target::handle_monitor_command (char *mon)
+{
+#ifdef USE_THREAD_DB
+  return thread_db_handle_monitor_command (mon);
+#else
+  return 0;
+#endif
+}
+
+int
+linux_process_target::core_of_thread (ptid_t ptid)
+{
+  return linux_common_core_of_thread (ptid);
+}
+
 static int
 linux_supports_disable_randomization (void)
 {
@@ -6453,9 +6483,15 @@ struct target_loadmap
 #  define LINUX_LOADMAP_INTERP PTRACE_GETFDPIC_INTERP
 # endif
 
-static int
-linux_read_loadmap (const char *annex, CORE_ADDR offset,
-                   unsigned char *myaddr, unsigned int len)
+bool
+linux_process_target::supports_read_loadmap ()
+{
+  return true;
+}
+
+int
+linux_process_target::read_loadmap (const char *annex, CORE_ADDR offset,
+                                   unsigned char *myaddr, unsigned int len)
 {
   int pid = lwpid_of (current_thread);
   int addr = -1;
@@ -6485,12 +6521,10 @@ linux_read_loadmap (const char *annex, CORE_ADDR offset,
   memcpy (myaddr, (char *) data + offset, copy_length);
   return copy_length;
 }
-#else
-# define linux_read_loadmap NULL
 #endif /* defined PT_GETDSBT || defined PTRACE_GETFDPIC */
 
-static void
-linux_process_qsupported (char **features, int count)
+void
+linux_process_target::process_qsupported (char **features, int count)
 {
   if (the_low_target.process_qsupported != NULL)
     the_low_target.process_qsupported (features, count);
@@ -6512,17 +6546,17 @@ linux_get_ipa_tdesc_idx (void)
   return (*the_low_target.get_ipa_tdesc_idx) ();
 }
 
-static int
-linux_supports_tracepoints (void)
+bool
+linux_process_target::supports_tracepoints ()
 {
   if (*the_low_target.supports_tracepoints == NULL)
-    return 0;
+    return false;
 
   return (*the_low_target.supports_tracepoints) ();
 }
 
-static CORE_ADDR
-linux_read_pc (struct regcache *regcache)
+CORE_ADDR
+linux_process_target::read_pc (regcache *regcache)
 {
   if (the_low_target.get_pc == NULL)
     return 0;
@@ -6530,16 +6564,22 @@ linux_read_pc (struct regcache *regcache)
   return (*the_low_target.get_pc) (regcache);
 }
 
-static void
-linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
+void
+linux_process_target::write_pc (regcache *regcache, CORE_ADDR pc)
 {
   gdb_assert (the_low_target.set_pc != NULL);
 
   (*the_low_target.set_pc) (regcache, pc);
 }
 
-static int
-linux_thread_stopped (struct thread_info *thread)
+bool
+linux_process_target::supports_thread_stopped ()
+{
+  return true;
+}
+
+bool
+linux_process_target::thread_stopped (thread_info *thread)
 {
   return get_thread_lwp (thread)->stopped;
 }
@@ -7415,30 +7455,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  hostio_last_error_from_errno,
-  linux_qxfer_osdata,
-  linux_xfer_siginfo,
-  linux_supports_non_stop,
-  linux_async,
-  linux_start_non_stop,
-  linux_supports_multi_process,
-  linux_supports_fork_events,
-  linux_supports_vfork_events,
-  linux_supports_exec_events,
-  linux_handle_new_gdb_connection,
-#ifdef USE_THREAD_DB
-  thread_db_handle_monitor_command,
-#else
-  NULL,
-#endif
-  linux_common_core_of_thread,
-  linux_read_loadmap,
-  linux_process_qsupported,
-  linux_supports_tracepoints,
-  linux_read_pc,
-  linux_write_pc,
-  linux_thread_stopped,
-  NULL,
   linux_pause_all,
   linux_unpause_all,
   linux_stabilize_threads,
This page took 0.027411 seconds and 4 git commands to generate.