public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 27/58] gdbserver: turn target op 'qxfer_osdata' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (3 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 02/58] gdbserver: turn target op 'create_inferior' " Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 13/58] gdbserver: turn prepare_to_access_memory & done_accessing_memory into methods Tankut Baris Aktemur
                   ` (54 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's qxfer_osdata op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_qxfer_osdata'.
	* target.cc (process_target::qxfer_osdata): Define.
	(process_target::supports_qxfer_osdata): Define.

	Update the derived classes and callers below.

	* server.cc (handle_qxfer_osdata): Update.
	(handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_qxfer_osdata): Define.
	(linux_qxfer_osdata): Turn into ...
	(linux_process_target::qxfer_osdata): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 16 +++++++++++-----
 gdbserver/linux-low.h  |  6 ++++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.cc    | 14 ++++++++++++++
 gdbserver/target.h     | 13 ++++++++-----
 gdbserver/win32-low.cc |  1 -
 8 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 789496719dc..7c15781c48e 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6141,10 +6141,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);
 }
@@ -7410,7 +7417,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_qxfer_osdata,
   linux_xfer_siginfo,
   linux_supports_non_stop,
   linux_async,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 3c2fdaf8fc3..892767140e1 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -345,6 +345,12 @@ public:
 
   int get_tls_address (thread_info *thread, CORE_ADDR offset,
 		       CORE_ADDR load_module, CORE_ADDR *address) override;
+
+  bool supports_qxfer_osdata () override;
+
+  int qxfer_osdata (const char *annex, unsigned char *readbuf,
+		    unsigned const char *writebuf,
+		    CORE_ADDR offset, int len) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 0e904d07328..ecd7476db45 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* qxfer_osdata */
   NULL,  /* qxfer_siginfo */
   NULL,  /* supports_non_stop */
   NULL,  /* async */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index ec0b477abe5..fffe6313305 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -956,7 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* nto_qxfer_osdata */
   NULL, /* xfer_siginfo */
   nto_supports_non_stop,
   NULL, /* async */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 01d41af0f89..59eb1c0c3d7 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1587,10 +1587,10 @@ handle_qxfer_osdata (const char *annex,
 		     gdb_byte *readbuf, const gdb_byte *writebuf,
 		     ULONGEST offset, LONGEST len)
 {
-  if (the_target->qxfer_osdata == NULL || writebuf != NULL)
+  if (!the_target->pt->supports_qxfer_osdata () || writebuf != NULL)
     return -2;
 
-  return (*the_target->qxfer_osdata) (annex, readbuf, NULL, offset, len);
+  return the_target->pt->qxfer_osdata (annex, readbuf, NULL, offset, len);
 }
 
 /* Handle qXfer:siginfo:read and qXfer:siginfo:write.  */
@@ -2392,7 +2392,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (cs.transport_is_reliable)
 	strcat (own_buf, ";QStartNoAckMode+");
 
-      if (the_target->qxfer_osdata != NULL)
+      if (the_target->pt->supports_qxfer_osdata ())
 	strcat (own_buf, ";qXfer:osdata:read+");
 
       if (target_supports_multi_process ())
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index e09ee7d0fa4..c6ed544e669 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -513,3 +513,17 @@ process_target::hostio_last_error (char *buf)
 {
   hostio_last_error_from_errno (buf);
 }
+
+bool
+process_target::supports_qxfer_osdata ()
+{
+  return false;
+}
+
+int
+process_target::qxfer_osdata (const char *annex, unsigned char *readbuf,
+			      unsigned const char *writebuf,
+			      CORE_ADDR offset, int len)
+{
+  gdb_assert_not_reached ("target op qxfer_osdata not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 5f603fdf0bc..53f88a02bac 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,11 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read/Write OS data using qXfer packets.  */
-  int (*qxfer_osdata) (const char *annex, unsigned char *readbuf,
-		       unsigned const char *writebuf, CORE_ADDR offset,
-		       int len);
-
   /* Read/Write extra signal info.  */
   int (*qxfer_siginfo) (const char *annex, unsigned char *readbuf,
 			unsigned const char *writebuf,
@@ -479,6 +474,14 @@ public:
   /* Fill BUF with an hostio error packet representing the last hostio
      error.  */
   virtual void hostio_last_error (char *buf);
+
+  /* Return true if the qxfer_osdata target op is supported.  */
+  virtual bool supports_qxfer_osdata ();
+
+  /* Read/Write OS data using qXfer packets.  */
+  virtual int qxfer_osdata (const char *annex, unsigned char *readbuf,
+			    unsigned const char *writebuf,
+			    CORE_ADDR offset, int len);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 727bc9c8c95..ce750b5e37c 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1844,7 +1844,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* qxfer_osdata */
   win32_xfer_siginfo,
   NULL, /* supports_non_stop */
   NULL, /* async */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 10/58] gdbserver: turn target op 'resume' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (6 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 08/58] gdbserver: turn target op 'join' into a method Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 14/58] gdbserver: turn target ops 'read_memory' and 'write_memory' into methods Tankut Baris Aktemur
                   ` (51 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's resume op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.

	Update the derived classes and callers below.

	* server.cc (resume): Update.
	* target.cc (target_stop_and_wait): Update.
	(target_continue_no_signal): Update.
	(target_continue): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_resume): Turn into ...
	(linux_process_target::resume): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_resume): Turn into ...
	(lynx_process_target::resume): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_resume): Turn into ...
	(nto_process_target::resume): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_resume): Turn into ...
	(win32_process_target::resume): ... this.
	(win32_process_target::detach): Update.
	(do_initial_child_stuff): Update.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc |  6 ++----
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  5 ++---
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/nto-low.cc   |  5 ++---
 gdbserver/nto-low.h    |  2 ++
 gdbserver/server.cc    |  2 +-
 gdbserver/target.cc    |  6 +++---
 gdbserver/target.h     |  7 +++----
 gdbserver/win32-low.cc | 10 ++++------
 gdbserver/win32-low.h  |  2 ++
 11 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index f7b1fc095fd..b2e06262464 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -262,7 +262,6 @@ static int stabilizing_threads;
 
 static void linux_resume_one_lwp (struct lwp_info *lwp,
 				  int step, int signal, siginfo_t *info);
-static void linux_resume (struct thread_resume *resume_info, size_t n);
 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);
@@ -5002,8 +5001,8 @@ linux_resume_one_thread (thread_info *thread, bool leave_all_stopped)
   lwp->resume = NULL;
 }
 
-static void
-linux_resume (struct thread_resume *resume_info, size_t n)
+void
+linux_process_target::resume (thread_resume *resume_info, size_t n)
 {
   struct thread_info *need_step_over = NULL;
 
@@ -7359,7 +7358,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_resume,
   linux_wait,
   linux_fetch_registers,
   linux_store_registers,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index a11964d61ef..a750f7cca83 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -286,6 +286,8 @@ public:
   void join (int pid) override;
 
   bool thread_alive (ptid_t pid) override;
+
+  void resume (thread_resume *resume_info, size_t n) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 24908786fad..9fc41e4ce99 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -326,8 +326,8 @@ lynx_process_target::attach (unsigned long pid)
 
 /* Implement the resume target_ops method.  */
 
-static void
-lynx_resume (struct thread_resume *resume_info, size_t n)
+void
+lynx_process_target::resume (thread_resume *resume_info, size_t n)
 {
   ptid_t ptid = resume_info[0].thread;
   const int request
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_resume,
   lynx_wait,
   lynx_fetch_registers,
   lynx_store_registers,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index b12e6cd2721..4a5e4ba6f8d 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -72,6 +72,8 @@ public:
   void join (int pid) override;
 
   bool thread_alive (ptid_t pid) override;
+
+  void resume (thread_resume *resume_info, size_t n) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 4153a4adde3..d9981540308 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -451,8 +451,8 @@ nto_process_target::thread_alive (ptid_t ptid)
 
 /* Resume inferior's execution.  */
 
-static void
-nto_resume (struct thread_resume *resume_info, size_t n)
+void
+nto_process_target::resume (thread_resume *resume_info, size_t n)
 {
   /* We can only work in all-stop mode.  */
   procfs_status status;
@@ -941,7 +941,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_resume,
   nto_wait,
   nto_fetch_registers,
   nto_store_registers,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index e861b5e885c..5b32ae7c514 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -62,6 +62,8 @@ public:
   void join (int pid) override;
 
   bool thread_alive (ptid_t pid) override;
+
+  void resume (thread_resume *resume_info, size_t n) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 73f8e185477..92feff36516 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2847,7 +2847,7 @@ resume (struct thread_resume *actions, size_t num_actions)
       enable_async_io ();
     }
 
-  (*the_target->resume) (actions, num_actions);
+  the_target->pt->resume (actions, num_actions);
 
   if (non_stop)
     write_ok (cs.own_buf);
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index f6d8d927b85..eca53de982e 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -211,7 +211,7 @@ target_stop_and_wait (ptid_t ptid)
   resume_info.thread = ptid;
   resume_info.kind = resume_stop;
   resume_info.sig = GDB_SIGNAL_0;
-  (*the_target->resume) (&resume_info, 1);
+  the_target->pt->resume (&resume_info, 1);
 
   non_stop = true;
   mywait (ptid, &status, 0, 0);
@@ -244,7 +244,7 @@ target_continue_no_signal (ptid_t ptid)
   resume_info.thread = ptid;
   resume_info.kind = resume_continue;
   resume_info.sig = GDB_SIGNAL_0;
-  (*the_target->resume) (&resume_info, 1);
+  the_target->pt->resume (&resume_info, 1);
 }
 
 /* See target/target.h.  */
@@ -257,7 +257,7 @@ target_continue (ptid_t ptid, enum gdb_signal signal)
   resume_info.thread = ptid;
   resume_info.kind = resume_continue;
   resume_info.sig = gdb_signal_to_host (signal);
-  (*the_target->resume) (&resume_info, 1);
+  the_target->pt->resume (&resume_info, 1);
 }
 
 /* See target/target.h.  */
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 923c92c7cb8..f64009f7521 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Resume the inferior process.  */
-
-  void (*resume) (struct thread_resume *resume_info, size_t n);
-
   /* Wait for the inferior process or thread to change state.  Store
      status through argument pointer STATUS.
 
@@ -483,6 +479,9 @@ public:
 
   /* Return true iff the thread with process ID PID is alive.  */
   virtual bool thread_alive (ptid_t pid) = 0;
+
+  /* Resume the inferior process.  */
+  virtual void resume (thread_resume *resume_info, size_t n) = 0;
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 46f0ddd58b8..1f4af2c66c8 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -105,7 +105,6 @@ typedef BOOL (WINAPI *winapi_GenerateConsoleCtrlEvent) (DWORD, DWORD);
 
 static ptid_t win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 			  int options);
-static void win32_resume (struct thread_resume *resume_info, size_t n);
 #ifndef _WIN32_WCE
 static void win32_add_all_dlls (void);
 #endif
@@ -396,7 +395,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
 	resume.kind = resume_continue;
 	resume.sig = 0;
 
-	win32_resume (&resume, 1);
+	the_target->pt->resume (&resume, 1);
       }
     }
 
@@ -865,7 +864,7 @@ win32_process_target::detach (process_info *process)
     resume.thread = minus_one_ptid;
     resume.kind = resume_continue;
     resume.sig = 0;
-    win32_resume (&resume, 1);
+    this->resume (&resume, 1);
   }
 
   if (!DebugActiveProcessStop (current_process_id))
@@ -908,8 +907,8 @@ win32_process_target::thread_alive (ptid_t ptid)
 
 /* Resume the inferior process.  RESUME_INFO describes how we want
    to resume.  */
-static void
-win32_resume (struct thread_resume *resume_info, size_t n)
+void
+win32_process_target::resume (thread_resume *resume_info, size_t n)
 {
   DWORD tid;
   enum gdb_signal sig;
@@ -1839,7 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_resume,
   win32_wait,
   win32_fetch_inferior_registers,
   win32_store_inferior_registers,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index b222fd3b57d..fbdf3c7395a 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -121,6 +121,8 @@ public:
   void join (int pid) override;
 
   bool thread_alive (ptid_t pid) override;
+
+  void resume (thread_resume *resume_info, size_t n) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 02/58] gdbserver: turn target op 'create_inferior' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (2 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 03/58] gdbserver: turn target op 'post_create_inferior' " Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 27/58] gdbserver: turn target op 'qxfer_osdata' " Tankut Baris Aktemur
                   ` (55 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's create_inferior op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(create_inferior): Rename the macro to ...
	(target_create_inferior): ... this.

	Update the derived classes and callers below.

	* server.cc (handle_v_run): Update.
	(captured_main): Update.
	(process_serial_event): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_create_inferior): Turn into ...
	(linux_process_target::create_inferior): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_create_inferior): Turn into ...
	(lynx_process_target::create_inferior): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_create_inferior): Turn into ...
	(nto_process_target::create_inferior): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_create_inferior): Turn into ...
	(win32_process_target::create_inferior): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc |  7 +++----
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  9 ++++-----
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/nto-low.cc   |  7 +++----
 gdbserver/nto-low.h    |  2 ++
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.h     | 26 +++++++++++++-------------
 gdbserver/win32-low.cc |  7 +++----
 gdbserver/win32-low.h  |  2 ++
 10 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 17f360639a4..0521afcfc19 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -996,9 +996,9 @@ linux_ptrace_fun ()
    PROGRAM is the name of the program to be started, and PROGRAM_ARGS
    are its arguments.  */
 
-static int
-linux_create_inferior (const char *program,
-		       const std::vector<char *> &program_args)
+int
+linux_process_target::create_inferior (const char *program,
+				       const std::vector<char *> &program_args)
 {
   client_state &cs = get_client_state ();
   struct lwp_info *new_lwp;
@@ -7359,7 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_create_inferior,
   linux_post_create_inferior,
   linux_attach,
   linux_kill,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index e6042735f38..f49af7b2be3 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -270,6 +270,8 @@ class linux_process_target : public process_target
 {
 public:
 
+  int create_inferior (const char *program,
+		       const std::vector<char *> &program_args) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index f1177920921..9566e12d2df 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -248,14 +248,14 @@ lynx_ptrace_fun ()
 
 /* Implement the create_inferior method of the target_ops vector.  */
 
-static int
-lynx_create_inferior (const char *program,
-		      const std::vector<char *> &program_args)
+int
+lynx_process_target::create_inferior (const char *program,
+				      const std::vector<char *> &program_args)
 {
   int pid;
   std::string str_program_args = stringify_argv (program_args);
 
-  lynx_debug ("lynx_create_inferior ()");
+  lynx_debug ("create_inferior ()");
 
   pid = fork_inferior (program,
 		       str_program_args.c_str (),
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_create_inferior,
   NULL,  /* post_create_inferior */
   lynx_attach,
   lynx_kill,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 923725dd003..66cfdfa870c 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -58,6 +58,8 @@ class lynx_process_target : public process_target
 {
 public:
 
+  int create_inferior (const char *program,
+		       const std::vector<char *> &program_args) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 6f12a735c12..c27126f3126 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -350,9 +350,9 @@ nto_read_auxv_from_initial_stack (CORE_ADDR initial_stack,
 /* Start inferior specified by PROGRAM, using PROGRAM_ARGS as its
    arguments.  */
 
-static int
-nto_create_inferior (const char *program,
-		     const std::vector<char *> &program_args)
+int
+nto_process_target::create_inferior (const char *program,
+				     const std::vector<char *> &program_args)
 {
   struct inheritance inherit;
   pid_t pid;
@@ -935,7 +935,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_create_inferior,
   NULL,  /* post_create_inferior */
   nto_attach,
   nto_kill,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 2695db98737..3bad08b82ac 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -48,6 +48,8 @@ class nto_process_target : public process_target
 {
 public:
 
+  int create_inferior (const char *program,
+		       const std::vector<char *> &program_args) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 3fc026f78eb..73f8e185477 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3028,7 +3028,7 @@ handle_v_run (char *own_buf)
   free_vector_argv (program_args);
   program_args = new_argv;
 
-  create_inferior (program_path.get (), program_args);
+  target_create_inferior (program_path.get (), program_args);
 
   if (cs.last_status.kind == TARGET_WAITKIND_STOPPED)
     {
@@ -3784,7 +3784,7 @@ captured_main (int argc, char *argv[])
       program_args.push_back (NULL);
 
       /* Wait till we are at first instruction in program.  */
-      create_inferior (program_path.get (), program_args);
+      target_create_inferior (program_path.get (), program_args);
 
       /* We are now (hopefully) stopped at the first instruction of
 	 the target process.  This assumes that the target process was
@@ -4303,7 +4303,7 @@ process_serial_event (void)
 	  /* Wait till we are at 1st instruction in prog.  */
 	  if (program_path.get () != NULL)
 	    {
-	      create_inferior (program_path.get (), program_args);
+	      target_create_inferior (program_path.get (), program_args);
 
 	      if (cs.last_status.kind == TARGET_WAITKIND_STOPPED)
 		{
diff --git a/gdbserver/target.h b/gdbserver/target.h
index af78d8caa90..b6d04139108 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,17 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Start a new process.
-
-     PROGRAM is a path to the program to execute.
-     PROGRAM_ARGS is a standard NULL-terminated array of arguments,
-     to be passed to the inferior as ``argv'' (along with PROGRAM).
-
-     Returns the new PID on success, -1 on failure.  Registers the new
-     process with the process list.  */
-  int (*create_inferior) (const char *program,
-			  const std::vector<char *> &program_args);
-
   /* Do additional setup after a new process is created, including
      exec-wrapper completion.  */
   void (*post_create_inferior) (void);
@@ -489,14 +478,25 @@ class process_target
 public:
 
   virtual ~process_target () = default;
+
+  /* Start a new process.
+
+     PROGRAM is a path to the program to execute.
+     PROGRAM_ARGS is a standard NULL-terminated array of arguments,
+     to be passed to the inferior as ``argv'' (along with PROGRAM).
+
+     Returns the new PID on success, -1 on failure.  Registers the new
+     process with the process list.  */
+  virtual int create_inferior (const char *program,
+			       const std::vector<char *> &program_args) = 0;
 };
 
 extern process_stratum_target *the_target;
 
 void set_target_ops (process_stratum_target *);
 
-#define create_inferior(program, program_args)	\
-  (*the_target->create_inferior) (program, program_args)
+#define target_create_inferior(program, program_args)	\
+  the_target->pt->create_inferior (program, program_args)
 
 #define target_post_create_inferior()			 \
   do							 \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 2a7b2964d92..ecef54c461e 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -633,9 +633,9 @@ Could not convert the expanded inferior cwd to wide-char."));
    PROGRAM_ARGS is the vector containing the inferior's args.
    Returns the new PID on success, -1 on failure.  Registers the new
    process with the process list.  */
-static int
-win32_create_inferior (const char *program,
-		       const std::vector<char *> &program_args)
+int
+win32_process_target::create_inferior (const char *program,
+				       const std::vector<char *> &program_args)
 {
   client_state &cs = get_client_state ();
 #ifndef USE_WIN32API
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_create_inferior,
   NULL,  /* post_create_inferior */
   win32_attach,
   win32_kill,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index ff96f804fbd..c922d735068 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -107,6 +107,8 @@ class win32_process_target : public process_target
 {
 public:
 
+  int create_inferior (const char *program,
+		       const std::vector<char *> &program_args) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 03/58] gdbserver: turn target op 'post_create_inferior' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 15/58] gdbserver: turn target op 'look_up_symbols' into a method Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 09/58] gdbserver: turn target op 'thread_alive' " Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 02/58] gdbserver: turn target op 'create_inferior' " Tankut Baris Aktemur
                   ` (56 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's post_create_inferior op into a method
	of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_post_create_inferior): Update the macro.
	* target.cc (process_target::post_create_inferior): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_post_create_inferior): Turn into ...
	(linux_process_target::post_create_inferior): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/target.cc    |  9 +++++++++
 gdbserver/target.h     | 14 +++++---------
 gdbserver/win32-low.cc |  1 -
 7 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 0521afcfc19..2e3daa2733f 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1029,8 +1029,8 @@ linux_process_target::create_inferior (const char *program,
 
 /* Implement the post_create_inferior target_ops method.  */
 
-static void
-linux_post_create_inferior (void)
+void
+linux_process_target::post_create_inferior ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
 
@@ -7359,7 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_post_create_inferior,
   linux_attach,
   linux_kill,
   linux_detach,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index f49af7b2be3..870a0d4d863 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -272,6 +272,8 @@ public:
 
   int create_inferior (const char *program,
 		       const std::vector<char *> &program_args) override;
+
+  void post_create_inferior () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 9566e12d2df..d9f96de70f6 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* post_create_inferior */
   lynx_attach,
   lynx_kill,
   lynx_detach,
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index c27126f3126..c295be732df 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -935,7 +935,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL,  /* post_create_inferior */
   nto_attach,
   nto_kill,
   nto_detach,
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index a4593cf6df9..81092e81ea4 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -393,3 +393,12 @@ target_terminal::info (const char *arg, int from_tty)
 {
   /* Placeholder.  */
 }
+
+/* Default implementations of target ops.
+   See target.h for definitions.  */
+
+void
+process_target::post_create_inferior ()
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index b6d04139108..87036e83846 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Do additional setup after a new process is created, including
-     exec-wrapper completion.  */
-  void (*post_create_inferior) (void);
-
   /* Attach to a running process.
 
      PID is the process ID to attach to, specified by the user
@@ -489,6 +485,10 @@ public:
      process with the process list.  */
   virtual int create_inferior (const char *program,
 			       const std::vector<char *> &program_args) = 0;
+
+  /* Do additional setup after a new process is created, including
+     exec-wrapper completion.  */
+  virtual void post_create_inferior ();
 };
 
 extern process_stratum_target *the_target;
@@ -499,11 +499,7 @@ void set_target_ops (process_stratum_target *);
   the_target->pt->create_inferior (program, program_args)
 
 #define target_post_create_inferior()			 \
-  do							 \
-    {							 \
-      if (the_target->post_create_inferior != NULL)	 \
-	(*the_target->post_create_inferior) ();		 \
-    } while (0)
+  the_target->pt->post_create_inferior ()
 
 #define myattach(pid) \
   (*the_target->attach) (pid)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index ecef54c461e..a9b1bfb2fd6 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL,  /* post_create_inferior */
   win32_attach,
   win32_kill,
   win32_detach,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 09/58] gdbserver: turn target op 'thread_alive' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 15/58] gdbserver: turn target op 'look_up_symbols' into a method Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 03/58] gdbserver: turn target op 'post_create_inferior' " Tankut Baris Aktemur
                   ` (57 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's thread_alive op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(mythread_alive): Update the macro.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_thread_alive): Turn into ...
	(linux_process_target::thread_alive): ... this.
	(wait_for_sigstop): Update.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_thread_alive): Turn into ...
	(lynx_process_target::thread_alive): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_thread_alive): Turn into ...
	(nto_process_target::thread_alive): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_thread_alive): Turn into ...
	(win32_process_target::thread_alive): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc | 10 +++++-----
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  5 ++---
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/nto-low.cc   |  7 +++----
 gdbserver/nto-low.h    |  2 ++
 gdbserver/target.h     |  9 ++++-----
 gdbserver/win32-low.cc |  7 +++----
 gdbserver/win32-low.h  |  2 ++
 9 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 39099cb37dd..f7b1fc095fd 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1681,9 +1681,10 @@ linux_process_target::join (int pid)
   } while (ret != -1 || errno != ECHILD);
 }
 
-/* Return nonzero if the given thread is still alive.  */
-static int
-linux_thread_alive (ptid_t ptid)
+/* Return true if the given thread is still alive.  */
+
+bool
+linux_process_target::thread_alive (ptid_t ptid)
 {
   struct lwp_info *lwp = find_lwp_pid (ptid);
 
@@ -4004,7 +4005,7 @@ wait_for_sigstop (void)
 				       &wstat, __WALL);
   gdb_assert (ret == -1);
 
-  if (saved_thread == NULL || linux_thread_alive (saved_tid))
+  if (saved_thread == NULL || mythread_alive (saved_tid))
     current_thread = saved_thread;
   else
     {
@@ -7358,7 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_thread_alive,
   linux_resume,
   linux_wait,
   linux_fetch_registers,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 772da9ef30b..a11964d61ef 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -284,6 +284,8 @@ public:
   void mourn (process_info *proc) override;
 
   void join (int pid) override;
+
+  bool thread_alive (ptid_t pid) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index b2ce1559e85..24908786fad 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -570,8 +570,8 @@ lynx_process_target::join (int pid)
 
 /* Implement the thread_alive target_ops method.  */
 
-static int
-lynx_thread_alive (ptid_t ptid)
+bool
+lynx_process_target::thread_alive (ptid_t ptid)
 {
   /* The list of threads is updated at the end of each wait, so it
      should be up to date.  No need to re-fetch it.  */
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_thread_alive,
   lynx_resume,
   lynx_wait,
   lynx_fetch_registers,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 3f42407a4d7..b12e6cd2721 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -70,6 +70,8 @@ public:
   void mourn (process_info *proc) override;
 
   void join (int pid) override;
+
+  bool thread_alive (ptid_t pid) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 2d6aaa0368e..4153a4adde3 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -431,10 +431,10 @@ nto_process_target::join (int pid)
 
 /* Check if the given thread is alive.  
 
-   Return 1 if alive, 0 otherwise.  */
+   Return true if alive, false otherwise.  */
 
-static int
-nto_thread_alive (ptid_t ptid)
+bool
+nto_process_target::thread_alive (ptid_t ptid)
 {
   int res;
 
@@ -941,7 +941,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_thread_alive,
   nto_resume,
   nto_wait,
   nto_fetch_registers,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 6e3471cc151..e861b5e885c 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -60,6 +60,8 @@ public:
   void mourn (process_info *proc) override;
 
   void join (int pid) override;
+
+  bool thread_alive (ptid_t pid) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 32905b176da..923c92c7cb8 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return 1 iff the thread with process ID PID is alive.  */
-
-  int (*thread_alive) (ptid_t pid);
-
   /* Resume the inferior process.  */
 
   void (*resume) (struct thread_resume *resume_info, size_t n);
@@ -484,6 +480,9 @@ public:
 
   /* Wait for process PID to exit.  */
   virtual void join (int pid) = 0;
+
+  /* Return true iff the thread with process ID PID is alive.  */
+  virtual bool thread_alive (ptid_t pid) = 0;
 };
 
 extern process_stratum_target *the_target;
@@ -524,7 +523,7 @@ int kill_inferior (process_info *proc);
   the_target->pt->detach (proc)
 
 #define mythread_alive(pid) \
-  (*the_target->thread_alive) (pid)
+  the_target->pt->thread_alive (pid)
 
 #define fetch_inferior_registers(regcache, regno)	\
   (*the_target->fetch_registers) (regcache, regno)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 0dd1137db87..46f0ddd58b8 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -897,9 +897,9 @@ win32_process_target::join (int pid)
     }
 }
 
-/* Return 1 iff the thread with thread ID TID is alive.  */
-static int
-win32_thread_alive (ptid_t ptid)
+/* Return true iff the thread with thread ID TID is alive.  */
+bool
+win32_process_target::thread_alive (ptid_t ptid)
 {
   /* Our thread list is reliable; don't bother to poll target
      threads.  */
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_thread_alive,
   win32_resume,
   win32_wait,
   win32_fetch_inferior_registers,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index a9da8d3a11f..b222fd3b57d 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -119,6 +119,8 @@ public:
   void mourn (process_info *proc) override;
 
   void join (int pid) override;
+
+  bool thread_alive (ptid_t pid) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 08/58] gdbserver: turn target op 'join' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (5 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 13/58] gdbserver: turn prepare_to_access_memory & done_accessing_memory into methods Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 10/58] gdbserver: turn target op 'resume' " Tankut Baris Aktemur
                   ` (52 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's join op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(join_inferior): Update the macro.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_join): Turn into ...
	(linux_process_target::join): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_join): Turn into ...
	(lynx_process_target::join): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_process_target::join): Define.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_join): Turn into ...
	(win32_process_target::join): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc | 5 ++---
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 5 ++---
 gdbserver/lynx-low.h   | 2 ++
 gdbserver/nto-low.cc   | 7 ++++++-
 gdbserver/nto-low.h    | 2 ++
 gdbserver/target.h     | 9 ++++-----
 gdbserver/win32-low.cc | 5 ++---
 gdbserver/win32-low.h  | 2 ++
 9 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 66790ee5ce1..39099cb37dd 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1669,8 +1669,8 @@ linux_process_target::mourn (process_info *process)
   remove_process (process);
 }
 
-static void
-linux_join (int pid)
+void
+linux_process_target::join (int pid)
 {
   int status, ret;
 
@@ -7358,7 +7358,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_join,
   linux_thread_alive,
   linux_resume,
   linux_wait,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 8f43812766e..772da9ef30b 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -282,6 +282,8 @@ public:
   int detach (process_info *proc) override;
 
   void mourn (process_info *proc) override;
+
+  void join (int pid) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 558f4aea8db..b2ce1559e85 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -561,8 +561,8 @@ lynx_process_target::mourn (struct process_info *proc)
 
 /* Implement the join target_ops method.  */
 
-static void
-lynx_join (int pid)
+void
+lynx_process_target::join (int pid)
 {
   /* The PTRACE_DETACH is sufficient to detach from the process.
      So no need to do anything extra.  */
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_join,
   lynx_thread_alive,
   lynx_resume,
   lynx_wait,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 6cffe6d811e..3f42407a4d7 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -68,6 +68,8 @@ public:
   int detach (process_info *proc) override;
 
   void mourn (process_info *proc) override;
+
+  void join (int pid) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 263f73d42c3..2d6aaa0368e 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -423,6 +423,12 @@ nto_process_target::mourn (struct process_info *process)
   remove_process (process);
 }
 
+void
+nto_process_target::join (int pid)
+{
+  error (_("nto target does not implement the join op"));
+}
+
 /* Check if the given thread is alive.  
 
    Return 1 if alive, 0 otherwise.  */
@@ -935,7 +941,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* nto_join */
   nto_thread_alive,
   nto_resume,
   nto_wait,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 69728b82795..6e3471cc151 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -58,6 +58,8 @@ public:
   int detach (process_info *proc) override;
 
   void mourn (process_info *proc) override;
+
+  void join (int pid) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.h b/gdbserver/target.h
index d6b7377722a..32905b176da 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Wait for process PID to exit.  */
-
-  void (*join) (int pid);
-
   /* Return 1 iff the thread with process ID PID is alive.  */
 
   int (*thread_alive) (ptid_t pid);
@@ -485,6 +481,9 @@ public:
 
   /* The inferior process has died.  Do what is right.  */
   virtual void mourn (process_info *proc) = 0;
+
+  /* Wait for process PID to exit.  */
+  virtual void join (int pid) = 0;
 };
 
 extern process_stratum_target *the_target;
@@ -534,7 +533,7 @@ int kill_inferior (process_info *proc);
   (*the_target->store_registers) (regcache, regno)
 
 #define join_inferior(pid) \
-  (*the_target->join) (pid)
+  the_target->pt->join (pid)
 
 #define target_supports_non_stop() \
   (the_target->supports_non_stop ? (*the_target->supports_non_stop ) () : 0)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 9bccc1bb9c7..0dd1137db87 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -886,8 +886,8 @@ win32_process_target::mourn (struct process_info *process)
 
 /* Implementation of target_ops::join.  */
 
-static void
-win32_join (int pid)
+void
+win32_process_target::join (int pid)
 {
   HANDLE h = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid);
   if (h != NULL)
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_join,
   win32_thread_alive,
   win32_resume,
   win32_wait,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index d07d99881e6..a9da8d3a11f 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -117,6 +117,8 @@ public:
   int detach (process_info *proc) override;
 
   void mourn (process_info *proc) override;
+
+  void join (int pid) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 13/58] gdbserver: turn prepare_to_access_memory & done_accessing_memory into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (4 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 27/58] gdbserver: turn target op 'qxfer_osdata' " Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 08/58] gdbserver: turn target op 'join' into a method Tankut Baris Aktemur
                   ` (53 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's prepare_to_access_memory and
	done_accessing_memory ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	* target.cc (process_target::prepare_to_access_memory): Define.
	(process_target::done_accessing_memory): Define.
	(prepare_to_access_memory): Update.
	(done_accessing_memory): Update.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_prepare_to_access_memory): Turn into ...
	(linux_process_target::prepare_to_access_memory): ... this.
	(linux_done_accessing_memory): Turn into ...
	(linux_process_target::done_accessing_memory): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 10 ++++------
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  |  2 --
 gdbserver/nto-low.cc   |  2 --
 gdbserver/target.cc    | 26 ++++++++++++++++----------
 gdbserver/target.h     | 32 +++++++++++++++-----------------
 gdbserver/win32-low.cc |  2 --
 7 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 7cf7d90fdbc..6f408ad9333 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6505,8 +6505,8 @@ linux_unpause_all (int unfreeze)
   unstop_all_lwps (unfreeze, NULL);
 }
 
-static int
-linux_prepare_to_access_memory (void)
+int
+linux_process_target::prepare_to_access_memory ()
 {
   /* Neither ptrace nor /proc/PID/mem allow accessing memory through a
      running LWP.  */
@@ -6515,8 +6515,8 @@ linux_prepare_to_access_memory (void)
   return 0;
 }
 
-static void
-linux_done_accessing_memory (void)
+void
+linux_process_target::done_accessing_memory ()
 {
   /* Neither ptrace nor /proc/PID/mem allow accessing memory through a
      running LWP.  */
@@ -7359,8 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_prepare_to_access_memory,
-  linux_done_accessing_memory,
   linux_read_memory,
   linux_write_memory,
   linux_look_up_symbols,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 85b5c8a62d1..2b7b357ba67 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -295,6 +295,10 @@ public:
   void fetch_registers (regcache *regcache, int regno) override;
 
   void store_registers (regcache *regcache, int regno) override;
+
+  int prepare_to_access_memory () override;
+
+  void done_accessing_memory () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 5c46567f9ed..e243764a863 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -727,8 +727,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* prepare_to_access_memory */
-  NULL,  /* done_accessing_memory */
   lynx_read_memory,
   lynx_write_memory,
   NULL,  /* look_up_symbols */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index a051f36eecc..36bd40c20d8 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -941,8 +941,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* prepare_to_access_memory */
-  NULL, /* done_accessing_memory */
   nto_read_memory,
   nto_write_memory,
   NULL, /* nto_look_up_symbols */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index b73c4465f1c..f88e9faf191 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -57,14 +57,9 @@ prepare_to_access_memory (void)
      it.  */
   prev_general_thread = cs.general_thread;
 
-  if (the_target->prepare_to_access_memory != NULL)
-    {
-      int res;
-
-      res = the_target->prepare_to_access_memory ();
-      if (res != 0)
-	return res;
-    }
+  int res = the_target->pt->prepare_to_access_memory ();
+  if (res != 0)
+    return res;
 
   for_each_thread (prev_general_thread.pid (), [&] (thread_info *thread)
     {
@@ -114,8 +109,7 @@ done_accessing_memory (void)
 {
   client_state &cs = get_client_state ();
 
-  if (the_target->done_accessing_memory != NULL)
-    the_target->done_accessing_memory ();
+  the_target->pt->done_accessing_memory ();
 
   /* Restore the previous selected thread.  */
   cs.general_thread = prev_general_thread;
@@ -402,3 +396,15 @@ process_target::post_create_inferior ()
 {
   /* Nop.  */
 }
+
+int
+process_target::prepare_to_access_memory ()
+{
+  return 0;
+}
+
+void
+process_target::done_accessing_memory ()
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index e42c7509bb1..e89ddbb0048 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,23 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Prepare to read or write memory from the inferior process.
-     Targets use this to do what is necessary to get the state of the
-     inferior such that it is possible to access memory.
-
-     This should generally only be called from client facing routines,
-     such as gdb_read_memory/gdb_write_memory, or the GDB breakpoint
-     insertion routine.
-
-     Like `read_memory' and `write_memory' below, returns 0 on success
-     and errno on failure.  */
-
-  int (*prepare_to_access_memory) (void);
-
-  /* Undo the effects of prepare_to_access_memory.  */
-
-  void (*done_accessing_memory) (void);
-
   /* Read memory from the inferior process.  This should generally be
      called through read_inferior_memory, which handles breakpoint shadowing.
 
@@ -480,6 +463,21 @@ public:
 
      If REGNO is -1, store all registers; otherwise, store at least REGNO.  */
   virtual void store_registers (regcache *regcache, int regno) = 0;
+
+  /* Prepare to read or write memory from the inferior process.
+     Targets use this to do what is necessary to get the state of the
+     inferior such that it is possible to access memory.
+
+     This should generally only be called from client facing routines,
+     such as gdb_read_memory/gdb_write_memory, or the GDB breakpoint
+     insertion routine.
+
+     Like `read_memory' and `write_memory' below, returns 0 on success
+     and errno on failure.  */
+  virtual int prepare_to_access_memory ();
+
+  /* Undo the effects of prepare_to_access_memory.  */
+  virtual void done_accessing_memory ();
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 9e4e4c368ca..4a8e64d11ae 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1837,8 +1837,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* prepare_to_access_memory */
-  NULL, /* done_accessing_memory */
   win32_read_inferior_memory,
   win32_write_inferior_memory,
   NULL, /* lookup_symbols */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 12/58] gdbserver: turn target ops 'fetch_registers' and 'store_registers' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (8 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 14/58] gdbserver: turn target ops 'read_memory' and 'write_memory' into methods Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 07/58] gdbserver: turn target op 'mourn' into a method Tankut Baris Aktemur
                   ` (49 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's fetch_registers and store_registers
	ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(fetch_inferior_registers): Update the macro.
	(store_inferior_registers): Update the macro.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_fetch_registers): Turn into ...
	(linux_process_target::fetch_registers): ... this.
	(linux_store_registers): Turn into ...
	(linux_process_target::store_registers): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_fetch_registers): Turn into ...
	(lynx_process_target::fetch_registers): ... this.
	(lynx_store_registers): Turn into ...
	(lynx_process_target::store_registers): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_fetch_registers): Turn into ...
	(nto_process_target::fetch_registers): ... this.
	(nto_store_registers): Turn into ...
	(nto_process_target::store_registers): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_fetch_inferior_registers): Turn into ...
	(win32_process_target::fetch_registers): ... this.
	(win32_store_inferior_registers): Turn into ...
	(win32_process_target::store_registers): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc | 10 ++++------
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  | 14 ++++++--------
 gdbserver/lynx-low.h   |  4 ++++
 gdbserver/nto-low.cc   | 10 ++++------
 gdbserver/nto-low.h    |  4 ++++
 gdbserver/target.h     | 26 ++++++++++++--------------
 gdbserver/win32-low.cc | 10 ++++------
 gdbserver/win32-low.h  |  4 ++++
 9 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 49511125897..7cf7d90fdbc 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5650,8 +5650,8 @@ usr_store_inferior_registers (const struct regs_info *regs_info,
 #endif
 
 
-static void
-linux_fetch_registers (struct regcache *regcache, int regno)
+void
+linux_process_target::fetch_registers (regcache *regcache, int regno)
 {
   int use_regsets;
   int all = 0;
@@ -5683,8 +5683,8 @@ linux_fetch_registers (struct regcache *regcache, int regno)
     }
 }
 
-static void
-linux_store_registers (struct regcache *regcache, int regno)
+void
+linux_process_target::store_registers (regcache *regcache, int regno)
 {
   int use_regsets;
   int all = 0;
@@ -7359,8 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_fetch_registers,
-  linux_store_registers,
   linux_prepare_to_access_memory,
   linux_done_accessing_memory,
   linux_read_memory,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index d1d89106e50..85b5c8a62d1 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -291,6 +291,10 @@ public:
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
 	       int options) override;
+
+  void fetch_registers (regcache *regcache, int regno) override;
+
+  void store_registers (regcache *regcache, int regno) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index f38c3110cbd..5c46567f9ed 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -581,13 +581,13 @@ lynx_process_target::thread_alive (ptid_t ptid)
 
 /* Implement the fetch_registers target_ops method.  */
 
-static void
-lynx_fetch_registers (struct regcache *regcache, int regno)
+void
+lynx_process_target::fetch_registers (regcache *regcache, int regno)
 {
   struct lynx_regset_info *regset = lynx_target_regsets;
   ptid_t inferior_ptid = ptid_of (current_thread);
 
-  lynx_debug ("lynx_fetch_registers (regno = %d)", regno);
+  lynx_debug ("fetch_registers (regno = %d)", regno);
 
   while (regset->size >= 0)
     {
@@ -606,13 +606,13 @@ lynx_fetch_registers (struct regcache *regcache, int regno)
 
 /* Implement the store_registers target_ops method.  */
 
-static void
-lynx_store_registers (struct regcache *regcache, int regno)
+void
+lynx_process_target::store_registers (regcache *regcache, int regno)
 {
   struct lynx_regset_info *regset = lynx_target_regsets;
   ptid_t inferior_ptid = ptid_of (current_thread);
 
-  lynx_debug ("lynx_store_registers (regno = %d)", regno);
+  lynx_debug ("store_registers (regno = %d)", regno);
 
   while (regset->size >= 0)
     {
@@ -727,8 +727,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_fetch_registers,
-  lynx_store_registers,
   NULL,  /* prepare_to_access_memory */
   NULL,  /* done_accessing_memory */
   lynx_read_memory,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 35714713fd2..ea6cf008f5b 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -77,6 +77,10 @@ public:
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
 	       int options) override;
+
+  void fetch_registers (regcache *regcache, int regno) override;
+
+  void store_registers (regcache *regcache, int regno) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 6cac6eb4329..a051f36eecc 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -623,8 +623,8 @@ nto_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
 /* Fetch inferior's registers for currently selected thread (CURRENT_INFERIOR).
    If REGNO is -1, fetch all registers, or REGNO register only otherwise.  */
 
-static void
-nto_fetch_registers (struct regcache *regcache, int regno)
+void
+nto_process_target::fetch_registers (regcache *regcache, int regno)
 {
   int regsize;
   procfs_greg greg;
@@ -671,8 +671,8 @@ nto_fetch_registers (struct regcache *regcache, int regno)
 /* Store registers for currently selected thread (CURRENT_INFERIOR).  
    We always store all registers, regardless of REGNO.  */
 
-static void
-nto_store_registers (struct regcache *regcache, int regno)
+void
+nto_process_target::store_registers (regcache *regcache, int regno)
 {
   procfs_greg greg;
   int err;
@@ -941,8 +941,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_fetch_registers,
-  nto_store_registers,
   NULL, /* prepare_to_access_memory */
   NULL, /* done_accessing_memory */
   nto_read_memory,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 94837ab6051..f630360a2f4 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -67,6 +67,10 @@ public:
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
 	       int options) override;
+
+  void fetch_registers (regcache *regcache, int regno) override;
+
+  void store_registers (regcache *regcache, int regno) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 16daf93440e..e42c7509bb1 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,18 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Fetch registers from the inferior process.
-
-     If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO.  */
-
-  void (*fetch_registers) (struct regcache *regcache, int regno);
-
-  /* Store registers to the inferior process.
-
-     If REGNO is -1, store all registers; otherwise, store at least REGNO.  */
-
-  void (*store_registers) (struct regcache *regcache, int regno);
-
   /* Prepare to read or write memory from the inferior process.
      Targets use this to do what is necessary to get the state of the
      inferior such that it is possible to access memory.
@@ -482,6 +470,16 @@ public:
      null_ptid/TARGET_WAITKIND_IGNORE.  */
   virtual ptid_t wait (ptid_t ptid, target_waitstatus *status,
 		       int options) = 0;
+
+  /* Fetch registers from the inferior process.
+
+     If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO.  */
+  virtual void fetch_registers (regcache *regcache, int regno) = 0;
+
+  /* Store registers to the inferior process.
+
+     If REGNO is -1, store all registers; otherwise, store at least REGNO.  */
+  virtual void store_registers (regcache *regcache, int regno) = 0;
 };
 
 extern process_stratum_target *the_target;
@@ -525,10 +523,10 @@ int kill_inferior (process_info *proc);
   the_target->pt->thread_alive (pid)
 
 #define fetch_inferior_registers(regcache, regno)	\
-  (*the_target->fetch_registers) (regcache, regno)
+  the_target->pt->fetch_registers (regcache, regno)
 
 #define store_inferior_registers(regcache, regno) \
-  (*the_target->store_registers) (regcache, regno)
+  the_target->pt->store_registers (regcache, regno)
 
 #define join_inferior(pid) \
   the_target->pt->join (pid)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index e7df444451d..9e4e4c368ca 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1659,16 +1659,16 @@ win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
 
 /* Fetch registers from the inferior process.
    If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO.  */
-static void
-win32_fetch_inferior_registers (struct regcache *regcache, int regno)
+void
+win32_process_target::fetch_registers (regcache *regcache, int regno)
 {
   child_fetch_inferior_registers (regcache, regno);
 }
 
 /* Store registers to the inferior process.
    If REGNO is -1, store all registers; otherwise, store at least REGNO.  */
-static void
-win32_store_inferior_registers (struct regcache *regcache, int regno)
+void
+win32_process_target::store_registers (regcache *regcache, int regno)
 {
   child_store_inferior_registers (regcache, regno);
 }
@@ -1837,8 +1837,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_fetch_inferior_registers,
-  win32_store_inferior_registers,
   NULL, /* prepare_to_access_memory */
   NULL, /* done_accessing_memory */
   win32_read_inferior_memory,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 9c74ffa9c58..ff3659f6dab 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -126,6 +126,10 @@ public:
 
   ptid_t wait (ptid_t ptid, target_waitstatus *status,
 	       int options) override;
+
+  void fetch_registers (regcache *regcache, int regno) override;
+
+  void store_registers (regcache *regcache, int regno) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 14/58] gdbserver: turn target ops 'read_memory' and 'write_memory' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (7 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 10/58] gdbserver: turn target op 'resume' " Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 12/58] gdbserver: turn target ops 'fetch_registers' and 'store_registers' " Tankut Baris Aktemur
                   ` (50 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's read_memory and write_memory
	ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.

	Update the derived classes and callers below.

	* linux-aarch32-low.cc (arm_breakpoint_at): Update.
	* linux-aarch64-low.cc (aarch64_breakpoint_at): Update.
	* linux-arm-low.cc (arm_sigreturn_next_pc): Update.
	(arm_get_syscall_trapinfo): Update.
	* linux-cris-low.cc (cris_breakpoint_at): Update.
	* linux-crisv32-low.cc (cris_breakpoint_at): Update.
	* linux-m32r-low.cc (m32r_breakpoint_at): Update.
	* linux-mips-low.cc (mips_breakpoint_at): Update.
	* linux-nios2-low.cc (nios2_breakpoint_at): Update.
	* linux-ppc-low.cc (ppc_breakpoint_at): Update.
	* linux-sh-low.cc (sh_breakpoint_at): Update.
	* linux-sparc-low.cc (sparc_fill_gregset_to_stack): Update.
	(sparc_store_gregset_from_stack): Update.
	(sparc_breakpoint_at): Update.
	* linux-tic6x-low.cc (tic6x_breakpoint_at): Update.
	* linux-tile-low.cc (tile_breakpoint_at): Update.
	* linux-x86-low.cc (x86_breakpoint_at): Update.
	* linux-xtensa-low.cc (xtensa_breakpoint_at): Update.
	* mem-brea.cc (insert_memory_breakpoint): Update.
	(validate_inserted_breakpoint): Update.
	* target.cc (read_inferior_memory): Update.
	(target_write_memory): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_read_memory): Make a wrapper around the read_memory target
	op call.
	(linux_process_target::read_memory): Rename from linux_read_memory.
	(linux_write_memory): Turn into ...
	(linux_process_target::write_memory): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_read_memory): Turn into ...
	(lynx_process_target::read_memory): ... this.
	(lynx_write_memory): Turn into ...
	(lynx_process_target::write_memory): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_read_memory): Turn into ...
	(nto_process_target::read_memory): ... this.
	(nto_write_memory): Turn into ...
	(nto_process_target::write_memory): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_read_inferior_memory): Turn into ...
	(win32_process_target::read_memory): ... this.
	(win32_write_inferior_memory): Turn into ...
	(win32_process_target::write_memory): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-aarch32-low.cc |  6 +++---
 gdbserver/linux-aarch64-low.cc |  4 ++--
 gdbserver/linux-arm-low.cc     |  8 ++++----
 gdbserver/linux-cris-low.cc    |  4 ++--
 gdbserver/linux-crisv32-low.cc |  4 ++--
 gdbserver/linux-low.cc         | 20 ++++++++++++------
 gdbserver/linux-low.h          |  6 ++++++
 gdbserver/linux-m32r-low.cc    |  4 ++--
 gdbserver/linux-mips-low.cc    |  2 +-
 gdbserver/linux-nios2-low.cc   |  4 ++--
 gdbserver/linux-ppc-low.cc     |  2 +-
 gdbserver/linux-sh-low.cc      |  2 +-
 gdbserver/linux-sparc-low.cc   |  6 +++---
 gdbserver/linux-tic6x-low.cc   |  2 +-
 gdbserver/linux-tile-low.cc    |  2 +-
 gdbserver/linux-x86-low.cc     |  2 +-
 gdbserver/linux-xtensa-low.cc  |  4 ++--
 gdbserver/lynx-low.cc          | 14 ++++++-------
 gdbserver/lynx-low.h           |  6 ++++++
 gdbserver/mem-break.cc         |  6 +++---
 gdbserver/nto-low.cc           | 12 +++++------
 gdbserver/nto-low.h            |  6 ++++++
 gdbserver/target.cc            |  4 ++--
 gdbserver/target.h             | 37 +++++++++++++++++-----------------
 gdbserver/win32-low.cc         | 13 ++++++------
 gdbserver/win32-low.h          |  6 ++++++
 26 files changed, 108 insertions(+), 78 deletions(-)

diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc
index c6a70249d3b..41e018ab528 100644
--- a/gdbserver/linux-aarch32-low.cc
+++ b/gdbserver/linux-aarch32-low.cc
@@ -192,13 +192,13 @@ arm_breakpoint_at (CORE_ADDR where)
       /* Thumb mode.  */
       unsigned short insn;
 
-      (*the_target->read_memory) (where, (unsigned char *) &insn, 2);
+      the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
       if (insn == thumb_breakpoint)
 	return 1;
 
       if (insn == thumb2_breakpoint[0])
 	{
-	  (*the_target->read_memory) (where + 2, (unsigned char *) &insn, 2);
+	  the_target->pt->read_memory (where + 2, (unsigned char *) &insn, 2);
 	  if (insn == thumb2_breakpoint[1])
 	    return 1;
 	}
@@ -208,7 +208,7 @@ arm_breakpoint_at (CORE_ADDR where)
       /* ARM mode.  */
       unsigned long insn;
 
-      (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
+      the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
       if (insn == arm_abi_breakpoint)
 	return 1;
 
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 961fd5b3cc4..97117f05780 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -192,8 +192,8 @@ aarch64_breakpoint_at (CORE_ADDR where)
     {
       gdb_byte insn[aarch64_breakpoint_len];
 
-      (*the_target->read_memory) (where, (unsigned char *) &insn,
-				  aarch64_breakpoint_len);
+      the_target->pt->read_memory (where, (unsigned char *) &insn,
+				   aarch64_breakpoint_len);
       if (memcmp (insn, aarch64_breakpoint, aarch64_breakpoint_len) == 0)
 	return 1;
 
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index 9f046c098bf..e7cc1196857 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -779,15 +779,15 @@ arm_sigreturn_next_pc (struct regcache *regcache, int svc_number,
   gdb_assert (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn);
 
   collect_register_by_name (regcache, "sp", &sp);
-  (*the_target->read_memory) (sp, (unsigned char *) &sp_data, 4);
+  the_target->pt->read_memory (sp, (unsigned char *) &sp_data, 4);
 
   pc_offset = arm_linux_sigreturn_next_pc_offset
     (sp, sp_data, svc_number, __NR_sigreturn == svc_number ? 1 : 0);
 
-  (*the_target->read_memory) (sp + pc_offset, (unsigned char *) &next_pc, 4);
+  the_target->pt->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
 
   /* Set IS_THUMB according the CPSR saved on the stack.  */
-  (*the_target->read_memory) (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
+  the_target->pt->read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
   *is_thumb = ((cpsr & CPSR_T) != 0);
 
   return next_pc;
@@ -939,7 +939,7 @@ arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
 
       collect_register_by_name (regcache, "pc", &pc);
 
-      if ((*the_target->read_memory) (pc - 4, (unsigned char *) &insn, 4))
+      if (the_target->pt->read_memory (pc - 4, (unsigned char *) &insn, 4))
 	*sysno = UNKNOWN_SYSCALL;
       else
 	{
diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc
index 8ea5af92e31..6a4e8b1946a 100644
--- a/gdbserver/linux-cris-low.cc
+++ b/gdbserver/linux-cris-low.cc
@@ -76,8 +76,8 @@ cris_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn,
-			      cris_breakpoint_len);
+  the_target->pt->read_memory (where, (unsigned char *) &insn,
+			       cris_breakpoint_len);
   if (insn == cris_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc
index facb5c5c274..fe12624c3b6 100644
--- a/gdbserver/linux-crisv32-low.cc
+++ b/gdbserver/linux-crisv32-low.cc
@@ -72,8 +72,8 @@ cris_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn,
-			      cris_breakpoint_len);
+  the_target->pt->read_memory (where, (unsigned char *) &insn,
+			       cris_breakpoint_len);
   if (insn == cris_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 6f408ad9333..1a790e5eae9 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5709,11 +5709,20 @@ linux_process_target::store_registers (regcache *regcache, int regno)
 }
 
 
-/* Copy LEN bytes from inferior's memory starting at MEMADDR
-   to debugger memory starting at MYADDR.  */
+/* 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);
+}
+
+/* Copy LEN bytes from inferior's memory starting at MEMADDR
+   to debugger memory starting at MYADDR.  */
+
+int
+linux_process_target::read_memory (CORE_ADDR memaddr,
+				   unsigned char *myaddr, int len)
 {
   int pid = lwpid_of (current_thread);
   PTRACE_XFER_TYPE *buffer;
@@ -5801,8 +5810,9 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
    memory at MEMADDR.  On failure (cannot write to the inferior)
    returns the value of errno.  Always succeeds if LEN is zero.  */
 
-static int
-linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
+int
+linux_process_target::write_memory (CORE_ADDR memaddr,
+				    const unsigned char *myaddr, int len)
 {
   int i;
   /* Round starting address down to longword boundary.  */
@@ -7359,8 +7369,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_read_memory,
-  linux_write_memory,
   linux_look_up_symbols,
   linux_request_interrupt,
   linux_read_auxv,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 2b7b357ba67..b8b10143dec 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -299,6 +299,12 @@ public:
   int prepare_to_access_memory () override;
 
   void done_accessing_memory () override;
+
+  int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+		   int len) override;
+
+  int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
+		    int len) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc
index c52e816e341..8fe8389618f 100644
--- a/gdbserver/linux-m32r-low.cc
+++ b/gdbserver/linux-m32r-low.cc
@@ -70,8 +70,8 @@ m32r_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn,
-			      m32r_breakpoint_len);
+  the_target->pt->read_memory (where, (unsigned char *) &insn,
+			       m32r_breakpoint_len);
   if (insn == m32r_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index f94e141be79..cb7eb53e3eb 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -302,7 +302,7 @@ mips_breakpoint_at (CORE_ADDR where)
 {
   unsigned int insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
+  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == mips_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc
index bfc5aee165d..6e5d3084dad 100644
--- a/gdbserver/linux-nios2-low.cc
+++ b/gdbserver/linux-nios2-low.cc
@@ -131,12 +131,12 @@ nios2_breakpoint_at (CORE_ADDR where)
 
   /* For R2, first check for the 2-byte CDX trap.n breakpoint encoding.  */
 #if defined(__nios2_arch__) && __nios2_arch__ == 2
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 2);
+  the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
   if (insn == CDX_BREAKPOINT)
     return 1;
 #endif
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
+  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == nios2_breakpoint)
     return 1;
   return 0;
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index 5d8d67bec2f..93b3511a2e1 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -277,7 +277,7 @@ ppc_breakpoint_at (CORE_ADDR where)
 {
   unsigned int insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
+  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == ppc_breakpoint)
     return 1;
   /* If necessary, recognize more trap instructions here.  GDB only uses
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index abe71ff4766..06ce8118ebf 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -76,7 +76,7 @@ sh_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 2);
+  the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
   if (insn == sh_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc
index cfa76c0b8e6..b0b6c96b3de 100644
--- a/gdbserver/linux-sparc-low.cc
+++ b/gdbserver/linux-sparc-low.cc
@@ -133,7 +133,7 @@ sparc_fill_gregset_to_stack (struct regcache *regcache, const void *buf)
   for (i = l0_regno; i <= i7_regno; i++)
     {
       collect_register (regcache, i, tmp_reg_buf);
-      (*the_target->write_memory) (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
+      the_target->pt->write_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
       addr += sizeof (tmp_reg_buf);
     }
 }
@@ -184,7 +184,7 @@ sparc_store_gregset_from_stack (struct regcache *regcache, const void *buf)
 
   for (i = l0_regno; i <= i7_regno; i++)
     {
-      (*the_target->read_memory) (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
+      the_target->pt->read_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
       supply_register (regcache, i, tmp_reg_buf);
       addr += sizeof (tmp_reg_buf);
     }
@@ -242,7 +242,7 @@ sparc_breakpoint_at (CORE_ADDR where)
 {
   unsigned char insn[INSN_SIZE];
 
-  (*the_target->read_memory) (where, (unsigned char *) insn, sizeof (insn));
+  the_target->pt->read_memory (where, (unsigned char *) insn, sizeof (insn));
 
   if (memcmp (sparc_breakpoint, insn, sizeof (insn)) == 0)
     return 1;
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index 51a31c7876a..b57f8c57710 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -241,7 +241,7 @@ tic6x_breakpoint_at (CORE_ADDR where)
 {
   unsigned int insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 4);
+  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == tic6x_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc
index cd85e945a46..baee93a5c24 100644
--- a/gdbserver/linux-tile-low.cc
+++ b/gdbserver/linux-tile-low.cc
@@ -85,7 +85,7 @@ tile_breakpoint_at (CORE_ADDR where)
 {
   uint64_t insn;
 
-  (*the_target->read_memory) (where, (unsigned char *) &insn, 8);
+  the_target->pt->read_memory (where, (unsigned char *) &insn, 8);
   if (insn == tile_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 09ec22ff678..cb2d3f59580 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -515,7 +515,7 @@ x86_breakpoint_at (CORE_ADDR pc)
 {
   unsigned char c;
 
-  (*the_target->read_memory) (pc, &c, 1);
+  the_target->pt->read_memory (pc, &c, 1);
   if (c == 0xCC)
     return 1;
 
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index 83af11e11dc..31e7bad36b8 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -207,8 +207,8 @@ xtensa_breakpoint_at (CORE_ADDR where)
 {
     unsigned long insn;
 
-    (*the_target->read_memory) (where, (unsigned char *) &insn,
-				xtensa_breakpoint_len);
+    the_target->pt->read_memory (where, (unsigned char *) &insn,
+				 xtensa_breakpoint_len);
     return memcmp((char *) &insn,
 		  xtensa_breakpoint, xtensa_breakpoint_len) == 0;
 }
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index e243764a863..eb5147d907b 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -638,8 +638,9 @@ lynx_process_target::store_registers (regcache *regcache, int regno)
 
 /* Implement the read_memory target_ops method.  */
 
-static int
-lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
+int
+lynx_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+				  int len)
 {
   /* On LynxOS, memory reads needs to be performed in chunks the size
      of int types, and they should also be aligned accordingly.  */
@@ -671,8 +672,9 @@ lynx_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
 
 /* Implement the write_memory target_ops method.  */
 
-static int
-lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
+int
+lynx_process_target::write_memory (CORE_ADDR memaddr,
+				   const unsigned char *myaddr, int len)
 {
   /* On LynxOS, memory writes needs to be performed in chunks the size
      of int types, and they should also be aligned accordingly.  */
@@ -694,7 +696,7 @@ lynx_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
 	{
 	  /* We need to read the memory at this address in order to preserve
 	     the data that we are not overwriting.  */
-	  lynx_read_memory (addr, (unsigned char *) &buf, xfer_size);
+	  read_memory (addr, (unsigned char *) &buf, xfer_size);
 	  if (errno)
 	    return errno;
 	}
@@ -727,8 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_read_memory,
-  lynx_write_memory,
   NULL,  /* look_up_symbols */
   lynx_request_interrupt,
   NULL,  /* read_auxv */
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index ea6cf008f5b..9036eb3eff0 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -81,6 +81,12 @@ public:
   void fetch_registers (regcache *regcache, int regno) override;
 
   void store_registers (regcache *regcache, int regno) override;
+
+  int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+		   int len) override;
+
+  int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
+		    int len) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index 1b6f2365814..43a07c390d1 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -380,8 +380,8 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
     {
       memcpy (bp->old_data, buf, bp_size (bp));
 
-      err = (*the_target->write_memory) (bp->pc, bp_opcode (bp),
-					 bp_size (bp));
+      err = the_target->pt->write_memory (bp->pc, bp_opcode (bp),
+					  bp_size (bp));
       if (err != 0)
 	{
 	  if (debug_threads)
@@ -1857,7 +1857,7 @@ validate_inserted_breakpoint (struct raw_breakpoint *bp)
   gdb_assert (bp->raw_type == raw_bkpt_type_sw);
 
   buf = (unsigned char *) alloca (bp_size (bp));
-  err = (*the_target->read_memory) (bp->pc, buf, bp_size (bp));
+  err = the_target->pt->read_memory (bp->pc, buf, bp_size (bp));
   if (err || memcmp (buf, bp_opcode (bp), bp_size (bp)) != 0)
     {
       /* Tag it as gone.  */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 36bd40c20d8..d56f247acb4 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -706,8 +706,9 @@ nto_process_target::store_registers (regcache *regcache, int regno)
 
    Return 0 on success -1 otherwise.  */
 
-static int
-nto_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
+int
+nto_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+				 int len)
 {
   TRACE ("%s memaddr:0x%08lx, len:%d\n", __func__, memaddr, len);
 
@@ -725,8 +726,9 @@ nto_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
 
    Return 0 on success -1 otherwise.  */
 
-static int
-nto_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
+int
+nto_process_target::write_memory (CORE_ADDR memaddr,
+				  const unsigned char *myaddr, int len)
 {
   int len_written;
 
@@ -941,8 +943,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_read_memory,
-  nto_write_memory,
   NULL, /* nto_look_up_symbols */
   nto_request_interrupt,
   nto_read_auxv,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index f630360a2f4..0f4bb434483 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -71,6 +71,12 @@ public:
   void fetch_registers (regcache *regcache, int regno) override;
 
   void store_registers (regcache *regcache, int regno) override;
+
+  int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+		   int len) override;
+
+  int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
+		    int len) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index f88e9faf191..49302f61dfb 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -120,7 +120,7 @@ int
 read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
 {
   int res;
-  res = (*the_target->read_memory) (memaddr, myaddr, len);
+  res = the_target->pt->read_memory (memaddr, myaddr, len);
   check_mem_read (memaddr, myaddr, len);
   return res;
 }
@@ -151,7 +151,7 @@ target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
      update it.  */
   gdb::byte_vector buffer (myaddr, myaddr + len);
   check_mem_write (memaddr, buffer.data (), myaddr, len);
-  return (*the_target->write_memory) (memaddr, buffer.data (), len);
+  return the_target->pt->write_memory (memaddr, buffer.data (), len);
 }
 
 ptid_t
diff --git a/gdbserver/target.h b/gdbserver/target.h
index e89ddbb0048..ead4a613e90 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,25 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read memory from the inferior process.  This should generally be
-     called through read_inferior_memory, which handles breakpoint shadowing.
-
-     Read LEN bytes at MEMADDR into a buffer at MYADDR.
-  
-     Returns 0 on success and errno on failure.  */
-
-  int (*read_memory) (CORE_ADDR memaddr, unsigned char *myaddr, int len);
-
-  /* Write memory to the inferior process.  This should generally be
-     called through target_write_memory, which handles breakpoint shadowing.
-
-     Write LEN bytes from the buffer at MYADDR to MEMADDR.
-
-     Returns 0 on success and errno on failure.  */
-
-  int (*write_memory) (CORE_ADDR memaddr, const unsigned char *myaddr,
-		       int len);
-
   /* Query GDB for the values of any symbols we're interested in.
      This function is called whenever we receive a "qSymbols::"
      query, which corresponds to every time more symbols (might)
@@ -478,6 +459,24 @@ public:
 
   /* Undo the effects of prepare_to_access_memory.  */
   virtual void done_accessing_memory ();
+
+  /* Read memory from the inferior process.  This should generally be
+     called through read_inferior_memory, which handles breakpoint shadowing.
+
+     Read LEN bytes at MEMADDR into a buffer at MYADDR.
+
+     Returns 0 on success and errno on failure.  */
+  virtual int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+			   int len) = 0;
+
+  /* Write memory to the inferior process.  This should generally be
+     called through target_write_memory, which handles breakpoint shadowing.
+
+     Write LEN bytes from the buffer at MYADDR to MEMADDR.
+
+     Returns 0 on success and errno on failure.  */
+  virtual int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
+			    int len) = 0;
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 4a8e64d11ae..ef0d6035e93 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1676,8 +1676,9 @@ win32_process_target::store_registers (regcache *regcache, int regno)
 /* Read memory from the inferior process.  This should generally be
    called through read_inferior_memory, which handles breakpoint shadowing.
    Read LEN bytes at MEMADDR into a buffer at MYADDR.  */
-static int
-win32_read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
+int
+win32_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+				   int len)
 {
   return child_xfer_memory (memaddr, (char *) myaddr, len, 0, 0) != len;
 }
@@ -1686,9 +1687,9 @@ win32_read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
    called through write_inferior_memory, which handles breakpoint shadowing.
    Write LEN bytes from the buffer at MYADDR to MEMADDR.
    Returns 0 on success and errno on failure.  */
-static int
-win32_write_inferior_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
-			     int len)
+int
+win32_process_target::write_memory (CORE_ADDR memaddr,
+				    const unsigned char *myaddr, int len)
 {
   return child_xfer_memory (memaddr, (char *) myaddr, len, 1, 0) != len;
 }
@@ -1837,8 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_read_inferior_memory,
-  win32_write_inferior_memory,
   NULL, /* lookup_symbols */
   win32_request_interrupt,
   NULL, /* read_auxv */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index ff3659f6dab..0ecb2f8ebb5 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -130,6 +130,12 @@ public:
   void fetch_registers (regcache *regcache, int regno) override;
 
   void store_registers (regcache *regcache, int regno) override;
+
+  int read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
+		   int len) override;
+
+  int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
+		    int len) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 15/58] gdbserver: turn target op 'look_up_symbols' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 09/58] gdbserver: turn target op 'thread_alive' " Tankut Baris Aktemur
                   ` (58 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's look_up_symbols op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	* target.cc (process_target::look_up_symbols): Define.

	Update the derived classes and callers below.

	* server.cc (handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_look_up_symbols): Turn into ...
	(linux_process_target::look_up_symbols): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  4 ++--
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     | 14 ++++++--------
 gdbserver/win32-low.cc |  1 -
 8 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 1a790e5eae9..f073a38f092 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5898,8 +5898,8 @@ linux_process_target::write_memory (CORE_ADDR memaddr,
   return 0;
 }
 
-static void
-linux_look_up_symbols (void)
+void
+linux_process_target::look_up_symbols ()
 {
 #ifdef USE_THREAD_DB
   struct process_info *proc = current_process ();
@@ -7369,7 +7369,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_look_up_symbols,
   linux_request_interrupt,
   linux_read_auxv,
   linux_supports_z_point_type,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index b8b10143dec..05269dc18ab 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -305,6 +305,8 @@ public:
 
   int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
 		    int len) override;
+
+  void look_up_symbols () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index eb5147d907b..bedf9182ce2 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -729,7 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* look_up_symbols */
   lynx_request_interrupt,
   NULL,  /* read_auxv */
   NULL,  /* supports_z_point_type */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index d56f247acb4..c229e41d525 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -943,7 +943,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* nto_look_up_symbols */
   nto_request_interrupt,
   nto_read_auxv,
   nto_supports_z_point_type,
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 92feff36516..4785eabaf06 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2192,8 +2192,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (target_supports_tracepoints ())
 	tracepoint_look_up_symbols ();
 
-      if (current_thread != NULL && the_target->look_up_symbols != NULL)
-	(*the_target->look_up_symbols) ();
+      if (current_thread != NULL)
+	the_target->pt->look_up_symbols ();
 
       current_thread = save_thread;
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 49302f61dfb..dd9ee8dfd47 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -408,3 +408,9 @@ process_target::done_accessing_memory ()
 {
   /* Nop.  */
 }
+
+void
+process_target::look_up_symbols ()
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index ead4a613e90..7f37a904f76 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,14 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Query GDB for the values of any symbols we're interested in.
-     This function is called whenever we receive a "qSymbols::"
-     query, which corresponds to every time more symbols (might)
-     become available.  NULL if we aren't interested in any
-     symbols.  */
-
-  void (*look_up_symbols) (void);
-
   /* Send an interrupt request to the inferior process,
      however is appropriate.  */
 
@@ -477,6 +469,12 @@ public:
      Returns 0 on success and errno on failure.  */
   virtual int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
 			    int len) = 0;
+
+  /* Query GDB for the values of any symbols we're interested in.
+     This function is called whenever we receive a "qSymbols::"
+     query, which corresponds to every time more symbols (might)
+     become available.  */
+  virtual void look_up_symbols ();
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index ef0d6035e93..4ac1b3a1ca2 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1838,7 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* lookup_symbols */
   win32_request_interrupt,
   NULL, /* read_auxv */
   win32_supports_z_point_type,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 16/58] gdbserver: turn target op 'request_interrupt' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (11 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 05/58] gdbserver: turn target op 'kill' " Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 42/58] gdbserver: turn target op 'stabilize_threads' " Tankut Baris Aktemur
                   ` (46 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's request_interrupt op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.

	Update the derived classes and callers below.

	* remote-utils.cc (putpkt_binary_1): Update.
	(input_interrupt): Update.
	(getpkt): Update.
	* server.cc (handle_v_requests): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_request_interrupt): Turn into ...
	(linux_process_target::request_interrupt): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_request_interrupt): Turn into ...
	(lynx_process_target::request_interrupt): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_request_interrupt): Turn into ...
	(nto_process_target::request_interrupt): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_request_interrupt): Turn into ...
	(win32_process_target::request_interrupt): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc    | 7 +++----
 gdbserver/linux-low.h     | 2 ++
 gdbserver/lynx-low.cc     | 5 ++---
 gdbserver/lynx-low.h      | 2 ++
 gdbserver/nto-low.cc      | 5 ++---
 gdbserver/nto-low.h       | 2 ++
 gdbserver/remote-utils.cc | 8 ++++----
 gdbserver/server.cc       | 2 +-
 gdbserver/target.h        | 9 ++++-----
 gdbserver/win32-low.cc    | 5 ++---
 gdbserver/win32-low.h     | 2 ++
 11 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index f073a38f092..3d02cb5431c 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5911,12 +5911,12 @@ linux_process_target::look_up_symbols ()
 #endif
 }
 
-static void
-linux_request_interrupt (void)
+void
+linux_process_target::request_interrupt ()
 {
   /* Send a SIGINT to the process group.  This acts just like the user
      typed a ^C on the controlling terminal.  */
-  kill (-signal_pid, SIGINT);
+  ::kill (-signal_pid, SIGINT);
 }
 
 /* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
@@ -7369,7 +7369,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_request_interrupt,
   linux_read_auxv,
   linux_supports_z_point_type,
   linux_insert_point,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 05269dc18ab..197a0bbe1d4 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -307,6 +307,8 @@ public:
 		    int len) override;
 
   void look_up_symbols () override;
+
+  void request_interrupt () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index bedf9182ce2..8b5300f08c2 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -714,8 +714,8 @@ lynx_process_target::write_memory (CORE_ADDR memaddr,
 
 /* Implement the kill_request target_ops method.  */
 
-static void
-lynx_request_interrupt (void)
+void
+lynx_process_target::request_interrupt ()
 {
   ptid_t inferior_ptid = ptid_of (get_first_thread ());
 
@@ -729,7 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_request_interrupt,
   NULL,  /* read_auxv */
   NULL,  /* supports_z_point_type */
   NULL,  /* insert_point */
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 9036eb3eff0..795603af0d7 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -87,6 +87,8 @@ public:
 
   int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
 		    int len) override;
+
+  void request_interrupt () override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index c229e41d525..d60f72affd5 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -746,8 +746,8 @@ nto_process_target::write_memory (CORE_ADDR memaddr,
 
 /* Stop inferior.  We always stop all threads.  */
 
-static void
-nto_request_interrupt (void)
+void
+nto_process_target::request_interrupt ()
 {
   TRACE ("%s\n", __func__);
   nto_set_thread (ptid_t (nto_inferior.pid, 1, 0));
@@ -943,7 +943,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_request_interrupt,
   nto_read_auxv,
   nto_supports_z_point_type,
   nto_insert_point,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 0f4bb434483..c6e0c295662 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -77,6 +77,8 @@ public:
 
   int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
 		    int len) override;
+
+  void request_interrupt () override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index b8a8c6576f9..b5248ab368e 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -710,7 +710,7 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
 
       /* Check for an input interrupt while we're here.  */
       if (cc == '\003' && current_thread != NULL)
-	(*the_target->request_interrupt) ();
+	the_target->pt->request_interrupt ();
     }
   while (cc != '+');
 
@@ -779,7 +779,7 @@ input_interrupt (int unused)
 	  return;
 	}
 
-      (*the_target->request_interrupt) ();
+      the_target->pt->request_interrupt ();
     }
 }
 
@@ -986,7 +986,7 @@ getpkt (char *buf)
 	     check for an input interrupt.  */
 	  if (c == '\003')
 	    {
-	      (*the_target->request_interrupt) ();
+	      the_target->pt->request_interrupt ();
 	      continue;
 	    }
 
@@ -1076,7 +1076,7 @@ getpkt (char *buf)
     {
       /* Consume the interrupt character in the buffer.  */
       readchar ();
-      (*the_target->request_interrupt) ();
+      the_target->pt->request_interrupt ();
     }
 
   return bp - buf;
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 4785eabaf06..bc497f87b7f 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3088,7 +3088,7 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
     {
       if (strcmp (own_buf, "vCtrlC") == 0)
 	{
-	  (*the_target->request_interrupt) ();
+	  the_target->pt->request_interrupt ();
 	  write_ok (own_buf);
 	  return;
 	}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 7f37a904f76..234a183427e 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,11 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Send an interrupt request to the inferior process,
-     however is appropriate.  */
-
-  void (*request_interrupt) (void);
-
   /* Read auxiliary vector data from the inferior process.
 
      Read LEN bytes at OFFSET into a buffer at MYADDR.  */
@@ -475,6 +470,10 @@ public:
      query, which corresponds to every time more symbols (might)
      become available.  */
   virtual void look_up_symbols ();
+
+  /* Send an interrupt request to the inferior process,
+     however is appropriate.  */
+  virtual void request_interrupt () = 0;
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 4ac1b3a1ca2..098da30017d 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1695,8 +1695,8 @@ win32_process_target::write_memory (CORE_ADDR memaddr,
 }
 
 /* Send an interrupt request to the inferior process. */
-static void
-win32_request_interrupt (void)
+void
+win32_process_target::request_interrupt ()
 {
   winapi_DebugBreakProcess DebugBreakProcess;
   winapi_GenerateConsoleCtrlEvent GenerateConsoleCtrlEvent;
@@ -1838,7 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_request_interrupt,
   NULL, /* read_auxv */
   win32_supports_z_point_type,
   win32_insert_point,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 0ecb2f8ebb5..2cb38a14195 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -136,6 +136,8 @@ public:
 
   int write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
 		    int len) override;
+
+  void request_interrupt () override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 05/58] gdbserver: turn target op 'kill' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (10 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 07/58] gdbserver: turn target op 'mourn' into a method Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 16/58] gdbserver: turn target op 'request_interrupt' " Tankut Baris Aktemur
                   ` (47 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's kill op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.

	Update the derived classes and callers below.

	* target.cc (kill_inferior): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_kill): Turn into ...
	(linux_process_target::kill): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_kill): Turn into ...
	(lynx_process_target::kill): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_kill): Turn into ...
	(nto_process_target::kill): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_kill): Turn into ...
	(win32_process_target::kill): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc | 5 ++---
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 5 ++---
 gdbserver/lynx-low.h   | 2 ++
 gdbserver/nto-low.cc   | 5 ++---
 gdbserver/nto-low.h    | 2 ++
 gdbserver/target.cc    | 2 +-
 gdbserver/target.h     | 7 +++----
 gdbserver/win32-low.cc | 5 ++---
 gdbserver/win32-low.h  | 2 ++
 10 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index aae29306df6..4510e3a1c5f 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1386,8 +1386,8 @@ kill_one_lwp_callback (thread_info *thread, int pid)
   kill_wait_lwp (lwp);
 }
 
-static int
-linux_kill (process_info *process)
+int
+linux_process_target::kill (process_info *process)
 {
   int pid = process->pid;
 
@@ -7359,7 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_kill,
   linux_detach,
   linux_mourn,
   linux_join,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 5458a9b99b9..4f8801150d5 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -276,6 +276,8 @@ public:
   void post_create_inferior () override;
 
   int attach (unsigned long pid) override;
+
+  int kill (process_info *proc) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 60abc75d8da..f6359e81575 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -521,8 +521,8 @@ lynx_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 
 /* Implement the kill target_ops method.  */
 
-static int
-lynx_kill (process_info *process)
+int
+lynx_process_target::kill (process_info *process)
 {
   ptid_t ptid = lynx_ptid_t (process->pid, 0);
   struct target_waitstatus status;
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_kill,
   lynx_detach,
   lynx_mourn,
   lynx_join,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 142a774011c..cf357ff9a1f 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -62,6 +62,8 @@ public:
 		       const std::vector<char *> &program_args) override;
 
   int attach (unsigned long pid) override;
+
+  int kill (process_info *proc) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 77b5fce4c50..15b3dc37f01 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -396,8 +396,8 @@ nto_process_target::attach (unsigned long pid)
 
 /* Send signal to process PID.  */
 
-static int
-nto_kill (process_info *proc)
+int
+nto_process_target::kill (process_info *proc)
 {
   int pid = proc->pid;
 
@@ -935,7 +935,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_kill,
   nto_detach,
   nto_mourn,
   NULL, /* nto_join */
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index f6faacb425e..5564dda3bb2 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -52,6 +52,8 @@ public:
 		       const std::vector<char *> &program_args) override;
 
   int attach (unsigned long pid) override;
+
+  int kill (process_info *proc) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 81092e81ea4..a9632aa8cd9 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -319,7 +319,7 @@ kill_inferior (process_info *proc)
 {
   gdb_agent_about_to_close (proc->pid);
 
-  return (*the_target->kill) (proc);
+  return the_target->pt->kill (proc);
 }
 
 /* Target can do hardware single step.  */
diff --git a/gdbserver/target.h b/gdbserver/target.h
index bd99737d4f1..0f3cb35f453 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Kill process PROC.  Return -1 on failure, and 0 on success.  */
-
-  int (*kill) (process_info *proc);
-
   /* Detach from process PROC.  Return -1 on failure, and 0 on
      success.  */
 
@@ -488,6 +484,9 @@ public:
      Returns -1 if attaching is unsupported, 0 on success, and calls
      error() otherwise.  */
   virtual int attach (unsigned long pid) = 0;
+
+  /* Kill process PROC.  Return -1 on failure, and 0 on success.  */
+  virtual int kill (process_info *proc) = 0;
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 0e7c1640522..a7fb1244e34 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -819,8 +819,8 @@ win32_clear_inferiors (void)
 
 /* Implementation of target_ops::kill.  */
 
-static int
-win32_kill (process_info *process)
+int
+win32_process_target::kill (process_info *process)
 {
   TerminateProcess (current_process_handle, 0);
   for (;;)
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_kill,
   win32_detach,
   win32_mourn,
   win32_join,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index fd6662dcab2..45a6262e38e 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -111,6 +111,8 @@ public:
 		       const std::vector<char *> &program_args) override;
 
   int attach (unsigned long pid) override;
+
+  int kill (process_info *proc) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 07/58] gdbserver: turn target op 'mourn' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (9 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 12/58] gdbserver: turn target ops 'fetch_registers' and 'store_registers' " Tankut Baris Aktemur
@ 2020-02-17 16:59 ` Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 05/58] gdbserver: turn target op 'kill' " Tankut Baris Aktemur
                   ` (48 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 16:59 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's mourn op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.

	Update the derived classes and callers below.

	* target.cc (target_mourn_inferior): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_mourn): Turn into ...
	(linux_process_target::mourn): ... this.
	(handle_extended_wait): Update.
	(linux_process_target::kill): Update.
	(linux_process_target::detach): Update.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_mourn): Turn into ...
	(lynx_process_target::mourn): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_mourn): Turn into ...
	(nto_process_target::mourn): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_mourn): Turn into ...
	(win32_process_target::mourn): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc | 12 +++++-------
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  9 ++++-----
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/nto-low.cc   |  5 ++---
 gdbserver/nto-low.h    |  2 ++
 gdbserver/target.cc    |  2 +-
 gdbserver/target.h     |  7 +++----
 gdbserver/win32-low.cc |  5 ++---
 gdbserver/win32-low.h  |  2 ++
 10 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 1feb7d971cd..66790ee5ce1 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -270,7 +270,6 @@ 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 linux_mourn (struct process_info *process);
 static int linux_stopped_by_watchpoint (void);
 static void mark_lwp_dead (struct lwp_info *lwp, int wstat);
 static int lwp_is_marked_dead (struct lwp_info *lwp);
@@ -707,7 +706,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.  */
-      linux_mourn (proc);
+      the_target->pt->mourn (proc);
       current_thread = NULL;
 
       /* Create a new process/lwp/thread.  */
@@ -1413,7 +1412,7 @@ linux_process_target::kill (process_info *process)
   else
     kill_wait_lwp (lwp);
 
-  the_target->mourn (process);
+  mourn (process);
 
   /* Since we presently can only stop all lwps of all processes, we
      need to unstop lwps of other processes.  */
@@ -1634,7 +1633,7 @@ linux_process_target::detach (process_info *process)
   main_lwp = find_lwp_pid (ptid_t (process->pid));
   linux_detach_one_lwp (main_lwp);
 
-  the_target->mourn (process);
+  mourn (process);
 
   /* Since we presently can only stop all lwps of all processes, we
      need to unstop lwps of other processes.  */
@@ -1644,8 +1643,8 @@ linux_process_target::detach (process_info *process)
 
 /* Remove all LWPs that belong to process PROC from the lwp list.  */
 
-static void
-linux_mourn (struct process_info *process)
+void
+linux_process_target::mourn (process_info *process)
 {
   struct process_info_private *priv;
 
@@ -7359,7 +7358,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_mourn,
   linux_join,
   linux_thread_alive,
   linux_resume,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index e8789e9c8a9..8f43812766e 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -280,6 +280,8 @@ public:
   int kill (process_info *proc) override;
 
   int detach (process_info *proc) override;
+
+  void mourn (process_info *proc) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index a6eceaf25b1..558f4aea8db 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -529,7 +529,7 @@ lynx_process_target::kill (process_info *process)
 
   lynx_ptrace (PTRACE_KILL, ptid, 0, 0, 0);
   lynx_wait (ptid, &status, 0);
-  the_target->mourn (process);
+  mourn (process);
   return 0;
 }
 
@@ -541,14 +541,14 @@ lynx_process_target::detach (process_info *process)
   ptid_t ptid = lynx_ptid_t (process->pid, 0);
 
   lynx_ptrace (PTRACE_DETACH, ptid, 0, 0, 0);
-  the_target->mourn (process);
+  mourn (process);
   return 0;
 }
 
 /* Implement the mourn target_ops method.  */
 
-static void
-lynx_mourn (struct process_info *proc)
+void
+lynx_process_target::mourn (struct process_info *proc)
 {
   for_each_thread (proc->pid, remove_thread);
 
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_mourn,
   lynx_join,
   lynx_thread_alive,
   lynx_resume,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 9b8065e3f37..6cffe6d811e 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -66,6 +66,8 @@ public:
   int kill (process_info *proc) override;
 
   int detach (process_info *proc) override;
+
+  void mourn (process_info *proc) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index ceff0d432e5..263f73d42c3 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -417,8 +417,8 @@ nto_process_target::detach (process_info *proc)
   return 0;
 }
 
-static void
-nto_mourn (struct process_info *process)
+void
+nto_process_target::mourn (struct process_info *process)
 {
   remove_process (process);
 }
@@ -935,7 +935,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_mourn,
   NULL, /* nto_join */
   nto_thread_alive,
   nto_resume,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index e7e10fcb842..69728b82795 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -56,6 +56,8 @@ public:
   int kill (process_info *proc) override;
 
   int detach (process_info *proc) override;
+
+  void mourn (process_info *proc) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index a9632aa8cd9..f6d8d927b85 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -231,7 +231,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 void
 target_mourn_inferior (ptid_t ptid)
 {
-  (*the_target->mourn) (find_process_pid (ptid.pid ()));
+  the_target->pt->mourn (find_process_pid (ptid.pid ()));
 }
 
 /* See target/target.h.  */
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 6c7c2869938..d6b7377722a 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* The inferior process has died.  Do what is right.  */
-
-  void (*mourn) (struct process_info *proc);
-
   /* Wait for process PID to exit.  */
 
   void (*join) (int pid);
@@ -486,6 +482,9 @@ public:
   /* Detach from process PROC.  Return -1 on failure, and 0 on
      success.  */
   virtual int detach (process_info *proc) = 0;
+
+  /* The inferior process has died.  Do what is right.  */
+  virtual void mourn (process_info *proc) = 0;
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 9cefb29b046..9bccc1bb9c7 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -878,8 +878,8 @@ win32_process_target::detach (process_info *process)
   return 0;
 }
 
-static void
-win32_mourn (struct process_info *process)
+void
+win32_process_target::mourn (struct process_info *process)
 {
   remove_process (process);
 }
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_mourn,
   win32_join,
   win32_thread_alive,
   win32_resume,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 10096b87682..d07d99881e6 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -115,6 +115,8 @@ public:
   int kill (process_info *proc) override;
 
   int detach (process_info *proc) override;
+
+  void mourn (process_info *proc) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 40/58] gdbserver: turn target op 'get_tib_address' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (32 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 28/58] gdbserver: turn target op 'qxfer_siginfo' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 34/58] gdbserver: turn target op 'core_of_thread' " Tankut Baris Aktemur
                   ` (25 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's get_tib_address op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_get_tib_address'.
	* target.cc (process_target::get_tib_address): Define.
	(process_target::supports_get_tib_address): Define.

	Update the derived classes and callers below.

	* server.cc (handle_query): Update.
	* linux-low.cc (win32_target_ops): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_process_target::supports_get_tib_address): Define.
	(win32_get_tib_address): Turn into ...
	(win32_process_target::get_tib_address): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc |  1 -
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  4 ++--
 gdbserver/target.cc    | 12 ++++++++++++
 gdbserver/target.h     |  9 ++++++---
 gdbserver/win32-low.cc | 11 ++++++++---
 gdbserver/win32-low.h  |  4 ++++
 8 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 692863d9e4b..c75d4ba9707 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -7451,7 +7451,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  NULL,
   linux_pause_all,
   linux_unpause_all,
   linux_stabilize_threads,
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 7cbde7c6e79..9f96faf802c 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* get_tib_address */
   NULL,  /* pause_all */
   NULL,  /* unpause_all */
   NULL,  /* stabilize_threads */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index c144d774f0c..08f73fa3871 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* get_tib_address */
   NULL, /* pause_all */
   NULL, /* unpause_all */
   NULL, /* stabilize_threads */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index f3dca8d3ce0..77155935fab 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2532,7 +2532,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
     }
 
   /* Windows OS Thread Information Block address support.  */
-  if (the_target->get_tib_address != NULL
+  if (the_target->pt->supports_get_tib_address ()
       && startswith (own_buf, "qGetTIBAddr:"))
     {
       const char *annex;
@@ -2540,7 +2540,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       CORE_ADDR tlb;
       ptid_t ptid = read_ptid (own_buf + 12, &annex);
 
-      n = (*the_target->get_tib_address) (ptid, &tlb);
+      n = the_target->pt->get_tib_address (ptid, &tlb);
       if (n == 1)
 	{
 	  strcpy (own_buf, paddress(tlb));
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index b44170a7cdd..680addadf78 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -638,3 +638,15 @@ process_target::thread_stopped (thread_info *thread)
 {
   gdb_assert_not_reached ("target op thread_stopped not supported");
 }
+
+bool
+process_target::supports_get_tib_address ()
+{
+  return false;
+}
+
+int
+process_target::get_tib_address (ptid_t ptid, CORE_ADDR *address)
+{
+  gdb_assert_not_reached ("target op get_tib_address not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 49d5eca479e..4da15a06734 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read Thread Information Block address.  */
-  int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address);
-
   /* Pause all threads.  If FREEZE, arrange for any resume attempt to
      be ignored until an unpause_all call unfreezes threads again.
      There can be nested calls to pause_all, so a freeze counter
@@ -491,6 +488,12 @@ public:
 
   /* Return true if THREAD is known to be stopped now.  */
   virtual bool thread_stopped (thread_info *thread);
+
+  /* Return true if the get_tib_address op is supported.  */
+  virtual bool supports_get_tib_address ();
+
+  /* Read Thread Information Block address.  */
+  virtual int get_tib_address (ptid_t ptid, CORE_ADDR *address);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 712624852d6..9bffdaaf1ae 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1824,10 +1824,16 @@ win32_process_target::qxfer_siginfo (const char *annex,
   return len;
 }
 
+bool
+win32_process_target::supports_get_tib_address ()
+{
+  return true;
+}
+
 /* Write Windows OS Thread Information Block address.  */
 
-static int
-win32_get_tib_address (ptid_t ptid, CORE_ADDR *addr)
+int
+win32_process_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
 {
   win32_thread_info *th;
   th = thread_rec (ptid, 0);
@@ -1852,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_get_tib_address,
   NULL, /* pause_all */
   NULL, /* unpause_all */
   NULL, /* stabilize_threads */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index b259b1fbac1..1618501838e 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -162,6 +162,10 @@ public:
   int qxfer_siginfo (const char *annex, unsigned char *readbuf,
 		     unsigned const char *writebuf,
 		     CORE_ADDR offset, int len) override;
+
+  bool supports_get_tib_address () override;
+
+  int get_tib_address (ptid_t ptid, CORE_ADDR *addr) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 45/58] gdbserver: turn target op 'supports_disable_randomization' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (26 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 21/58] gdbserver: turn target op '{supports_}stopped_by_hw_breakpoint' into a method Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 17/58] gdbserver: turn target op 'read_auxv' " Tankut Baris Aktemur
                   ` (31 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_disable_randomization op
	into a method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_supports_disable_randomization): Update the macro.
	* target.cc (process_target::supports_disable_randomization): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_disable_randomization): Turn into ...
	(linux_process_target::supports_disable_randomization): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 9 ++++-----
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 6 ++++++
 gdbserver/target.h     | 9 ++++-----
 gdbserver/win32-low.cc | 1 -
 7 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 0203afa66cf..72c66d647db 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6410,13 +6410,13 @@ 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
 }
 
@@ -7452,7 +7452,6 @@ linux_get_hwcap2 (int wordsize)
 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
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 3a6d2d02dff..ba02a06dedd 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -422,6 +422,8 @@ public:
   int get_min_fast_tracepoint_insn_len () override;
 
   struct emit_ops *emit_ops () override;
+
+  bool supports_disable_randomization () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 1c71c60f096..b5fd49f6fa8 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_disable_randomization */
   NULL,  /* qxfer_libraries_svr4 */
   NULL,  /* support_agent */
   NULL,  /* enable_btrace */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 502e6104638..81436e27945 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* supports_disable_randomization */
   NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
   NULL, /* enable_btrace */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 44069f1ad44..fa9c9bbb36a 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -699,3 +699,9 @@ process_target::emit_ops ()
 {
   return nullptr;
 }
+
+bool
+process_target::supports_disable_randomization ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 0d51af7965c..04c842d83bc 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns true if the target supports disabling randomization.  */
-  int (*supports_disable_randomization) (void);
-
   /* Read solib info on SVR4 platforms.  */
   int (*qxfer_libraries_svr4) (const char *annex, unsigned char *readbuf,
 			       unsigned const char *writebuf,
@@ -493,6 +490,9 @@ public:
   /* Return the bytecode operations vector for the current inferior.
      Returns nullptr if bytecode compilation is not supported.  */
   virtual struct emit_ops *emit_ops ();
+
+  /* Returns true if the target supports disabling randomization.  */
+  virtual bool supports_disable_randomization ();
 };
 
 extern process_stratum_target *the_target;
@@ -600,8 +600,7 @@ int kill_inferior (process_info *proc);
   the_target->pt->emit_ops ()
 
 #define target_supports_disable_randomization() \
-  (the_target->supports_disable_randomization ? \
-   (*the_target->supports_disable_randomization) () : 0)
+  the_target->pt->supports_disable_randomization ()
 
 #define target_supports_agent() \
   (the_target->supports_agent ? \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 297882bc8a8..7522a54e593 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_disable_randomization */
   NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
   NULL, /* enable_btrace */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 43/58] gdbserver: turn fast tracepoint target ops into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (17 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 24/58] gdbserver: turn target op 'read_offsets' into a method Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 23/58] gdbserver: turn target ops 'stopped_by_watchpoint' and 'stopped_data_address' " Tankut Baris Aktemur
                   ` (40 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's install_fast_tracepoint_jump_pad
	and get_min_fast_tracepoint_insn_len ops into methods of
	process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.  Also add
	'supports_fast_tracepoints'.
	(target_supports_fast_tracepoints): Update the macro.
	(target_get_min_fast_tracepoint_insn_len): Update the macro.
	(install_fast_tracepoint_jump_pad): Update and rename the macro
	to ...
	(target_install_fast_tracepoint_jump_pad): ... this.
	* target.cc (process_target::supports_fast_tracepoints): Define.
	(process_target::install_fast_tracepoint_jump_pad): Define.
	(process_target::get_min_fast_tracepoint_insn_len): Define.

	Update the derived classes and callers below.

	* tracepoint.cc (install_fast_tracepoint): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_fast_tracepoints): Define.
	(linux_install_fast_tracepoint_jump_pad): Turn into ...
	(linux_process_target::install_fast_tracepoint_jump_pad): ... this.
	(linux_get_min_fast_tracepoint_insn_len): Turn into ...
	(linux_process_target::get_min_fast_tracepoint_insn_len): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc  |  33 ++++++------
 gdbserver/linux-low.h   |  18 +++++++
 gdbserver/lynx-low.cc   |   2 -
 gdbserver/nto-low.cc    |   2 -
 gdbserver/target.cc     |  25 ++++++++++
 gdbserver/target.h      | 108 ++++++++++++++++++++--------------------
 gdbserver/tracepoint.cc |  16 ++----
 gdbserver/win32-low.cc  |   2 -
 8 files changed, 117 insertions(+), 89 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index aa255cb0f47..f1d61190b12 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6616,19 +6616,20 @@ linux_process_target::done_accessing_memory ()
     target_unpause_all (true);
 }
 
-static int
-linux_install_fast_tracepoint_jump_pad (CORE_ADDR tpoint, CORE_ADDR tpaddr,
-					CORE_ADDR collector,
-					CORE_ADDR lockaddr,
-					ULONGEST orig_size,
-					CORE_ADDR *jump_entry,
-					CORE_ADDR *trampoline,
-					ULONGEST *trampoline_size,
-					unsigned char *jjump_pad_insn,
-					ULONGEST *jjump_pad_insn_size,
-					CORE_ADDR *adjusted_insn_addr,
-					CORE_ADDR *adjusted_insn_addr_end,
-					char *err)
+bool
+linux_process_target::supports_fast_tracepoints ()
+{
+  return true;
+}
+
+int
+linux_process_target::install_fast_tracepoint_jump_pad
+  (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+   CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+   CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+   unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+   CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+   char *err)
 {
   return (*the_low_target.install_fast_tracepoint_jump_pad)
     (tpoint, tpaddr, collector, lockaddr, orig_size,
@@ -6647,8 +6648,8 @@ linux_emit_ops (void)
     return NULL;
 }
 
-static int
-linux_get_min_fast_tracepoint_insn_len (void)
+int
+linux_process_target::get_min_fast_tracepoint_insn_len ()
 {
   return (*the_low_target.get_min_fast_tracepoint_insn_len) ();
 }
@@ -7451,10 +7452,8 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_install_fast_tracepoint_jump_pad,
   linux_emit_ops,
   linux_supports_disable_randomization,
-  linux_get_min_fast_tracepoint_insn_len,
   linux_qxfer_libraries_svr4,
   linux_supports_agent,
 #ifdef HAVE_LINUX_BTRACE
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index d3866de03a2..35e30ed590d 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -402,6 +402,24 @@ public:
   void unpause_all (bool unfreeze) override;
 
   void stabilize_threads () override;
+
+  bool supports_fast_tracepoints () override;
+
+  int install_fast_tracepoint_jump_pad (CORE_ADDR tpoint,
+					CORE_ADDR tpaddr,
+					CORE_ADDR collector,
+					CORE_ADDR lockaddr,
+					ULONGEST orig_size,
+					CORE_ADDR *jump_entry,
+					CORE_ADDR *trampoline,
+					ULONGEST *trampoline_size,
+					unsigned char *jjump_pad_insn,
+					ULONGEST *jjump_pad_insn_size,
+					CORE_ADDR *adjusted_insn_addr,
+					CORE_ADDR *adjusted_insn_addr_end,
+					char *err) override;
+
+  int get_min_fast_tracepoint_insn_len () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 5ea50b4415d..4089b261bfd 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,10 +735,8 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* install_fast_tracepoint_jump_pad */
   NULL,  /* emit_ops */
   NULL,  /* supports_disable_randomization */
-  NULL,  /* get_min_fast_tracepoint_insn_len */
   NULL,  /* qxfer_libraries_svr4 */
   NULL,  /* support_agent */
   NULL,  /* enable_btrace */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index ef7a70ad97a..e0d3d49bb66 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,10 +947,8 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* supports_disable_randomization */
-  NULL, /* get_min_fast_tracepoint_insn_len */
   NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
   NULL, /* enable_btrace */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 42f22846d02..29b5bbcd9b1 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -668,3 +668,28 @@ process_target::stabilize_threads ()
 {
   /* Nop.  */
 }
+
+bool
+process_target::supports_fast_tracepoints ()
+{
+  return false;
+}
+
+int
+process_target::install_fast_tracepoint_jump_pad
+  (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+   CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+   CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+   unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+   CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+   char *err)
+{
+  gdb_assert_not_reached ("target op install_fast_tracepoint_jump_pad "
+			  "not supported");
+}
+
+int
+process_target::get_min_fast_tracepoint_insn_len ()
+{
+  return 0;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index c56267fb1f8..21f22a4d0db 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,34 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Install a fast tracepoint jump pad.  TPOINT is the address of the
-     tracepoint internal object as used by the IPA agent.  TPADDR is
-     the address of tracepoint.  COLLECTOR is address of the function
-     the jump pad redirects to.  LOCKADDR is the address of the jump
-     pad lock object.  ORIG_SIZE is the size in bytes of the
-     instruction at TPADDR.  JUMP_ENTRY points to the address of the
-     jump pad entry, and on return holds the address past the end of
-     the created jump pad.  If a trampoline is created by the function,
-     then TRAMPOLINE and TRAMPOLINE_SIZE return the address and size of
-     the trampoline, else they remain unchanged.  JJUMP_PAD_INSN is a
-     buffer containing a copy of the instruction at TPADDR.
-     ADJUST_INSN_ADDR and ADJUST_INSN_ADDR_END are output parameters that
-     return the address range where the instruction at TPADDR was relocated
-     to.  If an error occurs, the ERR may be used to pass on an error
-     message.  */
-  int (*install_fast_tracepoint_jump_pad) (CORE_ADDR tpoint, CORE_ADDR tpaddr,
-					   CORE_ADDR collector,
-					   CORE_ADDR lockaddr,
-					   ULONGEST orig_size,
-					   CORE_ADDR *jump_entry,
-					   CORE_ADDR *trampoline,
-					   ULONGEST *trampoline_size,
-					   unsigned char *jjump_pad_insn,
-					   ULONGEST *jjump_pad_insn_size,
-					   CORE_ADDR *adjusted_insn_addr,
-					   CORE_ADDR *adjusted_insn_addr_end,
-					   char *err);
-
   /* Return the bytecode operations vector for the current inferior.
      Returns NULL if bytecode compilation is not supported.  */
   struct emit_ops *(*emit_ops) (void);
@@ -105,10 +77,6 @@ struct process_stratum_target
   /* Returns true if the target supports disabling randomization.  */
   int (*supports_disable_randomization) (void);
 
-  /* Return the minimum length of an instruction that can be safely overwritten
-     for use as a fast tracepoint.  */
-  int (*get_min_fast_tracepoint_insn_len) (void);
-
   /* Read solib info on SVR4 platforms.  */
   int (*qxfer_libraries_svr4) (const char *annex, unsigned char *readbuf,
 			       unsigned const char *writebuf,
@@ -494,6 +462,37 @@ public:
 
   /* Stabilize all threads.  That is, force them out of jump pads.  */
   virtual void stabilize_threads ();
+
+  /* Return true if the install_fast_tracepoint_jump_pad op is
+     supported.  */
+  virtual bool supports_fast_tracepoints ();
+
+  /* Install a fast tracepoint jump pad.  TPOINT is the address of the
+     tracepoint internal object as used by the IPA agent.  TPADDR is
+     the address of tracepoint.  COLLECTOR is address of the function
+     the jump pad redirects to.  LOCKADDR is the address of the jump
+     pad lock object.  ORIG_SIZE is the size in bytes of the
+     instruction at TPADDR.  JUMP_ENTRY points to the address of the
+     jump pad entry, and on return holds the address past the end of
+     the created jump pad.  If a trampoline is created by the function,
+     then TRAMPOLINE and TRAMPOLINE_SIZE return the address and size of
+     the trampoline, else they remain unchanged.  JJUMP_PAD_INSN is a
+     buffer containing a copy of the instruction at TPADDR.
+     ADJUST_INSN_ADDR and ADJUST_INSN_ADDR_END are output parameters that
+     return the address range where the instruction at TPADDR was relocated
+     to.  If an error occurs, the ERR may be used to pass on an error
+     message.  */
+  virtual int install_fast_tracepoint_jump_pad
+    (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
+     CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
+     CORE_ADDR *trampoline, ULONGEST *trampoline_size,
+     unsigned char *jjump_pad_insn, ULONGEST *jjump_pad_insn_size,
+     CORE_ADDR *adjusted_insn_addr, CORE_ADDR *adjusted_insn_addr_end,
+     char *err);
+
+  /* Return the minimum length of an instruction that can be safely
+     overwritten for use as a fast tracepoint.  */
+  virtual int get_min_fast_tracepoint_insn_len ();
 };
 
 extern process_stratum_target *the_target;
@@ -559,11 +558,10 @@ int kill_inferior (process_info *proc);
   the_target->pt->supports_tracepoints ()
 
 #define target_supports_fast_tracepoints()		\
-  (the_target->install_fast_tracepoint_jump_pad != NULL)
+  the_target->pt->supports_fast_tracepoints ()
 
 #define target_get_min_fast_tracepoint_insn_len()	\
-  (the_target->get_min_fast_tracepoint_insn_len		\
-   ? (*the_target->get_min_fast_tracepoint_insn_len) () : 0)
+  the_target->pt->get_min_fast_tracepoint_insn_len ()
 
 #define target_thread_stopped(thread) \
   the_target->pt->thread_stopped (thread)
@@ -577,26 +575,26 @@ int kill_inferior (process_info *proc);
 #define target_stabilize_threads()		\
   the_target->pt->stabilize_threads ()
 
-#define install_fast_tracepoint_jump_pad(tpoint, tpaddr,		\
-					 collector, lockaddr,		\
-					 orig_size,			\
-					 jump_entry,			\
-					 trampoline, trampoline_size,	\
-					 jjump_pad_insn,		\
-					 jjump_pad_insn_size,		\
-					 adjusted_insn_addr,		\
-					 adjusted_insn_addr_end,	\
-					 err)				\
-  (*the_target->install_fast_tracepoint_jump_pad) (tpoint, tpaddr,	\
-						   collector,lockaddr,	\
-						   orig_size, jump_entry, \
-						   trampoline,		\
-						   trampoline_size,	\
-						   jjump_pad_insn,	\
-						   jjump_pad_insn_size, \
-						   adjusted_insn_addr,	\
-						   adjusted_insn_addr_end, \
-						   err)
+#define target_install_fast_tracepoint_jump_pad(tpoint, tpaddr,		\
+						collector, lockaddr,	\
+						orig_size,		\
+						jump_entry,		\
+						trampoline, trampoline_size, \
+						jjump_pad_insn,		\
+						jjump_pad_insn_size,	\
+						adjusted_insn_addr,	\
+						adjusted_insn_addr_end,	\
+						err)			\
+  the_target->pt->install_fast_tracepoint_jump_pad (tpoint, tpaddr,	\
+						    collector,lockaddr,	\
+						    orig_size, jump_entry, \
+						    trampoline,		\
+						    trampoline_size,	\
+						    jjump_pad_insn,	\
+						    jjump_pad_insn_size, \
+						    adjusted_insn_addr,	\
+						    adjusted_insn_addr_end, \
+						    err)
 
 #define target_emit_ops() \
   (the_target->emit_ops ? (*the_target->emit_ops) () : NULL)
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index be40c9b4cf1..e587d6561dc 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -3117,17 +3117,11 @@ install_fast_tracepoint (struct tracepoint *tpoint, char *errbuf)
   trampoline_size = 0;
 
   /* Install the jump pad.  */
-  err = install_fast_tracepoint_jump_pad (tpoint->obj_addr_on_target,
-					  tpoint->address,
-					  collect,
-					  ipa_sym_addrs.addr_collecting,
-					  tpoint->orig_size,
-					  &jentry,
-					  &trampoline, &trampoline_size,
-					  fjump, &fjump_size,
-					  &tpoint->adjusted_insn_addr,
-					  &tpoint->adjusted_insn_addr_end,
-					  errbuf);
+  err = target_install_fast_tracepoint_jump_pad
+    (tpoint->obj_addr_on_target, tpoint->address, collect,
+     ipa_sym_addrs.addr_collecting, tpoint->orig_size, &jentry,
+     &trampoline, &trampoline_size, fjump, &fjump_size,
+     &tpoint->adjusted_insn_addr, &tpoint->adjusted_insn_addr_end, errbuf);
 
   if (err)
     return 1;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 8e0be15fdaf..9c715fea362 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,10 +1858,8 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* supports_disable_randomization */
-  NULL, /* get_min_fast_tracepoint_insn_len */
   NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
   NULL, /* enable_btrace */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 01/58] gdbserver: start turning the target ops vector into a class
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (15 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 30/58] gdbserver: turn target op 'supports_multi_process' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 24/58] gdbserver: turn target op 'read_offsets' into a method Tankut Baris Aktemur
                   ` (42 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

This is the beginning of a series of patches where the goal is to turn
the target ops vector into a class and all the target op function
pointers into methods of this class.

Currently, the target ops is a struct of function pointers.  At the
end of the series, it becomes a class with methods, and the existing
low target definitions become subclasses.  That is, we end up with the
following class hierarchy:

  process_stratum_target
  ^
  |-- linux-low
  |-- lynx-low
  |-- nto-low
  |-- win32-low

process_stratum_target either defines the default behavior for the
target ops or leaves them as pure virtual for the subclasses to
override.

The transformation is done by first introducing a helper class, called
'process_target', that is initially empty.  An instance of this class
is added to the end of the current target ops vector.  This new field
is called 'pt'.  We will gradually carry target ops to the new class,
one by one, whereas the invocation of the target op will be converted
to a method call on 'pt'.

For instance, target op 'attach' is currently invoked as

  (*the_target->attach) (args)

After moving 'attach' as a method to 'process_target', it will be
invoked as

  the_target->pt->attach (args)

In this process, the concrete target vector definitions
(e.g. linux-low, win32-low, nto-low, etc.) are turned into derived
classes of 'process_target', so that they can either inherit the
default behavior of the target ops or can override the method.

We prefer to make this transition gradually rather than in a single
giant patch, to yield bite-size patches.  The goal is that after each
patch gdbserver will still be buildable and testable.

The general rule of thumb when converting a target op to a method is
this:

(1) If the function call is protected with a NULL-check with an
obvious default behavior, simply implement that default behavior in
the base class (e.g.: supports_non_stop).

(2) If there is no NULL-check guard, the method becomes pure
virtual, and the derived targets are required to implement the method
(e.g.: attach).

(3) If there is a NULL-check but no apparent default behavior, or if
the NULL-check is utilized to populate a feature support packet,
introduce a 'supports_XYZ' method (e.g.: pid_to_exec_file).

The overall strategy is to preserve the existing behavior as much as
possible.

When we're done moving all the target ops into 'process_target', the
target op vector will contain nothing but the field 'pt'.  At that
point, the auxiliary class 'process_target' will simply meld into
'process_stratum_target' and the method calls of the form
'the_target->pt->xyz' will be turned into 'the_target->xyz'.

The "linux-low" target has been built and reg-tested on X86_64 Linux
(Ubuntu).  The "win32-low" target has been built (but not tested) via
cross-compilation to a x86_64-w64-mingw32 target.  The "lynx-low" and
"nto-low" targets were neither built nor tested.

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* target.h (class process_target): New class definition.
	(struct process_stratum_target) <pt>: New field with type
	'process_target*'.
	* linux-low.h (class linux_process_target): Define as a derived
	class of 'process_target'.
	* linux-low.cc (linux_target_ops): Add a linux_process_target*
	as the 'pt' field.
	* lynx-low.h (class lynx_process_target): Define as a derived
	class of 'process_target'.
	* lynx-low.cc (lynx_target_ops): Add a lynx_process_target*
	as the 'pt' field.
	* nto-low.h (class nto_process_target): Define as a derived
	class of 'process_target'.
	* nto-low.cc (nto_target_ops): Add an nto_process_target*
	as the 'pt' field.
	* win32-low.h (class win32_process_target): Define as a derived
	class of 'process_target'.
	* win32-low.cc (win32_target_ops): Add a win32_process_target*
	as the 'pt' field.
---
 gdbserver/linux-low.cc |  5 +++++
 gdbserver/linux-low.h  |  8 ++++++++
 gdbserver/lynx-low.cc  | 39 +++++++++++++++++++++++++++++++++++++++
 gdbserver/lynx-low.h   |  8 ++++++++
 gdbserver/nto-low.cc   | 10 ++++++++++
 gdbserver/nto-low.h    |  8 ++++++++
 gdbserver/target.h     | 12 ++++++++++++
 gdbserver/win32-low.cc | 11 +++++++++++
 gdbserver/win32-low.h  |  8 ++++++++
 9 files changed, 109 insertions(+)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 676dea26c63..17f360639a4 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -7354,6 +7354,10 @@ 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_create_inferior,
   linux_post_create_inferior,
@@ -7457,6 +7461,7 @@ static process_stratum_target linux_target_ops = {
 #else
   NULL,
 #endif
+  &the_linux_target,
 };
 
 #ifdef HAVE_LINUX_REGSETS
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index e25ddd024dd..e6042735f38 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -264,6 +264,14 @@ struct linux_target_ops
 
 extern struct linux_target_ops the_low_target;
 
+/* Target ops definitions for a Linux target.  */
+
+class linux_process_target : public process_target
+{
+public:
+
+};
+
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
 #define get_lwp_thread(lwp) ((lwp)->thread)
 
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index a5b019396fa..f1177920921 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -719,6 +719,10 @@ lynx_request_interrupt (void)
   kill (lynx_ptid_get_pid (inferior_ptid), SIGINT);
 }
 
+/* The LynxOS target ops object.  */
+
+static lynx_process_target the_lynx_target;
+
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
@@ -765,6 +769,41 @@ static process_stratum_target lynx_target_ops = {
   NULL,  /* supports_exec_events */
   NULL,  /* handle_new_gdb_connection */
   NULL,  /* handle_monitor_command */
+  NULL,  /* core_of_thread */
+  NULL,  /* read_loadmap */
+  NULL,  /* process_qsupported */
+  NULL,  /* supports_tracepoints */
+  NULL,  /* read_pc */
+  NULL,  /* write_pc */
+  NULL,  /* thread_stopped */
+  NULL,  /* get_tib_address */
+  NULL,  /* pause_all */
+  NULL,  /* unpause_all */
+  NULL,  /* stabilize_threads */
+  NULL,  /* install_fast_tracepoint_jump_pad */
+  NULL,  /* emit_ops */
+  NULL,  /* supports_disable_randomization */
+  NULL,  /* get_min_fast_tracepoint_insn_len */
+  NULL,  /* qxfer_libraries_svr4 */
+  NULL,  /* support_agent */
+  NULL,  /* enable_btrace */
+  NULL,  /* disable_btrace */
+  NULL,  /* read_btrace */
+  NULL,  /* read_btrace_conf */
+  NULL,  /* supports_range_stepping */
+  NULL,  /* pid_to_exec_file */
+  NULL,  /* multifs_open */
+  NULL,  /* multifs_unlink */
+  NULL,  /* multifs_readlink */
+  NULL,  /* breakpoint_kind_from_pc */
+  NULL,  /* sw_breakpoint_from_kind */
+  NULL,  /* thread_name */
+  NULL,  /* breakpoint_kind_from_current_state */
+  NULL,  /* supports_software_single_step */
+  NULL,  /* supports_catch_syscall */
+  NULL,  /* get_ipa_tdesc_idx */
+  NULL,  /* thread_handle */
+  &the_lynx_target,
 };
 
 void
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index b122298fb88..923725dd003 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -52,6 +52,14 @@ struct lynx_target_ops
 
 extern struct lynx_target_ops the_low_target;
 
+/* Target ops definitions for a LynxOS target.  */
+
+class lynx_process_target : public process_target
+{
+public:
+
+};
+
 /* The inferior's target description.  This is a global because the
    LynxOS ports support neither bi-arch nor multi-process.  */
 extern const struct target_desc *lynx_tdesc;
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index b4dea479b9c..6f12a735c12 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -930,6 +930,9 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
   return the_low_target.breakpoint;
 }
 
+/* The QNX Neutrino target ops object.  */
+
+static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
   nto_create_inferior,
@@ -1003,6 +1006,13 @@ static process_stratum_target nto_target_ops = {
   NULL, /* multifs_readlink */
   NULL, /* breakpoint_kind_from_pc */
   nto_sw_breakpoint_from_kind,
+  NULL, /* thread_name */
+  NULL, /* breakpoint_kind_from_current_state */
+  NULL, /* supports_software_single_step */
+  NULL, /* supports_catch_syscall */
+  NULL, /* get_ipa_tdesc_idx */
+  NULL, /* thread_handle */
+  &the_nto_target,
 };
 
 
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 393b8a98695..2695db98737 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -42,6 +42,14 @@ struct nto_target_ops
 
 extern struct nto_target_ops the_low_target;
 
+/* Target ops definitions for a QNX Neutrino target.  */
+
+class nto_process_target : public process_target
+{
+public:
+
+};
+
 /* The inferior's target description.  This is a global because the
    LynxOS ports support neither bi-arch nor multi-process.  */
 extern const struct target_desc *nto_tdesc;
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 1b0810ba049..af78d8caa90 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -63,6 +63,8 @@ struct thread_resume
   CORE_ADDR step_range_end;	/* Exclusive */
 };
 
+class process_target;
+
 /* GDBserver doesn't have a concept of strata like GDB, but we call
    its target vector "process_stratum" anyway for the benefit of
    shared code.  */
@@ -477,6 +479,16 @@ struct process_stratum_target
      false for failure.  Return pointer to thread handle via HANDLE
      and the handle's length via HANDLE_LEN.  */
   bool (*thread_handle) (ptid_t ptid, gdb_byte **handle, int *handle_len);
+
+  /* The object that will gradually replace this struct.  */
+  process_target *pt;
+};
+
+class process_target
+{
+public:
+
+  virtual ~process_target () = default;
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index cdd70da8374..2a7b2964d92 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1834,6 +1834,10 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
   return the_low_target.breakpoint;
 }
 
+/* The win32 target ops object.  */
+
+static win32_process_target the_win32_target;
+
 static process_stratum_target win32_target_ops = {
   win32_create_inferior,
   NULL,  /* post_create_inferior */
@@ -1910,6 +1914,13 @@ static process_stratum_target win32_target_ops = {
   NULL, /* multifs_readlink */
   NULL, /* breakpoint_kind_from_pc */
   win32_sw_breakpoint_from_kind,
+  NULL, /* thread_name */
+  NULL, /* breakpoint_kind_from_current_state */
+  NULL, /* supports_software_single_step */
+  NULL, /* supports_catch_syscall */
+  NULL, /* get_ipa_tdesc_idx */
+  NULL, /* thread_handle */
+  &the_win32_target,
 };
 
 /* Initialize the Win32 backend.  */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 7a3eeda6e24..ff96f804fbd 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -101,6 +101,14 @@ struct win32_target_ops
 
 extern struct win32_target_ops the_low_target;
 
+/* Target ops definitions for a Win32 target.  */
+
+class win32_process_target : public process_target
+{
+public:
+
+};
+
 /* Retrieve the context for this thread, if not already retrieved.  */
 extern void win32_require_context (win32_thread_info *th);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 57/58] gdbserver: simply copy the pointer in 'set_target_ops'
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (24 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 56/58] gdbserver: turn target op 'get_ipa_tdesc_idx' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 21/58] gdbserver: turn target op '{supports_}stopped_by_hw_breakpoint' into a method Tankut Baris Aktemur
                   ` (33 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

From: Pedro Alves <palves@redhat.com>

The 'set_target_ops' function takes a target op vector and creates a
clone of it via XNEW and memcpy.  This is not necessary.  'the_target'
is a singleton, and the argument that is passed to 'set_target_ops' is
always the address of a global, static object.  Therefore, update the
implementation to simply copy the pointer.

gdbserver/ChangeLog:
2020-02-10  Pedro Alves  <palves@redhat.com>

	* target.cc (set_target_ops): Simply copy the given target pointer
	instead of creating a copy of the pointed object.
---
 gdbserver/target.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 4df1f9d4bd8..d0a7d36c868 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -270,8 +270,7 @@ target_supports_multi_process (void)
 void
 set_target_ops (process_stratum_target *target)
 {
-  the_target = XNEW (process_stratum_target);
-  memcpy (the_target, target, sizeof (*the_target));
+  the_target = target;
 }
 
 /* Convert pid to printable format.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 39/58] gdbserver: turn target op 'thread_stopped' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (29 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 47/58] gdbserver: turn target op 'supports_agent' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 20/58] gdbserver: turn target op '{supports_}stopped_by_sw_breakpoint' " Tankut Baris Aktemur
                   ` (28 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's thread_stopped op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_thread_stopped'.
	(target_thread_stopped): Update the macro.
	* target.cc (process_target::thread_stopped): Define.
	(process_target::supports_thread_stopped): Define.
	(prepare_to_access_memory): Update.

	Update the derived classes and callers below.

	* server.cc (queue_stop_reply_callback): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_thread_stopped): Define.
	(linux_thread_stopped): Turn into ...
	(linux_process_target::thread_stopped): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 11 ++++++++---
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  4 ++--
 gdbserver/target.cc    | 16 ++++++++++++++--
 gdbserver/target.h     | 13 ++++++++-----
 gdbserver/win32-low.cc |  1 -
 8 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 8065632a476..692863d9e4b 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6568,8 +6568,14 @@ linux_process_target::write_pc (regcache *regcache, CORE_ADDR pc)
   (*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;
 }
@@ -7445,7 +7451,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_thread_stopped,
   NULL,
   linux_pause_all,
   linux_unpause_all,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 67a36c8a67d..cbb2f48e135 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -392,6 +392,10 @@ public:
   CORE_ADDR read_pc (regcache *regcache) override;
 
   void write_pc (regcache *regcache, CORE_ADDR pc) override;
+
+  bool supports_thread_stopped () override;
+
+  bool thread_stopped (thread_info *thread) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 2ac59c3c14a..7cbde7c6e79 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* thread_stopped */
   NULL,  /* get_tib_address */
   NULL,  /* pause_all */
   NULL,  /* unpause_all */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 2b5b02b69bd..c144d774f0c 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* thread_stopped */
   NULL, /* get_tib_address */
   NULL, /* pause_all */
   NULL, /* unpause_all */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index df307f5594c..f3dca8d3ce0 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3217,7 +3217,7 @@ queue_stop_reply_callback (thread_info *thread)
 {
   /* For now, assume targets that don't have this callback also don't
      manage the thread's last_status field.  */
-  if (the_target->thread_stopped == NULL)
+  if (!the_target->pt->supports_thread_stopped ())
     {
       struct vstop_notif *new_notif = new struct vstop_notif;
 
@@ -3229,7 +3229,7 @@ queue_stop_reply_callback (thread_info *thread)
     }
   else
     {
-      if (thread_stopped (thread))
+      if (target_thread_stopped (thread))
 	{
 	  if (debug_threads)
 	    {
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 4f8d91c171f..b44170a7cdd 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -66,8 +66,8 @@ prepare_to_access_memory (void)
     {
       if (mythread_alive (thread->id))
 	{
-	  if (stopped == NULL && the_target->thread_stopped != NULL
-	      && thread_stopped (thread))
+	  if (stopped == NULL && the_target->pt->supports_thread_stopped ()
+	      && target_thread_stopped (thread))
 	    stopped = thread;
 
 	  if (first == NULL)
@@ -626,3 +626,15 @@ process_target::write_pc (regcache *regcache, CORE_ADDR pc)
 {
   gdb_assert_not_reached ("process_target::write_pc: Unable to update PC");
 }
+
+bool
+process_target::supports_thread_stopped ()
+{
+  return false;
+}
+
+bool
+process_target::thread_stopped (thread_info *thread)
+{
+  gdb_assert_not_reached ("target op thread_stopped not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 2aef0208c11..49d5eca479e 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return true if THREAD is known to be stopped now.  */
-  int (*thread_stopped) (struct thread_info *thread);
-
   /* Read Thread Information Block address.  */
   int (*get_tib_address) (ptid_t ptid, CORE_ADDR *address);
 
@@ -488,6 +485,12 @@ public:
 
   /* Write PC to REGCACHE.  */
   virtual void write_pc (regcache *regcache, CORE_ADDR pc);
+
+  /* Return true if the thread_stopped op is supported.  */
+  virtual bool supports_thread_stopped ();
+
+  /* Return true if THREAD is known to be stopped now.  */
+  virtual bool thread_stopped (thread_info *thread);
 };
 
 extern process_stratum_target *the_target;
@@ -559,8 +562,8 @@ int kill_inferior (process_info *proc);
   (the_target->get_min_fast_tracepoint_insn_len		\
    ? (*the_target->get_min_fast_tracepoint_insn_len) () : 0)
 
-#define thread_stopped(thread) \
-  (*the_target->thread_stopped) (thread)
+#define target_thread_stopped(thread) \
+  the_target->pt->thread_stopped (thread)
 
 #define pause_all(freeze)			\
   do						\
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index a7329fe20cf..712624852d6 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* thread_stopped */
   win32_get_tib_address,
   NULL, /* pause_all */
   NULL, /* unpause_all */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 19/58] gdbserver: turn target ops 'insert_point' and 'remove_point' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (38 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 33/58] gdbserver: turn target op 'handle_monitor_command' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 25/58] gdbserver: turn target op 'get_tls_address' into a method Tankut Baris Aktemur
                   ` (19 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's insert_point and remove_point ops
	into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	* target.cc (process_target::insert_point): Define.
	(process_target::remove_point): Define.

	Update the derived classes and callers below.

	* mem-break.cc (set_raw_breakpoint_at): Update.
	(delete_raw_breakpoint): Update.
	(uninsert_raw_breakpoint): Update.
	(reinsert_raw_breakpoint): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_insert_point): Turn into ...
	(linux_process_target::insert_point): ... this.
	(linux_remove_point): Turn into ...
	(linux_process_target::remove_point): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_insert_point): Turn into ...
	(nto_process_target::insert_point): ... this.
	(nto_remove_point): Turn into ...
	(nto_process_target::remove_point): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_insert_point): Turn into ...
	(win32_process_target::insert_point): ... this.
	(win32_remove_point): Turn into ...
	(win32_process_target::remove_point): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc | 14 ++++++--------
 gdbserver/linux-low.h  |  6 ++++++
 gdbserver/lynx-low.cc  |  2 --
 gdbserver/mem-break.cc | 10 +++++-----
 gdbserver/nto-low.cc   | 14 ++++++--------
 gdbserver/nto-low.h    |  6 ++++++
 gdbserver/target.cc    | 14 ++++++++++++++
 gdbserver/target.h     | 16 ++++++++--------
 gdbserver/win32-low.cc | 14 ++++++--------
 gdbserver/win32-low.h  |  6 ++++++
 10 files changed, 63 insertions(+), 39 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 37e46a8ca22..96692cd77a7 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5964,9 +5964,9 @@ linux_process_target::supports_z_point_type (char z_type)
 	  && the_low_target.supports_z_point_type (z_type));
 }
 
-static int
-linux_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
-		    int size, struct raw_breakpoint *bp)
+int
+linux_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+				    int size, raw_breakpoint *bp)
 {
   if (type == raw_bkpt_type_sw)
     return insert_memory_breakpoint (bp);
@@ -5977,9 +5977,9 @@ linux_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
     return 1;
 }
 
-static int
-linux_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
-		    int size, struct raw_breakpoint *bp)
+int
+linux_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+				    int size, raw_breakpoint *bp)
 {
   if (type == raw_bkpt_type_sw)
     return remove_memory_breakpoint (bp);
@@ -7376,8 +7376,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_insert_point,
-  linux_remove_point,
   linux_stopped_by_sw_breakpoint,
   linux_supports_stopped_by_sw_breakpoint,
   linux_stopped_by_hw_breakpoint,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 052beb6c44c..6d58d6620b6 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -316,6 +316,12 @@ public:
 		 unsigned int len) override;
 
   bool supports_z_point_type (char z_type) override;
+
+  int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+		    int size, raw_breakpoint *bp) override;
+
+  int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+		    int size, raw_breakpoint *bp) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index dd4584797c4..dc864e8bb10 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -729,8 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* insert_point */
-  NULL,  /* remove_point */
   NULL,  /* stopped_by_sw_breakpoint */
   NULL,  /* supports_stopped_by_sw_breakpoint */
   NULL,  /* stopped_by_hw_breakpoint */
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index b00e9fca353..682b3bc1832 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -460,7 +460,7 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
 
   if (!bp->inserted)
     {
-      *err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
+      *err = the_target->pt->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
       if (*err != 0)
 	{
 	  if (debug_threads)
@@ -890,8 +890,8 @@ delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel)
 
 	      *bp_link = bp->next;
 
-	      ret = the_target->remove_point (bp->raw_type, bp->pc, bp->kind,
-					      bp);
+	      ret = the_target->pt->remove_point (bp->raw_type, bp->pc,
+						  bp->kind, bp);
 	      if (ret != 0)
 		{
 		  /* Something went wrong, relink the breakpoint.  */
@@ -1532,7 +1532,7 @@ uninsert_raw_breakpoint (struct raw_breakpoint *bp)
 
       bp->inserted = 0;
 
-      err = the_target->remove_point (bp->raw_type, bp->pc, bp->kind, bp);
+      err = the_target->pt->remove_point (bp->raw_type, bp->pc, bp->kind, bp);
       if (err != 0)
 	{
 	  bp->inserted = 1;
@@ -1621,7 +1621,7 @@ reinsert_raw_breakpoint (struct raw_breakpoint *bp)
   if (bp->inserted)
     return;
 
-  err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
+  err = the_target->pt->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
   if (err == 0)
     bp->inserted = 1;
   else if (debug_threads)
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 204d8066455..56d34626667 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -807,9 +807,9 @@ nto_process_target::supports_z_point_type (char z_type)
 
 /* Insert {break/watch}point at address ADDR.  SIZE is not used.  */
 
-static int
-nto_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
-		  int size, struct raw_breakpoint *bp)
+int
+nto_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+				  int size, raw_breakpoint *bp)
 {
   int wtype = _DEBUG_BREAK_HW; /* Always request HW.  */
 
@@ -839,9 +839,9 @@ nto_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
 
 /* Remove {break/watch}point at address ADDR.  SIZE is not used.  */
 
-static int
-nto_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
-		  int size, struct raw_breakpoint *bp)
+int
+nto_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+				  int size, raw_breakpoint *bp)
 {
   int wtype = _DEBUG_BREAK_HW; /* Always request HW.  */
 
@@ -950,8 +950,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_insert_point,
-  nto_remove_point,
   NULL, /* stopped_by_sw_breakpoint */
   NULL, /* supports_stopped_by_sw_breakpoint */
   NULL, /* stopped_by_hw_breakpoint */
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 65bbf7e818c..b0b276319d2 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -86,6 +86,12 @@ public:
 		 unsigned int len) override;
 
   bool supports_z_point_type (char z_type) override;
+
+  int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+		    int size, raw_breakpoint *bp) override;
+
+  int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+		    int size, raw_breakpoint *bp) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 22339622e09..fd443efd61e 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -433,3 +433,17 @@ process_target::supports_z_point_type (char z_type)
 {
   return false;
 }
+
+int
+process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+			      int size, raw_breakpoint *bp)
+{
+  return 1;
+}
+
+int
+process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+			      int size, raw_breakpoint *bp)
+{
+  return 1;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 3262371749e..f04c1c15bcb 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,14 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Insert and remove a break or watchpoint.
-     Returns 0 on success, -1 on failure and 1 on unsupported.  */
-
-  int (*insert_point) (enum raw_bkpt_type type, CORE_ADDR addr,
-		       int size, struct raw_breakpoint *bp);
-  int (*remove_point) (enum raw_bkpt_type type, CORE_ADDR addr,
-		       int size, struct raw_breakpoint *bp);
-
   /* Returns 1 if the target stopped because it executed a software
      breakpoint instruction, 0 otherwise.  */
   int (*stopped_by_sw_breakpoint) (void);
@@ -476,6 +468,14 @@ public:
        '4' - access watchpoint
   */
   virtual bool supports_z_point_type (char z_type);
+
+  /* Insert and remove a break or watchpoint.
+     Returns 0 on success, -1 on failure and 1 on unsupported.  */
+  virtual int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+			    int size, raw_breakpoint *bp);
+
+  virtual int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+			    int size, raw_breakpoint *bp);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 024748e9282..c42d8d7414c 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -261,9 +261,9 @@ win32_process_target::supports_z_point_type (char z_type)
 	  && the_low_target.supports_z_point_type (z_type));
 }
 
-static int
-win32_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
-		    int size, struct raw_breakpoint *bp)
+int
+win32_process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+				    int size, raw_breakpoint *bp)
 {
   if (the_low_target.insert_point != NULL)
     return the_low_target.insert_point (type, addr, size, bp);
@@ -272,9 +272,9 @@ win32_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
     return 1;
 }
 
-static int
-win32_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
-		    int size, struct raw_breakpoint *bp)
+int
+win32_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+				    int size, raw_breakpoint *bp)
 {
   if (the_low_target.remove_point != NULL)
     return the_low_target.remove_point (type, addr, size, bp);
@@ -1838,8 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_insert_point,
-  win32_remove_point,
   NULL, /* stopped_by_sw_breakpoint */
   NULL, /* supports_stopped_by_sw_breakpoint */
   NULL, /* stopped_by_hw_breakpoint */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index a095ed80ffe..a6b27918f4c 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -140,6 +140,12 @@ public:
   void request_interrupt () override;
 
   bool supports_z_point_type (char z_type) override;
+
+  int insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
+		    int size, raw_breakpoint *bp) override;
+
+  int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
+		    int size, raw_breakpoint *bp) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class
@ 2020-02-17 17:01 Tankut Baris Aktemur
  2020-02-17 16:59 ` [PATCH v2 15/58] gdbserver: turn target op 'look_up_symbols' into a method Tankut Baris Aktemur
                   ` (59 more replies)
  0 siblings, 60 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

Hello,

This is v2 of the series that was posted at

  https://sourceware.org/ml/gdb-patches/2020-02/msg00313.html

This revision makes the following updates to the previous version:

1. Pedro's comments have been addressed.

2. The series has been rebased on the current master.

3. The win32-low target has been built (but not tested) via
cross-compilation (my thanks to Christian for the tips).  There were a
couple problems detected -- I fixed them.

I am in the process of using buildbot to test on a wide range of
available targets (assuming a series of this size will be accepted by
buildbot).  However, I'm afraid I won't be able to build and test
nto-low and lynx-low.

Finally, this revision is also available at
https://github.com/barisaktemur/gdb/tree/gdbserver-cppify-target-v2

Regards,
Baris


Pedro Alves (1):
  gdbserver: simply copy the pointer in 'set_target_ops'

Tankut Baris Aktemur (57):
  gdbserver: start turning the target ops vector into a class
  gdbserver: turn target op 'create_inferior' into a method
  gdbserver: turn target op 'post_create_inferior' into a method
  gdbserver: turn target op 'attach' into a method
  gdbserver: turn target op 'kill' into a method
  gdbserver: turn target op 'detach' into a method
  gdbserver: turn target op 'mourn' into a method
  gdbserver: turn target op 'join' into a method
  gdbserver: turn target op 'thread_alive' into a method
  gdbserver: turn target op 'resume' into a method
  gdbserver: turn target op 'wait' into a method
  gdbserver: turn target ops 'fetch_registers' and 'store_registers'
    into methods
  gdbserver: turn prepare_to_access_memory & done_accessing_memory into
    methods
  gdbserver: turn target ops 'read_memory' and 'write_memory' into
    methods
  gdbserver: turn target op 'look_up_symbols' into a method
  gdbserver: turn target op 'request_interrupt' into a method
  gdbserver: turn target op 'read_auxv' into a method
  gdbserver: turn target op 'supports_z_point_type' into a method
  gdbserver: turn target ops 'insert_point' and 'remove_point' into
    methods
  gdbserver: turn target op '{supports_}stopped_by_sw_breakpoint' into a
    method
  gdbserver: turn target op '{supports_}stopped_by_hw_breakpoint' into a
    method
  gdbserver: turn target op 'supports_hardware_single_step' into a
    method
  gdbserver: turn target ops 'stopped_by_watchpoint' and
    'stopped_data_address' into methods
  gdbserver: turn target op 'read_offsets' into a method
  gdbserver: turn target op 'get_tls_address' into a method
  gdbserver: turn target op 'hostio_last_error' into a method
  gdbserver: turn target op 'qxfer_osdata' into a method
  gdbserver: turn target op 'qxfer_siginfo' into a method
  gdbserver: turn non-stop and async target ops into methods
  gdbserver: turn target op 'supports_multi_process' into a method
  gdbserver: turn target ops 'supports_{fork,vfork,exec}_events' into
    methods
  gdbserver: turn target op 'handle_new_gdb_connection' into a method
  gdbserver: turn target op 'handle_monitor_command' into a method
  gdbserver: turn target op 'core_of_thread' into a method
  gdbserver: turn target op 'read_loadmap' into a method
  gdbserver: turn target op 'process_qsupported' into a method
  gdbserver: turn target op 'supports_tracepoints' into a method
  gdbserver: turn target ops 'read_pc' and 'write_pc' into methods
  gdbserver: turn target op 'thread_stopped' into a method
  gdbserver: turn target op 'get_tib_address' into a method
  gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods
  gdbserver: turn target op 'stabilize_threads' into a method
  gdbserver: turn fast tracepoint target ops into methods
  gdbserver: turn target op 'emit_ops' into a method
  gdbserver: turn target op 'supports_disable_randomization' into a
    method
  gdbserver: turn target op 'qxfer_libraries_svr4' into a method
  gdbserver: turn target op 'supports_agent' into a method
  gdbserver: turn btrace-related target ops into methods
  gdbserver: turn target op 'supports_range_stepping' into a method
  gdbserver: turn target op 'pid_to_exec_file' into a method
  gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into
    methods
  gdbserver: turn breakpoint kind-related target ops into methods
  gdbserver: turn target ops 'thread_name' and 'thread_handle' into
    methods
  gdbserver: turn target op 'supports_software_single_step' into a
    method
  gdbserver: turn target op 'supports_catch_syscall' into a method
  gdbserver: turn target op 'get_ipa_tdesc_idx' into a method
  gdbserver: finish turning the target ops vector into a class

 gdbserver/hostio.cc            |  13 +-
 gdbserver/linux-aarch32-low.cc |   6 +-
 gdbserver/linux-aarch64-low.cc |   4 +-
 gdbserver/linux-arm-low.cc     |   8 +-
 gdbserver/linux-cris-low.cc    |   4 +-
 gdbserver/linux-crisv32-low.cc |   4 +-
 gdbserver/linux-low.cc         | 654 ++++++++++++++++++---------------
 gdbserver/linux-low.h          | 219 +++++++++++
 gdbserver/linux-m32r-low.cc    |   4 +-
 gdbserver/linux-mips-low.cc    |   2 +-
 gdbserver/linux-nios2-low.cc   |   4 +-
 gdbserver/linux-ppc-low.cc     |   2 +-
 gdbserver/linux-sh-low.cc      |   2 +-
 gdbserver/linux-sparc-low.cc   |   6 +-
 gdbserver/linux-tic6x-low.cc   |   2 +-
 gdbserver/linux-tile-low.cc    |   2 +-
 gdbserver/linux-x86-low.cc     |   2 +-
 gdbserver/linux-xtensa-low.cc  |   4 +-
 gdbserver/lynx-low.cc          | 139 +++----
 gdbserver/lynx-low.h           |  43 +++
 gdbserver/mem-break.cc         |  11 +-
 gdbserver/nto-low.cc           | 208 ++++-------
 gdbserver/nto-low.h            |  60 +++
 gdbserver/regcache.cc          |  16 +-
 gdbserver/remote-utils.cc      |  13 +-
 gdbserver/server.cc            |  77 ++--
 gdbserver/target.cc            | 570 ++++++++++++++++++++++++----
 gdbserver/target.h             | 554 +++++++++++++---------------
 gdbserver/tracepoint.cc        |  54 ++-
 gdbserver/win32-low.cc         | 221 +++++------
 gdbserver/win32-low.h          |  69 ++++
 31 files changed, 1830 insertions(+), 1147 deletions(-)

-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 35/58] gdbserver: turn target op 'read_loadmap' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (22 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 37/58] gdbserver: turn target op 'supports_tracepoints' into a method Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 56/58] gdbserver: turn target op 'get_ipa_tdesc_idx' " Tankut Baris Aktemur
                   ` (35 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's read_loadmap op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_read_loadmap'.
	* target.cc (process_target::read_loadmap): Define.
	(process_target::supports_read_loadmap): Define.

	Update the derived classes and callers below.

	* server.cc (handle_qxfer_fdpic): Update.
	(handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_read_loadmap): Define.
	(linux_read_loadmap): Turn into ...
	(linux_process_target::read_loadmap): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 15 +++++++++------
 gdbserver/linux-low.h  |  7 +++++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.cc    | 13 +++++++++++++
 gdbserver/target.h     | 11 +++++++----
 gdbserver/win32-low.cc |  1 -
 8 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 8ddaf64c103..6dd13129618 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6479,9 +6479,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;
@@ -6511,8 +6517,6 @@ 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
@@ -7441,7 +7445,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_read_loadmap,
   linux_process_qsupported,
   linux_supports_tracepoints,
   linux_read_pc,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 1d89ebd7a2d..9f4fdab33d5 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -377,6 +377,13 @@ public:
   int handle_monitor_command (char *mon) override;
 
   int core_of_thread (ptid_t ptid) override;
+
+#if defined PT_GETDSBT || defined PTRACE_GETFDPIC
+  bool supports_read_loadmap () override;
+
+  int read_loadmap (const char *annex, CORE_ADDR offset,
+		    unsigned char *myaddr, unsigned int len) override;
+#endif
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 2e177594c3a..b384d20a37b 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* read_loadmap */
   NULL,  /* process_qsupported */
   NULL,  /* supports_tracepoints */
   NULL,  /* read_pc */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 9a708712905..70d218cb924 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* read_loadmap */
   NULL, /* process_qsupported */
   NULL, /* supports_tracepoints */
   NULL, /* read_pc */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index f9817881d77..df307f5594c 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1792,13 +1792,13 @@ static int
 handle_qxfer_fdpic (const char *annex, gdb_byte *readbuf,
 		    const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
 {
-  if (the_target->read_loadmap == NULL)
+  if (!the_target->pt->supports_read_loadmap ())
     return -2;
 
   if (current_thread == NULL)
     return -1;
 
-  return (*the_target->read_loadmap) (annex, offset, readbuf, len);
+  return the_target->pt->read_loadmap (annex, offset, readbuf, len);
 }
 
 /* Handle qXfer:btrace:read.  */
@@ -2380,7 +2380,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (the_target->pt->supports_qxfer_siginfo ())
 	strcat (own_buf, ";qXfer:siginfo:read+;qXfer:siginfo:write+");
 
-      if (the_target->read_loadmap != NULL)
+      if (the_target->pt->supports_read_loadmap ())
 	strcat (own_buf, ";qXfer:fdpic:read+");
 
       /* We always report qXfer:features:read, as targets may
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index e1c802d65bc..26b9d8b6afe 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -589,3 +589,16 @@ process_target::core_of_thread (ptid_t ptid)
 {
   return -1;
 }
+
+bool
+process_target::supports_read_loadmap ()
+{
+  return false;
+}
+
+int
+process_target::read_loadmap (const char *annex, CORE_ADDR offset,
+			      unsigned char *myaddr, unsigned int len)
+{
+  gdb_assert_not_reached ("target op read_loadmap not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 96d986a09ab..f69bd9d0e01 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read loadmaps.  Read LEN bytes at OFFSET into a buffer at MYADDR.  */
-  int (*read_loadmap) (const char *annex, CORE_ADDR offset,
-		       unsigned char *myaddr, unsigned int len);
-
   /* Target specific qSupported support.  FEATURES is an array of
      features with COUNT elements.  */
   void (*process_qsupported) (char **features, int count);
@@ -486,6 +482,13 @@ public:
 
   /* Returns the core given a thread, or -1 if not known.  */
   virtual int core_of_thread (ptid_t ptid);
+
+  /* Returns true if the read_loadmap target op is supported.  */
+  virtual bool supports_read_loadmap ();
+
+  /* Read loadmaps.  Read LEN bytes at OFFSET into a buffer at MYADDR.  */
+  virtual int read_loadmap (const char *annex, CORE_ADDR offset,
+			    unsigned char *myaddr, unsigned int len);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index c0b73268238..9fc882523b0 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* read_loadmap */
   NULL, /* process_qsupported */
   NULL, /* supports_tracepoints */
   NULL, /* read_pc */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 04/58] gdbserver: turn target op 'attach' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (13 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 42/58] gdbserver: turn target op 'stabilize_threads' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 30/58] gdbserver: turn target op 'supports_multi_process' " Tankut Baris Aktemur
                   ` (44 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's attach op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(myattach): Update the macro.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_attach): Turn into ...
	(linux_process_target::attach): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_attach): Turn into ...
	(lynx_process_target::attach): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_attach): Turn into ...
	(nto_process_target::attach): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_attach): Turn into ...
	(win32_process_target::attach): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  5 ++---
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/nto-low.cc   |  5 ++---
 gdbserver/nto-low.h    |  2 ++
 gdbserver/target.h     | 21 ++++++++++-----------
 gdbserver/win32-low.cc |  5 ++---
 gdbserver/win32-low.h  |  2 ++
 9 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 2e3daa2733f..aae29306df6 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1181,8 +1181,8 @@ static void async_file_mark (void);
 /* Attach to PID.  If PID is the tgid, attach to it and all
    of its threads.  */
 
-static int
-linux_attach (unsigned long pid)
+int
+linux_process_target::attach (unsigned long pid)
 {
   struct process_info *proc;
   struct thread_info *initial_thread;
@@ -7359,7 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_attach,
   linux_kill,
   linux_detach,
   linux_mourn,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 870a0d4d863..5458a9b99b9 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -274,6 +274,8 @@ public:
 		       const std::vector<char *> &program_args) override;
 
   void post_create_inferior () override;
+
+  int attach (unsigned long pid) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index d9f96de70f6..60abc75d8da 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -309,8 +309,8 @@ lynx_add_threads_after_attach (int pid)
 
 /* Implement the attach target_ops method.  */
 
-static int
-lynx_attach (unsigned long pid)
+int
+lynx_process_target::attach (unsigned long pid)
 {
   ptid_t ptid = lynx_ptid_t (pid, 0);
 
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_attach,
   lynx_kill,
   lynx_detach,
   lynx_mourn,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 66cfdfa870c..142a774011c 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -60,6 +60,8 @@ public:
 
   int create_inferior (const char *program,
 		       const std::vector<char *> &program_args) override;
+
+  int attach (unsigned long pid) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index c295be732df..77b5fce4c50 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -385,8 +385,8 @@ nto_process_target::create_inferior (const char *program,
 
 /* Attach to process PID.  */
 
-static int
-nto_attach (unsigned long pid)
+int
+nto_process_target::attach (unsigned long pid)
 {
   TRACE ("%s %ld\n", __func__, pid);
   if (do_attach (pid) != pid)
@@ -935,7 +935,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_attach,
   nto_kill,
   nto_detach,
   nto_mourn,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 3bad08b82ac..f6faacb425e 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -50,6 +50,8 @@ public:
 
   int create_inferior (const char *program,
 		       const std::vector<char *> &program_args) override;
+
+  int attach (unsigned long pid) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 87036e83846..bd99737d4f1 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,16 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Attach to a running process.
-
-     PID is the process ID to attach to, specified by the user
-     or a higher layer.
-
-     Returns -1 if attaching is unsupported, 0 on success, and calls
-     error() otherwise.  */
-
-  int (*attach) (unsigned long pid);
-
   /* Kill process PROC.  Return -1 on failure, and 0 on success.  */
 
   int (*kill) (process_info *proc);
@@ -489,6 +479,15 @@ public:
   /* Do additional setup after a new process is created, including
      exec-wrapper completion.  */
   virtual void post_create_inferior ();
+
+  /* Attach to a running process.
+
+     PID is the process ID to attach to, specified by the user
+     or a higher layer.
+
+     Returns -1 if attaching is unsupported, 0 on success, and calls
+     error() otherwise.  */
+  virtual int attach (unsigned long pid) = 0;
 };
 
 extern process_stratum_target *the_target;
@@ -502,7 +501,7 @@ void set_target_ops (process_stratum_target *);
   the_target->pt->post_create_inferior ()
 
 #define myattach(pid) \
-  (*the_target->attach) (pid)
+  the_target->pt->attach (pid)
 
 int kill_inferior (process_info *proc);
 
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index a9b1bfb2fd6..0e7c1640522 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -726,8 +726,8 @@ win32_process_target::create_inferior (const char *program,
 /* Attach to a running process.
    PID is the process ID to attach to, specified by the user
    or a higher layer.  */
-static int
-win32_attach (unsigned long pid)
+int
+win32_process_target::attach (unsigned long pid)
 {
   HANDLE h;
   winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit = NULL;
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_attach,
   win32_kill,
   win32_detach,
   win32_mourn,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index c922d735068..fd6662dcab2 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -109,6 +109,8 @@ public:
 
   int create_inferior (const char *program,
 		       const std::vector<char *> &program_args) override;
+
+  int attach (unsigned long pid) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 53/58] gdbserver: turn target ops 'thread_name' and 'thread_handle' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (20 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 44/58] gdbserver: turn target op 'emit_ops' into a method Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 37/58] gdbserver: turn target op 'supports_tracepoints' into a method Tankut Baris Aktemur
                   ` (37 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's thread_name and thread_handle ops
	into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(target_thread_name): Update the macro.
	(target_thread_handle): Update the macro.
	* target.cc (process_target::thread_name): Define.
	(process_target::thread_handle): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::thread_name): Define.
	(linux_process_target::thread_handle): Define.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 21 +++++++++++++++------
 gdbserver/linux-low.h  |  7 +++++++
 gdbserver/lynx-low.cc  |  2 --
 gdbserver/nto-low.cc   |  2 --
 gdbserver/target.cc    | 13 +++++++++++++
 gdbserver/target.h     | 27 +++++++++++++--------------
 gdbserver/win32-low.cc |  2 --
 7 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 9dce2a7c35e..cd079562d47 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -7393,6 +7393,21 @@ linux_process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
     return breakpoint_kind_from_pc (pcptr);
 }
 
+const char *
+linux_process_target::thread_name (ptid_t thread)
+{
+  return linux_proc_tid_get_name (thread);
+}
+
+#if USE_THREAD_DB
+bool
+linux_process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
+				     int *handle_len)
+{
+  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".  */
 
@@ -7505,15 +7520,9 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_proc_tid_get_name,
   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,
 };
 
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index ae422b83879..2acd65f2828 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -468,6 +468,13 @@ public:
   const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
 
   int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
+
+  const char *thread_name (ptid_t thread) override;
+
+#if USE_THREAD_DB
+  bool thread_handle (ptid_t ptid, gdb_byte **handle,
+		      int *handle_len) override;
+#endif
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index b07412f0dcd..0c460be5f31 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -741,11 +741,9 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* thread_name */
   NULL,  /* supports_software_single_step */
   NULL,  /* supports_catch_syscall */
   NULL,  /* get_ipa_tdesc_idx */
-  NULL,  /* thread_handle */
   &the_lynx_target,
 };
 
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index b0ac86f8790..4c3c5a3a42d 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,11 +947,9 @@ nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* thread_name */
   NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
-  NULL, /* thread_handle */
   &the_nto_target,
 };
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 76eef626ce8..b7ed26b22f4 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -801,3 +801,16 @@ process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
 {
   return breakpoint_kind_from_pc (pcptr);
 }
+
+const char *
+process_target::thread_name (ptid_t thread)
+{
+  return nullptr;
+}
+
+bool
+process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
+			       int *handle_len)
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 4651e449a80..4d9de5513aa 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return the thread's name, or NULL if the target is unable to determine it.
-     The returned value must not be freed by the caller.  */
-  const char *(*thread_name) (ptid_t thread);
-
   /* Returns true if the target can software single step.  */
   int (*supports_software_single_step) (void);
 
@@ -84,11 +80,6 @@ struct process_stratum_target
   /* Return tdesc index for IPA.  */
   int (*get_ipa_tdesc_idx) (void);
 
-  /* Thread ID to (numeric) thread handle: Return true on success and
-     false for failure.  Return pointer to thread handle via HANDLE
-     and the handle's length via HANDLE_LEN.  */
-  bool (*thread_handle) (ptid_t ptid, gdb_byte **handle, int *handle_len);
-
   /* The object that will gradually replace this struct.  */
   process_target *pt;
 };
@@ -503,6 +494,17 @@ public:
      PC.  The PCPTR is adjusted to the real memory location in case a
      flag (e.g., the Thumb bit on ARM) is present in the  PC.  */
   virtual int breakpoint_kind_from_current_state (CORE_ADDR *pcptr);
+
+  /* Return the thread's name, or NULL if the target is unable to
+     determine it.  The returned value must not be freed by the
+     caller.  */
+  virtual const char *thread_name (ptid_t thread);
+
+  /* Thread ID to (numeric) thread handle: Return true on success and
+     false for failure.  Return pointer to thread handle via HANDLE
+     and the handle's length via HANDLE_LEN.  */
+  virtual bool thread_handle (ptid_t ptid, gdb_byte **handle,
+			      int *handle_len);
 };
 
 extern process_stratum_target *the_target;
@@ -683,13 +685,10 @@ void done_accessing_memory (void);
   the_target->pt->core_of_thread (ptid)
 
 #define target_thread_name(ptid)                                \
-  (the_target->thread_name ? (*the_target->thread_name) (ptid)  \
-   : NULL)
+  the_target->pt->thread_name (ptid)
 
 #define target_thread_handle(ptid, handle, handle_len) \
-   (the_target->thread_handle ? (*the_target->thread_handle) \
-                                  (ptid, handle, handle_len) \
-   : false)
+  the_target->pt->thread_handle (ptid, handle, handle_len)
 
 int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
 
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 71adf18ebb5..218f007bdec 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,11 +1858,9 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* thread_name */
   NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
-  NULL, /* thread_handle */
   &the_win32_target,
 };
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 56/58] gdbserver: turn target op 'get_ipa_tdesc_idx' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (23 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 35/58] gdbserver: turn target op 'read_loadmap' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 57/58] gdbserver: simply copy the pointer in 'set_target_ops' Tankut Baris Aktemur
                   ` (34 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's get_ipa_tdesc_idx op into a method
	of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_get_ipa_tdesc_idx): Update the macro.
	* target.cc (process_target::get_ipa_tdesc_idx): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_get_ipa_tdesc_idx): Turn into ...
	(linux_process_target::get_ipa_tdesc_idx): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 5 ++---
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 6 ++++++
 gdbserver/target.h     | 9 ++++-----
 gdbserver/win32-low.cc | 1 -
 7 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 559f7519a7d..8183567137b 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6571,8 +6571,8 @@ linux_process_target::supports_catch_syscall ()
 	  && 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;
@@ -7520,7 +7520,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_get_ipa_tdesc_idx,
   &the_linux_target,
 };
 
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 349f4b7e1eb..33f208efd3b 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -479,6 +479,8 @@ public:
   bool supports_software_single_step () override;
 
   bool supports_catch_syscall () override;
+
+  int get_ipa_tdesc_idx () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 76519692a3e..5e11355fcaa 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -741,7 +741,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* get_ipa_tdesc_idx */
   &the_lynx_target,
 };
 
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 2ee84420169..309c698bc2a 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* get_ipa_tdesc_idx */
   &the_nto_target,
 };
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 2ea8234be08..4df1f9d4bd8 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -826,3 +826,9 @@ process_target::supports_catch_syscall ()
 {
   return false;
 }
+
+int
+process_target::get_ipa_tdesc_idx ()
+{
+  return 0;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 21b6bace681..f6976303ee0 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return tdesc index for IPA.  */
-  int (*get_ipa_tdesc_idx) (void);
-
   /* The object that will gradually replace this struct.  */
   process_target *pt;
 };
@@ -504,6 +501,9 @@ public:
 
   /* Return true if the target supports catch syscall.  */
   virtual bool supports_catch_syscall ();
+
+  /* Return tdesc index for IPA.  */
+  virtual int get_ipa_tdesc_idx ();
 };
 
 extern process_stratum_target *the_target;
@@ -561,8 +561,7 @@ int kill_inferior (process_info *proc);
   the_target->pt->supports_catch_syscall ()
 
 #define target_get_ipa_tdesc_idx()			\
-  (the_target->get_ipa_tdesc_idx			\
-   ? (*the_target->get_ipa_tdesc_idx) () : 0)
+  the_target->pt->get_ipa_tdesc_idx ()
 
 #define target_supports_tracepoints()			\
   the_target->pt->supports_tracepoints ()
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 132d33441bf..640252805e0 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* get_ipa_tdesc_idx */
   &the_win32_target,
 };
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 37/58] gdbserver: turn target op 'supports_tracepoints' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (21 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 53/58] gdbserver: turn target ops 'thread_name' and 'thread_handle' into methods Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 35/58] gdbserver: turn target op 'read_loadmap' " Tankut Baris Aktemur
                   ` (36 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_tracepoints op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_supports_tracepoints): Update the macro.
	* target.cc (process_target::supports_tracepoints): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_tracepoints): Turn into ...
	(linux_process_target::supports_tracepoints): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc |  7 +++----
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     | 10 ++++------
 gdbserver/win32-low.cc |  1 -
 7 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index fbfb295b923..5e325eb0e7f 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6542,11 +6542,11 @@ 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) ();
 }
@@ -7445,7 +7445,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_tracepoints,
   linux_read_pc,
   linux_write_pc,
   linux_thread_stopped,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 5c75ae44ecd..1d71ff51cf2 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -386,6 +386,8 @@ public:
 #endif
 
   void process_qsupported (char **features, int count) override;
+
+  bool supports_tracepoints () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index c42a9b401e5..5a0648987c7 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_tracepoints */
   NULL,  /* read_pc */
   NULL,  /* write_pc */
   NULL,  /* thread_stopped */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 86863f67f72..efb342f5938 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* supports_tracepoints */
   NULL, /* read_pc */
   NULL, /* write_pc */
   NULL, /* thread_stopped */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 49e4b01495c..ded8f3fee9d 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -608,3 +608,9 @@ process_target::process_qsupported (char **features, int count)
 {
   /* Nop.  */
 }
+
+bool
+process_target::supports_tracepoints ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 61f13e3a6f6..e36f121a9ae 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return 1 if the target supports tracepoints, 0 (or leave the
-     callback NULL) otherwise.  */
-  int (*supports_tracepoints) (void);
-
   /* Read PC from REGCACHE.  */
   CORE_ADDR (*read_pc) (struct regcache *regcache);
 
@@ -489,6 +485,9 @@ public:
   /* Target specific qSupported support.  FEATURES is an array of
      features with COUNT elements.  */
   virtual void process_qsupported (char **features, int count);
+
+  /* Return true if the target supports tracepoints, false otherwise.  */
+  virtual bool supports_tracepoints ();
 };
 
 extern process_stratum_target *the_target;
@@ -551,8 +550,7 @@ int kill_inferior (process_info *proc);
    ? (*the_target->get_ipa_tdesc_idx) () : 0)
 
 #define target_supports_tracepoints()			\
-  (the_target->supports_tracepoints			\
-   ? (*the_target->supports_tracepoints) () : 0)
+  the_target->pt->supports_tracepoints ()
 
 #define target_supports_fast_tracepoints()		\
   (the_target->install_fast_tracepoint_jump_pad != NULL)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index f068091dc98..87a59648c30 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_tracepoints */
   NULL, /* read_pc */
   NULL, /* write_pc */
   NULL, /* thread_stopped */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 21/58] gdbserver: turn target op '{supports_}stopped_by_hw_breakpoint' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (25 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 57/58] gdbserver: simply copy the pointer in 'set_target_ops' Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 45/58] gdbserver: turn target op 'supports_disable_randomization' " Tankut Baris Aktemur
                   ` (32 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's {supports_}stopped_by_hw_breakpoint
	ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(target_stopped_by_hw_breakpoint): Update the macro.
	(target_supports_stopped_by_hw_breakpoint): Update the macro.
	* target.cc (process_target::stopped_by_hw_breakpoint): Define.
	(process_target::supports_stopped_by_hw_breakpoint): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_stopped_by_hw_breakpoint): Turn into ...
	(linux_process_target::stopped_by_hw_breakpoint): ... this.
	(linux_supports_stopped_by_hw_breakpoint): Turn into ...
	(linux_process_target::supports_stopped_by_hw_breakpoint): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 14 ++++++--------
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  |  2 --
 gdbserver/nto-low.cc   |  2 --
 gdbserver/target.cc    | 12 ++++++++++++
 gdbserver/target.h     | 20 +++++++++-----------
 gdbserver/win32-low.cc |  2 --
 7 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index b1cba91344d..9ad5e19207a 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6010,22 +6010,22 @@ linux_process_target::supports_stopped_by_sw_breakpoint ()
   return USE_SIGTRAP_SIGINFO;
 }
 
-/* Implement the to_stopped_by_hw_breakpoint target_ops
+/* Implement the stopped_by_hw_breakpoint target_ops
    method.  */
 
-static int
-linux_stopped_by_hw_breakpoint (void)
+bool
+linux_process_target::stopped_by_hw_breakpoint ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
 
   return (lwp->stop_reason == TARGET_STOPPED_BY_HW_BREAKPOINT);
 }
 
-/* Implement the to_supports_stopped_by_hw_breakpoint target_ops
+/* Implement the supports_stopped_by_hw_breakpoint target_ops
    method.  */
 
-static int
-linux_supports_stopped_by_hw_breakpoint (void)
+bool
+linux_process_target::supports_stopped_by_hw_breakpoint ()
 {
   return USE_SIGTRAP_SIGINFO;
 }
@@ -7376,8 +7376,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_stopped_by_hw_breakpoint,
-  linux_supports_stopped_by_hw_breakpoint,
   linux_supports_hardware_single_step,
   linux_stopped_by_watchpoint,
   linux_stopped_data_address,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index bb9c4b011cf..95dabf3a44e 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -326,6 +326,10 @@ public:
   bool stopped_by_sw_breakpoint () override;
 
   bool supports_stopped_by_sw_breakpoint () override;
+
+  bool stopped_by_hw_breakpoint () override;
+
+  bool supports_stopped_by_hw_breakpoint () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 0bb7e001aed..e4f276b5af0 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -729,8 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* stopped_by_hw_breakpoint */
-  NULL,  /* supports_stopped_by_hw_breakpoint */
   target_can_do_hardware_single_step,
   NULL,  /* stopped_by_watchpoint */
   NULL,  /* stopped_data_address */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 5912ee9295e..6bb926d5278 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -950,8 +950,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* stopped_by_hw_breakpoint */
-  NULL, /* supports_stopped_by_hw_breakpoint */
   target_can_do_hardware_single_step,
   nto_stopped_by_watchpoint,
   nto_stopped_data_address,
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 70630db6d84..f7dc0f4d658 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -459,3 +459,15 @@ process_target::supports_stopped_by_sw_breakpoint ()
 {
   return false;
 }
+
+bool
+process_target::stopped_by_hw_breakpoint ()
+{
+  return false;
+}
+
+bool
+process_target::supports_stopped_by_hw_breakpoint ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 563884f3535..c5b1ef21b07 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,13 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns 1 if the target stopped for a hardware breakpoint.  */
-  int (*stopped_by_hw_breakpoint) (void);
-
-  /* Returns true if the target knows whether a trap was caused by a
-     HW breakpoint triggering.  */
-  int (*supports_stopped_by_hw_breakpoint) (void);
-
   /* Returns true if the target can do hardware single step.  */
   int (*supports_hardware_single_step) (void);
 
@@ -476,6 +469,13 @@ public:
   /* Returns true if the target knows whether a trap was caused by a
      SW breakpoint triggering.  */
   virtual bool supports_stopped_by_sw_breakpoint ();
+
+  /* Returns true if the target stopped for a hardware breakpoint.  */
+  virtual bool stopped_by_hw_breakpoint ();
+
+  /* Returns true if the target knows whether a trap was caused by a
+     HW breakpoint triggering.  */
+  virtual bool supports_stopped_by_hw_breakpoint ();
 };
 
 extern process_stratum_target *the_target;
@@ -665,16 +665,14 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
   the_target->pt->stopped_by_sw_breakpoint ()
 
 #define target_supports_stopped_by_hw_breakpoint() \
-  (the_target->supports_stopped_by_hw_breakpoint ? \
-   (*the_target->supports_stopped_by_hw_breakpoint) () : 0)
+  the_target->pt->supports_stopped_by_hw_breakpoint ()
 
 #define target_supports_hardware_single_step() \
   (the_target->supports_hardware_single_step ? \
    (*the_target->supports_hardware_single_step) () : 0)
 
 #define target_stopped_by_hw_breakpoint() \
-  (the_target->stopped_by_hw_breakpoint ? \
-   (*the_target->stopped_by_hw_breakpoint) () : 0)
+  the_target->pt->stopped_by_hw_breakpoint ()
 
 #define target_breakpoint_kind_from_pc(pcptr) \
   (the_target->breakpoint_kind_from_pc \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 6f8b51f3e44..7edad620050 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1838,8 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* stopped_by_hw_breakpoint */
-  NULL, /* supports_stopped_by_hw_breakpoint */
   target_can_do_hardware_single_step,
   win32_stopped_by_watchpoint,
   win32_stopped_data_address,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 17/58] gdbserver: turn target op 'read_auxv' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (27 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 45/58] gdbserver: turn target op 'supports_disable_randomization' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 47/58] gdbserver: turn target op 'supports_agent' " Tankut Baris Aktemur
                   ` (30 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's read_auxv op into a method of
	process_target.

	* target.h (class process_stratum_target): Remove the target op.
	(struct process_target): Add the target op.  Also add
	'supports_read_auxv'.
	* target.cc (process_target::read_auxv): Define.
	(process_target::supports_read_auxv): Define.

	Update the derived classes and callers below.

	* server.cc (handle_qxfer_auxv): Update.
	(handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_read_auxv): Define.
	(linux_read_auxv): Turn into ...
	(linux_process_target::read_auxv): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_process_target::supports_read_auxv): Define.
	(nto_read_auxv): Turn into ...
	(nto_process_target::read_auxv): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 14 ++++++++++----
 gdbserver/linux-low.h  |  5 +++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   | 12 +++++++++---
 gdbserver/nto-low.h    |  5 +++++
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.cc    | 13 +++++++++++++
 gdbserver/target.h     | 16 +++++++++-------
 gdbserver/win32-low.cc |  1 -
 9 files changed, 54 insertions(+), 19 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 3d02cb5431c..47ac768d929 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5919,11 +5919,18 @@ linux_process_target::request_interrupt ()
   ::kill (-signal_pid, SIGINT);
 }
 
+bool
+linux_process_target::supports_read_auxv ()
+{
+  return true;
+}
+
 /* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
    to debugger memory starting at MYADDR.  */
 
-static int
-linux_read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len)
+int
+linux_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
+				 unsigned int len)
 {
   char filename[PATH_MAX];
   int fd, n;
@@ -7317,7 +7324,7 @@ linux_get_auxv (int wordsize, CORE_ADDR match, CORE_ADDR *valp)
 
   gdb_assert (wordsize == 4 || wordsize == 8);
 
-  while ((*the_target->read_auxv) (offset, data, 2 * wordsize) == 2 * wordsize)
+  while (the_target->pt->read_auxv (offset, data, 2 * wordsize) == 2 * wordsize)
     {
       if (wordsize == 4)
 	{
@@ -7369,7 +7376,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_read_auxv,
   linux_supports_z_point_type,
   linux_insert_point,
   linux_remove_point,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 197a0bbe1d4..0130c22ce27 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -309,6 +309,11 @@ public:
   void look_up_symbols () override;
 
   void request_interrupt () override;
+
+  bool supports_read_auxv () override;
+
+  int read_auxv (CORE_ADDR offset, unsigned char *myaddr,
+		 unsigned int len) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 8b5300f08c2..bf73e81993e 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -729,7 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* read_auxv */
   NULL,  /* supports_z_point_type */
   NULL,  /* insert_point */
   NULL,  /* remove_point */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index d60f72affd5..d828fa7a607 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -755,14 +755,21 @@ nto_process_target::request_interrupt ()
     TRACE ("Error stopping inferior.\n");
 }
 
+bool
+nto_process_target::supports_read_auxv ()
+{
+  return true;
+}
+
 /* Read auxiliary vector from inferior's memory into gdbserver's buffer
    MYADDR.  We always read whole auxv.  
    
    Return number of bytes stored in MYADDR buffer, 0 if OFFSET > 0
    or -1 on error.  */
 
-static int
-nto_read_auxv (CORE_ADDR offset, unsigned char *myaddr, unsigned int len)
+int
+nto_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
+			       unsigned int len)
 {
   int err;
   CORE_ADDR initial_stack;
@@ -943,7 +950,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_read_auxv,
   nto_supports_z_point_type,
   nto_insert_point,
   nto_remove_point,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index c6e0c295662..e135dd3b68a 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -79,6 +79,11 @@ public:
 		    int len) override;
 
   void request_interrupt () override;
+
+  bool supports_read_auxv () override;
+
+  int read_auxv (CORE_ADDR offset, unsigned char *myaddr,
+		 unsigned int len) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index bc497f87b7f..f13061c871b 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1442,13 +1442,13 @@ handle_qxfer_auxv (const char *annex,
 		   gdb_byte *readbuf, const gdb_byte *writebuf,
 		   ULONGEST offset, LONGEST len)
 {
-  if (the_target->read_auxv == NULL || writebuf != NULL)
+  if (!the_target->pt->supports_read_auxv () || writebuf != NULL)
     return -2;
 
   if (annex[0] != '\0' || current_thread == NULL)
     return -1;
 
-  return (*the_target->read_auxv) (offset, readbuf, len);
+  return the_target->pt->read_auxv (offset, readbuf, len);
 }
 
 /* Handle qXfer:exec-file:read.  */
@@ -2374,7 +2374,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 	  strcat (own_buf, ";qXfer:libraries:read+");
 	}
 
-      if (the_target->read_auxv != NULL)
+      if (the_target->pt->supports_read_auxv ())
 	strcat (own_buf, ";qXfer:auxv:read+");
 
       if (the_target->qxfer_siginfo != NULL)
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index dd9ee8dfd47..97e9d4ac507 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -414,3 +414,16 @@ process_target::look_up_symbols ()
 {
   /* Nop.  */
 }
+
+bool
+process_target::supports_read_auxv ()
+{
+  return false;
+}
+
+int
+process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
+			   unsigned int len)
+{
+  gdb_assert_not_reached ("target op read_auxv not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 234a183427e..cd11da670ca 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,13 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read auxiliary vector data from the inferior process.
-
-     Read LEN bytes at OFFSET into a buffer at MYADDR.  */
-
-  int (*read_auxv) (CORE_ADDR offset, unsigned char *myaddr,
-		    unsigned int len);
-
   /* Returns true if GDB Z breakpoint type TYPE is supported, false
      otherwise.  The type is coded as follows:
        '0' - software-breakpoint
@@ -474,6 +467,15 @@ public:
   /* Send an interrupt request to the inferior process,
      however is appropriate.  */
   virtual void request_interrupt () = 0;
+
+  /* Return true if the read_auxv target op is supported.  */
+  virtual bool supports_read_auxv ();
+
+  /* Read auxiliary vector data from the inferior process.
+
+     Read LEN bytes at OFFSET into a buffer at MYADDR.  */
+  virtual int read_auxv (CORE_ADDR offset, unsigned char *myaddr,
+			 unsigned int len);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 098da30017d..2d617d889ec 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1838,7 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* read_auxv */
   win32_supports_z_point_type,
   win32_insert_point,
   win32_remove_point,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 26/58] gdbserver: turn target op 'hostio_last_error' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (36 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 06/58] gdbserver: turn target op 'detach' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 33/58] gdbserver: turn target op 'handle_monitor_command' " Tankut Baris Aktemur
                   ` (21 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's hostio_last_error op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	* target.cc: Add "hostio.h" to includes.
	(process_target::hostio_last_error): Define.

	Update the derived classes and callers below.

	* hostio.cc (hostio_error): Update.
	* linux-low.cc: Remove "hostio.h" from includes.
	(linux_target_ops): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.h (class win32_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(wince_hostio_last_error): Turn into ...
	(win32_process_target::hostio_last_error): ... this.
---
 gdbserver/hostio.cc    | 2 +-
 gdbserver/linux-low.cc | 2 --
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 7 +++++++
 gdbserver/target.h     | 8 ++++----
 gdbserver/win32-low.cc | 9 ++-------
 gdbserver/win32-low.h  | 4 ++++
 8 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index 8af4fbf4087..a3b32cd0fdc 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -196,7 +196,7 @@ require_valid_fd (int fd)
 static void
 hostio_error (char *own_buf)
 {
-  the_target->hostio_last_error (own_buf);
+  the_target->pt->hostio_last_error (own_buf);
 }
 
 static void
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 42bfcde6203..789496719dc 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -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"
@@ -7411,7 +7410,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,
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index f0d0d4456c4..0e904d07328 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* hostio_last_error */
   NULL,  /* qxfer_osdata */
   NULL,  /* qxfer_siginfo */
   NULL,  /* supports_non_stop */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index b9e7ed06337..ec0b477abe5 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -956,7 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  hostio_last_error_from_errno,
   NULL, /* nto_qxfer_osdata */
   NULL, /* xfer_siginfo */
   nto_supports_non_stop,
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index f578dbea0da..e09ee7d0fa4 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -21,6 +21,7 @@
 #include "server.h"
 #include "tracepoint.h"
 #include "gdbsupport/byte-vector.h"
+#include "hostio.h"
 
 process_stratum_target *the_target;
 
@@ -506,3 +507,9 @@ process_target::get_tls_address (thread_info *thread, CORE_ADDR offset,
 {
   gdb_assert_not_reached ("target op get_tls_address not supported");
 }
+
+void
+process_target::hostio_last_error (char *buf)
+{
+  hostio_last_error_from_errno (buf);
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 2c818b3fb12..5f603fdf0bc 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Fill BUF with an hostio error packet representing the last hostio
-     error.  */
-  void (*hostio_last_error) (char *buf);
-
   /* Read/Write OS data using qXfer packets.  */
   int (*qxfer_osdata) (const char *annex, unsigned char *readbuf,
 		       unsigned const char *writebuf, CORE_ADDR offset,
@@ -479,6 +475,10 @@ public:
      support the operation.  */
   virtual int get_tls_address (thread_info *thread, CORE_ADDR offset,
 			       CORE_ADDR load_module, CORE_ADDR *address);
+
+  /* Fill BUF with an hostio error packet representing the last hostio
+     error.  */
+  virtual void hostio_last_error (char *buf);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 84223e129bf..727bc9c8c95 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1784,8 +1784,8 @@ win32_error_to_fileio_error (DWORD err)
   return FILEIO_EUNKNOWN;
 }
 
-static void
-wince_hostio_last_error (char *buf)
+void
+win32_process_target::hostio_last_error (char *buf)
 {
   DWORD winerr = GetLastError ();
   int fileio_err = win32_error_to_fileio_error (winerr);
@@ -1844,11 +1844,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-#ifdef _WIN32_WCE
-  wince_hostio_last_error,
-#else
-  hostio_last_error_from_errno,
-#endif
   NULL, /* qxfer_osdata */
   win32_xfer_siginfo,
   NULL, /* supports_non_stop */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index b2b8a6dedc3..86447fd541a 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -152,6 +152,10 @@ public:
   bool stopped_by_watchpoint () override;
 
   CORE_ADDR stopped_data_address () override;
+
+#ifdef _WIN32_WCE
+  void hostio_last_error (char *buf) override;
+#endif
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 20/58] gdbserver: turn target op '{supports_}stopped_by_sw_breakpoint' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (30 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 39/58] gdbserver: turn target op 'thread_stopped' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 28/58] gdbserver: turn target op 'qxfer_siginfo' " Tankut Baris Aktemur
                   ` (27 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's {supports_}stopped_by_sw_breakpoint
	ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(target_stopped_by_sw_breakpoint): Update the macro.
	(target_supports_stopped_by_sw_breakpoint): Update the macro.
	* target.cc (process_target::stopped_by_sw_breakpoint): Define.
	(process_target::supports_stopped_by_sw_breakpoint): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_stopped_by_sw_breakpoint): Turn into ...
	(linux_process_target::stopped_by_sw_breakpoint): ... this.
	(linux_supports_stopped_by_sw_breakpoint): Turn into ...
	(linux_process_target::supports_stopped_by_sw_breakpoint): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 14 ++++++--------
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  |  2 --
 gdbserver/nto-low.cc   |  2 --
 gdbserver/target.cc    | 12 ++++++++++++
 gdbserver/target.h     | 22 ++++++++++------------
 gdbserver/win32-low.cc |  2 --
 7 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 96692cd77a7..b1cba91344d 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5990,22 +5990,22 @@ linux_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
     return 1;
 }
 
-/* Implement the to_stopped_by_sw_breakpoint target_ops
+/* Implement the stopped_by_sw_breakpoint target_ops
    method.  */
 
-static int
-linux_stopped_by_sw_breakpoint (void)
+bool
+linux_process_target::stopped_by_sw_breakpoint ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
 
   return (lwp->stop_reason == TARGET_STOPPED_BY_SW_BREAKPOINT);
 }
 
-/* Implement the to_supports_stopped_by_sw_breakpoint target_ops
+/* Implement the supports_stopped_by_sw_breakpoint target_ops
    method.  */
 
-static int
-linux_supports_stopped_by_sw_breakpoint (void)
+bool
+linux_process_target::supports_stopped_by_sw_breakpoint ()
 {
   return USE_SIGTRAP_SIGINFO;
 }
@@ -7376,8 +7376,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_stopped_by_sw_breakpoint,
-  linux_supports_stopped_by_sw_breakpoint,
   linux_stopped_by_hw_breakpoint,
   linux_supports_stopped_by_hw_breakpoint,
   linux_supports_hardware_single_step,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 6d58d6620b6..bb9c4b011cf 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -322,6 +322,10 @@ public:
 
   int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 		    int size, raw_breakpoint *bp) override;
+
+  bool stopped_by_sw_breakpoint () override;
+
+  bool supports_stopped_by_sw_breakpoint () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index dc864e8bb10..0bb7e001aed 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -729,8 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* stopped_by_sw_breakpoint */
-  NULL,  /* supports_stopped_by_sw_breakpoint */
   NULL,  /* stopped_by_hw_breakpoint */
   NULL,  /* supports_stopped_by_hw_breakpoint */
   target_can_do_hardware_single_step,
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 56d34626667..5912ee9295e 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -950,8 +950,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* stopped_by_sw_breakpoint */
-  NULL, /* supports_stopped_by_sw_breakpoint */
   NULL, /* stopped_by_hw_breakpoint */
   NULL, /* supports_stopped_by_hw_breakpoint */
   target_can_do_hardware_single_step,
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index fd443efd61e..70630db6d84 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -447,3 +447,15 @@ process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 {
   return 1;
 }
+
+bool
+process_target::stopped_by_sw_breakpoint ()
+{
+  return false;
+}
+
+bool
+process_target::supports_stopped_by_sw_breakpoint ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index f04c1c15bcb..563884f3535 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,14 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns 1 if the target stopped because it executed a software
-     breakpoint instruction, 0 otherwise.  */
-  int (*stopped_by_sw_breakpoint) (void);
-
-  /* Returns true if the target knows whether a trap was caused by a
-     SW breakpoint triggering.  */
-  int (*supports_stopped_by_sw_breakpoint) (void);
-
   /* Returns 1 if the target stopped for a hardware breakpoint.  */
   int (*stopped_by_hw_breakpoint) (void);
 
@@ -476,6 +468,14 @@ public:
 
   virtual int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 			    int size, raw_breakpoint *bp);
+
+  /* Returns true if the target stopped because it executed a software
+     breakpoint instruction, false otherwise.  */
+  virtual bool stopped_by_sw_breakpoint ();
+
+  /* Returns true if the target knows whether a trap was caused by a
+     SW breakpoint triggering.  */
+  virtual bool supports_stopped_by_sw_breakpoint ();
 };
 
 extern process_stratum_target *the_target;
@@ -659,12 +659,10 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
    (*the_target->supports_range_stepping) () : 0)
 
 #define target_supports_stopped_by_sw_breakpoint() \
-  (the_target->supports_stopped_by_sw_breakpoint ? \
-   (*the_target->supports_stopped_by_sw_breakpoint) () : 0)
+  the_target->pt->supports_stopped_by_sw_breakpoint ()
 
 #define target_stopped_by_sw_breakpoint() \
-  (the_target->stopped_by_sw_breakpoint ? \
-   (*the_target->stopped_by_sw_breakpoint) () : 0)
+  the_target->pt->stopped_by_sw_breakpoint ()
 
 #define target_supports_stopped_by_hw_breakpoint() \
   (the_target->supports_stopped_by_hw_breakpoint ? \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index c42d8d7414c..6f8b51f3e44 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1838,8 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* stopped_by_sw_breakpoint */
-  NULL, /* supports_stopped_by_sw_breakpoint */
   NULL, /* stopped_by_hw_breakpoint */
   NULL, /* supports_stopped_by_hw_breakpoint */
   target_can_do_hardware_single_step,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 52/58] gdbserver: turn breakpoint kind-related target ops into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (41 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 32/58] gdbserver: turn target op 'handle_new_gdb_connection' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 22/58] gdbserver: turn target op 'supports_hardware_single_step' into a method Tankut Baris Aktemur
                   ` (16 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's breakpoint_kind_from_pc,
	sw_breakpoint_from_kind, and breakpoint_kind_from_current_state
	ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_breakpoint_kind_from_pc): Update the macro.
	(target_breakpoint_kind_from_current_state): Update the macro.
	(default_breakpoint_kind_from_pc): Remove declaration.
	* target.cc (default_breakpoint_kind_from_pc): Turn into ...
	(process_target::breakpoint_kind_from_pc): ... this.
	(process_target::breakpoint_kind_from_current_state): Define.

	Update the derived classes and callers below.

	* mem-break.cc (bp_size): Update.
	(bp_opcode): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_wait_1): Update.
	(linux_breakpoint_kind_from_pc): Turn into ...
	(linux_process_target::breakpoint_kind_from_pc): ... this.
	(linux_sw_breakpoint_from_kind): Turn into ...
	(linux_process_target::sw_breakpoint_from_kind): ... this.
	(linux_breakpoint_kind_from_current_state): Turn into ...
	(linux_process_target::breakpoint_kind_from_current_state): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_process_target::sw_breakpoint_from_kind): Define.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_sw_breakpoint_from_kind): Turn into ...
	(nto_process_target::sw_breakpoint_from_kind): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_sw_breakpoint_from_kind): Turn into ...
	(win32_process_target::sw_breakpoint_from_kind): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc | 23 ++++++++++-------------
 gdbserver/linux-low.h  |  6 ++++++
 gdbserver/lynx-low.cc  |  9 ++++++---
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/mem-break.cc |  4 ++--
 gdbserver/nto-low.cc   |  7 ++-----
 gdbserver/nto-low.h    |  2 ++
 gdbserver/target.cc    | 32 ++++++++++++++++----------------
 gdbserver/target.h     | 42 ++++++++++++++++++------------------------
 gdbserver/win32-low.cc |  7 ++-----
 gdbserver/win32-low.h  |  2 ++
 11 files changed, 68 insertions(+), 68 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 398c5fc6a82..9dce2a7c35e 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -3218,8 +3218,8 @@ linux_wait_1 (ptid_t ptid,
       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);
+	the_target->pt->breakpoint_kind_from_current_state (&stop_pc);
+      the_target->pt->sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
 
       if (debug_threads)
 	{
@@ -7362,19 +7362,19 @@ current_lwp_ptid (void)
 
 /* Implementation of the target_ops method "breakpoint_kind_from_pc".  */
 
-static int
-linux_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
+int
+linux_process_target::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);
+    return process_target::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 gdb_byte *
+linux_process_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   gdb_assert (the_low_target.sw_breakpoint_from_kind != NULL);
 
@@ -7384,13 +7384,13 @@ linux_sw_breakpoint_from_kind (int kind, int *size)
 /* Implementation of the target_ops method
    "breakpoint_kind_from_current_state".  */
 
-static int
-linux_breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
+int
+linux_process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
 {
   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 breakpoint_kind_from_pc (pcptr);
 }
 
 /* Default implementation of linux_target_ops method "set_pc" for
@@ -7505,10 +7505,7 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  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,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 9fd2bc0ea35..ae422b83879 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -462,6 +462,12 @@ public:
 
   ssize_t multifs_readlink (int pid, const char *filename, char *buf,
 			    size_t bufsiz) override;
+
+  int breakpoint_kind_from_pc (CORE_ADDR *pcptr) override;
+
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
+  int breakpoint_kind_from_current_state (CORE_ADDR *pcptr) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index ad669c8e9d7..b07412f0dcd 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -728,6 +728,12 @@ lynx_process_target::supports_hardware_single_step ()
   return true;
 }
 
+const gdb_byte *
+lynx_process_target::sw_breakpoint_from_kind (int kind, int *size)
+{
+  error (_("Target does not implement the sw_breakpoint_from_kind op"));
+}
+
 /* The LynxOS target ops object.  */
 
 static lynx_process_target the_lynx_target;
@@ -735,10 +741,7 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* breakpoint_kind_from_pc */
-  NULL,  /* sw_breakpoint_from_kind */
   NULL,  /* thread_name */
-  NULL,  /* breakpoint_kind_from_current_state */
   NULL,  /* supports_software_single_step */
   NULL,  /* supports_catch_syscall */
   NULL,  /* get_ipa_tdesc_idx */
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 4253f1259c2..7da97b3b073 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -91,6 +91,8 @@ public:
   void request_interrupt () override;
 
   bool supports_hardware_single_step () override;
+
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index 682b3bc1832..3802d72a573 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -223,7 +223,7 @@ bp_size (struct raw_breakpoint *bp)
 {
   int size = 0;
 
-  the_target->sw_breakpoint_from_kind (bp->kind, &size);
+  the_target->pt->sw_breakpoint_from_kind (bp->kind, &size);
   return size;
 }
 
@@ -234,7 +234,7 @@ bp_opcode (struct raw_breakpoint *bp)
 {
   int size = 0;
 
-  return the_target->sw_breakpoint_from_kind (bp->kind, &size);
+  return the_target->pt->sw_breakpoint_from_kind (bp->kind, &size);
 }
 
 /* See mem-break.h.  */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 1140b5b6d49..b0ac86f8790 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -935,8 +935,8 @@ nto_process_target::stopped_data_address ()
 
 /* Implementation of the target_ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-nto_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = the_low_target.breakpoint_len;
   return the_low_target.breakpoint;
@@ -947,10 +947,7 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* breakpoint_kind_from_pc */
-  nto_sw_breakpoint_from_kind,
   NULL, /* thread_name */
-  NULL, /* breakpoint_kind_from_current_state */
   NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index c3e7099e702..ff2003b60b0 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -98,6 +98,8 @@ public:
   bool stopped_by_watchpoint () override;
 
   CORE_ADDR stopped_data_address () override;
+
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 4c92fa6f89d..76eef626ce8 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -306,22 +306,6 @@ kill_inferior (process_info *proc)
   return the_target->pt->kill (proc);
 }
 
-/* Default implementation for breakpoint_kind_for_pc.
-
-   The default behavior for targets that don't implement breakpoint_kind_for_pc
-   is to use the size of a breakpoint as the kind.  */
-
-int
-default_breakpoint_kind_from_pc (CORE_ADDR *pcptr)
-{
-  int size = 0;
-
-  gdb_assert (the_target->sw_breakpoint_from_kind != NULL);
-
-  (*the_target->sw_breakpoint_from_kind) (0, &size);
-  return size;
-}
-
 /* Define it.  */
 
 target_terminal_state target_terminal::m_terminal_state
@@ -801,3 +785,19 @@ process_target::multifs_readlink (int pid, const char *filename,
 {
   return readlink (filename, buf, bufsiz);
 }
+
+int
+process_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
+{
+  /* The default behavior is to use the size of a breakpoint as the
+     kind.  */
+  int size = 0;
+  sw_breakpoint_from_kind (0, &size);
+  return size;
+}
+
+int
+process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
+{
+  return breakpoint_kind_from_pc (pcptr);
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index bf653a4d08a..4651e449a80 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,26 +70,10 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return the breakpoint kind for this target based on PC.  The PCPTR is
-     adjusted to the real memory location in case a flag (e.g., the Thumb bit on
-     ARM) was present in the PC.  */
-  int (*breakpoint_kind_from_pc) (CORE_ADDR *pcptr);
-
-  /* Return the software breakpoint from KIND.  KIND can have target
-     specific meaning like the Z0 kind parameter.
-     SIZE is set to the software breakpoint's length in memory.  */
-  const gdb_byte *(*sw_breakpoint_from_kind) (int kind, int *size);
-
   /* Return the thread's name, or NULL if the target is unable to determine it.
      The returned value must not be freed by the caller.  */
   const char *(*thread_name) (ptid_t thread);
 
-  /* Return the breakpoint kind for this target based on the current
-     processor state (e.g. the current instruction mode on ARM) and the
-     PC.  The PCPTR is adjusted to the real memory location in case a flag
-     (e.g., the Thumb bit on ARM) is present in the PC.  */
-  int (*breakpoint_kind_from_current_state) (CORE_ADDR *pcptr);
-
   /* Returns true if the target can software single step.  */
   int (*supports_software_single_step) (void);
 
@@ -503,6 +487,22 @@ public:
      not override this.  The default behavior is to use readlink(2).  */
   virtual ssize_t multifs_readlink (int pid, const char *filename,
 				    char *buf, size_t bufsiz);
+
+  /* Return the breakpoint kind for this target based on PC.  The
+     PCPTR is adjusted to the real memory location in case a flag
+     (e.g., the Thumb bit on ARM) was present in the PC.  */
+  virtual int breakpoint_kind_from_pc (CORE_ADDR *pcptr);
+
+  /* Return the software breakpoint from KIND.  KIND can have target
+     specific meaning like the Z0 kind parameter.
+     SIZE is set to the software breakpoint's length in memory.  */
+  virtual const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) = 0;
+
+  /* Return the breakpoint kind for this target based on the current
+     processor state (e.g. the current instruction mode on ARM) and the
+     PC.  The PCPTR is adjusted to the real memory location in case a
+     flag (e.g., the Thumb bit on ARM) is present in the  PC.  */
+  virtual int breakpoint_kind_from_current_state (CORE_ADDR *pcptr);
 };
 
 extern process_stratum_target *the_target;
@@ -661,14 +661,10 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
   the_target->pt->stopped_by_hw_breakpoint ()
 
 #define target_breakpoint_kind_from_pc(pcptr) \
-  (the_target->breakpoint_kind_from_pc \
-   ? (*the_target->breakpoint_kind_from_pc) (pcptr) \
-   : default_breakpoint_kind_from_pc (pcptr))
+  the_target->pt->breakpoint_kind_from_pc (pcptr)
 
 #define target_breakpoint_kind_from_current_state(pcptr) \
-  (the_target->breakpoint_kind_from_current_state \
-   ? (*the_target->breakpoint_kind_from_current_state) (pcptr) \
-   : target_breakpoint_kind_from_pc (pcptr))
+  the_target->pt->breakpoint_kind_from_current_state (pcptr)
 
 #define target_supports_software_single_step() \
   (the_target->supports_software_single_step ? \
@@ -701,6 +697,4 @@ int set_desired_thread ();
 
 const char *target_pid_to_str (ptid_t);
 
-int default_breakpoint_kind_from_pc (CORE_ADDR *pcptr);
-
 #endif /* GDBSERVER_TARGET_H */
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index eb51a857b25..71adf18ebb5 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1846,8 +1846,8 @@ win32_process_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr)
 
 /* Implementation of the target_ops method "sw_breakpoint_from_kind".  */
 
-static const gdb_byte *
-win32_sw_breakpoint_from_kind (int kind, int *size)
+const gdb_byte *
+win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
 {
   *size = the_low_target.breakpoint_len;
   return the_low_target.breakpoint;
@@ -1858,10 +1858,7 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* breakpoint_kind_from_pc */
-  win32_sw_breakpoint_from_kind,
   NULL, /* thread_name */
-  NULL, /* breakpoint_kind_from_current_state */
   NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 1618501838e..d4c7cae3013 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -166,6 +166,8 @@ public:
   bool supports_get_tib_address () override;
 
   int get_tib_address (ptid_t ptid, CORE_ADDR *addr) override;
+
+  const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 44/58] gdbserver: turn target op 'emit_ops' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (19 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 23/58] gdbserver: turn target ops 'stopped_by_watchpoint' and 'stopped_data_address' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 53/58] gdbserver: turn target ops 'thread_name' and 'thread_handle' into methods Tankut Baris Aktemur
                   ` (38 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's emit_ops op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_emit_ops): Update the macro.
	* target.cc (process_target::emit_ops): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_emit_ops): Turn into ...
	(linux_process_target::emit_ops): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     | 10 +++++-----
 gdbserver/win32-low.cc |  1 -
 7 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index f1d61190b12..0203afa66cf 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6639,8 +6639,8 @@ linux_process_target::install_fast_tracepoint_jump_pad
      err);
 }
 
-static struct emit_ops *
-linux_emit_ops (void)
+emit_ops *
+linux_process_target::emit_ops ()
 {
   if (the_low_target.emit_ops != NULL)
     return (*the_low_target.emit_ops) ();
@@ -7452,7 +7452,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_emit_ops,
   linux_supports_disable_randomization,
   linux_qxfer_libraries_svr4,
   linux_supports_agent,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 35e30ed590d..3a6d2d02dff 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -420,6 +420,8 @@ public:
 					char *err) override;
 
   int get_min_fast_tracepoint_insn_len () override;
+
+  struct emit_ops *emit_ops () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 4089b261bfd..1c71c60f096 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* emit_ops */
   NULL,  /* supports_disable_randomization */
   NULL,  /* qxfer_libraries_svr4 */
   NULL,  /* support_agent */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index e0d3d49bb66..502e6104638 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* emit_ops */
   NULL, /* supports_disable_randomization */
   NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 29b5bbcd9b1..44069f1ad44 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -693,3 +693,9 @@ process_target::get_min_fast_tracepoint_insn_len ()
 {
   return 0;
 }
+
+struct emit_ops *
+process_target::emit_ops ()
+{
+  return nullptr;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 21f22a4d0db..0d51af7965c 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return the bytecode operations vector for the current inferior.
-     Returns NULL if bytecode compilation is not supported.  */
-  struct emit_ops *(*emit_ops) (void);
-
   /* Returns true if the target supports disabling randomization.  */
   int (*supports_disable_randomization) (void);
 
@@ -493,6 +489,10 @@ public:
   /* Return the minimum length of an instruction that can be safely
      overwritten for use as a fast tracepoint.  */
   virtual int get_min_fast_tracepoint_insn_len ();
+
+  /* Return the bytecode operations vector for the current inferior.
+     Returns nullptr if bytecode compilation is not supported.  */
+  virtual struct emit_ops *emit_ops ();
 };
 
 extern process_stratum_target *the_target;
@@ -597,7 +597,7 @@ int kill_inferior (process_info *proc);
 						    err)
 
 #define target_emit_ops() \
-  (the_target->emit_ops ? (*the_target->emit_ops) () : NULL)
+  the_target->pt->emit_ops ()
 
 #define target_supports_disable_randomization() \
   (the_target->supports_disable_randomization ? \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 9c715fea362..297882bc8a8 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* emit_ops */
   NULL, /* supports_disable_randomization */
   NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 47/58] gdbserver: turn target op 'supports_agent' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (28 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 17/58] gdbserver: turn target op 'read_auxv' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 39/58] gdbserver: turn target op 'thread_stopped' " Tankut Baris Aktemur
                   ` (29 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_agent op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_supports_agent): Update the macro.
	* target.cc (process_target::supports_agent): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_agent): Turn into ...
	(linux_process_target::supports_agent): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 7 +++----
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 6 ++++++
 gdbserver/target.h     | 9 ++++-----
 gdbserver/win32-low.cc | 1 -
 7 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index cab3c679d47..9ba2927eef4 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6420,10 +6420,10 @@ linux_process_target::supports_disable_randomization ()
 #endif
 }
 
-static int
-linux_supports_agent (void)
+bool
+linux_process_target::supports_agent ()
 {
-  return 1;
+  return true;
 }
 
 static int
@@ -7459,7 +7459,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_agent,
 #ifdef HAVE_LINUX_BTRACE
   linux_enable_btrace,
   linux_low_disable_btrace,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 463e4e9b708..0f0f3e0b869 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -431,6 +431,8 @@ public:
 			    unsigned char *readbuf,
 			    unsigned const char *writebuf,
 			    CORE_ADDR offset, int len) override;
+
+  bool supports_agent () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 74e7de526f7..031166ed126 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* support_agent */
   NULL,  /* enable_btrace */
   NULL,  /* disable_btrace */
   NULL,  /* read_btrace */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 037a053183d..27fe3ca4132 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* support_agent */
   NULL, /* enable_btrace */
   NULL, /* disable_btrace */
   NULL, /* read_btrace */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index fa04bd011b5..2bbd8b4d7a9 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -720,3 +720,9 @@ process_target::qxfer_libraries_svr4 (const char *annex,
 {
   gdb_assert_not_reached ("target op qxfer_libraries_svr4 not supported");
 }
+
+bool
+process_target::supports_agent ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index fe0a7df5794..8a1c12260f1 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return true if target supports debugging agent.  */
-  int (*supports_agent) (void);
-
   /* Enable branch tracing for PTID based on CONF and allocate a branch trace
      target information struct for reading and for disabling branch trace.  */
   struct btrace_target_info *(*enable_btrace)
@@ -497,6 +494,9 @@ public:
 				    unsigned char *readbuf,
 				    unsigned const char *writebuf,
 				    CORE_ADDR offset, int len);
+
+  /* Return true if target supports debugging agent.  */
+  virtual bool supports_agent ();
 };
 
 extern process_stratum_target *the_target;
@@ -607,8 +607,7 @@ int kill_inferior (process_info *proc);
   the_target->pt->supports_disable_randomization ()
 
 #define target_supports_agent() \
-  (the_target->supports_agent ? \
-   (*the_target->supports_agent) () : 0)
+  the_target->pt->supports_agent ()
 
 static inline struct btrace_target_info *
 target_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 54d7fde89b6..84b6ea3e285 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* support_agent */
   NULL, /* enable_btrace */
   NULL, /* disable_btrace */
   NULL, /* read_btrace */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 23/58] gdbserver: turn target ops 'stopped_by_watchpoint' and 'stopped_data_address' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (18 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 43/58] gdbserver: turn fast tracepoint target ops into methods Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 44/58] gdbserver: turn target op 'emit_ops' into a method Tankut Baris Aktemur
                   ` (39 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's stopped_by_watchpoint and
	stopped_data_address ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	* target.cc (process_target::stopped_by_watchpoint): Define.
	(process_target::stopped_data_address): Define.

	Update the derived classes and callers below.

	* remote-utils.cc (prepare_resume_reply): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_stopped_by_watchpoint): Turn into ...
	(linux_process_target::stopped_by_watchpoint): ... this.
	(linux_stopped_data_address): Turn into ...
	(linux_process_target::stopped_data_address): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_stopped_by_watchpoint): Turn into ...
	(nto_process_target::stopped_by_watchpoint): ... this.
	(nto_stopped_data_address): Turn into ...
	(nto_process_target::stopped_data_address): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_stopped_by_watchpoint): Turn into ...
	(win32_process_target::stopped_by_watchpoint): ... this.
	(win32_stopped_data_address): Turn into ...
	(win32_process_target::stopped_data_address): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc    | 11 ++++-------
 gdbserver/linux-low.h     |  4 ++++
 gdbserver/lynx-low.cc     |  2 --
 gdbserver/nto-low.cc      | 16 +++++++---------
 gdbserver/nto-low.h       |  4 ++++
 gdbserver/remote-utils.cc |  5 ++---
 gdbserver/target.cc       | 12 ++++++++++++
 gdbserver/target.h        | 17 ++++++++---------
 gdbserver/win32-low.cc    | 12 +++++-------
 gdbserver/win32-low.h     |  4 ++++
 10 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index fec2c3c5673..5a5c6372823 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -269,7 +269,6 @@ 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 int linux_stopped_by_watchpoint (void);
 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);
@@ -6044,16 +6043,16 @@ linux_supports_software_single_step (void)
   return can_software_single_step ();
 }
 
-static int
-linux_stopped_by_watchpoint (void)
+bool
+linux_process_target::stopped_by_watchpoint ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
 
   return lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT;
 }
 
-static CORE_ADDR
-linux_stopped_data_address (void)
+CORE_ADDR
+linux_process_target::stopped_data_address ()
 {
   struct lwp_info *lwp = get_thread_lwp (current_thread);
 
@@ -7376,8 +7375,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_stopped_by_watchpoint,
-  linux_stopped_data_address,
 #if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
     && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
     && defined(PT_TEXT_END_ADDR)
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 57fc9a59415..af2a0c6671e 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -332,6 +332,10 @@ public:
   bool supports_stopped_by_hw_breakpoint () override;
 
   bool supports_hardware_single_step () override;
+
+  bool stopped_by_watchpoint () override;
+
+  CORE_ADDR stopped_data_address () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index ea328b7efe3..e9dfccede05 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,8 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* stopped_by_watchpoint */
-  NULL,  /* stopped_data_address */
   NULL,  /* read_offsets */
   NULL,  /* get_tls_address */
   NULL,  /* hostio_last_error */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 3e10436df3d..53020a25e73 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -878,12 +878,12 @@ nto_process_target::supports_hardware_single_step ()
 /* Check if the reason of stop for current thread (CURRENT_INFERIOR) is
    a watchpoint.
 
-   Return 1 if stopped by watchpoint, 0 otherwise.  */
+   Return true if stopped by watchpoint, false otherwise.  */
 
-static int
-nto_stopped_by_watchpoint (void)
+bool
+nto_process_target::stopped_by_watchpoint ()
 {
-  int ret = 0;
+  bool ret = false;
 
   TRACE ("%s\n", __func__);
   if (nto_inferior.ctl_fd != -1 && current_thread != NULL)
@@ -899,7 +899,7 @@ nto_stopped_by_watchpoint (void)
 	  err = devctl (nto_inferior.ctl_fd, DCMD_PROC_STATUS, &status,
 			sizeof (status), 0);
 	  if (err == EOK && (status.flags & watchmask))
-	    ret = 1;
+	    ret = true;
 	}
     }
   TRACE ("%s: %s\n", __func__, ret ? "yes" : "no");
@@ -910,8 +910,8 @@ nto_stopped_by_watchpoint (void)
 
    Return inferior's instruction pointer value, or 0 on error.  */ 
 
-static CORE_ADDR
-nto_stopped_data_address (void)
+CORE_ADDR
+nto_process_target::stopped_data_address ()
 {
   CORE_ADDR ret = (CORE_ADDR)0;
 
@@ -956,8 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_stopped_by_watchpoint,
-  nto_stopped_data_address,
   NULL, /* nto_read_offsets */
   NULL, /* thread_db_set_tls_address */
   hostio_last_error_from_errno,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 001ccb6687c..c3e7099e702 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -94,6 +94,10 @@ public:
 		    int size, raw_breakpoint *bp) override;
 
   bool supports_hardware_single_step () override;
+
+  bool stopped_by_watchpoint () override;
+
+  CORE_ADDR stopped_data_address () override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index b5248ab368e..316f04e32ee 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -1214,8 +1214,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 
 	regcache = get_thread_regcache (current_thread, 1);
 
-	if (the_target->stopped_by_watchpoint != NULL
-	    && (*the_target->stopped_by_watchpoint) ())
+	if (the_target->pt->stopped_by_watchpoint ())
 	  {
 	    CORE_ADDR addr;
 	    int i;
@@ -1223,7 +1222,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 	    memcpy (buf, "watch:", 6);
 	    buf += 6;
 
-	    addr = (*the_target->stopped_data_address) ();
+	    addr = the_target->pt->stopped_data_address ();
 
 	    /* Convert each byte of the address into two hexadecimal
 	       chars.  Note that we take sizeof (void *) instead of
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 09b3a633fc8..00f5f794b85 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -469,3 +469,15 @@ process_target::supports_hardware_single_step ()
 {
   return false;
 }
+
+bool
+process_target::stopped_by_watchpoint ()
+{
+  return false;
+}
+
+CORE_ADDR
+process_target::stopped_data_address ()
+{
+  return 0;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 92b85cb061e..83595fad520 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,15 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise.  */
-
-  int (*stopped_by_watchpoint) (void);
-
-  /* Returns the address associated with the watchpoint that hit, if any;
-     returns 0 otherwise.  */
-
-  CORE_ADDR (*stopped_data_address) (void);
-
   /* Reports the text, data offsets of the executable.  This is
      needed for uclinux where the executable is relocated during load
      time.  */
@@ -476,6 +467,14 @@ public:
 
   /* Returns true if the target can do hardware single step.  */
   virtual bool supports_hardware_single_step ();
+
+  /* Returns true if target was stopped due to a watchpoint hit, false
+     otherwise.  */
+  virtual bool stopped_by_watchpoint ();
+
+  /* Returns the address associated with the watchpoint that hit, if any;
+     returns 0 otherwise.  */
+  virtual CORE_ADDR stopped_data_address ();
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 2862a9c241c..ff62bcefb0d 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -283,17 +283,17 @@ win32_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
     return 1;
 }
 
-static int
-win32_stopped_by_watchpoint (void)
+bool
+win32_process_target::stopped_by_watchpoint ()
 {
   if (the_low_target.stopped_by_watchpoint != NULL)
     return the_low_target.stopped_by_watchpoint ();
   else
-    return 0;
+    return false;
 }
 
-static CORE_ADDR
-win32_stopped_data_address (void)
+CORE_ADDR
+win32_process_target::stopped_data_address ()
 {
   if (the_low_target.stopped_data_address != NULL)
     return the_low_target.stopped_data_address ();
@@ -1844,8 +1844,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_stopped_by_watchpoint,
-  win32_stopped_data_address,
   NULL, /* read_offsets */
   NULL, /* get_tls_address */
 #ifdef _WIN32_WCE
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index c5f9a13e029..b2b8a6dedc3 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -148,6 +148,10 @@ public:
 		    int size, raw_breakpoint *bp) override;
 
   bool supports_hardware_single_step () override;
+
+  bool stopped_by_watchpoint () override;
+
+  CORE_ADDR stopped_data_address () override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 06/58] gdbserver: turn target op 'detach' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (35 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 11/58] gdbserver: turn target op 'wait' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 26/58] gdbserver: turn target op 'hostio_last_error' " Tankut Baris Aktemur
                   ` (22 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's detach op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(detach_inferior): Update the macro.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_detach): Turn into ...
	(linux_process_target::detach): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_detach): Turn into ...
	(lynx_process_target::detach): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_detach): Turn into ...
	(nto_process_target::detach): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_detach): Turn into ...
	(win32_process_target::detach): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  5 ++---
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/nto-low.cc   |  5 ++---
 gdbserver/nto-low.h    |  2 ++
 gdbserver/target.h     | 11 +++++------
 gdbserver/win32-low.cc |  5 ++---
 gdbserver/win32-low.h  |  2 ++
 9 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 4510e3a1c5f..1feb7d971cd 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1603,8 +1603,8 @@ linux_detach_lwp_callback (thread_info *thread)
   linux_detach_one_lwp (lwp);
 }
 
-static int
-linux_detach (process_info *process)
+int
+linux_process_target::detach (process_info *process)
 {
   struct lwp_info *main_lwp;
 
@@ -7359,7 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_detach,
   linux_mourn,
   linux_join,
   linux_thread_alive,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 4f8801150d5..e8789e9c8a9 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -278,6 +278,8 @@ public:
   int attach (unsigned long pid) override;
 
   int kill (process_info *proc) override;
+
+  int detach (process_info *proc) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index f6359e81575..a6eceaf25b1 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -535,8 +535,8 @@ lynx_process_target::kill (process_info *process)
 
 /* Implement the detach target_ops method.  */
 
-static int
-lynx_detach (process_info *process)
+int
+lynx_process_target::detach (process_info *process)
 {
   ptid_t ptid = lynx_ptid_t (process->pid, 0);
 
@@ -726,7 +726,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_detach,
   lynx_mourn,
   lynx_join,
   lynx_thread_alive,
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index cf357ff9a1f..9b8065e3f37 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -64,6 +64,8 @@ public:
   int attach (unsigned long pid) override;
 
   int kill (process_info *proc) override;
+
+  int detach (process_info *proc) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 15b3dc37f01..ceff0d432e5 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -409,8 +409,8 @@ nto_process_target::kill (process_info *proc)
 
 /* Detach from process PID.  */
 
-static int
-nto_detach (process_info *proc)
+int
+nto_process_target::detach (process_info *proc)
 {
   TRACE ("%s %d\n", __func__, proc->pid);
   do_detach ();
@@ -935,7 +935,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_detach,
   nto_mourn,
   NULL, /* nto_join */
   nto_thread_alive,
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 5564dda3bb2..e7e10fcb842 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -54,6 +54,8 @@ public:
   int attach (unsigned long pid) override;
 
   int kill (process_info *proc) override;
+
+  int detach (process_info *proc) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 0f3cb35f453..6c7c2869938 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,11 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Detach from process PROC.  Return -1 on failure, and 0 on
-     success.  */
-
-  int (*detach) (process_info *proc);
-
   /* The inferior process has died.  Do what is right.  */
 
   void (*mourn) (struct process_info *proc);
@@ -487,6 +482,10 @@ public:
 
   /* Kill process PROC.  Return -1 on failure, and 0 on success.  */
   virtual int kill (process_info *proc) = 0;
+
+  /* Detach from process PROC.  Return -1 on failure, and 0 on
+     success.  */
+  virtual int detach (process_info *proc) = 0;
 };
 
 extern process_stratum_target *the_target;
@@ -524,7 +523,7 @@ int kill_inferior (process_info *proc);
     } while (0)
 
 #define detach_inferior(proc) \
-  (*the_target->detach) (proc)
+  the_target->pt->detach (proc)
 
 #define mythread_alive(pid) \
   (*the_target->thread_alive) (pid)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index a7fb1244e34..9cefb29b046 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -843,8 +843,8 @@ win32_process_target::kill (process_info *process)
 
 /* Implementation of target_ops::detach.  */
 
-static int
-win32_detach (process_info *process)
+int
+win32_process_target::detach (process_info *process)
 {
   winapi_DebugActiveProcessStop DebugActiveProcessStop = NULL;
   winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit = NULL;
@@ -1839,7 +1839,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_detach,
   win32_mourn,
   win32_join,
   win32_thread_alive,
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 45a6262e38e..10096b87682 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -113,6 +113,8 @@ public:
   int attach (unsigned long pid) override;
 
   int kill (process_info *proc) override;
+
+  int detach (process_info *proc) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 38/58] gdbserver: turn target ops 'read_pc' and 'write_pc' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (46 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 29/58] gdbserver: turn non-stop and async target ops into methods Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 18/58] gdbserver: turn target op 'supports_z_point_type' into a method Tankut Baris Aktemur
                   ` (11 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's read_pc and write_pc ops into
	methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	* target.cc (process_target::read_pc): Define.
	(process_target::write_pc): Define.

	Update the derived classes and callers below.

	* regcache.cc (regcache_read_pc): Update.
	(regcache_write_pc): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_read_pc): Turn into ...
	(linux_process_target::read_pc): ... this.
	(linux_write_pc): Turn into ...
	(linux_process_target::write_pc): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 10 ++++------
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  |  2 --
 gdbserver/nto-low.cc   |  2 --
 gdbserver/regcache.cc  | 16 ++--------------
 gdbserver/target.cc    | 12 ++++++++++++
 gdbserver/target.h     | 12 ++++++------
 gdbserver/win32-low.cc |  2 --
 8 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 5e325eb0e7f..8065632a476 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6551,8 +6551,8 @@ linux_process_target::supports_tracepoints ()
   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;
@@ -6560,8 +6560,8 @@ 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);
 
@@ -7445,8 +7445,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_read_pc,
-  linux_write_pc,
   linux_thread_stopped,
   NULL,
   linux_pause_all,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 1d71ff51cf2..67a36c8a67d 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -388,6 +388,10 @@ public:
   void process_qsupported (char **features, int count) override;
 
   bool supports_tracepoints () override;
+
+  CORE_ADDR read_pc (regcache *regcache) override;
+
+  void write_pc (regcache *regcache, CORE_ADDR pc) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 5a0648987c7..2ac59c3c14a 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,8 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* read_pc */
-  NULL,  /* write_pc */
   NULL,  /* thread_stopped */
   NULL,  /* get_tib_address */
   NULL,  /* pause_all */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index efb342f5938..2b5b02b69bd 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,8 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* read_pc */
-  NULL, /* write_pc */
   NULL, /* thread_stopped */
   NULL, /* get_tib_address */
   NULL, /* pause_all */
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index f63463344af..ec9d70d42fb 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -477,25 +477,13 @@ collect_register_by_name (struct regcache *regcache,
 CORE_ADDR
 regcache_read_pc (struct regcache *regcache)
 {
-  CORE_ADDR pc_val;
-
-  if (the_target->read_pc)
-    pc_val = the_target->read_pc (regcache);
-  else
-    internal_error (__FILE__, __LINE__,
-		    "regcache_read_pc: Unable to find PC");
-
-  return pc_val;
+  return the_target->pt->read_pc (regcache);
 }
 
 void
 regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
-  if (the_target->write_pc)
-    the_target->write_pc (regcache, pc);
-  else
-    internal_error (__FILE__, __LINE__,
-		    "regcache_write_pc: Unable to update PC");
+  the_target->pt->write_pc (regcache, pc);
 }
 
 #endif
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index ded8f3fee9d..4f8d91c171f 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -614,3 +614,15 @@ process_target::supports_tracepoints ()
 {
   return false;
 }
+
+CORE_ADDR
+process_target::read_pc (regcache *regcache)
+{
+  gdb_assert_not_reached ("process_target::read_pc: Unable to find PC");
+}
+
+void
+process_target::write_pc (regcache *regcache, CORE_ADDR pc)
+{
+  gdb_assert_not_reached ("process_target::write_pc: Unable to update PC");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index e36f121a9ae..2aef0208c11 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,12 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read PC from REGCACHE.  */
-  CORE_ADDR (*read_pc) (struct regcache *regcache);
-
-  /* Write PC to REGCACHE.  */
-  void (*write_pc) (struct regcache *regcache, CORE_ADDR pc);
-
   /* Return true if THREAD is known to be stopped now.  */
   int (*thread_stopped) (struct thread_info *thread);
 
@@ -488,6 +482,12 @@ public:
 
   /* Return true if the target supports tracepoints, false otherwise.  */
   virtual bool supports_tracepoints ();
+
+  /* Read PC from REGCACHE.  */
+  virtual CORE_ADDR read_pc (regcache *regcache);
+
+  /* Write PC to REGCACHE.  */
+  virtual void write_pc (regcache *regcache, CORE_ADDR pc);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 87a59648c30..a7329fe20cf 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,8 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* read_pc */
-  NULL, /* write_pc */
   NULL, /* thread_stopped */
   win32_get_tib_address,
   NULL, /* pause_all */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 49/58] gdbserver: turn target op 'supports_range_stepping' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (48 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 18/58] gdbserver: turn target op 'supports_z_point_type' into a method Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:04 ` [PATCH v2 50/58] gdbserver: turn target op 'pid_to_exec_file' " Tankut Baris Aktemur
                   ` (9 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_range_stepping op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_supports_range_stepping): Update the macro.
	* target.cc (process_target::supports_range_stepping): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_range_stepping): Turn into ...
	(linux_process_target::supports_range_stepping): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 9 ++++-----
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 6 ++++++
 gdbserver/target.h     | 9 ++++-----
 gdbserver/win32-low.cc | 1 -
 7 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 1af37044a8e..e5e32006496 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6426,13 +6426,13 @@ linux_process_target::supports_agent ()
   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) ();
 }
@@ -7467,7 +7467,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_range_stepping,
   linux_proc_pid_to_exec_file,
   linux_mntns_open_cloexec,
   linux_mntns_unlink,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 8c33dccc678..f47d9ed816f 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -446,6 +446,8 @@ public:
   int read_btrace_conf (const btrace_target_info *tinfo,
 			buffer *buf) override;
 #endif
+
+  bool supports_range_stepping () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index a890b660bb1..854037a631b 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_range_stepping */
   NULL,  /* pid_to_exec_file */
   NULL,  /* multifs_open */
   NULL,  /* multifs_unlink */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index ef79105877b..3532aa460f0 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* supports_range_stepping */
   NULL, /* pid_to_exec_file */
   NULL, /* multifs_open */
   NULL, /* multifs_unlink */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index e2ce7ff0869..8739ba864f8 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -753,3 +753,9 @@ process_target::read_btrace_conf (const btrace_target_info *tinfo,
 {
   error (_("Target does not support branch tracing."));
 }
+
+bool
+process_target::supports_range_stepping ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 9d7c599b1e6..cdb3c119433 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return true if target supports range stepping.  */
-  int (*supports_range_stepping) (void);
-
   /* Return the full absolute name of the executable file that was
      run to create the process PID.  If the executable file cannot
      be determined, NULL is returned.  Otherwise, a pointer to a
@@ -498,6 +495,9 @@ public:
      otherwise.  */
   virtual int read_btrace_conf (const btrace_target_info *tinfo,
 				buffer *buf);
+
+  /* Return true if target supports range stepping.  */
+  virtual bool supports_range_stepping ();
 };
 
 extern process_stratum_target *the_target;
@@ -638,8 +638,7 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
 }
 
 #define target_supports_range_stepping() \
-  (the_target->supports_range_stepping ? \
-   (*the_target->supports_range_stepping) () : 0)
+  the_target->pt->supports_range_stepping ()
 
 #define target_supports_stopped_by_sw_breakpoint() \
   the_target->pt->supports_stopped_by_sw_breakpoint ()
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 7fdc90feff1..b270745275f 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_range_stepping */
   NULL, /* pid_to_exec_file */
   NULL, /* multifs_open */
   NULL, /* multifs_unlink */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 29/58] gdbserver: turn non-stop and async target ops into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (45 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 55/58] gdbserver: turn target op 'supports_catch_syscall' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 38/58] gdbserver: turn target ops 'read_pc' and 'write_pc' " Tankut Baris Aktemur
                   ` (12 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_non_stop, async, and
	start_non_stop ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(target_supports_non_stop): Update the macro.
	(target_async): Update the macro.
	(start_non_stop): Remove declaration.
	* target.cc (process_target::supports_non_stop): Define.
	(process_target::async): Define.
	(process_target::start_non_stop): Define.
	(start_non_stop): Remove.

	Update the derived classes and callers below.

	* server.cc (handle_qxfer_siginfo): Update.
	(handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_non_stop): Turn into ...
	(linux_process_target::supports_non_stop): ... this.
	(linux_async): Turn into ...
	(linux_process_target::async): ... this.
	(linux_start_non_stop): Turn into ...
	(linux_process_target::start_non_stop): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_supports_non_stop): Remove; rely on the default behavior
	instead.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 23 ++++++++++-------------
 gdbserver/linux-low.h  |  6 ++++++
 gdbserver/lynx-low.cc  |  3 ---
 gdbserver/nto-low.cc   | 12 ------------
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.cc    | 35 +++++++++++++++++++++--------------
 gdbserver/target.h     | 29 +++++++++++++----------------
 gdbserver/win32-low.cc |  3 ---
 8 files changed, 53 insertions(+), 64 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 1b811618682..192989a9a4e 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6261,16 +6261,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",
@@ -6322,13 +6322,13 @@ 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;
@@ -7425,9 +7425,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_non_stop,
-  linux_async,
-  linux_start_non_stop,
   linux_supports_multi_process,
   linux_supports_fork_events,
   linux_supports_vfork_events,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 5a0e370dd89..c5982ca3e5b 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -357,6 +357,12 @@ public:
   int qxfer_siginfo (const char *annex, unsigned char *readbuf,
 		     unsigned const char *writebuf,
 		     CORE_ADDR offset, int len) override;
+
+  bool supports_non_stop () override;
+
+  bool async (bool enable) override;
+
+  int start_non_stop (bool enable) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 86e90df0086..15811d2034a 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,9 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_non_stop */
-  NULL,  /* async */
-  NULL,  /* start_non_stop */
   NULL,  /* supports_multi_process */
   NULL,  /* supports_fork_events */
   NULL,  /* supports_vfork_events */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 78e8fd966b9..bb0b14aa951 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -933,15 +933,6 @@ nto_process_target::stopped_data_address ()
   return ret;
 }
 
-/* We do not currently support non-stop.  */
-
-static int
-nto_supports_non_stop (void)
-{
-  TRACE ("%s\n", __func__);
-  return 0;
-}
-
 /* Implementation of the target_ops method "sw_breakpoint_from_kind".  */
 
 static const gdb_byte *
@@ -956,9 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_supports_non_stop,
-  NULL, /* async */
-  NULL, /* start_non_stop */
   NULL, /* supports_multi_process */
   NULL, /* supports_fork_events */
   NULL, /* supports_vfork_events */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index ece75f01868..f427e7706fb 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -740,7 +740,7 @@ handle_general_set (char *own_buf)
 	}
 
       req_str = req ? "non-stop" : "all-stop";
-      if (start_non_stop (req) != 0)
+      if (the_target->pt->start_non_stop (req == 1) != 0)
 	{
 	  fprintf (stderr, "Setting %s mode failed\n", req_str);
 	  write_enn (own_buf);
@@ -1234,7 +1234,7 @@ handle_detach (char *own_buf)
 	    debug_printf ("Forcing non-stop mode\n");
 
 	  non_stop = true;
-	  start_non_stop (1);
+	  the_target->pt->start_non_stop (true);
 	}
 
       process->gdb_detached = 1;
@@ -3885,7 +3885,7 @@ captured_main (int argc, char *argv[])
 		     down without informing GDB.  */
 		  if (!non_stop)
 		    {
-		      if (start_non_stop (1))
+		      if (the_target->pt->start_non_stop (true))
 			non_stop = 1;
 
 		      /* Detaching implicitly resumes all threads;
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 94bb45fcace..33e31a748ef 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -264,20 +264,6 @@ target_supports_multi_process (void)
 	  (*the_target->supports_multi_process) () : 0);
 }
 
-int
-start_non_stop (int nonstop)
-{
-  if (the_target->start_non_stop == NULL)
-    {
-      if (nonstop)
-	return -1;
-      else
-	return 0;
-    }
-
-  return (*the_target->start_non_stop) (nonstop);
-}
-
 void
 set_target_ops (process_stratum_target *target)
 {
@@ -541,3 +527,24 @@ process_target::qxfer_siginfo (const char *annex, unsigned char *readbuf,
 {
   gdb_assert_not_reached ("target op qxfer_siginfo not supported");
 }
+
+bool
+process_target::supports_non_stop ()
+{
+  return false;
+}
+
+bool
+process_target::async (bool enable)
+{
+  return false;
+}
+
+int
+process_target::start_non_stop (bool enable)
+{
+  if (enable)
+    return -1;
+  else
+    return 0;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 1ad0005c8f4..d3ee4452b63 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,16 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  int (*supports_non_stop) (void);
-
-  /* Enables async target events.  Returns the previous enable
-     state.  */
-  int (*async) (int enable);
-
-  /* Switch to non-stop (1) or all-stop (0) mode.  Return 0 on
-     success, -1 otherwise.  */
-  int (*start_non_stop) (int);
-
   /* Returns true if the target supports multi-process debugging.  */
   int (*supports_multi_process) (void);
 
@@ -485,6 +475,17 @@ public:
   virtual int qxfer_siginfo (const char *annex, unsigned char *readbuf,
 			     unsigned const char *writebuf,
 			     CORE_ADDR offset, int len);
+
+  /* Return true if non-stop mode is supported.  */
+  virtual bool supports_non_stop ();
+
+  /* Enables async target events.  Returns the previous enable
+     state.  */
+  virtual bool async (bool enable);
+
+  /* Switch to non-stop (ENABLE == true) or all-stop (ENABLE == false)
+     mode.  Return 0 on success, -1 otherwise.  */
+  virtual int start_non_stop (bool enable);
 };
 
 extern process_stratum_target *the_target;
@@ -537,10 +538,10 @@ int kill_inferior (process_info *proc);
   the_target->pt->join (pid)
 
 #define target_supports_non_stop() \
-  (the_target->supports_non_stop ? (*the_target->supports_non_stop ) () : 0)
+  the_target->pt->supports_non_stop ()
 
 #define target_async(enable) \
-  (the_target->async ? (*the_target->async) (enable) : 0)
+  the_target->pt->async (enable)
 
 #define target_process_qsupported(features, count)	\
   do							\
@@ -696,10 +697,6 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
   (the_target->supports_software_single_step ? \
    (*the_target->supports_software_single_step) () : 0)
 
-/* Start non-stop mode, returns 0 on success, -1 on failure.   */
-
-int start_non_stop (int nonstop);
-
 ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
 	       int connected_wait);
 
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 23c23bc7ed8..60a7f475f84 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,9 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_non_stop */
-  NULL, /* async */
-  NULL, /* start_non_stop */
   NULL, /* supports_multi_process */
   NULL, /* supports_fork_events */
   NULL, /* supports_vfork_events */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 28/58] gdbserver: turn target op 'qxfer_siginfo' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (31 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 20/58] gdbserver: turn target op '{supports_}stopped_by_sw_breakpoint' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 40/58] gdbserver: turn target op 'get_tib_address' " Tankut Baris Aktemur
                   ` (26 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's qxfer_siginfo op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_qxfer_siginfo'.
	* target.cc (process_target::qxfer_siginfo): Define.
	(process_target::supports_qxfer_siginfo): Define.

	Update the derived classes and callers below.

	* server.cc (handle_qxfer_siginfo): Update.
	(handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_qxfer_siginfo): Define.
	(linux_xfer_siginfo): Turn into ...
	(linux_process_target::qxfer_siginfo): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 15 +++++++++++----
 gdbserver/linux-low.h  |  6 ++++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.cc    | 14 ++++++++++++++
 gdbserver/target.h     | 13 ++++++++-----
 gdbserver/win32-low.cc | 15 +++++++++++----
 gdbserver/win32-low.h  |  6 ++++++
 9 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 7c15781c48e..1b811618682 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6178,9 +6178,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;
@@ -7417,7 +7425,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_xfer_siginfo,
   linux_supports_non_stop,
   linux_async,
   linux_start_non_stop,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 892767140e1..5a0e370dd89 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -351,6 +351,12 @@ public:
   int qxfer_osdata (const char *annex, unsigned char *readbuf,
 		    unsigned const char *writebuf,
 		    CORE_ADDR offset, int len) override;
+
+  bool supports_qxfer_siginfo () override;
+
+  int qxfer_siginfo (const char *annex, unsigned char *readbuf,
+		     unsigned const char *writebuf,
+		     CORE_ADDR offset, int len) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index ecd7476db45..86e90df0086 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* qxfer_siginfo */
   NULL,  /* supports_non_stop */
   NULL,  /* async */
   NULL,  /* start_non_stop */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index fffe6313305..78e8fd966b9 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -956,7 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* xfer_siginfo */
   nto_supports_non_stop,
   NULL, /* async */
   NULL, /* start_non_stop */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 59eb1c0c3d7..ece75f01868 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1600,13 +1600,13 @@ handle_qxfer_siginfo (const char *annex,
 		      gdb_byte *readbuf, const gdb_byte *writebuf,
 		      ULONGEST offset, LONGEST len)
 {
-  if (the_target->qxfer_siginfo == NULL)
+  if (!the_target->pt->supports_qxfer_siginfo ())
     return -2;
 
   if (annex[0] != '\0' || current_thread == NULL)
     return -1;
 
-  return (*the_target->qxfer_siginfo) (annex, readbuf, writebuf, offset, len);
+  return the_target->pt->qxfer_siginfo (annex, readbuf, writebuf, offset, len);
 }
 
 /* Handle qXfer:statictrace:read.  */
@@ -2377,7 +2377,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (the_target->pt->supports_read_auxv ())
 	strcat (own_buf, ";qXfer:auxv:read+");
 
-      if (the_target->qxfer_siginfo != NULL)
+      if (the_target->pt->supports_qxfer_siginfo ())
 	strcat (own_buf, ";qXfer:siginfo:read+;qXfer:siginfo:write+");
 
       if (the_target->read_loadmap != NULL)
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index c6ed544e669..94bb45fcace 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -527,3 +527,17 @@ process_target::qxfer_osdata (const char *annex, unsigned char *readbuf,
 {
   gdb_assert_not_reached ("target op qxfer_osdata not supported");
 }
+
+bool
+process_target::supports_qxfer_siginfo ()
+{
+  return false;
+}
+
+int
+process_target::qxfer_siginfo (const char *annex, unsigned char *readbuf,
+			       unsigned const char *writebuf,
+			       CORE_ADDR offset, int len)
+{
+  gdb_assert_not_reached ("target op qxfer_siginfo not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 53f88a02bac..1ad0005c8f4 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,11 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read/Write extra signal info.  */
-  int (*qxfer_siginfo) (const char *annex, unsigned char *readbuf,
-			unsigned const char *writebuf,
-			CORE_ADDR offset, int len);
-
   int (*supports_non_stop) (void);
 
   /* Enables async target events.  Returns the previous enable
@@ -482,6 +477,14 @@ public:
   virtual int qxfer_osdata (const char *annex, unsigned char *readbuf,
 			    unsigned const char *writebuf,
 			    CORE_ADDR offset, int len);
+
+  /* Return true if the qxfer_siginfo target op is supported.  */
+  virtual bool supports_qxfer_siginfo ();
+
+  /* Read/Write extra signal info.  */
+  virtual int qxfer_siginfo (const char *annex, unsigned char *readbuf,
+			     unsigned const char *writebuf,
+			     CORE_ADDR offset, int len);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index ce750b5e37c..23c23bc7ed8 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1793,11 +1793,19 @@ win32_process_target::hostio_last_error (char *buf)
 }
 #endif
 
+bool
+win32_process_target::supports_qxfer_siginfo ()
+{
+  return true;
+}
+
 /* Write Windows signal info.  */
 
-static int
-win32_xfer_siginfo (const char *annex, unsigned char *readbuf,
-		    unsigned const char *writebuf, CORE_ADDR offset, int len)
+int
+win32_process_target::qxfer_siginfo (const char *annex,
+				     unsigned char *readbuf,
+				     unsigned const char *writebuf,
+				     CORE_ADDR offset, int len)
 {
   if (siginfo_er.ExceptionCode == 0)
     return -1;
@@ -1844,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_xfer_siginfo,
   NULL, /* supports_non_stop */
   NULL, /* async */
   NULL, /* start_non_stop */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 86447fd541a..b259b1fbac1 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -156,6 +156,12 @@ public:
 #ifdef _WIN32_WCE
   void hostio_last_error (char *buf) override;
 #endif
+
+  bool supports_qxfer_siginfo () override;
+
+  int qxfer_siginfo (const char *annex, unsigned char *readbuf,
+		     unsigned const char *writebuf,
+		     CORE_ADDR offset, int len) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 11/58] gdbserver: turn target op 'wait' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (34 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 34/58] gdbserver: turn target op 'core_of_thread' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 06/58] gdbserver: turn target op 'detach' " Tankut Baris Aktemur
                   ` (23 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's wait op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.

	Update the derived classes and callers below.

	* target.cc (target_wait): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_wait): Turn into ...
	(linux_process_target::wait): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_wait): Turn into ...
	(lynx_process_target::wait): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_wait): Turn into ...
	(nto_process_target::wait): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_wait): Turn into ...
	(win32_process_target::wait): ... this.
	(do_initial_child_stuff): Update.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc |  8 ++++----
 gdbserver/linux-low.h  |  3 +++
 gdbserver/lynx-low.cc  |  8 ++++----
 gdbserver/lynx-low.h   |  3 +++
 gdbserver/nto-low.cc   |  7 +++----
 gdbserver/nto-low.h    |  3 +++
 gdbserver/target.cc    |  2 +-
 gdbserver/target.h     | 26 +++++++++++++-------------
 gdbserver/win32-low.cc | 12 +++++-------
 gdbserver/win32-low.h  |  3 +++
 10 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index b2e06262464..49511125897 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -3833,9 +3833,10 @@ async_file_mark (void)
      be awakened anyway.  */
 }
 
-static ptid_t
-linux_wait (ptid_t ptid,
-	    struct target_waitstatus *ourstatus, int target_options)
+ptid_t
+linux_process_target::wait (ptid_t ptid,
+			    target_waitstatus *ourstatus,
+			    int target_options)
 {
   ptid_t event_ptid;
 
@@ -7358,7 +7359,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_wait,
   linux_fetch_registers,
   linux_store_registers,
   linux_prepare_to_access_memory,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index a750f7cca83..d1d89106e50 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -288,6 +288,9 @@ public:
   bool thread_alive (ptid_t pid) override;
 
   void resume (thread_resume *resume_info, size_t n) override;
+
+  ptid_t wait (ptid_t ptid, target_waitstatus *status,
+	       int options) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 9fc41e4ce99..f38c3110cbd 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -505,12 +505,13 @@ retry:
 /* A wrapper around lynx_wait_1 that also prints debug traces when
    such debug traces have been activated.  */
 
-static ptid_t
-lynx_wait (ptid_t ptid, struct target_waitstatus *status, int options)
+ptid_t
+lynx_process_target::wait (ptid_t ptid, target_waitstatus *status,
+			   int options)
 {
   ptid_t new_ptid;
 
-  lynx_debug ("lynx_wait (pid = %d, tid = %ld)",
+  lynx_debug ("wait (pid = %d, tid = %ld)",
               lynx_ptid_get_pid (ptid), lynx_ptid_get_tid (ptid));
   new_ptid = lynx_wait_1 (ptid, status, options);
   lynx_debug ("          -> (pid=%d, tid=%ld, status->kind = %d)",
@@ -726,7 +727,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  lynx_wait,
   lynx_fetch_registers,
   lynx_store_registers,
   NULL,  /* prepare_to_access_memory */
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 4a5e4ba6f8d..35714713fd2 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -74,6 +74,9 @@ public:
   bool thread_alive (ptid_t pid) override;
 
   void resume (thread_resume *resume_info, size_t n) override;
+
+  ptid_t wait (ptid_t ptid, target_waitstatus *status,
+	       int options) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index d9981540308..6cac6eb4329 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -518,9 +518,9 @@ nto_process_target::resume (thread_resume *resume_info, size_t n)
 
    Return ptid of thread that caused the event.  */
 
-static ptid_t
-nto_wait (ptid_t ptid,
-	  struct target_waitstatus *ourstatus, int target_options)
+ptid_t
+nto_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
+			  int target_options)
 {
   sigset_t set;
   siginfo_t info;
@@ -941,7 +941,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_wait,
   nto_fetch_registers,
   nto_store_registers,
   NULL, /* prepare_to_access_memory */
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index 5b32ae7c514..94837ab6051 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -64,6 +64,9 @@ public:
   bool thread_alive (ptid_t pid) override;
 
   void resume (thread_resume *resume_info, size_t n) override;
+
+  ptid_t wait (ptid_t ptid, target_waitstatus *status,
+	       int options) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index eca53de982e..b73c4465f1c 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -223,7 +223,7 @@ target_stop_and_wait (ptid_t ptid)
 ptid_t
 target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 {
-  return (*the_target->wait) (ptid, status, options);
+  return the_target->pt->wait (ptid, status, options);
 }
 
 /* See target/target.h.  */
diff --git a/gdbserver/target.h b/gdbserver/target.h
index f64009f7521..16daf93440e 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,19 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Wait for the inferior process or thread to change state.  Store
-     status through argument pointer STATUS.
-
-     PTID = -1 to wait for any pid to do something, PTID(pid,0,0) to
-     wait for any thread of process pid to do something.  Return ptid
-     of child, or -1 in case of error; store status through argument
-     pointer STATUS.  OPTIONS is a bit set of options defined as
-     TARGET_W* above.  If options contains TARGET_WNOHANG and there's
-     no child stop to report, return is
-     null_ptid/TARGET_WAITKIND_IGNORE.  */
-
-  ptid_t (*wait) (ptid_t ptid, struct target_waitstatus *status, int options);
-
   /* Fetch registers from the inferior process.
 
      If REGNO is -1, fetch all registers; otherwise, fetch at least REGNO.  */
@@ -482,6 +469,19 @@ public:
 
   /* Resume the inferior process.  */
   virtual void resume (thread_resume *resume_info, size_t n) = 0;
+
+  /* Wait for the inferior process or thread to change state.  Store
+     status through argument pointer STATUS.
+
+     PTID = -1 to wait for any pid to do something, PTID(pid,0,0) to
+     wait for any thread of process pid to do something.  Return ptid
+     of child, or -1 in case of error; store status through argument
+     pointer STATUS.  OPTIONS is a bit set of options defined as
+     TARGET_W* above.  If options contains TARGET_WNOHANG and there's
+     no child stop to report, return is
+     null_ptid/TARGET_WAITKIND_IGNORE.  */
+  virtual ptid_t wait (ptid_t ptid, target_waitstatus *status,
+		       int options) = 0;
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 1f4af2c66c8..e7df444451d 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -103,8 +103,6 @@ typedef BOOL (WINAPI *winapi_DebugSetProcessKillOnExit) (BOOL KillOnExit);
 typedef BOOL (WINAPI *winapi_DebugBreakProcess) (HANDLE);
 typedef BOOL (WINAPI *winapi_GenerateConsoleCtrlEvent) (DWORD, DWORD);
 
-static ptid_t win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus,
-			  int options);
 #ifndef _WIN32_WCE
 static void win32_add_all_dlls (void);
 #endif
@@ -379,7 +377,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
     {
       struct target_waitstatus status;
 
-      win32_wait (minus_one_ptid, &status, 0);
+      the_target->pt->wait (minus_one_ptid, &status, 0);
 
       /* Note win32_wait doesn't return thread events.  */
       if (status.kind != TARGET_WAITKIND_LOADED)
@@ -714,7 +712,7 @@ win32_process_target::create_inferior (const char *program,
 
   /* Wait till we are at 1st instruction in program, return new pid
      (assuming success).  */
-  cs.last_ptid = win32_wait (ptid_t (current_process_id), &cs.last_status, 0);
+  cs.last_ptid = wait (ptid_t (current_process_id), &cs.last_status, 0);
 
   /* Necessary for handle_v_kill.  */
   signal_pid = current_process_id;
@@ -1610,8 +1608,9 @@ get_child_debug_event (struct target_waitstatus *ourstatus)
 /* Wait for the inferior process to change state.
    STATUS will be filled in with a response code to send to GDB.
    Returns the signal which caused the process to stop. */
-static ptid_t
-win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
+ptid_t
+win32_process_target::wait (ptid_t ptid, target_waitstatus *ourstatus,
+			    int options)
 {
   struct regcache *regcache;
 
@@ -1838,7 +1837,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_wait,
   win32_fetch_inferior_registers,
   win32_store_inferior_registers,
   NULL, /* prepare_to_access_memory */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index fbdf3c7395a..9c74ffa9c58 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -123,6 +123,9 @@ public:
   bool thread_alive (ptid_t pid) override;
 
   void resume (thread_resume *resume_info, size_t n) override;
+
+  ptid_t wait (ptid_t ptid, target_waitstatus *status,
+	       int options) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 34/58] gdbserver: turn target op 'core_of_thread' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (33 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 40/58] gdbserver: turn target op 'get_tib_address' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 11/58] gdbserver: turn target op 'wait' " Tankut Baris Aktemur
                   ` (24 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's core_of_thread op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_core_of_thread): Update the macro.
	* target.cc (process_target::core_of_thread): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::core_of_thread): Define.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 7 ++++++-
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 6 ++++++
 gdbserver/target.h     | 9 ++++-----
 gdbserver/win32-low.cc | 1 -
 7 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 5fb38819e61..8ddaf64c103 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6404,6 +6404,12 @@ linux_process_target::handle_monitor_command (char *mon)
 #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)
 {
@@ -7435,7 +7441,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_common_core_of_thread,
   linux_read_loadmap,
   linux_process_qsupported,
   linux_supports_tracepoints,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index d3157220730..1d89ebd7a2d 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -375,6 +375,8 @@ public:
   void handle_new_gdb_connection () override;
 
   int handle_monitor_command (char *mon) override;
+
+  int core_of_thread (ptid_t ptid) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index d489886755e..2e177594c3a 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* core_of_thread */
   NULL,  /* read_loadmap */
   NULL,  /* process_qsupported */
   NULL,  /* supports_tracepoints */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 9cd30da32e6..9a708712905 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* core_of_thread */
   NULL, /* read_loadmap */
   NULL, /* process_qsupported */
   NULL, /* supports_tracepoints */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 74cd90a48a4..e1c802d65bc 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -583,3 +583,9 @@ process_target::handle_monitor_command (char *mon)
 {
   return 0;
 }
+
+int
+process_target::core_of_thread (ptid_t ptid)
+{
+  return -1;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index b607ca62540..96d986a09ab 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns the core given a thread, or -1 if not known.  */
-  int (*core_of_thread) (ptid_t);
-
   /* Read loadmaps.  Read LEN bytes at OFFSET into a buffer at MYADDR.  */
   int (*read_loadmap) (const char *annex, CORE_ADDR offset,
 		       unsigned char *myaddr, unsigned int len);
@@ -486,6 +483,9 @@ public:
   /* The target-specific routine to process monitor command.
      Returns 1 if handled, or 0 to perform default processing.  */
   virtual int handle_monitor_command (char *mon);
+
+  /* Returns the core given a thread, or -1 if not known.  */
+  virtual int core_of_thread (ptid_t ptid);
 };
 
 extern process_stratum_target *the_target;
@@ -700,8 +700,7 @@ int prepare_to_access_memory (void);
 void done_accessing_memory (void);
 
 #define target_core_of_thread(ptid)		\
-  (the_target->core_of_thread ? (*the_target->core_of_thread) (ptid) \
-   : -1)
+  the_target->pt->core_of_thread (ptid)
 
 #define target_thread_name(ptid)                                \
   (the_target->thread_name ? (*the_target->thread_name) (ptid)  \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index fcb3906197d..c0b73268238 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* core_of_thread */
   NULL, /* read_loadmap */
   NULL, /* process_qsupported */
   NULL, /* supports_tracepoints */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 22/58] gdbserver: turn target op 'supports_hardware_single_step' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (42 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 52/58] gdbserver: turn breakpoint kind-related target ops into methods Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 54/58] gdbserver: turn target op 'supports_software_single_step' " Tankut Baris Aktemur
                   ` (15 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_hardware_single_step op into
	a method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_supports_hardware_single_step): Update the macro.
	(target_can_do_hardware_single_step): Remove declaration.
	* target.cc (process_target::supports_hardware_single_step): Define.
	(target_can_do_hardware_single_step): Remove.

	Update the derived classes and callers below.

	* linux-low.h (class linux_process_target): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_hardware_single_step): Turn into ...
	(linux_process_target::supports_hardware_single_step): ... this.
	* lynx-low.h (class lynx_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	(lynx_process_target::supports_hardware_single_step): Define.
	* nto-low.h (class nto_process_target): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_process_target::supports_hardware_single_step): Define.
	* win32-low.h (class win32_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_process_target::supports_hardware_single_step): Define.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  7 ++++++-
 gdbserver/lynx-low.h   |  2 ++
 gdbserver/nto-low.cc   |  7 ++++++-
 gdbserver/nto-low.h    |  2 ++
 gdbserver/target.cc    | 14 ++++++--------
 gdbserver/target.h     | 11 ++++-------
 gdbserver/win32-low.cc |  7 ++++++-
 gdbserver/win32-low.h  |  2 ++
 10 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 9ad5e19207a..fec2c3c5673 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6032,8 +6032,8 @@ linux_process_target::supports_stopped_by_hw_breakpoint ()
 
 /* Implement the supports_hardware_single_step target_ops method.  */
 
-static int
-linux_supports_hardware_single_step (void)
+bool
+linux_process_target::supports_hardware_single_step ()
 {
   return can_hardware_single_step ();
 }
@@ -7376,7 +7376,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_hardware_single_step,
   linux_stopped_by_watchpoint,
   linux_stopped_data_address,
 #if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 95dabf3a44e..57fc9a59415 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -330,6 +330,8 @@ public:
   bool stopped_by_hw_breakpoint () override;
 
   bool supports_stopped_by_hw_breakpoint () override;
+
+  bool supports_hardware_single_step () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index e4f276b5af0..ea328b7efe3 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -722,6 +722,12 @@ lynx_process_target::request_interrupt ()
   kill (lynx_ptid_get_pid (inferior_ptid), SIGINT);
 }
 
+bool
+lynx_process_target::supports_hardware_single_step ()
+{
+  return true;
+}
+
 /* The LynxOS target ops object.  */
 
 static lynx_process_target the_lynx_target;
@@ -729,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  target_can_do_hardware_single_step,
   NULL,  /* stopped_by_watchpoint */
   NULL,  /* stopped_data_address */
   NULL,  /* read_offsets */
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 795603af0d7..4253f1259c2 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -89,6 +89,8 @@ public:
 		    int len) override;
 
   void request_interrupt () override;
+
+  bool supports_hardware_single_step () override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 6bb926d5278..3e10436df3d 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -869,6 +869,12 @@ nto_process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
   return nto_breakpoint (addr, wtype, -1);
 }
 
+bool
+nto_process_target::supports_hardware_single_step ()
+{
+  return true;
+}
+
 /* Check if the reason of stop for current thread (CURRENT_INFERIOR) is
    a watchpoint.
 
@@ -950,7 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  target_can_do_hardware_single_step,
   nto_stopped_by_watchpoint,
   nto_stopped_data_address,
   NULL, /* nto_read_offsets */
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index b0b276319d2..001ccb6687c 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -92,6 +92,8 @@ public:
 
   int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 		    int size, raw_breakpoint *bp) override;
+
+  bool supports_hardware_single_step () override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index f7dc0f4d658..09b3a633fc8 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -316,14 +316,6 @@ kill_inferior (process_info *proc)
   return the_target->pt->kill (proc);
 }
 
-/* Target can do hardware single step.  */
-
-int
-target_can_do_hardware_single_step (void)
-{
-  return 1;
-}
-
 /* Default implementation for breakpoint_kind_for_pc.
 
    The default behavior for targets that don't implement breakpoint_kind_for_pc
@@ -471,3 +463,9 @@ process_target::supports_stopped_by_hw_breakpoint ()
 {
   return false;
 }
+
+bool
+process_target::supports_hardware_single_step ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index c5b1ef21b07..92b85cb061e 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns true if the target can do hardware single step.  */
-  int (*supports_hardware_single_step) (void);
-
   /* Returns 1 if target was stopped due to a watchpoint hit, 0 otherwise.  */
 
   int (*stopped_by_watchpoint) (void);
@@ -476,6 +473,9 @@ public:
   /* Returns true if the target knows whether a trap was caused by a
      HW breakpoint triggering.  */
   virtual bool supports_stopped_by_hw_breakpoint ();
+
+  /* Returns true if the target can do hardware single step.  */
+  virtual bool supports_hardware_single_step ();
 };
 
 extern process_stratum_target *the_target;
@@ -668,8 +668,7 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
   the_target->pt->supports_stopped_by_hw_breakpoint ()
 
 #define target_supports_hardware_single_step() \
-  (the_target->supports_hardware_single_step ? \
-   (*the_target->supports_hardware_single_step) () : 0)
+  the_target->pt->supports_hardware_single_step ()
 
 #define target_stopped_by_hw_breakpoint() \
   the_target->pt->stopped_by_hw_breakpoint ()
@@ -720,8 +719,6 @@ int set_desired_thread ();
 
 const char *target_pid_to_str (ptid_t);
 
-int target_can_do_hardware_single_step (void);
-
 int default_breakpoint_kind_from_pc (CORE_ADDR *pcptr);
 
 #endif /* GDBSERVER_TARGET_H */
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 7edad620050..2862a9c241c 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1728,6 +1728,12 @@ win32_process_target::request_interrupt ()
   soft_interrupt_requested = 1;
 }
 
+bool
+win32_process_target::supports_hardware_single_step ()
+{
+  return true;
+}
+
 #ifdef _WIN32_WCE
 int
 win32_error_to_fileio_error (DWORD err)
@@ -1838,7 +1844,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  target_can_do_hardware_single_step,
   win32_stopped_by_watchpoint,
   win32_stopped_data_address,
   NULL, /* read_offsets */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index a6b27918f4c..c5f9a13e029 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -146,6 +146,8 @@ public:
 
   int remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
 		    int size, raw_breakpoint *bp) override;
+
+  bool supports_hardware_single_step () override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 30/58] gdbserver: turn target op 'supports_multi_process' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (14 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 04/58] gdbserver: turn target op 'attach' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 01/58] gdbserver: start turning the target ops vector into a class Tankut Baris Aktemur
                   ` (43 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_multi_process op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	* target.cc (process_target::supports_multi_process): Define.
	(target_supports_multi_process): Update.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_multi_process): Turn into ...
	(linux_process_target::supports_multi_process): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 7 +++----
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 9 +++++++--
 gdbserver/target.h     | 6 +++---
 gdbserver/win32-low.cc | 1 -
 7 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 192989a9a4e..770cf472840 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6334,10 +6334,10 @@ linux_process_target::start_non_stop (bool nonstop)
   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.  */
@@ -7425,7 +7425,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_multi_process,
   linux_supports_fork_events,
   linux_supports_vfork_events,
   linux_supports_exec_events,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index c5982ca3e5b..58730e2c0a3 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -363,6 +363,8 @@ public:
   bool async (bool enable) override;
 
   int start_non_stop (bool enable) override;
+
+  bool supports_multi_process () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 15811d2034a..897bc9e663f 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_multi_process */
   NULL,  /* supports_fork_events */
   NULL,  /* supports_vfork_events */
   NULL,  /* supports_exec_events */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index bb0b14aa951..11b290a20a3 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* supports_multi_process */
   NULL, /* supports_fork_events */
   NULL, /* supports_vfork_events */
   NULL, /* supports_exec_events */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 33e31a748ef..485eecbee91 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -260,8 +260,7 @@ target_continue (ptid_t ptid, enum gdb_signal signal)
 int
 target_supports_multi_process (void)
 {
-  return (the_target->supports_multi_process != NULL ?
-	  (*the_target->supports_multi_process) () : 0);
+  return the_target->pt->supports_multi_process ();
 }
 
 void
@@ -548,3 +547,9 @@ process_target::start_non_stop (bool enable)
   else
     return 0;
 }
+
+bool
+process_target::supports_multi_process ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index d3ee4452b63..52c80b848d0 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns true if the target supports multi-process debugging.  */
-  int (*supports_multi_process) (void);
-
   /* Returns true if fork events are supported.  */
   int (*supports_fork_events) (void);
 
@@ -486,6 +483,9 @@ public:
   /* Switch to non-stop (ENABLE == true) or all-stop (ENABLE == false)
      mode.  Return 0 on success, -1 otherwise.  */
   virtual int start_non_stop (bool enable);
+
+  /* Returns true if the target supports multi-process debugging.  */
+  virtual bool supports_multi_process ();
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 60a7f475f84..ee7a0ea92a6 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_multi_process */
   NULL, /* supports_fork_events */
   NULL, /* supports_vfork_events */
   NULL, /* supports_exec_events */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 32/58] gdbserver: turn target op 'handle_new_gdb_connection' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (40 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 25/58] gdbserver: turn target op 'get_tls_address' into a method Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 52/58] gdbserver: turn breakpoint kind-related target ops into methods Tankut Baris Aktemur
                   ` (17 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's handle_new_gdb_connection op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_handle_new_gdb_connection): Update the macro.
	* target.cc (process_target::handle_new_gdb_connection): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_handle_new_gdb_connection): Turn into ...
	(linux_process_target::handle_new_gdb_connection): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     | 12 ++++--------
 gdbserver/win32-low.cc |  1 -
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 7c96b45ff16..623499190d4 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6368,8 +6368,8 @@ linux_process_target::supports_exec_events ()
    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)
@@ -7425,7 +7425,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_handle_new_gdb_connection,
 #ifdef USE_THREAD_DB
   thread_db_handle_monitor_command,
 #else
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index f78ef78ad6f..aa3baf3327f 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -371,6 +371,8 @@ public:
   bool supports_vfork_events () override;
 
   bool supports_exec_events () override;
+
+  void handle_new_gdb_connection () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 088582b2609..f19713981bc 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* handle_new_gdb_connection */
   NULL,  /* handle_monitor_command */
   NULL,  /* core_of_thread */
   NULL,  /* read_loadmap */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 0d1432b8bac..3cb0f638f20 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* handle_new_gdb_connection */
   NULL, /* handle_monitor_command */
   NULL, /* core_of_thread */
   NULL, /* read_loadmap */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 15d48427f31..3416a3f449f 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -571,3 +571,9 @@ process_target::supports_exec_events ()
 {
   return false;
 }
+
+void
+process_target::handle_new_gdb_connection ()
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index ef2fd018463..b6150631674 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Allows target to re-initialize connection-specific settings.  */
-  void (*handle_new_gdb_connection) (void);
-
   /* If not NULL, target-specific routine to process monitor command.
      Returns 1 if handled, or 0 to perform default processing.  */
   int (*handle_monitor_command) (char *);
@@ -486,6 +483,9 @@ public:
 
   /* Returns true if exec events are supported.  */
   virtual bool supports_exec_events ();
+
+  /* Allows target to re-initialize connection-specific settings.  */
+  virtual void handle_new_gdb_connection ();
 };
 
 extern process_stratum_target *the_target;
@@ -513,11 +513,7 @@ int kill_inferior (process_info *proc);
   the_target->pt->supports_exec_events ()
 
 #define target_handle_new_gdb_connection()		 \
-  do							 \
-    {							 \
-      if (the_target->handle_new_gdb_connection != NULL) \
-	(*the_target->handle_new_gdb_connection) ();	 \
-    } while (0)
+  the_target->pt->handle_new_gdb_connection ()
 
 #define detach_inferior(proc) \
   the_target->pt->detach (proc)
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 4cea682ee52..024479d1540 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* handle_new_gdb_connection */
   NULL, /* handle_monitor_command */
   NULL, /* core_of_thread */
   NULL, /* read_loadmap */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 33/58] gdbserver: turn target op 'handle_monitor_command' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (37 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 26/58] gdbserver: turn target op 'hostio_last_error' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 19/58] gdbserver: turn target ops 'insert_point' and 'remove_point' into methods Tankut Baris Aktemur
                   ` (20 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's handle_monitor_command op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_handle_monitor_command): Update the macro.
	* target.cc (process_target::handle_monitor_command): Define.

	Update the derived classes and callers below.

	* server.cc (handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::handle_monitor_command): Define.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 15 ++++++++++-----
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  3 +--
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     |  8 ++++----
 gdbserver/win32-low.cc |  1 -
 8 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 623499190d4..5fb38819e61 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6394,6 +6394,16 @@ linux_process_target::handle_new_gdb_connection ()
     });
 }
 
+int
+linux_process_target::handle_monitor_command (char *mon)
+{
+#ifdef USE_THREAD_DB
+  return thread_db_handle_monitor_command (mon);
+#else
+  return 0;
+#endif
+}
+
 static int
 linux_supports_disable_randomization (void)
 {
@@ -7425,11 +7435,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-#ifdef USE_THREAD_DB
-  thread_db_handle_monitor_command,
-#else
-  NULL,
-#endif
   linux_common_core_of_thread,
   linux_read_loadmap,
   linux_process_qsupported,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index aa3baf3327f..d3157220730 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -373,6 +373,8 @@ public:
   bool supports_exec_events () override;
 
   void handle_new_gdb_connection () override;
+
+  int handle_monitor_command (char *mon) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index f19713981bc..d489886755e 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* handle_monitor_command */
   NULL,  /* core_of_thread */
   NULL,  /* read_loadmap */
   NULL,  /* process_qsupported */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 3cb0f638f20..9cd30da32e6 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* handle_monitor_command */
   NULL, /* core_of_thread */
   NULL, /* read_loadmap */
   NULL, /* process_qsupported */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index f427e7706fb..f9817881d77 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2577,8 +2577,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 
       write_ok (own_buf);
 
-      if (the_target->handle_monitor_command == NULL
-	  || (*the_target->handle_monitor_command) (mon) == 0)
+      if (the_target->pt->handle_monitor_command (mon) == 0)
 	/* Default processing.  */
 	handle_monitor_command (mon, own_buf);
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 3416a3f449f..74cd90a48a4 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -577,3 +577,9 @@ process_target::handle_new_gdb_connection ()
 {
   /* Nop.  */
 }
+
+int
+process_target::handle_monitor_command (char *mon)
+{
+  return 0;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index b6150631674..b607ca62540 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* If not NULL, target-specific routine to process monitor command.
-     Returns 1 if handled, or 0 to perform default processing.  */
-  int (*handle_monitor_command) (char *);
-
   /* Returns the core given a thread, or -1 if not known.  */
   int (*core_of_thread) (ptid_t);
 
@@ -486,6 +482,10 @@ public:
 
   /* Allows target to re-initialize connection-specific settings.  */
   virtual void handle_new_gdb_connection ();
+
+  /* The target-specific routine to process monitor command.
+     Returns 1 if handled, or 0 to perform default processing.  */
+  virtual int handle_monitor_command (char *mon);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 024479d1540..fcb3906197d 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* handle_monitor_command */
   NULL, /* core_of_thread */
   NULL, /* read_loadmap */
   NULL, /* process_qsupported */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 55/58] gdbserver: turn target op 'supports_catch_syscall' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (44 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 54/58] gdbserver: turn target op 'supports_software_single_step' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 29/58] gdbserver: turn non-stop and async target ops into methods Tankut Baris Aktemur
                   ` (13 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_catch_syscall op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_supports_catch_syscall): Update the macro.
	* target.cc (process_target::supports_catch_syscall): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_catch_syscall): Turn into ...
	(linux_process_target::supports_catch_syscall): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     | 10 ++++------
 gdbserver/win32-low.cc |  1 -
 7 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 19ab8fd1eab..559f7519a7d 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6564,8 +6564,8 @@ 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 ());
@@ -7520,7 +7520,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_catch_syscall,
   linux_get_ipa_tdesc_idx,
   &the_linux_target,
 };
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 1595926eae5..349f4b7e1eb 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -477,6 +477,8 @@ public:
 #endif
 
   bool supports_software_single_step () override;
+
+  bool supports_catch_syscall () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 399ccaefad7..76519692a3e 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -741,7 +741,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_catch_syscall */
   NULL,  /* get_ipa_tdesc_idx */
   &the_lynx_target,
 };
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index a50213583b2..2ee84420169 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
   &the_nto_target,
 };
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index b1a28e68cc0..2ea8234be08 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -820,3 +820,9 @@ process_target::supports_software_single_step ()
 {
   return false;
 }
+
+bool
+process_target::supports_catch_syscall ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 26ce137bf55..21b6bace681 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return 1 if the target supports catch syscall, 0 (or leave the
-     callback NULL) otherwise.  */
-  int (*supports_catch_syscall) (void);
-
   /* Return tdesc index for IPA.  */
   int (*get_ipa_tdesc_idx) (void);
 
@@ -505,6 +501,9 @@ public:
 
   /* Returns true if the target can software single step.  */
   virtual bool supports_software_single_step ();
+
+  /* Return true if the target supports catch syscall.  */
+  virtual bool supports_catch_syscall ();
 };
 
 extern process_stratum_target *the_target;
@@ -559,8 +558,7 @@ int kill_inferior (process_info *proc);
   the_target->pt->process_qsupported (features, count)
 
 #define target_supports_catch_syscall()              	\
-  (the_target->supports_catch_syscall ?			\
-   (*the_target->supports_catch_syscall) () : 0)
+  the_target->pt->supports_catch_syscall ()
 
 #define target_get_ipa_tdesc_idx()			\
   (the_target->get_ipa_tdesc_idx			\
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index b218ff5f3fe..132d33441bf 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
   &the_win32_target,
 };
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 54/58] gdbserver: turn target op 'supports_software_single_step' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (43 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 22/58] gdbserver: turn target op 'supports_hardware_single_step' into a method Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 55/58] gdbserver: turn target op 'supports_catch_syscall' " Tankut Baris Aktemur
                   ` (14 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_software_single_step op
	into a method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_supports_software_single_step): Update the macro.
	* target.cc (process_target::supports_software_single_step): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_software_single_step): Turn into ...
	(linux_process_target::supports_software_single_step): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 5 ++---
 gdbserver/linux-low.h  | 2 ++
 gdbserver/lynx-low.cc  | 1 -
 gdbserver/nto-low.cc   | 1 -
 gdbserver/target.cc    | 6 ++++++
 gdbserver/target.h     | 9 ++++-----
 gdbserver/win32-low.cc | 1 -
 7 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index cd079562d47..19ab8fd1eab 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6036,8 +6036,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 ();
 }
@@ -7520,7 +7520,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_software_single_step,
   linux_supports_catch_syscall,
   linux_get_ipa_tdesc_idx,
   &the_linux_target,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 2acd65f2828..1595926eae5 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -475,6 +475,8 @@ public:
   bool thread_handle (ptid_t ptid, gdb_byte **handle,
 		      int *handle_len) override;
 #endif
+
+  bool supports_software_single_step () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 0c460be5f31..399ccaefad7 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -741,7 +741,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_software_single_step */
   NULL,  /* supports_catch_syscall */
   NULL,  /* get_ipa_tdesc_idx */
   &the_lynx_target,
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 4c3c5a3a42d..a50213583b2 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
   &the_nto_target,
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index b7ed26b22f4..b1a28e68cc0 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -814,3 +814,9 @@ process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
 {
   return false;
 }
+
+bool
+process_target::supports_software_single_step ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 4d9de5513aa..26ce137bf55 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns true if the target can software single step.  */
-  int (*supports_software_single_step) (void);
-
   /* Return 1 if the target supports catch syscall, 0 (or leave the
      callback NULL) otherwise.  */
   int (*supports_catch_syscall) (void);
@@ -505,6 +502,9 @@ public:
      and the handle's length via HANDLE_LEN.  */
   virtual bool thread_handle (ptid_t ptid, gdb_byte **handle,
 			      int *handle_len);
+
+  /* Returns true if the target can software single step.  */
+  virtual bool supports_software_single_step ();
 };
 
 extern process_stratum_target *the_target;
@@ -669,8 +669,7 @@ target_read_btrace_conf (struct btrace_target_info *tinfo,
   the_target->pt->breakpoint_kind_from_current_state (pcptr)
 
 #define target_supports_software_single_step() \
-  (the_target->supports_software_single_step ? \
-   (*the_target->supports_software_single_step) () : 0)
+  the_target->pt->supports_software_single_step ()
 
 ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
 	       int connected_wait);
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 218f007bdec..b218ff5f3fe 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_software_single_step */
   NULL, /* supports_catch_syscall */
   NULL, /* get_ipa_tdesc_idx */
   &the_win32_target,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 25/58] gdbserver: turn target op 'get_tls_address' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (39 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 19/58] gdbserver: turn target ops 'insert_point' and 'remove_point' into methods Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 32/58] gdbserver: turn target op 'handle_new_gdb_connection' " Tankut Baris Aktemur
                   ` (18 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's get_tls_address op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_get_tls_address'.
	* target.cc (process_target::get_tls_address): Define.
	(process_target::supports_get_tls_address): Define.

	Update the derived classes and callers below.

	* server.cc (handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_get_tls_address): Define.
	(linux_process_target::get_tls_address): Define.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 28 +++++++++++++++++++++++-----
 gdbserver/linux-low.h  |  5 +++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.cc    | 13 +++++++++++++
 gdbserver/target.h     | 20 +++++++++++---------
 gdbserver/win32-low.cc |  1 -
 8 files changed, 55 insertions(+), 20 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index a90f509874f..42bfcde6203 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6119,6 +6119,29 @@ linux_process_target::read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
 #endif
 }
 
+bool
+linux_process_target::supports_get_tls_address ()
+{
+#ifdef USE_THREAD_DB
+  return true;
+#else
+  return false;
+#endif
+}
+
+int
+linux_process_target::get_tls_address (thread_info *thread,
+				       CORE_ADDR offset,
+				       CORE_ADDR load_module,
+				       CORE_ADDR *address)
+{
+#ifdef USE_THREAD_DB
+  return thread_db_get_tls_address (thread, offset, load_module, address);
+#else
+  return -1;
+#endif
+}
+
 static int
 linux_qxfer_osdata (const char *annex,
 		    unsigned char *readbuf, unsigned const char *writebuf,
@@ -7388,11 +7411,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-#ifdef USE_THREAD_DB
-  thread_db_get_tls_address,
-#else
-  NULL,
-#endif
   hostio_last_error_from_errno,
   linux_qxfer_osdata,
   linux_xfer_siginfo,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index f2e2dfd98e2..3c2fdaf8fc3 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -340,6 +340,11 @@ public:
   bool supports_read_offsets () override;
 
   int read_offsets (CORE_ADDR *text, CORE_ADDR *data) override;
+
+  bool supports_get_tls_address () override;
+
+  int get_tls_address (thread_info *thread, CORE_ADDR offset,
+		       CORE_ADDR load_module, CORE_ADDR *address) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 44c57a5ca71..f0d0d4456c4 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* get_tls_address */
   NULL,  /* hostio_last_error */
   NULL,  /* qxfer_osdata */
   NULL,  /* qxfer_siginfo */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 040fa93859f..b9e7ed06337 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -956,7 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* thread_db_set_tls_address */
   hostio_last_error_from_errno,
   NULL, /* nto_qxfer_osdata */
   NULL, /* xfer_siginfo */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index b4fd9c6a5e5..01d41af0f89 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2467,7 +2467,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
     }
 
   /* Thread-local storage support.  */
-  if (the_target->get_tls_address != NULL
+  if (the_target->pt->supports_get_tls_address ()
       && startswith (own_buf, "qGetTLSAddr:"))
     {
       char *p = own_buf + 12;
@@ -2513,8 +2513,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 	  if (thread == NULL)
 	    err = 2;
 	  else
-	    err = the_target->get_tls_address (thread, parts[0], parts[1],
-					       &address);
+	    err = the_target->pt->get_tls_address (thread, parts[0], parts[1],
+						   &address);
 	}
 
       if (err == 0)
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 501a8d675db..f578dbea0da 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -493,3 +493,16 @@ process_target::read_offsets (CORE_ADDR *text, CORE_ADDR *data)
 {
   gdb_assert_not_reached ("target op read_offsets not supported");
 }
+
+bool
+process_target::supports_get_tls_address ()
+{
+  return false;
+}
+
+int
+process_target::get_tls_address (thread_info *thread, CORE_ADDR offset,
+				 CORE_ADDR load_module, CORE_ADDR *address)
+{
+  gdb_assert_not_reached ("target op get_tls_address not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 5cf039e5f70..2c818b3fb12 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,15 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Fetch the address associated with a specific thread local storage
-     area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
-     Stores it in *ADDRESS and returns zero on success; otherwise returns
-     an error code.  A return value of -1 means this system does not
-     support the operation.  */
-
-  int (*get_tls_address) (struct thread_info *thread, CORE_ADDR offset,
-			  CORE_ADDR load_module, CORE_ADDR *address);
-
   /* Fill BUF with an hostio error packet representing the last hostio
      error.  */
   void (*hostio_last_error) (char *buf);
@@ -477,6 +468,17 @@ public:
      needed for uclinux where the executable is relocated during load
      time.  */
   virtual int read_offsets (CORE_ADDR *text, CORE_ADDR *data);
+
+  /* Return true if the get_tls_address target op is supported.  */
+  virtual bool supports_get_tls_address ();
+
+  /* Fetch the address associated with a specific thread local storage
+     area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
+     Stores it in *ADDRESS and returns zero on success; otherwise returns
+     an error code.  A return value of -1 means this system does not
+     support the operation.  */
+  virtual int get_tls_address (thread_info *thread, CORE_ADDR offset,
+			       CORE_ADDR load_module, CORE_ADDR *address);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 875736a5eec..84223e129bf 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1844,7 +1844,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* get_tls_address */
 #ifdef _WIN32_WCE
   wince_hostio_last_error,
 #else
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 18/58] gdbserver: turn target op 'supports_z_point_type' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (47 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 38/58] gdbserver: turn target ops 'read_pc' and 'write_pc' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 49/58] gdbserver: turn target op 'supports_range_stepping' " Tankut Baris Aktemur
                   ` (10 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_z_point_type op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	* target.cc (process_target::supports_z_point_type): Define.

	Update the derived classes and callers below.

	* mem-break.cc (z_type_supported): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_z_point_type): Turn into ...
	(linux_process_target::supports_z_point_type): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	(nto_supports_z_point_type): Turn into ...
	(nto_process_target::supports_z_point_type): ... this.
	* nto-low.h (class nto_process_target): Update.
	* win32-low.cc (win32_target_ops): Update.
	(win32_supports_z_point_type): Turn into ...
	(win32_process_target::supports_z_point_type): ... this.
	* win32-low.h (class win32_process_target): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/mem-break.cc |  3 +--
 gdbserver/nto-low.cc   |  9 ++++-----
 gdbserver/nto-low.h    |  2 ++
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     | 20 ++++++++++----------
 gdbserver/win32-low.cc |  5 ++---
 gdbserver/win32-low.h  |  2 ++
 10 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 47ac768d929..37e46a8ca22 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5957,8 +5957,8 @@ linux_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
    pass on the function call if the target has registered a
    corresponding function.  */
 
-static int
-linux_supports_z_point_type (char z_type)
+bool
+linux_process_target::supports_z_point_type (char z_type)
 {
   return (the_low_target.supports_z_point_type != NULL
 	  && the_low_target.supports_z_point_type (z_type));
@@ -7376,7 +7376,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_supports_z_point_type,
   linux_insert_point,
   linux_remove_point,
   linux_stopped_by_sw_breakpoint,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 0130c22ce27..052beb6c44c 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -314,6 +314,8 @@ public:
 
   int read_auxv (CORE_ADDR offset, unsigned char *myaddr,
 		 unsigned int len) override;
+
+  bool supports_z_point_type (char z_type) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index bf73e81993e..dd4584797c4 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -729,7 +729,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_z_point_type */
   NULL,  /* insert_point */
   NULL,  /* remove_point */
   NULL,  /* stopped_by_sw_breakpoint */
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index 43a07c390d1..b00e9fca353 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -1005,8 +1005,7 @@ static int
 z_type_supported (char z_type)
 {
   return (z_type >= '0' && z_type <= '4'
-	  && the_target->supports_z_point_type != NULL
-	  && the_target->supports_z_point_type (z_type));
+	  && the_target->pt->supports_z_point_type (z_type));
 }
 
 /* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index d828fa7a607..204d8066455 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -789,8 +789,8 @@ nto_process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
   return nto_read_auxv_from_initial_stack (initial_stack, myaddr, len);
 }
 
-static int
-nto_supports_z_point_type (char z_type)
+bool
+nto_process_target::supports_z_point_type (char z_type)
 {
   switch (z_type)
     {
@@ -799,9 +799,9 @@ nto_supports_z_point_type (char z_type)
     case Z_PACKET_WRITE_WP:
     case Z_PACKET_READ_WP:
     case Z_PACKET_ACCESS_WP:
-      return 1;
+      return true;
     default:
-      return 0;
+      return false;
     }
 }
 
@@ -950,7 +950,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  nto_supports_z_point_type,
   nto_insert_point,
   nto_remove_point,
   NULL, /* stopped_by_sw_breakpoint */
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index e135dd3b68a..65bbf7e818c 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -84,6 +84,8 @@ public:
 
   int read_auxv (CORE_ADDR offset, unsigned char *myaddr,
 		 unsigned int len) override;
+
+  bool supports_z_point_type (char z_type) override;
 };
 
 /* The inferior's target description.  This is a global because the
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 97e9d4ac507..22339622e09 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -427,3 +427,9 @@ process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
 {
   gdb_assert_not_reached ("target op read_auxv not supported");
 }
+
+bool
+process_target::supports_z_point_type (char z_type)
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index cd11da670ca..3262371749e 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,16 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns true if GDB Z breakpoint type TYPE is supported, false
-     otherwise.  The type is coded as follows:
-       '0' - software-breakpoint
-       '1' - hardware-breakpoint
-       '2' - write watchpoint
-       '3' - read watchpoint
-       '4' - access watchpoint
-  */
-  int (*supports_z_point_type) (char z_type);
-
   /* Insert and remove a break or watchpoint.
      Returns 0 on success, -1 on failure and 1 on unsupported.  */
 
@@ -476,6 +466,16 @@ public:
      Read LEN bytes at OFFSET into a buffer at MYADDR.  */
   virtual int read_auxv (CORE_ADDR offset, unsigned char *myaddr,
 			 unsigned int len);
+
+  /* Returns true if GDB Z breakpoint type TYPE is supported, false
+     otherwise.  The type is coded as follows:
+       '0' - software-breakpoint
+       '1' - hardware-breakpoint
+       '2' - write watchpoint
+       '3' - read watchpoint
+       '4' - access watchpoint
+  */
+  virtual bool supports_z_point_type (char z_type);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 2d617d889ec..024748e9282 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -254,8 +254,8 @@ child_delete_thread (DWORD pid, DWORD tid)
 /* These watchpoint related wrapper functions simply pass on the function call
    if the low target has registered a corresponding function.  */
 
-static int
-win32_supports_z_point_type (char z_type)
+bool
+win32_process_target::supports_z_point_type (char z_type)
 {
   return (the_low_target.supports_z_point_type != NULL
 	  && the_low_target.supports_z_point_type (z_type));
@@ -1838,7 +1838,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  win32_supports_z_point_type,
   win32_insert_point,
   win32_remove_point,
   NULL, /* stopped_by_sw_breakpoint */
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 2cb38a14195..a095ed80ffe 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -138,6 +138,8 @@ public:
 		    int len) override;
 
   void request_interrupt () override;
+
+  bool supports_z_point_type (char z_type) override;
 };
 
 /* Retrieve the context for this thread, if not already retrieved.  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 42/58] gdbserver: turn target op 'stabilize_threads' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (12 preceding siblings ...)
  2020-02-17 16:59 ` [PATCH v2 16/58] gdbserver: turn target op 'request_interrupt' " Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-17 17:01 ` [PATCH v2 04/58] gdbserver: turn target op 'attach' " Tankut Baris Aktemur
                   ` (45 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's stabilize_threads op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_stabilize_threads): Update the macro.
	* target.cc (process_target::stabilize_threads): Define.

	Update the derived classes and callers below.

	* server.cc (handle_status): Update.
	* tracepoint.cc (cmd_qtdp): Update.
	(cmd_qtstart): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_stabilize_threads): Turn into ...
	(linux_process_target::stabilize_threads): ... this.
	(linux_wait_1): Update.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc  |  9 ++++-----
 gdbserver/linux-low.h   |  2 ++
 gdbserver/lynx-low.cc   |  1 -
 gdbserver/nto-low.cc    |  1 -
 gdbserver/server.cc     |  2 +-
 gdbserver/target.cc     |  6 ++++++
 gdbserver/target.h      | 14 +++++---------
 gdbserver/tracepoint.cc |  4 ++--
 gdbserver/win32-low.cc  |  1 -
 9 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 97a8aa46f5a..aa255cb0f47 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1620,7 +1620,7 @@ linux_process_target::detach (process_info *process)
 #endif
 
   /* Stabilize threads (move out of jump pads).  */
-  stabilize_threads ();
+  target_stabilize_threads ();
 
   /* Detach from the clone lwps first.  If the thread group exits just
      while we're detaching, we must reap the clone lwps before we're
@@ -2926,8 +2926,8 @@ static ptid_t linux_wait_1 (ptid_t ptid,
    since for something else in the new run, the thread would now
    execute the wrong / random instructions.  */
 
-static void
-linux_stabilize_threads (void)
+void
+linux_process_target::stabilize_threads ()
 {
   thread_info *thread_stuck = find_thread (stuck_in_jump_pad_callback);
 
@@ -3713,7 +3713,7 @@ linux_wait_1 (ptid_t ptid,
 
       /* Stabilize threads (move out of jump pads).  */
       if (!non_stop)
-	stabilize_threads ();
+	target_stabilize_threads ();
     }
   else
     {
@@ -7451,7 +7451,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_stabilize_threads,
   linux_install_fast_tracepoint_jump_pad,
   linux_emit_ops,
   linux_supports_disable_randomization,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index e5d54c5e08d..d3866de03a2 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -400,6 +400,8 @@ public:
   void pause_all (bool freeze) override;
 
   void unpause_all (bool unfreeze) override;
+
+  void stabilize_threads () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 92c086d97c3..5ea50b4415d 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* stabilize_threads */
   NULL,  /* install_fast_tracepoint_jump_pad */
   NULL,  /* emit_ops */
   NULL,  /* supports_disable_randomization */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index ee411a1e375..ef7a70ad97a 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* stabilize_threads */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* supports_disable_randomization */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 670c0fed968..448089fd47c 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3324,7 +3324,7 @@ handle_status (char *own_buf)
       thread_info *thread = NULL;
 
       target_pause_all (false);
-      stabilize_threads ();
+      target_stabilize_threads ();
       gdb_wants_all_threads_stopped ();
 
       /* We can only report one status, but we might be coming out of
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 912f4b8bdad..42f22846d02 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -662,3 +662,9 @@ process_target::unpause_all (bool unfreeze)
 {
   /* Nop.  */
 }
+
+void
+process_target::stabilize_threads ()
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 60fb14f69e6..c56267fb1f8 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,9 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Stabilize all threads.  That is, force them out of jump pads.  */
-  void (*stabilize_threads) (void);
-
   /* Install a fast tracepoint jump pad.  TPOINT is the address of the
      tracepoint internal object as used by the IPA agent.  TPADDR is
      the address of tracepoint.  COLLECTOR is address of the function
@@ -494,6 +491,9 @@ public:
      pair should not end up resuming threads that were stopped before
      the pause call.  */
   virtual void unpause_all (bool unfreeze);
+
+  /* Stabilize all threads.  That is, force them out of jump pads.  */
+  virtual void stabilize_threads ();
 };
 
 extern process_stratum_target *the_target;
@@ -574,12 +574,8 @@ int kill_inferior (process_info *proc);
 #define target_unpause_all(unfreeze)		\
   the_target->pt->unpause_all (unfreeze)
 
-#define stabilize_threads()			\
-  do						\
-    {						\
-      if (the_target->stabilize_threads)     	\
-	(*the_target->stabilize_threads) ();  	\
-    } while (0)
+#define target_stabilize_threads()		\
+  the_target->pt->stabilize_threads ()
 
 #define install_fast_tracepoint_jump_pad(tpoint, tpaddr,		\
 					 collector, lockaddr,		\
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index ffa819cf24e..be40c9b4cf1 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2606,7 +2606,7 @@ cmd_qtdp (char *own_buf)
 
       /* download_tracepoint will update global `tracepoints'
 	 list, so it is unsafe to leave threads in jump pad.  */
-      stabilize_threads ();
+      target_stabilize_threads ();
 
       /* Freeze threads.  */
       target_pause_all (true);
@@ -3226,7 +3226,7 @@ cmd_qtstart (char *packet)
      top level command.  And, required to do here, since we're
      deleting/rewriting jump pads.  */
 
-  stabilize_threads ();
+  target_stabilize_threads ();
 
   /* Freeze threads.  */
   target_pause_all (true);
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index a06cea22fc8..8e0be15fdaf 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* stabilize_threads */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
   NULL, /* supports_disable_randomization */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 24/58] gdbserver: turn target op 'read_offsets' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (16 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 01/58] gdbserver: start turning the target ops vector into a class Tankut Baris Aktemur
@ 2020-02-17 17:01 ` Tankut Baris Aktemur
  2020-02-19 14:09   ` Pedro Alves
  2020-02-17 17:01 ` [PATCH v2 43/58] gdbserver: turn fast tracepoint target ops into methods Tankut Baris Aktemur
                   ` (41 subsequent siblings)
  59 siblings, 1 reply; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's read_offsets op into a method of
	process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_read_offsets'.
	* target.cc (process_target::read_offsets): Define.
	(process_target::supports_read_offsets): Define.

	Update the derived classes and callers below.

	* server.cc (handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_read_offsets): Define.
	(linux_read_offsets): Turn into ...
	(linux_process_target::read_offsets): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 36 +++++++++++++++++++++---------------
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  4 ++--
 gdbserver/target.cc    | 12 ++++++++++++
 gdbserver/target.h     | 14 ++++++++------
 gdbserver/win32-low.cc |  1 -
 8 files changed, 47 insertions(+), 26 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 5a5c6372823..a90f509874f 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6059,21 +6059,32 @@ linux_process_target::stopped_data_address ()
   return lwp->stopped_data_address;
 }
 
-#if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
-    && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
-    && defined(PT_TEXT_END_ADDR)
-
 /* This is only used for targets that define PT_TEXT_ADDR,
    PT_DATA_ADDR and PT_TEXT_END_ADDR.  If those are not defined, supposedly
    the target has different ways of acquiring this information, like
    loadmaps.  */
 
+bool
+linux_process_target::supports_read_offsets ()
+{
+#if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
+    && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
+    && defined(PT_TEXT_END_ADDR)
+  return true;
+#else
+  return false;
+#endif
+}
+
 /* Under uClinux, programs are loaded at non-zero offsets, which we need
    to tell gdb about.  */
 
-static int
-linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
+int
+linux_process_target::read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
 {
+#if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
+    && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
+    && defined(PT_TEXT_END_ADDR)
   unsigned long text, text_end, data;
   int pid = lwpid_of (current_thread);
 
@@ -6102,9 +6113,11 @@ linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
 
       return 1;
     }
- return 0;
-}
+  return 0;
+#else
+  gdb_assert_not_reached ("target op read_offsets not supported");
 #endif
+}
 
 static int
 linux_qxfer_osdata (const char *annex,
@@ -7375,13 +7388,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-#if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
-    && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
-    && defined(PT_TEXT_END_ADDR)
-  linux_read_offsets,
-#else
-  NULL,
-#endif
 #ifdef USE_THREAD_DB
   thread_db_get_tls_address,
 #else
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index af2a0c6671e..f2e2dfd98e2 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -336,6 +336,10 @@ public:
   bool stopped_by_watchpoint () override;
 
   CORE_ADDR stopped_data_address () override;
+
+  bool supports_read_offsets () override;
+
+  int read_offsets (CORE_ADDR *text, CORE_ADDR *data) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index e9dfccede05..44c57a5ca71 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* read_offsets */
   NULL,  /* get_tls_address */
   NULL,  /* hostio_last_error */
   NULL,  /* qxfer_osdata */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 53020a25e73..040fa93859f 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -956,7 +956,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* nto_read_offsets */
   NULL, /* thread_db_set_tls_address */
   hostio_last_error_from_errno,
   NULL, /* nto_qxfer_osdata */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index f13061c871b..b4fd9c6a5e5 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2234,13 +2234,13 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 	}
     }
 
-  if (the_target->read_offsets != NULL
+  if (the_target->pt->supports_read_offsets ()
       && strcmp ("qOffsets", own_buf) == 0)
     {
       CORE_ADDR text, data;
 
       require_running_or_return (own_buf);
-      if (the_target->read_offsets (&text, &data))
+      if (the_target->pt->read_offsets (&text, &data))
 	sprintf (own_buf, "Text=%lX;Data=%lX;Bss=%lX",
 		 (long)text, (long)data, (long)data);
       else
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 00f5f794b85..501a8d675db 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -481,3 +481,15 @@ process_target::stopped_data_address ()
 {
   return 0;
 }
+
+bool
+process_target::supports_read_offsets ()
+{
+  return false;
+}
+
+int
+process_target::read_offsets (CORE_ADDR *text, CORE_ADDR *data)
+{
+  gdb_assert_not_reached ("target op read_offsets not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 83595fad520..5cf039e5f70 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,12 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Reports the text, data offsets of the executable.  This is
-     needed for uclinux where the executable is relocated during load
-     time.  */
-
-  int (*read_offsets) (CORE_ADDR *text, CORE_ADDR *data);
-
   /* Fetch the address associated with a specific thread local storage
      area, determined by the specified THREAD, OFFSET, and LOAD_MODULE.
      Stores it in *ADDRESS and returns zero on success; otherwise returns
@@ -475,6 +469,14 @@ public:
   /* Returns the address associated with the watchpoint that hit, if any;
      returns 0 otherwise.  */
   virtual CORE_ADDR stopped_data_address ();
+
+  /* Return true if the read_offsets target op is supported.  */
+  virtual bool supports_read_offsets ();
+
+  /* Reports the text, data offsets of the executable.  This is
+     needed for uclinux where the executable is relocated during load
+     time.  */
+  virtual int read_offsets (CORE_ADDR *text, CORE_ADDR *data);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index ff62bcefb0d..875736a5eec 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1844,7 +1844,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* read_offsets */
   NULL, /* get_tls_address */
 #ifdef _WIN32_WCE
   wince_hostio_last_error,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 48/58] gdbserver: turn btrace-related target ops into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (50 preceding siblings ...)
  2020-02-17 17:04 ` [PATCH v2 50/58] gdbserver: turn target op 'pid_to_exec_file' " Tankut Baris Aktemur
@ 2020-02-17 17:04 ` Tankut Baris Aktemur
  2020-02-17 17:04 ` [PATCH v2 58/58] gdbserver: finish turning the target ops vector into a class Tankut Baris Aktemur
                   ` (7 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's btrace-related ops (enable_btrace,
	disable_btrace, read_btrace, read_btrace_conf) into methods of
	process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(target_enable_btrace): Update.
	(target_disable_btrace): Update.
	(target_read_btrace): Update.
	(target_read_btrace_conf): Update.
	* target.cc (process_target::enable_btrace): Define.
	(process_target::disable_btrace): Define.
	(process_target::read_btrace): Define.
	(process_target::read_btrace_conf): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target:enable_btrace): Define as a wrapper around
	linux_enable_btrace.
	(linux_low_disable_btrace): Turn into ...
	(linux_process_target::disable_btrace): ... this.
	(linux_low_read_btrace): Turn into ...
	(linux_process_target::read_btrace): ... this.
	(linux_low_btrace_conf): Turn into ...
	(linux_process_target::read_btrace_conf): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 35 +++++++++++-------------
 gdbserver/linux-low.h  | 13 +++++++++
 gdbserver/lynx-low.cc  |  4 ---
 gdbserver/nto-low.cc   |  4 ---
 gdbserver/target.cc    | 27 +++++++++++++++++++
 gdbserver/target.h     | 61 +++++++++++++++++-------------------------
 gdbserver/win32-low.cc |  4 ---
 7 files changed, 81 insertions(+), 67 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 9ba2927eef4..1af37044a8e 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -7149,10 +7149,17 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex,
 
 #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;
 
@@ -7211,9 +7218,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;
@@ -7270,9 +7278,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;
 
@@ -7459,17 +7467,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-#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,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 0f0f3e0b869..8c33dccc678 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -433,6 +433,19 @@ public:
 			    CORE_ADDR offset, int len) override;
 
   bool supports_agent () override;
+
+#ifdef HAVE_LINUX_BTRACE
+  btrace_target_info *enable_btrace (ptid_t ptid,
+				     const btrace_config *conf) override;
+
+  int disable_btrace (btrace_target_info *tinfo) override;
+
+  int read_btrace (btrace_target_info *tinfo, buffer *buf,
+		   enum btrace_read_type type) override;
+
+  int read_btrace_conf (const btrace_target_info *tinfo,
+			buffer *buf) override;
+#endif
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 031166ed126..a890b660bb1 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,10 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* enable_btrace */
-  NULL,  /* disable_btrace */
-  NULL,  /* read_btrace */
-  NULL,  /* read_btrace_conf */
   NULL,  /* supports_range_stepping */
   NULL,  /* pid_to_exec_file */
   NULL,  /* multifs_open */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 27fe3ca4132..ef79105877b 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,10 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* enable_btrace */
-  NULL, /* disable_btrace */
-  NULL, /* read_btrace */
-  NULL, /* read_btrace_conf */
   NULL, /* supports_range_stepping */
   NULL, /* pid_to_exec_file */
   NULL, /* multifs_open */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 2bbd8b4d7a9..e2ce7ff0869 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -726,3 +726,30 @@ process_target::supports_agent ()
 {
   return false;
 }
+
+btrace_target_info *
+process_target::enable_btrace (ptid_t ptid, const btrace_config *conf)
+{
+  error (_("Target does not support branch tracing."));
+}
+
+int
+process_target::disable_btrace (btrace_target_info *tinfo)
+{
+  error (_("Target does not support branch tracing."));
+}
+
+int
+process_target::read_btrace (btrace_target_info *tinfo,
+			     buffer *buffer,
+			     enum btrace_read_type type)
+{
+  error (_("Target does not support branch tracing."));
+}
+
+int
+process_target::read_btrace_conf (const btrace_target_info *tinfo,
+				  buffer *buffer)
+{
+  error (_("Target does not support branch tracing."));
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 8a1c12260f1..9d7c599b1e6 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,26 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Enable branch tracing for PTID based on CONF and allocate a branch trace
-     target information struct for reading and for disabling branch trace.  */
-  struct btrace_target_info *(*enable_btrace)
-    (ptid_t ptid, const struct btrace_config *conf);
-
-  /* Disable branch tracing.
-     Returns zero on success, non-zero otherwise.  */
-  int (*disable_btrace) (struct btrace_target_info *tinfo);
-
-  /* Read branch trace data into buffer.
-     Return 0 on success; print an error message into BUFFER and return -1,
-     otherwise.  */
-  int (*read_btrace) (struct btrace_target_info *, struct buffer *,
-		      enum btrace_read_type type);
-
-  /* Read the branch trace configuration into BUFFER.
-     Return 0 on success; print an error message into BUFFER and return -1
-     otherwise.  */
-  int (*read_btrace_conf) (const struct btrace_target_info *, struct buffer *);
-
   /* Return true if target supports range stepping.  */
   int (*supports_range_stepping) (void);
 
@@ -497,6 +477,27 @@ public:
 
   /* Return true if target supports debugging agent.  */
   virtual bool supports_agent ();
+
+  /* Enable branch tracing for PTID based on CONF and allocate a branch trace
+     target information struct for reading and for disabling branch trace.  */
+  virtual btrace_target_info *enable_btrace (ptid_t ptid,
+					     const btrace_config *conf);
+
+  /* Disable branch tracing.
+     Returns zero on success, non-zero otherwise.  */
+  virtual int disable_btrace (btrace_target_info *tinfo);
+
+  /* Read branch trace data into buffer.
+     Return 0 on success; print an error message into BUFFER and return -1,
+     otherwise.  */
+  virtual int read_btrace (btrace_target_info *tinfo, buffer *buf,
+			   enum btrace_read_type type);
+
+  /* Read the branch trace configuration into BUFFER.
+     Return 0 on success; print an error message into BUFFER and return -1
+     otherwise.  */
+  virtual int read_btrace_conf (const btrace_target_info *tinfo,
+				buffer *buf);
 };
 
 extern process_stratum_target *the_target;
@@ -612,19 +613,13 @@ int kill_inferior (process_info *proc);
 static inline struct btrace_target_info *
 target_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
 {
-  if (the_target->enable_btrace == nullptr)
-    error (_("Target does not support branch tracing."));
-
-  return (*the_target->enable_btrace) (ptid, conf);
+  return the_target->pt->enable_btrace (ptid, conf);
 }
 
 static inline int
 target_disable_btrace (struct btrace_target_info *tinfo)
 {
-  if (the_target->disable_btrace == nullptr)
-    error (_("Target does not support branch tracing."));
-
-  return (*the_target->disable_btrace) (tinfo);
+  return the_target->pt->disable_btrace (tinfo);
 }
 
 static inline int
@@ -632,20 +627,14 @@ target_read_btrace (struct btrace_target_info *tinfo,
 		    struct buffer *buffer,
 		    enum btrace_read_type type)
 {
-  if (the_target->read_btrace == nullptr)
-    error (_("Target does not support branch tracing."));
-
-  return (*the_target->read_btrace) (tinfo, buffer, type);
+  return the_target->pt->read_btrace (tinfo, buffer, type);
 }
 
 static inline int
 target_read_btrace_conf (struct btrace_target_info *tinfo,
 			 struct buffer *buffer)
 {
-  if (the_target->read_btrace_conf == nullptr)
-    error (_("Target does not support branch tracing."));
-
-  return (*the_target->read_btrace_conf) (tinfo, buffer);
+  return the_target->pt->read_btrace_conf (tinfo, buffer);
 }
 
 #define target_supports_range_stepping() \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 84b6ea3e285..7fdc90feff1 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,10 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* enable_btrace */
-  NULL, /* disable_btrace */
-  NULL, /* read_btrace */
-  NULL, /* read_btrace_conf */
   NULL, /* supports_range_stepping */
   NULL, /* pid_to_exec_file */
   NULL, /* multifs_open */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 58/58] gdbserver: finish turning the target ops vector into a class
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (51 preceding siblings ...)
  2020-02-17 17:04 ` [PATCH v2 48/58] gdbserver: turn btrace-related target ops into methods Tankut Baris Aktemur
@ 2020-02-17 17:04 ` Tankut Baris Aktemur
  2020-02-17 17:04 ` [PATCH v2 41/58] gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods Tankut Baris Aktemur
                   ` (6 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

Now that 'process_stratum_target' has a single field left, namely 'pt'
of type 'process_target', and that all the requests to a
'process_stratum_target' are forwarded to 'pt', meld the
'process_target' class into 'process_stratum_target'.

This essentially means

1. All the references of the form 'the_target->pt' become 'the_target'.

2. All the uses of the name 'process_target' become
   'process_stratum_target'.

3. The platform-specific target op vectors (e.g. linux_target_ops) are
   removed and instances of their "process target" classes are used
   instead.

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* target.h (struct process_stratum_target): Remove.
	(class process_target): Rename to ...
	(class process_stratum_target): ... this.
	* linux-low.h (class linux_process_target): Derive from
	'process_stratum_target'.
	* linux-low.cc (linux_target_ops): Remove.
	(initialize_low): Set the_target to the singleton instance of
	linux_process_target.
	* lynx-low.h (class lynx_process_target): Derive from
	'process_stratum_target'.
	* lynx-low.cc (lynx_target_ops): Remove.
	(initialize_low): Set the_target to the singleton instance of
	lynx_process_target.
	* nto-low.h (class nto_process_target): Derive from
	'process_stratum_target'.
	* nto-low.cc (nto_target_ops): Remove.
	(initialize_low): Set the_target to the singleton instance of
	nto_process_target.
	* win32-low.h (class win32_process_target): Derive from
	'process_stratum_target'.
	* win32-low.cc (win32_target_ops): Remove.
	(initialize_low): Set the_target to the singleton instance of
	win32_process_target.

	Replace 'the_target->pt' with 'the_target' in the uses below.

	* hostio.cc (hostio_error)
	(handle_setfs)
	(handle_open)
	(handle_unlink)
	(handle_readlink)
	* linux-aarch32-low.cc (arm_breakpoint_at)
	* linux-aarch64-low.cc (aarch64_breakpoint_at)
	* linux-arm-low.cc (arm_sigreturn_next_pc)
	(arm_get_hwcap)
	(arm_get_syscall_trapinfo)
	* linux-cris-low.cc (cris_breakpoint_at)
	* linux-crisv32-low.cc (cris_breakpoint_at)
	* linux-low.cc (handle_extended_wait)
	(linux_wait_1)
	(linux_read_memory)
	(linux_process_target::breakpoint_kind_from_pc)
	(linux_get_auxv)
	* linux-m32r-low.cc (m32r_breakpoint_at)
	* linux-mips-low.cc (mips_breakpoint_at)
	* linux-nios2-low.cc (nios2_breakpoint_at)
	* linux-ppc-low.cc (ppc_breakpoint_at)
	* linux-s390-low.cc (s390_get_hwcap)
	* linux-sh-low.cc (sh_breakpoint_at)
	* linux-sparc-low.cc (sparc_fill_gregset_to_stack)
	(sparc_store_gregset_from_stack)
	(sparc_breakpoint_at)
	* linux-tic6x-low.cc (tic6x_breakpoint_at)
	* linux-tile-low.cc (tile_breakpoint_at)
	* linux-x86-low.cc (x86_breakpoint_at)
	* linux-xtensa-low.cc (xtensa_breakpoint_at)
	* mem-break.cc (bp_size)
	(bp_opcode)
	(insert_memory_breakpoint)
	(set_raw_breakpoint_at)
	(delete_raw_breakpoint)
	(z_type_supported)
	(uninsert_raw_breakpoint)
	(reinsert_raw_breakpoint)
	(validate_inserted_breakpoint)
	* regcache.cc (regcache_read_pc)
	(regcache_write_pc)
	* remote-utils.cc (putpkt_binary_1)
	(input_interrupt)
	(getpkt)
	(prepare_resume_reply)
	* server.cc (handle_general_set)
	(handle_detach)
	(handle_qxfer_auxv)
	(handle_qxfer_exec_file)
	(handle_qxfer_libraries_svr4)
	(handle_qxfer_osdata)
	(handle_qxfer_siginfo)
	(handle_qxfer_fdpic)
	(handle_query)
	(resume)
	(handle_v_requests)
	(queue_stop_reply_callback)
	(captured_main)
	* target.cc (prepare_to_access_memory)
	(done_accessing_memory)
	(read_inferior_memory)
	(target_write_memory)
	(target_stop_and_wait)
	(target_wait)
	(target_mourn_inferior)
	(target_continue_no_signal)
	(target_continue)
	(target_supports_multi_process)
	(kill_inferior)
	* target.h
	(target_create_inferior)
	(target_post_create_inferior)
	(myattach)
	(target_supports_fork_events)
	(target_supports_vfork_events)
	(target_supports_exec_events)
	(target_handle_new_gdb_connection)
	(detach_inferior)
	(mythread_alive)
	(fetch_inferior_registers)
	(store_inferior_registers)
	(join_inferior)
	(target_supports_non_stop)
	(target_async)
	(target_process_qsupported)
	(target_supports_catch_syscall)
	(target_get_ipa_tdesc_idx)
	(target_supports_tracepoints)
	(target_supports_fast_tracepoints)
	(target_get_min_fast_tracepoint_insn_len)
	(target_thread_stopped)
	(target_pause_all)
	(target_unpause_all)
	(target_stabilize_threads)
	(target_install_fast_tracepoint_jump_pad)
	(target_emit_ops)
	(target_supports_disable_randomization)
	(target_supports_agent)
	(target_enable_btrace)
	(target_disable_btrace)
	(target_read_btrace)
	(target_read_btrace_conf)
	(target_supports_range_stepping)
	(target_supports_stopped_by_sw_breakpoint)
	(target_stopped_by_sw_breakpoint)
	(target_supports_stopped_by_hw_breakpoint)
	(target_supports_hardware_single_step)
	(target_stopped_by_hw_breakpoint)
	(target_breakpoint_kind_from_pc)
	(target_breakpoint_kind_from_current_state)
	(target_supports_software_single_step)
	(target_core_of_thread)
	(target_thread_name)
	(target_thread_handle)
	* win32-low.cc (do_initial_child_stuff)

	Rename target op default definitions listed below.

	* target.cc (process_target::post_create_inferior): Rename as ...
	(process_stratum_target::post_create_inferior): ... this.
	(process_target::prepare_to_access_memory): Rename as ...
	(process_stratum_target::prepare_to_access_memory): ... this.
	(process_target::done_accessing_memory): Rename as ...
	(process_stratum_target::done_accessing_memory): ... this.
	(process_target::look_up_symbols): Rename as ...
	(process_stratum_target::look_up_symbols): ... this.
	(process_target::supports_read_auxv): Rename as ...
	(process_stratum_target::supports_read_auxv): ... this.
	(process_target::read_auxv): Rename as ...
	(process_stratum_target::read_auxv): ... this.
	(process_target::supports_z_point_type): Rename as ...
	(process_stratum_target::supports_z_point_type): ... this.
	(process_target::insert_point): Rename as ...
	(process_stratum_target::insert_point): ... this.
	(process_target::remove_point): Rename as ...
	(process_stratum_target::remove_point): ... this.
	(process_target::stopped_by_sw_breakpoint): Rename as ...
	(process_stratum_target::stopped_by_sw_breakpoint): ... this.
	(process_target::supports_stopped_by_sw_breakpoint): Rename as ...
	(process_stratum_target::supports_stopped_by_sw_breakpoint): ... this.
	(process_target::stopped_by_hw_breakpoint): Rename as ...
	(process_stratum_target::stopped_by_hw_breakpoint): ... this.
	(process_target::supports_stopped_by_hw_breakpoint): Rename as ...
	(process_stratum_target::supports_stopped_by_hw_breakpoint): ... this.
	(process_target::supports_hardware_single_step): Rename as ...
	(process_stratum_target::supports_hardware_single_step): ... this.
	(process_target::stopped_by_watchpoint): Rename as ...
	(process_stratum_target::stopped_by_watchpoint): ... this.
	(process_target::stopped_data_address): Rename as ...
	(process_stratum_target::stopped_data_address): ... this.
	(process_target::supports_read_offsets): Rename as ...
	(process_stratum_target::supports_read_offsets): ... this.
	(process_target::read_offsets): Rename as ...
	(process_stratum_target::read_offsets): ... this.
	(process_target::supports_get_tls_address): Rename as ...
	(process_stratum_target::supports_get_tls_address): ... this.
	(process_target::get_tls_address): Rename as ...
	(process_stratum_target::get_tls_address): ... this.
	(process_target::hostio_last_error): Rename as ...
	(process_stratum_target::hostio_last_error): ... this.
	(process_target::supports_qxfer_osdata): Rename as ...
	(process_stratum_target::supports_qxfer_osdata): ... this.
	(process_target::qxfer_osdata): Rename as ...
	(process_stratum_target::qxfer_osdata): ... this.
	(process_target::supports_qxfer_siginfo): Rename as ...
	(process_stratum_target::supports_qxfer_siginfo): ... this.
	(process_target::qxfer_siginfo): Rename as ...
	(process_stratum_target::qxfer_siginfo): ... this.
	(process_target::supports_non_stop): Rename as ...
	(process_stratum_target::supports_non_stop): ... this.
	(process_target::async): Rename as ...
	(process_stratum_target::async): ... this.
	(process_target::start_non_stop): Rename as ...
	(process_stratum_target::start_non_stop): ... this.
	(process_target::supports_multi_process): Rename as ...
	(process_stratum_target::supports_multi_process): ... this.
	(process_target::supports_fork_events): Rename as ...
	(process_stratum_target::supports_fork_events): ... this.
	(process_target::supports_vfork_events): Rename as ...
	(process_stratum_target::supports_vfork_events): ... this.
	(process_target::supports_exec_events): Rename as ...
	(process_stratum_target::supports_exec_events): ... this.
	(process_target::handle_new_gdb_connection): Rename as ...
	(process_stratum_target::handle_new_gdb_connection): ... this.
	(process_target::handle_monitor_command): Rename as ...
	(process_stratum_target::handle_monitor_command): ... this.
	(process_target::core_of_thread): Rename as ...
	(process_stratum_target::core_of_thread): ... this.
	(process_target::supports_read_loadmap): Rename as ...
	(process_stratum_target::supports_read_loadmap): ... this.
	(process_target::read_loadmap): Rename as ...
	(process_stratum_target::read_loadmap): ... this.
	(process_target::process_qsupported): Rename as ...
	(process_stratum_target::process_qsupported): ... this.
	(process_target::supports_tracepoints): Rename as ...
	(process_stratum_target::supports_tracepoints): ... this.
	(process_target::read_pc): Rename as ...
	(process_stratum_target::read_pc): ... this.
	(process_target::write_pc): Rename as ...
	(process_stratum_target::write_pc): ... this.
	(process_target::supports_thread_stopped): Rename as ...
	(process_stratum_target::supports_thread_stopped): ... this.
	(process_target::thread_stopped): Rename as ...
	(process_stratum_target::thread_stopped): ... this.
	(process_target::supports_get_tib_address): Rename as ...
	(process_stratum_target::supports_get_tib_address): ... this.
	(process_target::get_tib_address): Rename as ...
	(process_stratum_target::get_tib_address): ... this.
	(process_target::pause_all): Rename as ...
	(process_stratum_target::pause_all): ... this.
	(process_target::unpause_all): Rename as ...
	(process_stratum_target::unpause_all): ... this.
	(process_target::stabilize_threads): Rename as ...
	(process_stratum_target::stabilize_threads): ... this.
	(process_target::supports_fast_tracepoints): Rename as ...
	(process_stratum_target::supports_fast_tracepoints): ... this.
	(process_target::get_min_fast_tracepoint_insn_len): Rename as ...
	(process_stratum_target::get_min_fast_tracepoint_insn_len): ... this.
	(process_target::emit_ops): Rename as ...
	(process_stratum_target::emit_ops): ... this.
	(process_target::supports_disable_randomization): Rename as ...
	(process_stratum_target::supports_disable_randomization): ... this.
	(process_target::supports_qxfer_libraries_svr4): Rename as ...
	(process_stratum_target::supports_qxfer_libraries_svr4): ... this.
	(process_target::qxfer_libraries_svr4): Rename as ...
	(process_stratum_target::qxfer_libraries_svr4): ... this.
	(process_target::supports_agent): Rename as ...
	(process_stratum_target::supports_agent): ... this.
	(process_target::enable_btrace): Rename as ...
	(process_stratum_target::enable_btrace): ... this.
	(process_target::disable_btrace): Rename as ...
	(process_stratum_target::disable_btrace): ... this.
	(process_target::read_btrace): Rename as ...
	(process_stratum_target::read_btrace): ... this.
	(process_target::read_btrace_conf): Rename as ...
	(process_stratum_target::read_btrace_conf): ... this.
	(process_target::supports_range_stepping): Rename as ...
	(process_stratum_target::supports_range_stepping): ... this.
	(process_target::supports_pid_to_exec_file): Rename as ...
	(process_stratum_target::supports_pid_to_exec_file): ... this.
	(process_target::pid_to_exec_file): Rename as ...
	(process_stratum_target::pid_to_exec_file): ... this.
	(process_target::supports_multifs): Rename as ...
	(process_stratum_target::supports_multifs): ... this.
	(process_target::multifs_open): Rename as ...
	(process_stratum_target::multifs_open): ... this.
	(process_target::multifs_unlink): Rename as ...
	(process_stratum_target::multifs_unlink): ... this.
	(process_target::multifs_readlink): Rename as ...
	(process_stratum_target::multifs_readlink): ... this.
	(process_target::breakpoint_kind_from_pc): Rename as ...
	(process_stratum_target::breakpoint_kind_from_pc): ... this.
	(process_target::breakpoint_kind_from_current_state): Rename as ...
	(process_stratum_target::breakpoint_kind_from_current_state): ... this.
	(process_target::thread_name): Rename as ...
	(process_stratum_target::thread_name): ... this.
	(process_target::thread_handle): Rename as ...
	(process_stratum_target::thread_handle): ... this.
	(process_target::supports_software_single_step): Rename as ...
	(process_stratum_target::supports_software_single_step): ... this.
	(process_target::supports_catch_syscall): Rename as ...
	(process_stratum_target::supports_catch_syscall): ... this.
	(process_target::get_ipa_tdesc_idx): Rename as ...
	(process_stratum_target::get_ipa_tdesc_idx): ... this.
---
 gdbserver/hostio.cc            |  15 ++-
 gdbserver/linux-aarch32-low.cc |   6 +-
 gdbserver/linux-aarch64-low.cc |   4 +-
 gdbserver/linux-arm-low.cc     |   8 +-
 gdbserver/linux-cris-low.cc    |   4 +-
 gdbserver/linux-crisv32-low.cc |   4 +-
 gdbserver/linux-low.cc         |  18 ++-
 gdbserver/linux-low.h          |   2 +-
 gdbserver/linux-m32r-low.cc    |   4 +-
 gdbserver/linux-mips-low.cc    |   2 +-
 gdbserver/linux-nios2-low.cc   |   4 +-
 gdbserver/linux-ppc-low.cc     |   2 +-
 gdbserver/linux-sh-low.cc      |   2 +-
 gdbserver/linux-sparc-low.cc   |   6 +-
 gdbserver/linux-tic6x-low.cc   |   2 +-
 gdbserver/linux-tile-low.cc    |   2 +-
 gdbserver/linux-x86-low.cc     |   2 +-
 gdbserver/linux-xtensa-low.cc  |   4 +-
 gdbserver/lynx-low.cc          |   8 +-
 gdbserver/lynx-low.h           |   2 +-
 gdbserver/mem-break.cc         |  22 ++--
 gdbserver/nto-low.cc           |   7 +-
 gdbserver/nto-low.h            |   2 +-
 gdbserver/regcache.cc          |   4 +-
 gdbserver/remote-utils.cc      |  12 +-
 gdbserver/server.cc            |  68 +++++------
 gdbserver/target.cc            | 212 +++++++++++++++++----------------
 gdbserver/target.h             | 117 +++++++++---------
 gdbserver/win32-low.cc         |  10 +-
 gdbserver/win32-low.h          |   2 +-
 30 files changed, 269 insertions(+), 288 deletions(-)

diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index 6223b24a887..0185a3ba038 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -196,7 +196,7 @@ require_valid_fd (int fd)
 static void
 hostio_error (char *own_buf)
 {
-  the_target->pt->hostio_last_error (own_buf);
+  the_target->hostio_last_error (own_buf);
 }
 
 static void
@@ -272,7 +272,7 @@ handle_setfs (char *own_buf)
      then there's no point in GDB sending "vFile:setfs:" packets.  We
      reply with an empty packet (i.e. we pretend we don't understand
      "vFile:setfs:") and that should stop GDB sending any more.  */
-  if (!the_target->pt->supports_multifs ())
+  if (!the_target->supports_multifs ())
     {
       own_buf[0] = '\0';
       return;
@@ -320,8 +320,7 @@ handle_open (char *own_buf)
   /* We do not need to convert MODE, since the fileio protocol
      uses the standard values.  */
   if (hostio_fs_pid != 0)
-    fd = the_target->pt->multifs_open (hostio_fs_pid, filename,
-				       flags, mode);
+    fd = the_target->multifs_open (hostio_fs_pid, filename, flags, mode);
   else
     fd = open (filename, flags, mode);
 
@@ -540,7 +539,7 @@ handle_unlink (char *own_buf)
     }
 
   if (hostio_fs_pid != 0)
-    ret = the_target->pt->multifs_unlink (hostio_fs_pid, filename);
+    ret = the_target->multifs_unlink (hostio_fs_pid, filename);
   else
     ret = unlink (filename);
 
@@ -570,9 +569,9 @@ handle_readlink (char *own_buf, int *new_packet_len)
     }
 
   if (hostio_fs_pid != 0)
-    ret = the_target->pt->multifs_readlink (hostio_fs_pid, filename,
-					    linkname,
-					    sizeof (linkname) - 1);
+    ret = the_target->multifs_readlink (hostio_fs_pid, filename,
+					linkname,
+					sizeof (linkname) - 1);
   else
     ret = readlink (filename, linkname, sizeof (linkname) - 1);
 
diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc
index 41e018ab528..1ca0bfa8210 100644
--- a/gdbserver/linux-aarch32-low.cc
+++ b/gdbserver/linux-aarch32-low.cc
@@ -192,13 +192,13 @@ arm_breakpoint_at (CORE_ADDR where)
       /* Thumb mode.  */
       unsigned short insn;
 
-      the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
+      the_target->read_memory (where, (unsigned char *) &insn, 2);
       if (insn == thumb_breakpoint)
 	return 1;
 
       if (insn == thumb2_breakpoint[0])
 	{
-	  the_target->pt->read_memory (where + 2, (unsigned char *) &insn, 2);
+	  the_target->read_memory (where + 2, (unsigned char *) &insn, 2);
 	  if (insn == thumb2_breakpoint[1])
 	    return 1;
 	}
@@ -208,7 +208,7 @@ arm_breakpoint_at (CORE_ADDR where)
       /* ARM mode.  */
       unsigned long insn;
 
-      the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
+      the_target->read_memory (where, (unsigned char *) &insn, 4);
       if (insn == arm_abi_breakpoint)
 	return 1;
 
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 97117f05780..6ce5452945e 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -192,8 +192,8 @@ aarch64_breakpoint_at (CORE_ADDR where)
     {
       gdb_byte insn[aarch64_breakpoint_len];
 
-      the_target->pt->read_memory (where, (unsigned char *) &insn,
-				   aarch64_breakpoint_len);
+      the_target->read_memory (where, (unsigned char *) &insn,
+			       aarch64_breakpoint_len);
       if (memcmp (insn, aarch64_breakpoint, aarch64_breakpoint_len) == 0)
 	return 1;
 
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index e7cc1196857..f60543eae94 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -779,15 +779,15 @@ arm_sigreturn_next_pc (struct regcache *regcache, int svc_number,
   gdb_assert (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn);
 
   collect_register_by_name (regcache, "sp", &sp);
-  the_target->pt->read_memory (sp, (unsigned char *) &sp_data, 4);
+  the_target->read_memory (sp, (unsigned char *) &sp_data, 4);
 
   pc_offset = arm_linux_sigreturn_next_pc_offset
     (sp, sp_data, svc_number, __NR_sigreturn == svc_number ? 1 : 0);
 
-  the_target->pt->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
+  the_target->read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
 
   /* Set IS_THUMB according the CPSR saved on the stack.  */
-  the_target->pt->read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
+  the_target->read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
   *is_thumb = ((cpsr & CPSR_T) != 0);
 
   return next_pc;
@@ -939,7 +939,7 @@ arm_get_syscall_trapinfo (struct regcache *regcache, int *sysno)
 
       collect_register_by_name (regcache, "pc", &pc);
 
-      if (the_target->pt->read_memory (pc - 4, (unsigned char *) &insn, 4))
+      if (the_target->read_memory (pc - 4, (unsigned char *) &insn, 4))
 	*sysno = UNKNOWN_SYSCALL;
       else
 	{
diff --git a/gdbserver/linux-cris-low.cc b/gdbserver/linux-cris-low.cc
index 6a4e8b1946a..81d84a1b5c8 100644
--- a/gdbserver/linux-cris-low.cc
+++ b/gdbserver/linux-cris-low.cc
@@ -76,8 +76,8 @@ cris_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn,
-			       cris_breakpoint_len);
+  the_target->read_memory (where, (unsigned char *) &insn,
+			   cris_breakpoint_len);
   if (insn == cris_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-crisv32-low.cc b/gdbserver/linux-crisv32-low.cc
index fe12624c3b6..06135efcfa2 100644
--- a/gdbserver/linux-crisv32-low.cc
+++ b/gdbserver/linux-crisv32-low.cc
@@ -72,8 +72,8 @@ cris_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn,
-			       cris_breakpoint_len);
+  the_target->read_memory (where, (unsigned char *) &insn,
+			   cris_breakpoint_len);
   if (insn == cris_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 8183567137b..037266a446c 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -703,7 +703,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);
+      the_target->mourn (proc);
       current_thread = NULL;
 
       /* Create a new process/lwp/thread.  */
@@ -3218,8 +3218,8 @@ linux_wait_1 (ptid_t ptid,
       CORE_ADDR stop_pc = event_child->stop_pc;
 
       breakpoint_kind =
-	the_target->pt->breakpoint_kind_from_current_state (&stop_pc);
-      the_target->pt->sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
+	the_target->breakpoint_kind_from_current_state (&stop_pc);
+      the_target->sw_breakpoint_from_kind (breakpoint_kind, &increment_pc);
 
       if (debug_threads)
 	{
@@ -5712,7 +5712,7 @@ linux_process_target::store_registers (regcache *regcache, int regno)
 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
@@ -7368,7 +7368,7 @@ linux_process_target::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 process_target::breakpoint_kind_from_pc (pcptr);
+    return process_stratum_target::breakpoint_kind_from_pc (pcptr);
 }
 
 /* Implementation of the target_ops method "sw_breakpoint_from_kind".  */
@@ -7468,7 +7468,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)
 	{
@@ -7519,10 +7519,6 @@ linux_get_hwcap2 (int wordsize)
 
 static linux_process_target the_linux_target;
 
-static process_stratum_target linux_target_ops = {
-  &the_linux_target,
-};
-
 #ifdef HAVE_LINUX_REGSETS
 void
 initialize_regsets_info (struct regsets_info *info)
@@ -7540,7 +7536,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 ();
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 33f208efd3b..b69ade98e41 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -266,7 +266,7 @@ extern struct linux_target_ops the_low_target;
 
 /* Target ops definitions for a Linux target.  */
 
-class linux_process_target : public process_target
+class linux_process_target : public process_stratum_target
 {
 public:
 
diff --git a/gdbserver/linux-m32r-low.cc b/gdbserver/linux-m32r-low.cc
index 8fe8389618f..74e0f3f74c6 100644
--- a/gdbserver/linux-m32r-low.cc
+++ b/gdbserver/linux-m32r-low.cc
@@ -70,8 +70,8 @@ m32r_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn,
-			       m32r_breakpoint_len);
+  the_target->read_memory (where, (unsigned char *) &insn,
+			   m32r_breakpoint_len);
   if (insn == m32r_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index cb7eb53e3eb..3caab02e503 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -302,7 +302,7 @@ mips_breakpoint_at (CORE_ADDR where)
 {
   unsigned int insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
+  the_target->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == mips_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-nios2-low.cc b/gdbserver/linux-nios2-low.cc
index 6e5d3084dad..a8bb87a390e 100644
--- a/gdbserver/linux-nios2-low.cc
+++ b/gdbserver/linux-nios2-low.cc
@@ -131,12 +131,12 @@ nios2_breakpoint_at (CORE_ADDR where)
 
   /* For R2, first check for the 2-byte CDX trap.n breakpoint encoding.  */
 #if defined(__nios2_arch__) && __nios2_arch__ == 2
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
+  the_target->read_memory (where, (unsigned char *) &insn, 2);
   if (insn == CDX_BREAKPOINT)
     return 1;
 #endif
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
+  the_target->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == nios2_breakpoint)
     return 1;
   return 0;
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index 93b3511a2e1..fd6d0369c48 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -277,7 +277,7 @@ ppc_breakpoint_at (CORE_ADDR where)
 {
   unsigned int insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
+  the_target->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == ppc_breakpoint)
     return 1;
   /* If necessary, recognize more trap instructions here.  GDB only uses
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index 06ce8118ebf..f55402c3d41 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -76,7 +76,7 @@ sh_breakpoint_at (CORE_ADDR where)
 {
   unsigned short insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 2);
+  the_target->read_memory (where, (unsigned char *) &insn, 2);
   if (insn == sh_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc
index b0b6c96b3de..e6cb43209af 100644
--- a/gdbserver/linux-sparc-low.cc
+++ b/gdbserver/linux-sparc-low.cc
@@ -133,7 +133,7 @@ sparc_fill_gregset_to_stack (struct regcache *regcache, const void *buf)
   for (i = l0_regno; i <= i7_regno; i++)
     {
       collect_register (regcache, i, tmp_reg_buf);
-      the_target->pt->write_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
+      the_target->write_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
       addr += sizeof (tmp_reg_buf);
     }
 }
@@ -184,7 +184,7 @@ sparc_store_gregset_from_stack (struct regcache *regcache, const void *buf)
 
   for (i = l0_regno; i <= i7_regno; i++)
     {
-      the_target->pt->read_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
+      the_target->read_memory (addr, tmp_reg_buf, sizeof (tmp_reg_buf));
       supply_register (regcache, i, tmp_reg_buf);
       addr += sizeof (tmp_reg_buf);
     }
@@ -242,7 +242,7 @@ sparc_breakpoint_at (CORE_ADDR where)
 {
   unsigned char insn[INSN_SIZE];
 
-  the_target->pt->read_memory (where, (unsigned char *) insn, sizeof (insn));
+  the_target->read_memory (where, (unsigned char *) insn, sizeof (insn));
 
   if (memcmp (sparc_breakpoint, insn, sizeof (insn)) == 0)
     return 1;
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index b57f8c57710..ca7c983a8ac 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -241,7 +241,7 @@ tic6x_breakpoint_at (CORE_ADDR where)
 {
   unsigned int insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 4);
+  the_target->read_memory (where, (unsigned char *) &insn, 4);
   if (insn == tic6x_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-tile-low.cc b/gdbserver/linux-tile-low.cc
index baee93a5c24..1fe77a3fa57 100644
--- a/gdbserver/linux-tile-low.cc
+++ b/gdbserver/linux-tile-low.cc
@@ -85,7 +85,7 @@ tile_breakpoint_at (CORE_ADDR where)
 {
   uint64_t insn;
 
-  the_target->pt->read_memory (where, (unsigned char *) &insn, 8);
+  the_target->read_memory (where, (unsigned char *) &insn, 8);
   if (insn == tile_breakpoint)
     return 1;
 
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index cb2d3f59580..96818b85a86 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -515,7 +515,7 @@ x86_breakpoint_at (CORE_ADDR pc)
 {
   unsigned char c;
 
-  the_target->pt->read_memory (pc, &c, 1);
+  the_target->read_memory (pc, &c, 1);
   if (c == 0xCC)
     return 1;
 
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index 31e7bad36b8..510c9bd8879 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -207,8 +207,8 @@ xtensa_breakpoint_at (CORE_ADDR where)
 {
     unsigned long insn;
 
-    the_target->pt->read_memory (where, (unsigned char *) &insn,
-				 xtensa_breakpoint_len);
+    the_target->read_memory (where, (unsigned char *) &insn,
+			     xtensa_breakpoint_len);
     return memcmp((char *) &insn,
 		  xtensa_breakpoint, xtensa_breakpoint_len) == 0;
 }
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 5e11355fcaa..9aa140c1298 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -738,16 +738,10 @@ lynx_process_target::sw_breakpoint_from_kind (int kind, int *size)
 
 static lynx_process_target the_lynx_target;
 
-/* The LynxOS target_ops vector.  */
-
-static process_stratum_target lynx_target_ops = {
-  &the_lynx_target,
-};
-
 void
 initialize_low (void)
 {
-  set_target_ops (&lynx_target_ops);
+  set_target_ops (&the_lynx_target);
   the_low_target.arch_setup ();
 }
 
diff --git a/gdbserver/lynx-low.h b/gdbserver/lynx-low.h
index 7da97b3b073..fa975a21f30 100644
--- a/gdbserver/lynx-low.h
+++ b/gdbserver/lynx-low.h
@@ -54,7 +54,7 @@ extern struct lynx_target_ops the_low_target;
 
 /* Target ops definitions for a LynxOS target.  */
 
-class lynx_process_target : public process_target
+class lynx_process_target : public process_stratum_target
 {
 public:
 
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index 3802d72a573..6b7af3a7d33 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -223,7 +223,7 @@ bp_size (struct raw_breakpoint *bp)
 {
   int size = 0;
 
-  the_target->pt->sw_breakpoint_from_kind (bp->kind, &size);
+  the_target->sw_breakpoint_from_kind (bp->kind, &size);
   return size;
 }
 
@@ -234,7 +234,7 @@ bp_opcode (struct raw_breakpoint *bp)
 {
   int size = 0;
 
-  return the_target->pt->sw_breakpoint_from_kind (bp->kind, &size);
+  return the_target->sw_breakpoint_from_kind (bp->kind, &size);
 }
 
 /* See mem-break.h.  */
@@ -380,8 +380,8 @@ insert_memory_breakpoint (struct raw_breakpoint *bp)
     {
       memcpy (bp->old_data, buf, bp_size (bp));
 
-      err = the_target->pt->write_memory (bp->pc, bp_opcode (bp),
-					  bp_size (bp));
+      err = the_target->write_memory (bp->pc, bp_opcode (bp),
+				      bp_size (bp));
       if (err != 0)
 	{
 	  if (debug_threads)
@@ -460,7 +460,7 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind,
 
   if (!bp->inserted)
     {
-      *err = the_target->pt->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
+      *err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
       if (*err != 0)
 	{
 	  if (debug_threads)
@@ -890,8 +890,8 @@ delete_raw_breakpoint (struct process_info *proc, struct raw_breakpoint *todel)
 
 	      *bp_link = bp->next;
 
-	      ret = the_target->pt->remove_point (bp->raw_type, bp->pc,
-						  bp->kind, bp);
+	      ret = the_target->remove_point (bp->raw_type, bp->pc,
+					      bp->kind, bp);
 	      if (ret != 0)
 		{
 		  /* Something went wrong, relink the breakpoint.  */
@@ -1005,7 +1005,7 @@ static int
 z_type_supported (char z_type)
 {
   return (z_type >= '0' && z_type <= '4'
-	  && the_target->pt->supports_z_point_type (z_type));
+	  && the_target->supports_z_point_type (z_type));
 }
 
 /* Create a new GDB breakpoint of type Z_TYPE at ADDR with kind KIND.
@@ -1532,7 +1532,7 @@ uninsert_raw_breakpoint (struct raw_breakpoint *bp)
 
       bp->inserted = 0;
 
-      err = the_target->pt->remove_point (bp->raw_type, bp->pc, bp->kind, bp);
+      err = the_target->remove_point (bp->raw_type, bp->pc, bp->kind, bp);
       if (err != 0)
 	{
 	  bp->inserted = 1;
@@ -1621,7 +1621,7 @@ reinsert_raw_breakpoint (struct raw_breakpoint *bp)
   if (bp->inserted)
     return;
 
-  err = the_target->pt->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
+  err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp);
   if (err == 0)
     bp->inserted = 1;
   else if (debug_threads)
@@ -1856,7 +1856,7 @@ validate_inserted_breakpoint (struct raw_breakpoint *bp)
   gdb_assert (bp->raw_type == raw_bkpt_type_sw);
 
   buf = (unsigned char *) alloca (bp_size (bp));
-  err = the_target->pt->read_memory (bp->pc, buf, bp_size (bp));
+  err = the_target->read_memory (bp->pc, buf, bp_size (bp));
   if (err || memcmp (buf, bp_opcode (bp), bp_size (bp)) != 0)
     {
       /* Tag it as gone.  */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 309c698bc2a..642fe9ffd21 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -946,11 +946,6 @@ nto_process_target::sw_breakpoint_from_kind (int kind, int *size)
 
 static nto_process_target the_nto_target;
 
-static process_stratum_target nto_target_ops = {
-  &the_nto_target,
-};
-
-
 /* Global function called by server.c.  Initializes QNX Neutrino
    gdbserver.  */
 
@@ -960,7 +955,7 @@ initialize_low (void)
   sigset_t set;
 
   TRACE ("%s\n", __func__);
-  set_target_ops (&nto_target_ops);
+  set_target_ops (&the_nto_target);
 
   /* We use SIGUSR1 to gain control after we block waiting for a process.
      We use sigwaitevent to wait.  */
diff --git a/gdbserver/nto-low.h b/gdbserver/nto-low.h
index ff2003b60b0..e26dcab331d 100644
--- a/gdbserver/nto-low.h
+++ b/gdbserver/nto-low.h
@@ -44,7 +44,7 @@ extern struct nto_target_ops the_low_target;
 
 /* Target ops definitions for a QNX Neutrino target.  */
 
-class nto_process_target : public process_target
+class nto_process_target : public process_stratum_target
 {
 public:
 
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index ec9d70d42fb..33d38879dc6 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -477,13 +477,13 @@ collect_register_by_name (struct regcache *regcache,
 CORE_ADDR
 regcache_read_pc (struct regcache *regcache)
 {
-  return the_target->pt->read_pc (regcache);
+  return the_target->read_pc (regcache);
 }
 
 void
 regcache_write_pc (struct regcache *regcache, CORE_ADDR pc)
 {
-  the_target->pt->write_pc (regcache, pc);
+  the_target->write_pc (regcache, pc);
 }
 
 #endif
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 316f04e32ee..6b547493a71 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -710,7 +710,7 @@ putpkt_binary_1 (char *buf, int cnt, int is_notif)
 
       /* Check for an input interrupt while we're here.  */
       if (cc == '\003' && current_thread != NULL)
-	the_target->pt->request_interrupt ();
+	the_target->request_interrupt ();
     }
   while (cc != '+');
 
@@ -779,7 +779,7 @@ input_interrupt (int unused)
 	  return;
 	}
 
-      the_target->pt->request_interrupt ();
+      the_target->request_interrupt ();
     }
 }
 
@@ -986,7 +986,7 @@ getpkt (char *buf)
 	     check for an input interrupt.  */
 	  if (c == '\003')
 	    {
-	      the_target->pt->request_interrupt ();
+	      the_target->request_interrupt ();
 	      continue;
 	    }
 
@@ -1076,7 +1076,7 @@ getpkt (char *buf)
     {
       /* Consume the interrupt character in the buffer.  */
       readchar ();
-      the_target->pt->request_interrupt ();
+      the_target->request_interrupt ();
     }
 
   return bp - buf;
@@ -1214,7 +1214,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 
 	regcache = get_thread_regcache (current_thread, 1);
 
-	if (the_target->pt->stopped_by_watchpoint ())
+	if (the_target->stopped_by_watchpoint ())
 	  {
 	    CORE_ADDR addr;
 	    int i;
@@ -1222,7 +1222,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 	    memcpy (buf, "watch:", 6);
 	    buf += 6;
 
-	    addr = the_target->pt->stopped_data_address ();
+	    addr = the_target->stopped_data_address ();
 
 	    /* Convert each byte of the address into two hexadecimal
 	       chars.  Note that we take sizeof (void *) instead of
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 00456d8d7ed..a4cb1eb4181 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -740,7 +740,7 @@ handle_general_set (char *own_buf)
 	}
 
       req_str = req ? "non-stop" : "all-stop";
-      if (the_target->pt->start_non_stop (req == 1) != 0)
+      if (the_target->start_non_stop (req == 1) != 0)
 	{
 	  fprintf (stderr, "Setting %s mode failed\n", req_str);
 	  write_enn (own_buf);
@@ -1234,7 +1234,7 @@ handle_detach (char *own_buf)
 	    debug_printf ("Forcing non-stop mode\n");
 
 	  non_stop = true;
-	  the_target->pt->start_non_stop (true);
+	  the_target->start_non_stop (true);
 	}
 
       process->gdb_detached = 1;
@@ -1442,13 +1442,13 @@ handle_qxfer_auxv (const char *annex,
 		   gdb_byte *readbuf, const gdb_byte *writebuf,
 		   ULONGEST offset, LONGEST len)
 {
-  if (!the_target->pt->supports_read_auxv () || writebuf != NULL)
+  if (!the_target->supports_read_auxv () || writebuf != NULL)
     return -2;
 
   if (annex[0] != '\0' || current_thread == NULL)
     return -1;
 
-  return the_target->pt->read_auxv (offset, readbuf, len);
+  return the_target->read_auxv (offset, readbuf, len);
 }
 
 /* Handle qXfer:exec-file:read.  */
@@ -1462,7 +1462,7 @@ handle_qxfer_exec_file (const char *annex,
   ULONGEST pid;
   int total_len;
 
-  if (!the_target->pt->supports_pid_to_exec_file () || writebuf != NULL)
+  if (!the_target->supports_pid_to_exec_file () || writebuf != NULL)
     return -2;
 
   if (annex[0] == '\0')
@@ -1482,7 +1482,7 @@ handle_qxfer_exec_file (const char *annex,
   if (pid <= 0)
     return -1;
 
-  file = the_target->pt->pid_to_exec_file (pid);
+  file = the_target->pid_to_exec_file (pid);
   if (file == NULL)
     return -1;
 
@@ -1575,11 +1575,11 @@ handle_qxfer_libraries_svr4 (const char *annex,
     return -2;
 
   if (current_thread == NULL
-      || !the_target->pt->supports_qxfer_libraries_svr4 ())
+      || !the_target->supports_qxfer_libraries_svr4 ())
     return -1;
 
-  return the_target->pt->qxfer_libraries_svr4 (annex, readbuf, writebuf,
-					       offset, len);
+  return the_target->qxfer_libraries_svr4 (annex, readbuf, writebuf,
+					   offset, len);
 }
 
 /* Handle qXfer:osadata:read.  */
@@ -1589,10 +1589,10 @@ handle_qxfer_osdata (const char *annex,
 		     gdb_byte *readbuf, const gdb_byte *writebuf,
 		     ULONGEST offset, LONGEST len)
 {
-  if (!the_target->pt->supports_qxfer_osdata () || writebuf != NULL)
+  if (!the_target->supports_qxfer_osdata () || writebuf != NULL)
     return -2;
 
-  return the_target->pt->qxfer_osdata (annex, readbuf, NULL, offset, len);
+  return the_target->qxfer_osdata (annex, readbuf, NULL, offset, len);
 }
 
 /* Handle qXfer:siginfo:read and qXfer:siginfo:write.  */
@@ -1602,13 +1602,13 @@ handle_qxfer_siginfo (const char *annex,
 		      gdb_byte *readbuf, const gdb_byte *writebuf,
 		      ULONGEST offset, LONGEST len)
 {
-  if (!the_target->pt->supports_qxfer_siginfo ())
+  if (!the_target->supports_qxfer_siginfo ())
     return -2;
 
   if (annex[0] != '\0' || current_thread == NULL)
     return -1;
 
-  return the_target->pt->qxfer_siginfo (annex, readbuf, writebuf, offset, len);
+  return the_target->qxfer_siginfo (annex, readbuf, writebuf, offset, len);
 }
 
 /* Handle qXfer:statictrace:read.  */
@@ -1794,13 +1794,13 @@ static int
 handle_qxfer_fdpic (const char *annex, gdb_byte *readbuf,
 		    const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
 {
-  if (!the_target->pt->supports_read_loadmap ())
+  if (!the_target->supports_read_loadmap ())
     return -2;
 
   if (current_thread == NULL)
     return -1;
 
-  return the_target->pt->read_loadmap (annex, offset, readbuf, len);
+  return the_target->read_loadmap (annex, offset, readbuf, len);
 }
 
 /* Handle qXfer:btrace:read.  */
@@ -2195,7 +2195,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 	tracepoint_look_up_symbols ();
 
       if (current_thread != NULL)
-	the_target->pt->look_up_symbols ();
+	the_target->look_up_symbols ();
 
       current_thread = save_thread;
 
@@ -2236,13 +2236,13 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 	}
     }
 
-  if (the_target->pt->supports_read_offsets ()
+  if (the_target->supports_read_offsets ()
       && strcmp ("qOffsets", own_buf) == 0)
     {
       CORE_ADDR text, data;
 
       require_running_or_return (own_buf);
-      if (the_target->pt->read_offsets (&text, &data))
+      if (the_target->read_offsets (&text, &data))
 	sprintf (own_buf, "Text=%lX;Data=%lX;Bss=%lX",
 		 (long)text, (long)data, (long)data);
       else
@@ -2366,7 +2366,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (target_supports_catch_syscall ())
 	strcat (own_buf, ";QCatchSyscalls+");
 
-      if (the_target->pt->supports_qxfer_libraries_svr4 ())
+      if (the_target->supports_qxfer_libraries_svr4 ())
 	strcat (own_buf, ";qXfer:libraries-svr4:read+"
 		";augmented-libraries-svr4-read+");
       else
@@ -2376,13 +2376,13 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 	  strcat (own_buf, ";qXfer:libraries:read+");
 	}
 
-      if (the_target->pt->supports_read_auxv ())
+      if (the_target->supports_read_auxv ())
 	strcat (own_buf, ";qXfer:auxv:read+");
 
-      if (the_target->pt->supports_qxfer_siginfo ())
+      if (the_target->supports_qxfer_siginfo ())
 	strcat (own_buf, ";qXfer:siginfo:read+;qXfer:siginfo:write+");
 
-      if (the_target->pt->supports_read_loadmap ())
+      if (the_target->supports_read_loadmap ())
 	strcat (own_buf, ";qXfer:fdpic:read+");
 
       /* We always report qXfer:features:read, as targets may
@@ -2394,7 +2394,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (cs.transport_is_reliable)
 	strcat (own_buf, ";QStartNoAckMode+");
 
-      if (the_target->pt->supports_qxfer_osdata ())
+      if (the_target->supports_qxfer_osdata ())
 	strcat (own_buf, ";qXfer:osdata:read+");
 
       if (target_supports_multi_process ())
@@ -2452,7 +2452,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (target_supports_stopped_by_hw_breakpoint ())
 	strcat (own_buf, ";hwbreak+");
 
-      if (the_target->pt->supports_pid_to_exec_file ())
+      if (the_target->supports_pid_to_exec_file ())
 	strcat (own_buf, ";qXfer:exec-file:read+");
 
       strcat (own_buf, ";vContSupported+");
@@ -2469,7 +2469,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
     }
 
   /* Thread-local storage support.  */
-  if (the_target->pt->supports_get_tls_address ()
+  if (the_target->supports_get_tls_address ()
       && startswith (own_buf, "qGetTLSAddr:"))
     {
       char *p = own_buf + 12;
@@ -2515,8 +2515,8 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 	  if (thread == NULL)
 	    err = 2;
 	  else
-	    err = the_target->pt->get_tls_address (thread, parts[0], parts[1],
-						   &address);
+	    err = the_target->get_tls_address (thread, parts[0], parts[1],
+					       &address);
 	}
 
       if (err == 0)
@@ -2534,7 +2534,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
     }
 
   /* Windows OS Thread Information Block address support.  */
-  if (the_target->pt->supports_get_tib_address ()
+  if (the_target->supports_get_tib_address ()
       && startswith (own_buf, "qGetTIBAddr:"))
     {
       const char *annex;
@@ -2542,7 +2542,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       CORE_ADDR tlb;
       ptid_t ptid = read_ptid (own_buf + 12, &annex);
 
-      n = the_target->pt->get_tib_address (ptid, &tlb);
+      n = the_target->get_tib_address (ptid, &tlb);
       if (n == 1)
 	{
 	  strcpy (own_buf, paddress(tlb));
@@ -2579,7 +2579,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
 
       write_ok (own_buf);
 
-      if (the_target->pt->handle_monitor_command (mon) == 0)
+      if (the_target->handle_monitor_command (mon) == 0)
 	/* Default processing.  */
 	handle_monitor_command (mon, own_buf);
 
@@ -2848,7 +2848,7 @@ resume (struct thread_resume *actions, size_t num_actions)
       enable_async_io ();
     }
 
-  the_target->pt->resume (actions, num_actions);
+  the_target->resume (actions, num_actions);
 
   if (non_stop)
     write_ok (cs.own_buf);
@@ -3089,7 +3089,7 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
     {
       if (strcmp (own_buf, "vCtrlC") == 0)
 	{
-	  the_target->pt->request_interrupt ();
+	  the_target->request_interrupt ();
 	  write_ok (own_buf);
 	  return;
 	}
@@ -3219,7 +3219,7 @@ queue_stop_reply_callback (thread_info *thread)
 {
   /* For now, assume targets that don't have this callback also don't
      manage the thread's last_status field.  */
-  if (!the_target->pt->supports_thread_stopped ())
+  if (!the_target->supports_thread_stopped ())
     {
       struct vstop_notif *new_notif = new struct vstop_notif;
 
@@ -3886,7 +3886,7 @@ captured_main (int argc, char *argv[])
 		     down without informing GDB.  */
 		  if (!non_stop)
 		    {
-		      if (the_target->pt->start_non_stop (true))
+		      if (the_target->start_non_stop (true))
 			non_stop = 1;
 
 		      /* Detaching implicitly resumes all threads;
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index d0a7d36c868..b5190e1f52a 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -62,7 +62,7 @@ prepare_to_access_memory (void)
      it.  */
   prev_general_thread = cs.general_thread;
 
-  int res = the_target->pt->prepare_to_access_memory ();
+  int res = the_target->prepare_to_access_memory ();
   if (res != 0)
     return res;
 
@@ -70,7 +70,7 @@ prepare_to_access_memory (void)
     {
       if (mythread_alive (thread->id))
 	{
-	  if (stopped == NULL && the_target->pt->supports_thread_stopped ()
+	  if (stopped == NULL && the_target->supports_thread_stopped ()
 	      && target_thread_stopped (thread))
 	    stopped = thread;
 
@@ -114,7 +114,7 @@ done_accessing_memory (void)
 {
   client_state &cs = get_client_state ();
 
-  the_target->pt->done_accessing_memory ();
+  the_target->done_accessing_memory ();
 
   /* Restore the previous selected thread.  */
   cs.general_thread = prev_general_thread;
@@ -125,7 +125,7 @@ int
 read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
 {
   int res;
-  res = the_target->pt->read_memory (memaddr, myaddr, len);
+  res = the_target->read_memory (memaddr, myaddr, len);
   check_mem_read (memaddr, myaddr, len);
   return res;
 }
@@ -156,7 +156,7 @@ target_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr,
      update it.  */
   gdb::byte_vector buffer (myaddr, myaddr + len);
   check_mem_write (memaddr, buffer.data (), myaddr, len);
-  return the_target->pt->write_memory (memaddr, buffer.data (), len);
+  return the_target->write_memory (memaddr, buffer.data (), len);
 }
 
 ptid_t
@@ -210,7 +210,7 @@ target_stop_and_wait (ptid_t ptid)
   resume_info.thread = ptid;
   resume_info.kind = resume_stop;
   resume_info.sig = GDB_SIGNAL_0;
-  the_target->pt->resume (&resume_info, 1);
+  the_target->resume (&resume_info, 1);
 
   non_stop = true;
   mywait (ptid, &status, 0, 0);
@@ -222,7 +222,7 @@ target_stop_and_wait (ptid_t ptid)
 ptid_t
 target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 {
-  return the_target->pt->wait (ptid, status, options);
+  return the_target->wait (ptid, status, options);
 }
 
 /* See target/target.h.  */
@@ -230,7 +230,7 @@ target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
 void
 target_mourn_inferior (ptid_t ptid)
 {
-  the_target->pt->mourn (find_process_pid (ptid.pid ()));
+  the_target->mourn (find_process_pid (ptid.pid ()));
 }
 
 /* See target/target.h.  */
@@ -243,7 +243,7 @@ target_continue_no_signal (ptid_t ptid)
   resume_info.thread = ptid;
   resume_info.kind = resume_continue;
   resume_info.sig = GDB_SIGNAL_0;
-  the_target->pt->resume (&resume_info, 1);
+  the_target->resume (&resume_info, 1);
 }
 
 /* See target/target.h.  */
@@ -256,7 +256,7 @@ target_continue (ptid_t ptid, enum gdb_signal signal)
   resume_info.thread = ptid;
   resume_info.kind = resume_continue;
   resume_info.sig = gdb_signal_to_host (signal);
-  the_target->pt->resume (&resume_info, 1);
+  the_target->resume (&resume_info, 1);
 }
 
 /* See target/target.h.  */
@@ -264,7 +264,7 @@ target_continue (ptid_t ptid, enum gdb_signal signal)
 int
 target_supports_multi_process (void)
 {
-  return the_target->pt->supports_multi_process ();
+  return the_target->supports_multi_process ();
 }
 
 void
@@ -302,7 +302,7 @@ kill_inferior (process_info *proc)
 {
   gdb_agent_about_to_close (proc->pid);
 
-  return the_target->pt->kill (proc);
+  return the_target->kill (proc);
 }
 
 /* Define it.  */
@@ -357,177 +357,183 @@ target_terminal::info (const char *arg, int from_tty)
    See target.h for definitions.  */
 
 void
-process_target::post_create_inferior ()
+process_stratum_target::post_create_inferior ()
 {
   /* Nop.  */
 }
 
 int
-process_target::prepare_to_access_memory ()
+process_stratum_target::prepare_to_access_memory ()
 {
   return 0;
 }
 
 void
-process_target::done_accessing_memory ()
+process_stratum_target::done_accessing_memory ()
 {
   /* Nop.  */
 }
 
 void
-process_target::look_up_symbols ()
+process_stratum_target::look_up_symbols ()
 {
   /* Nop.  */
 }
 
 bool
-process_target::supports_read_auxv ()
+process_stratum_target::supports_read_auxv ()
 {
   return false;
 }
 
 int
-process_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
-			   unsigned int len)
+process_stratum_target::read_auxv (CORE_ADDR offset, unsigned char *myaddr,
+				   unsigned int len)
 {
   gdb_assert_not_reached ("target op read_auxv not supported");
 }
 
 bool
-process_target::supports_z_point_type (char z_type)
+process_stratum_target::supports_z_point_type (char z_type)
 {
   return false;
 }
 
 int
-process_target::insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
-			      int size, raw_breakpoint *bp)
+process_stratum_target::insert_point (enum raw_bkpt_type type,
+				      CORE_ADDR addr,
+				      int size, raw_breakpoint *bp)
 {
   return 1;
 }
 
 int
-process_target::remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
-			      int size, raw_breakpoint *bp)
+process_stratum_target::remove_point (enum raw_bkpt_type type,
+				      CORE_ADDR addr,
+				      int size, raw_breakpoint *bp)
 {
   return 1;
 }
 
 bool
-process_target::stopped_by_sw_breakpoint ()
+process_stratum_target::stopped_by_sw_breakpoint ()
 {
   return false;
 }
 
 bool
-process_target::supports_stopped_by_sw_breakpoint ()
+process_stratum_target::supports_stopped_by_sw_breakpoint ()
 {
   return false;
 }
 
 bool
-process_target::stopped_by_hw_breakpoint ()
+process_stratum_target::stopped_by_hw_breakpoint ()
 {
   return false;
 }
 
 bool
-process_target::supports_stopped_by_hw_breakpoint ()
+process_stratum_target::supports_stopped_by_hw_breakpoint ()
 {
   return false;
 }
 
 bool
-process_target::supports_hardware_single_step ()
+process_stratum_target::supports_hardware_single_step ()
 {
   return false;
 }
 
 bool
-process_target::stopped_by_watchpoint ()
+process_stratum_target::stopped_by_watchpoint ()
 {
   return false;
 }
 
 CORE_ADDR
-process_target::stopped_data_address ()
+process_stratum_target::stopped_data_address ()
 {
   return 0;
 }
 
 bool
-process_target::supports_read_offsets ()
+process_stratum_target::supports_read_offsets ()
 {
   return false;
 }
 
 int
-process_target::read_offsets (CORE_ADDR *text, CORE_ADDR *data)
+process_stratum_target::read_offsets (CORE_ADDR *text, CORE_ADDR *data)
 {
   gdb_assert_not_reached ("target op read_offsets not supported");
 }
 
 bool
-process_target::supports_get_tls_address ()
+process_stratum_target::supports_get_tls_address ()
 {
   return false;
 }
 
 int
-process_target::get_tls_address (thread_info *thread, CORE_ADDR offset,
-				 CORE_ADDR load_module, CORE_ADDR *address)
+process_stratum_target::get_tls_address (thread_info *thread,
+					 CORE_ADDR offset,
+					 CORE_ADDR load_module,
+					 CORE_ADDR *address)
 {
   gdb_assert_not_reached ("target op get_tls_address not supported");
 }
 
 void
-process_target::hostio_last_error (char *buf)
+process_stratum_target::hostio_last_error (char *buf)
 {
   hostio_last_error_from_errno (buf);
 }
 
 bool
-process_target::supports_qxfer_osdata ()
+process_stratum_target::supports_qxfer_osdata ()
 {
   return false;
 }
 
 int
-process_target::qxfer_osdata (const char *annex, unsigned char *readbuf,
-			      unsigned const char *writebuf,
-			      CORE_ADDR offset, int len)
+process_stratum_target::qxfer_osdata (const char *annex,
+				      unsigned char *readbuf,
+				      unsigned const char *writebuf,
+				      CORE_ADDR offset, int len)
 {
   gdb_assert_not_reached ("target op qxfer_osdata not supported");
 }
 
 bool
-process_target::supports_qxfer_siginfo ()
+process_stratum_target::supports_qxfer_siginfo ()
 {
   return false;
 }
 
 int
-process_target::qxfer_siginfo (const char *annex, unsigned char *readbuf,
-			       unsigned const char *writebuf,
-			       CORE_ADDR offset, int len)
+process_stratum_target::qxfer_siginfo (const char *annex,
+				       unsigned char *readbuf,
+				       unsigned const char *writebuf,
+				       CORE_ADDR offset, int len)
 {
   gdb_assert_not_reached ("target op qxfer_siginfo not supported");
 }
 
 bool
-process_target::supports_non_stop ()
+process_stratum_target::supports_non_stop ()
 {
   return false;
 }
 
 bool
-process_target::async (bool enable)
+process_stratum_target::async (bool enable)
 {
   return false;
 }
 
 int
-process_target::start_non_stop (bool enable)
+process_stratum_target::start_non_stop (bool enable)
 {
   if (enable)
     return -1;
@@ -536,134 +542,136 @@ process_target::start_non_stop (bool enable)
 }
 
 bool
-process_target::supports_multi_process ()
+process_stratum_target::supports_multi_process ()
 {
   return false;
 }
 
 bool
-process_target::supports_fork_events ()
+process_stratum_target::supports_fork_events ()
 {
   return false;
 }
 
 bool
-process_target::supports_vfork_events ()
+process_stratum_target::supports_vfork_events ()
 {
   return false;
 }
 
 bool
-process_target::supports_exec_events ()
+process_stratum_target::supports_exec_events ()
 {
   return false;
 }
 
 void
-process_target::handle_new_gdb_connection ()
+process_stratum_target::handle_new_gdb_connection ()
 {
   /* Nop.  */
 }
 
 int
-process_target::handle_monitor_command (char *mon)
+process_stratum_target::handle_monitor_command (char *mon)
 {
   return 0;
 }
 
 int
-process_target::core_of_thread (ptid_t ptid)
+process_stratum_target::core_of_thread (ptid_t ptid)
 {
   return -1;
 }
 
 bool
-process_target::supports_read_loadmap ()
+process_stratum_target::supports_read_loadmap ()
 {
   return false;
 }
 
 int
-process_target::read_loadmap (const char *annex, CORE_ADDR offset,
-			      unsigned char *myaddr, unsigned int len)
+process_stratum_target::read_loadmap (const char *annex,
+				      CORE_ADDR offset,
+				      unsigned char *myaddr,
+				      unsigned int len)
 {
   gdb_assert_not_reached ("target op read_loadmap not supported");
 }
 
 void
-process_target::process_qsupported (char **features, int count)
+process_stratum_target::process_qsupported (char **features, int count)
 {
   /* Nop.  */
 }
 
 bool
-process_target::supports_tracepoints ()
+process_stratum_target::supports_tracepoints ()
 {
   return false;
 }
 
 CORE_ADDR
-process_target::read_pc (regcache *regcache)
+process_stratum_target::read_pc (regcache *regcache)
 {
   gdb_assert_not_reached ("process_target::read_pc: Unable to find PC");
 }
 
 void
-process_target::write_pc (regcache *regcache, CORE_ADDR pc)
+process_stratum_target::write_pc (regcache *regcache, CORE_ADDR pc)
 {
   gdb_assert_not_reached ("process_target::write_pc: Unable to update PC");
 }
 
 bool
-process_target::supports_thread_stopped ()
+process_stratum_target::supports_thread_stopped ()
 {
   return false;
 }
 
 bool
-process_target::thread_stopped (thread_info *thread)
+process_stratum_target::thread_stopped (thread_info *thread)
 {
   gdb_assert_not_reached ("target op thread_stopped not supported");
 }
 
 bool
-process_target::supports_get_tib_address ()
+process_stratum_target::supports_get_tib_address ()
 {
   return false;
 }
 
 int
-process_target::get_tib_address (ptid_t ptid, CORE_ADDR *address)
+process_stratum_target::get_tib_address (ptid_t ptid, CORE_ADDR *address)
 {
   gdb_assert_not_reached ("target op get_tib_address not supported");
 }
 
 void
-process_target::pause_all (bool freeze)
+process_stratum_target::pause_all (bool freeze)
 {
   /* Nop.  */
 }
 
 void
-process_target::unpause_all (bool unfreeze)
+process_stratum_target::unpause_all (bool unfreeze)
 {
   /* Nop.  */
 }
 
 void
-process_target::stabilize_threads ()
+process_stratum_target::stabilize_threads ()
 {
   /* Nop.  */
 }
 
 bool
-process_target::supports_fast_tracepoints ()
+process_stratum_target::supports_fast_tracepoints ()
 {
   return false;
 }
 
 int
-process_target::install_fast_tracepoint_jump_pad
+process_stratum_target::install_fast_tracepoint_jump_pad
   (CORE_ADDR tpoint, CORE_ADDR tpaddr, CORE_ADDR collector,
    CORE_ADDR lockaddr, ULONGEST orig_size, CORE_ADDR *jump_entry,
    CORE_ADDR *trampoline, ULONGEST *trampoline_size,
@@ -676,58 +684,58 @@ process_target::install_fast_tracepoint_jump_pad
 }
 
 int
-process_target::get_min_fast_tracepoint_insn_len ()
+process_stratum_target::get_min_fast_tracepoint_insn_len ()
 {
   return 0;
 }
 
 struct emit_ops *
-process_target::emit_ops ()
+process_stratum_target::emit_ops ()
 {
   return nullptr;
 }
 
 bool
-process_target::supports_disable_randomization ()
+process_stratum_target::supports_disable_randomization ()
 {
   return false;
 }
 
 bool
-process_target::supports_qxfer_libraries_svr4 ()
+process_stratum_target::supports_qxfer_libraries_svr4 ()
 {
   return false;
 }
 
 int
-process_target::qxfer_libraries_svr4 (const char *annex,
-				      unsigned char *readbuf,
-				      unsigned const char *writebuf,
-				      CORE_ADDR offset, int len)
+process_stratum_target::qxfer_libraries_svr4 (const char *annex,
+					      unsigned char *readbuf,
+					      unsigned const char *writebuf,
+					      CORE_ADDR offset, int len)
 {
   gdb_assert_not_reached ("target op qxfer_libraries_svr4 not supported");
 }
 
 bool
-process_target::supports_agent ()
+process_stratum_target::supports_agent ()
 {
   return false;
 }
 
 btrace_target_info *
-process_target::enable_btrace (ptid_t ptid, const btrace_config *conf)
+process_stratum_target::enable_btrace (ptid_t ptid, const btrace_config *conf)
 {
   error (_("Target does not support branch tracing."));
 }
 
 int
-process_target::disable_btrace (btrace_target_info *tinfo)
+process_stratum_target::disable_btrace (btrace_target_info *tinfo)
 {
   error (_("Target does not support branch tracing."));
 }
 
 int
-process_target::read_btrace (btrace_target_info *tinfo,
+process_stratum_target::read_btrace (btrace_target_info *tinfo,
 			     buffer *buffer,
 			     enum btrace_read_type type)
 {
@@ -735,58 +743,58 @@ process_target::read_btrace (btrace_target_info *tinfo,
 }
 
 int
-process_target::read_btrace_conf (const btrace_target_info *tinfo,
-				  buffer *buffer)
+process_stratum_target::read_btrace_conf (const btrace_target_info *tinfo,
+					  buffer *buffer)
 {
   error (_("Target does not support branch tracing."));
 }
 
 bool
-process_target::supports_range_stepping ()
+process_stratum_target::supports_range_stepping ()
 {
   return false;
 }
 
 bool
-process_target::supports_pid_to_exec_file ()
+process_stratum_target::supports_pid_to_exec_file ()
 {
   return false;
 }
 
 char *
-process_target::pid_to_exec_file (int pid)
+process_stratum_target::pid_to_exec_file (int pid)
 {
   gdb_assert_not_reached ("target op pid_to_exec_file not supported");
 }
 
 bool
-process_target::supports_multifs ()
+process_stratum_target::supports_multifs ()
 {
   return false;
 }
 
 int
-process_target::multifs_open (int pid, const char *filename,
-			      int flags, mode_t mode)
+process_stratum_target::multifs_open (int pid, const char *filename,
+				      int flags, mode_t mode)
 {
   return open (filename, flags, mode);
 }
 
 int
-process_target::multifs_unlink (int pid, const char *filename)
+process_stratum_target::multifs_unlink (int pid, const char *filename)
 {
   return unlink (filename);
 }
 
 ssize_t
-process_target::multifs_readlink (int pid, const char *filename,
-				  char *buf, size_t bufsiz)
+process_stratum_target::multifs_readlink (int pid, const char *filename,
+					  char *buf, size_t bufsiz)
 {
   return readlink (filename, buf, bufsiz);
 }
 
 int
-process_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
+process_stratum_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
 {
   /* The default behavior is to use the size of a breakpoint as the
      kind.  */
@@ -796,38 +804,38 @@ process_target::breakpoint_kind_from_pc (CORE_ADDR *pcptr)
 }
 
 int
-process_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
+process_stratum_target::breakpoint_kind_from_current_state (CORE_ADDR *pcptr)
 {
   return breakpoint_kind_from_pc (pcptr);
 }
 
 const char *
-process_target::thread_name (ptid_t thread)
+process_stratum_target::thread_name (ptid_t thread)
 {
   return nullptr;
 }
 
 bool
-process_target::thread_handle (ptid_t ptid, gdb_byte **handle,
-			       int *handle_len)
+process_stratum_target::thread_handle (ptid_t ptid, gdb_byte **handle,
+				       int *handle_len)
 {
   return false;
 }
 
 bool
-process_target::supports_software_single_step ()
+process_stratum_target::supports_software_single_step ()
 {
   return false;
 }
 
 bool
-process_target::supports_catch_syscall ()
+process_stratum_target::supports_catch_syscall ()
 {
   return false;
 }
 
 int
-process_target::get_ipa_tdesc_idx ()
+process_stratum_target::get_ipa_tdesc_idx ()
 {
   return 0;
 }
diff --git a/gdbserver/target.h b/gdbserver/target.h
index f6976303ee0..701c8ef8767 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -63,22 +63,15 @@ struct thread_resume
   CORE_ADDR step_range_end;	/* Exclusive */
 };
 
-class process_target;
-
 /* GDBserver doesn't have a concept of strata like GDB, but we call
    its target vector "process_stratum" anyway for the benefit of
    shared code.  */
-struct process_stratum_target
-{
-  /* The object that will gradually replace this struct.  */
-  process_target *pt;
-};
 
-class process_target
+class process_stratum_target
 {
 public:
 
-  virtual ~process_target () = default;
+  virtual ~process_stratum_target () = default;
 
   /* Start a new process.
 
@@ -511,78 +504,78 @@ extern process_stratum_target *the_target;
 void set_target_ops (process_stratum_target *);
 
 #define target_create_inferior(program, program_args)	\
-  the_target->pt->create_inferior (program, program_args)
+  the_target->create_inferior (program, program_args)
 
 #define target_post_create_inferior()			 \
-  the_target->pt->post_create_inferior ()
+  the_target->post_create_inferior ()
 
 #define myattach(pid) \
-  the_target->pt->attach (pid)
+  the_target->attach (pid)
 
 int kill_inferior (process_info *proc);
 
 #define target_supports_fork_events() \
-  the_target->pt->supports_fork_events ()
+  the_target->supports_fork_events ()
 
 #define target_supports_vfork_events() \
-  the_target->pt->supports_vfork_events ()
+  the_target->supports_vfork_events ()
 
 #define target_supports_exec_events() \
-  the_target->pt->supports_exec_events ()
+  the_target->supports_exec_events ()
 
 #define target_handle_new_gdb_connection()		 \
-  the_target->pt->handle_new_gdb_connection ()
+  the_target->handle_new_gdb_connection ()
 
 #define detach_inferior(proc) \
-  the_target->pt->detach (proc)
+  the_target->detach (proc)
 
 #define mythread_alive(pid) \
-  the_target->pt->thread_alive (pid)
+  the_target->thread_alive (pid)
 
 #define fetch_inferior_registers(regcache, regno)	\
-  the_target->pt->fetch_registers (regcache, regno)
+  the_target->fetch_registers (regcache, regno)
 
 #define store_inferior_registers(regcache, regno) \
-  the_target->pt->store_registers (regcache, regno)
+  the_target->store_registers (regcache, regno)
 
 #define join_inferior(pid) \
-  the_target->pt->join (pid)
+  the_target->join (pid)
 
 #define target_supports_non_stop() \
-  the_target->pt->supports_non_stop ()
+  the_target->supports_non_stop ()
 
 #define target_async(enable) \
-  the_target->pt->async (enable)
+  the_target->async (enable)
 
 #define target_process_qsupported(features, count)	\
-  the_target->pt->process_qsupported (features, count)
+  the_target->process_qsupported (features, count)
 
 #define target_supports_catch_syscall()              	\
-  the_target->pt->supports_catch_syscall ()
+  the_target->supports_catch_syscall ()
 
 #define target_get_ipa_tdesc_idx()			\
-  the_target->pt->get_ipa_tdesc_idx ()
+  the_target->get_ipa_tdesc_idx ()
 
 #define target_supports_tracepoints()			\
-  the_target->pt->supports_tracepoints ()
+  the_target->supports_tracepoints ()
 
 #define target_supports_fast_tracepoints()		\
-  the_target->pt->supports_fast_tracepoints ()
+  the_target->supports_fast_tracepoints ()
 
 #define target_get_min_fast_tracepoint_insn_len()	\
-  the_target->pt->get_min_fast_tracepoint_insn_len ()
+  the_target->get_min_fast_tracepoint_insn_len ()
 
 #define target_thread_stopped(thread) \
-  the_target->pt->thread_stopped (thread)
+  the_target->thread_stopped (thread)
 
 #define target_pause_all(freeze)		\
-  the_target->pt->pause_all (freeze)
+  the_target->pause_all (freeze)
 
 #define target_unpause_all(unfreeze)		\
-  the_target->pt->unpause_all (unfreeze)
+  the_target->unpause_all (unfreeze)
 
 #define target_stabilize_threads()		\
-  the_target->pt->stabilize_threads ()
+  the_target->stabilize_threads ()
 
 #define target_install_fast_tracepoint_jump_pad(tpoint, tpaddr,		\
 						collector, lockaddr,	\
@@ -594,36 +587,36 @@ int kill_inferior (process_info *proc);
 						adjusted_insn_addr,	\
 						adjusted_insn_addr_end,	\
 						err)			\
-  the_target->pt->install_fast_tracepoint_jump_pad (tpoint, tpaddr,	\
-						    collector,lockaddr,	\
-						    orig_size, jump_entry, \
-						    trampoline,		\
-						    trampoline_size,	\
-						    jjump_pad_insn,	\
-						    jjump_pad_insn_size, \
-						    adjusted_insn_addr,	\
-						    adjusted_insn_addr_end, \
-						    err)
+  the_target->install_fast_tracepoint_jump_pad (tpoint, tpaddr,	\
+						collector,lockaddr,	\
+						orig_size, jump_entry,	\
+						trampoline,		\
+						trampoline_size,	\
+						jjump_pad_insn,		\
+						jjump_pad_insn_size,	\
+						adjusted_insn_addr,	\
+						adjusted_insn_addr_end, \
+						err)
 
 #define target_emit_ops() \
-  the_target->pt->emit_ops ()
+  the_target->emit_ops ()
 
 #define target_supports_disable_randomization() \
-  the_target->pt->supports_disable_randomization ()
+  the_target->supports_disable_randomization ()
 
 #define target_supports_agent() \
-  the_target->pt->supports_agent ()
+  the_target->supports_agent ()
 
 static inline struct btrace_target_info *
 target_enable_btrace (ptid_t ptid, const struct btrace_config *conf)
 {
-  return the_target->pt->enable_btrace (ptid, conf);
+  return the_target->enable_btrace (ptid, conf);
 }
 
 static inline int
 target_disable_btrace (struct btrace_target_info *tinfo)
 {
-  return the_target->pt->disable_btrace (tinfo);
+  return the_target->disable_btrace (tinfo);
 }
 
 static inline int
@@ -631,42 +624,42 @@ target_read_btrace (struct btrace_target_info *tinfo,
 		    struct buffer *buffer,
 		    enum btrace_read_type type)
 {
-  return the_target->pt->read_btrace (tinfo, buffer, type);
+  return the_target->read_btrace (tinfo, buffer, type);
 }
 
 static inline int
 target_read_btrace_conf (struct btrace_target_info *tinfo,
 			 struct buffer *buffer)
 {
-  return the_target->pt->read_btrace_conf (tinfo, buffer);
+  return the_target->read_btrace_conf (tinfo, buffer);
 }
 
 #define target_supports_range_stepping() \
-  the_target->pt->supports_range_stepping ()
+  the_target->supports_range_stepping ()
 
 #define target_supports_stopped_by_sw_breakpoint() \
-  the_target->pt->supports_stopped_by_sw_breakpoint ()
+  the_target->supports_stopped_by_sw_breakpoint ()
 
 #define target_stopped_by_sw_breakpoint() \
-  the_target->pt->stopped_by_sw_breakpoint ()
+  the_target->stopped_by_sw_breakpoint ()
 
 #define target_supports_stopped_by_hw_breakpoint() \
-  the_target->pt->supports_stopped_by_hw_breakpoint ()
+  the_target->supports_stopped_by_hw_breakpoint ()
 
 #define target_supports_hardware_single_step() \
-  the_target->pt->supports_hardware_single_step ()
+  the_target->supports_hardware_single_step ()
 
 #define target_stopped_by_hw_breakpoint() \
-  the_target->pt->stopped_by_hw_breakpoint ()
+  the_target->stopped_by_hw_breakpoint ()
 
 #define target_breakpoint_kind_from_pc(pcptr) \
-  the_target->pt->breakpoint_kind_from_pc (pcptr)
+  the_target->breakpoint_kind_from_pc (pcptr)
 
 #define target_breakpoint_kind_from_current_state(pcptr) \
-  the_target->pt->breakpoint_kind_from_current_state (pcptr)
+  the_target->breakpoint_kind_from_current_state (pcptr)
 
 #define target_supports_software_single_step() \
-  the_target->pt->supports_software_single_step ()
+  the_target->supports_software_single_step ()
 
 ptid_t mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
 	       int connected_wait);
@@ -678,13 +671,13 @@ int prepare_to_access_memory (void);
 void done_accessing_memory (void);
 
 #define target_core_of_thread(ptid)		\
-  the_target->pt->core_of_thread (ptid)
+  the_target->core_of_thread (ptid)
 
 #define target_thread_name(ptid)                                \
-  the_target->pt->thread_name (ptid)
+  the_target->thread_name (ptid)
 
 #define target_thread_handle(ptid, handle, handle_len) \
-  the_target->pt->thread_handle (ptid, handle, handle_len)
+  the_target->thread_handle (ptid, handle, handle_len)
 
 int read_inferior_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len);
 
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 640252805e0..8b2a16e86dc 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -377,7 +377,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
     {
       struct target_waitstatus status;
 
-      the_target->pt->wait (minus_one_ptid, &status, 0);
+      the_target->wait (minus_one_ptid, &status, 0);
 
       /* Note win32_wait doesn't return thread events.  */
       if (status.kind != TARGET_WAITKIND_LOADED)
@@ -393,7 +393,7 @@ do_initial_child_stuff (HANDLE proch, DWORD pid, int attached)
 	resume.kind = resume_continue;
 	resume.sig = 0;
 
-	the_target->pt->resume (&resume, 1);
+	the_target->resume (&resume, 1);
       }
     }
 
@@ -1857,14 +1857,10 @@ win32_process_target::sw_breakpoint_from_kind (int kind, int *size)
 
 static win32_process_target the_win32_target;
 
-static process_stratum_target win32_target_ops = {
-  &the_win32_target,
-};
-
 /* Initialize the Win32 backend.  */
 void
 initialize_low (void)
 {
-  set_target_ops (&win32_target_ops);
+  set_target_ops (&the_win32_target);
   the_low_target.arch_setup ();
 }
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index d4c7cae3013..9d2f0b4fbec 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -103,7 +103,7 @@ extern struct win32_target_ops the_low_target;
 
 /* Target ops definitions for a Win32 target.  */
 
-class win32_process_target : public process_target
+class win32_process_target : public process_stratum_target
 {
 public:
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 50/58] gdbserver: turn target op 'pid_to_exec_file' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (49 preceding siblings ...)
  2020-02-17 17:01 ` [PATCH v2 49/58] gdbserver: turn target op 'supports_range_stepping' " Tankut Baris Aktemur
@ 2020-02-17 17:04 ` Tankut Baris Aktemur
  2020-02-17 17:04 ` [PATCH v2 48/58] gdbserver: turn btrace-related target ops into methods Tankut Baris Aktemur
                   ` (8 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's pid_to_exec_file op into a method
	of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_pid_to_exec_file'.
	* target.cc (process_target::pid_to_exec_file): Define.
	(process_target::supports_pid_to_exec_file): Define.

	Update the derived classes and callers below.

	* server.cc (handle_qxfer_exec_file): Update.
	(handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_pid_to_exec_file): Define.
	(linux_process_target::pid_to_exec_file): Define.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 13 ++++++++++++-
 gdbserver/linux-low.h  |  4 ++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  6 +++---
 gdbserver/target.cc    | 12 ++++++++++++
 gdbserver/target.h     | 19 +++++++++++--------
 gdbserver/win32-low.cc |  1 -
 8 files changed, 42 insertions(+), 15 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index e5e32006496..a3d0bd98f54 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6437,6 +6437,18 @@ linux_process_target::supports_range_stepping ()
   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);
+}
+
 #if defined PT_GETDSBT || defined PTRACE_GETFDPIC
 struct target_loadseg
 {
@@ -7467,7 +7479,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_proc_pid_to_exec_file,
   linux_mntns_open_cloexec,
   linux_mntns_unlink,
   linux_mntns_readlink,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index f47d9ed816f..af5892e767a 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -448,6 +448,10 @@ public:
 #endif
 
   bool supports_range_stepping () override;
+
+  bool supports_pid_to_exec_file () override;
+
+  char *pid_to_exec_file (int pid) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 854037a631b..5e23713cfaf 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* pid_to_exec_file */
   NULL,  /* multifs_open */
   NULL,  /* multifs_unlink */
   NULL,  /* multifs_readlink */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 3532aa460f0..9a798bf6ec1 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* pid_to_exec_file */
   NULL, /* multifs_open */
   NULL, /* multifs_unlink */
   NULL, /* multifs_readlink */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 61346e3ce5b..00456d8d7ed 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1462,7 +1462,7 @@ handle_qxfer_exec_file (const char *annex,
   ULONGEST pid;
   int total_len;
 
-  if (the_target->pid_to_exec_file == NULL || writebuf != NULL)
+  if (!the_target->pt->supports_pid_to_exec_file () || writebuf != NULL)
     return -2;
 
   if (annex[0] == '\0')
@@ -1482,7 +1482,7 @@ handle_qxfer_exec_file (const char *annex,
   if (pid <= 0)
     return -1;
 
-  file = (*the_target->pid_to_exec_file) (pid);
+  file = the_target->pt->pid_to_exec_file (pid);
   if (file == NULL)
     return -1;
 
@@ -2452,7 +2452,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (target_supports_stopped_by_hw_breakpoint ())
 	strcat (own_buf, ";hwbreak+");
 
-      if (the_target->pid_to_exec_file != NULL)
+      if (the_target->pt->supports_pid_to_exec_file ())
 	strcat (own_buf, ";qXfer:exec-file:read+");
 
       strcat (own_buf, ";vContSupported+");
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 8739ba864f8..3787e94ad55 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -759,3 +759,15 @@ process_target::supports_range_stepping ()
 {
   return false;
 }
+
+bool
+process_target::supports_pid_to_exec_file ()
+{
+  return false;
+}
+
+char *
+process_target::pid_to_exec_file (int pid)
+{
+  gdb_assert_not_reached ("target op pid_to_exec_file not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index cdb3c119433..d728646d274 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,14 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Return the full absolute name of the executable file that was
-     run to create the process PID.  If the executable file cannot
-     be determined, NULL is returned.  Otherwise, a pointer to a
-     character string containing the pathname is returned.  This
-     string should be copied into a buffer by the client if the string
-     will not be immediately used, or if it must persist.  */
-  char *(*pid_to_exec_file) (int pid);
-
   /* Multiple-filesystem-aware open.  Like open(2), but operating in
      the filesystem as it appears to process PID.  Systems where all
      processes share a common filesystem should set this to NULL.
@@ -498,6 +490,17 @@ public:
 
   /* Return true if target supports range stepping.  */
   virtual bool supports_range_stepping ();
+
+  /* Return true if the pid_to_exec_file op is supported.  */
+  virtual bool supports_pid_to_exec_file ();
+
+  /* Return the full absolute name of the executable file that was
+     run to create the process PID.  If the executable file cannot
+     be determined, NULL is returned.  Otherwise, a pointer to a
+     character string containing the pathname is returned.  This
+     string should be copied into a buffer by the client if the string
+     will not be immediately used, or if it must persist.  */
+  virtual char *pid_to_exec_file (int pid);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index b270745275f..3b1f7d33f40 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* pid_to_exec_file */
   NULL, /* multifs_open */
   NULL, /* multifs_unlink */
   NULL, /* multifs_readlink */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 41/58] gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (52 preceding siblings ...)
  2020-02-17 17:04 ` [PATCH v2 58/58] gdbserver: finish turning the target ops vector into a class Tankut Baris Aktemur
@ 2020-02-17 17:04 ` Tankut Baris Aktemur
  2020-02-17 17:05 ` [PATCH v2 36/58] gdbserver: turn target op 'process_qsupported' into a method Tankut Baris Aktemur
                   ` (5 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:04 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's pause_all and unpause_all ops
	into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(pause_all): Update the macro and rename to...
	(target_pause_all): ... this.
	(unpause_all): Update the macro and rename to...
	(target_unpause_all): ... this.
	* target.cc (process_target::pause_all): Define.
	(process_target::unpause_all): Define.

	Update the derived classes and callers below.

	* server.cc (handle_status): Update.
	* tracepoint.cc (clear_installed_tracepoints): Update.
	(cmd_qtdp): Update.
	(cmd_qtstart): Update.
	(stop_tracing): Update.
	(cmd_qtstatus): Update.
	(upload_fast_traceframes): Update.
	(run_inferior_command): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_pause_all): Turn into ...
	(linux_process_target::pause_all): ... this.
	(linux_unpause_all): Turn into ...
	(linux_process_target::unpause_all): ... this.
	(linux_process_target::prepare_to_access_memory): Update.
	(linux_process_target::done_accessing_memory): Update.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc  | 14 ++++++--------
 gdbserver/linux-low.h   |  4 ++++
 gdbserver/lynx-low.cc   |  2 --
 gdbserver/nto-low.cc    |  2 --
 gdbserver/server.cc     |  2 +-
 gdbserver/target.cc     | 12 ++++++++++++
 gdbserver/target.h      | 40 ++++++++++++++++------------------------
 gdbserver/tracepoint.cc | 34 +++++++++++++++++-----------------
 gdbserver/win32-low.cc  |  2 --
 9 files changed, 56 insertions(+), 56 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index c75d4ba9707..97a8aa46f5a 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6582,8 +6582,8 @@ linux_process_target::thread_stopped (thread_info *thread)
 
 /* This exposes stop-all-threads functionality to other modules.  */
 
-static void
-linux_pause_all (int freeze)
+void
+linux_process_target::pause_all (bool freeze)
 {
   stop_all_lwps (freeze, NULL);
 }
@@ -6591,8 +6591,8 @@ linux_pause_all (int freeze)
 /* This exposes unstop-all-threads functionality to other gdbserver
    modules.  */
 
-static void
-linux_unpause_all (int unfreeze)
+void
+linux_process_target::unpause_all (bool unfreeze)
 {
   unstop_all_lwps (unfreeze, NULL);
 }
@@ -6603,7 +6603,7 @@ linux_process_target::prepare_to_access_memory ()
   /* Neither ptrace nor /proc/PID/mem allow accessing memory through a
      running LWP.  */
   if (non_stop)
-    linux_pause_all (1);
+    target_pause_all (true);
   return 0;
 }
 
@@ -6613,7 +6613,7 @@ linux_process_target::done_accessing_memory ()
   /* Neither ptrace nor /proc/PID/mem allow accessing memory through a
      running LWP.  */
   if (non_stop)
-    linux_unpause_all (1);
+    target_unpause_all (true);
 }
 
 static int
@@ -7451,8 +7451,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_pause_all,
-  linux_unpause_all,
   linux_stabilize_threads,
   linux_install_fast_tracepoint_jump_pad,
   linux_emit_ops,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index cbb2f48e135..e5d54c5e08d 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -396,6 +396,10 @@ public:
   bool supports_thread_stopped () override;
 
   bool thread_stopped (thread_info *thread) override;
+
+  void pause_all (bool freeze) override;
+
+  void unpause_all (bool unfreeze) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 9f96faf802c..92c086d97c3 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,8 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* pause_all */
-  NULL,  /* unpause_all */
   NULL,  /* stabilize_threads */
   NULL,  /* install_fast_tracepoint_jump_pad */
   NULL,  /* emit_ops */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 08f73fa3871..ee411a1e375 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,8 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* pause_all */
-  NULL, /* unpause_all */
   NULL, /* stabilize_threads */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 77155935fab..670c0fed968 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -3323,7 +3323,7 @@ handle_status (char *own_buf)
     {
       thread_info *thread = NULL;
 
-      pause_all (0);
+      target_pause_all (false);
       stabilize_threads ();
       gdb_wants_all_threads_stopped ();
 
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 680addadf78..912f4b8bdad 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -650,3 +650,15 @@ process_target::get_tib_address (ptid_t ptid, CORE_ADDR *address)
 {
   gdb_assert_not_reached ("target op get_tib_address not supported");
 }
+
+void
+process_target::pause_all (bool freeze)
+{
+  /* Nop.  */
+}
+
+void
+process_target::unpause_all (bool unfreeze)
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 4da15a06734..60fb14f69e6 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,18 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Pause all threads.  If FREEZE, arrange for any resume attempt to
-     be ignored until an unpause_all call unfreezes threads again.
-     There can be nested calls to pause_all, so a freeze counter
-     should be maintained.  */
-  void (*pause_all) (int freeze);
-
-  /* Unpause all threads.  Threads that hadn't been resumed by the
-     client should be left stopped.  Basically a pause/unpause call
-     pair should not end up resuming threads that were stopped before
-     the pause call.  */
-  void (*unpause_all) (int unfreeze);
-
   /* Stabilize all threads.  That is, force them out of jump pads.  */
   void (*stabilize_threads) (void);
 
@@ -494,6 +482,18 @@ public:
 
   /* Read Thread Information Block address.  */
   virtual int get_tib_address (ptid_t ptid, CORE_ADDR *address);
+
+  /* Pause all threads.  If FREEZE, arrange for any resume attempt to
+     be ignored until an unpause_all call unfreezes threads again.
+     There can be nested calls to pause_all, so a freeze counter
+     should be maintained.  */
+  virtual void pause_all (bool freeze);
+
+  /* Unpause all threads.  Threads that hadn't been resumed by the
+     client should be left stopped.  Basically a pause/unpause call
+     pair should not end up resuming threads that were stopped before
+     the pause call.  */
+  virtual void unpause_all (bool unfreeze);
 };
 
 extern process_stratum_target *the_target;
@@ -568,19 +568,11 @@ int kill_inferior (process_info *proc);
 #define target_thread_stopped(thread) \
   the_target->pt->thread_stopped (thread)
 
-#define pause_all(freeze)			\
-  do						\
-    {						\
-      if (the_target->pause_all)		\
-	(*the_target->pause_all) (freeze);	\
-    } while (0)
+#define target_pause_all(freeze)		\
+  the_target->pt->pause_all (freeze)
 
-#define unpause_all(unfreeze)			\
-  do						\
-    {						\
-      if (the_target->unpause_all)		\
-	(*the_target->unpause_all) (unfreeze);	\
-    } while (0)
+#define target_unpause_all(unfreeze)		\
+  the_target->pt->unpause_all (unfreeze)
 
 #define stabilize_threads()			\
   do						\
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index bbca48b2efd..ffa819cf24e 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -2433,7 +2433,7 @@ clear_installed_tracepoints (void)
   struct tracepoint *tpoint;
   struct tracepoint *prev_stpoint;
 
-  pause_all (1);
+  target_pause_all (true);
 
   prev_stpoint = NULL;
 
@@ -2486,7 +2486,7 @@ clear_installed_tracepoints (void)
       tpoint->handle = NULL;
     }
 
-  unpause_all (1);
+  target_unpause_all (true);
 }
 
 /* Parse a packet that defines a tracepoint.  */
@@ -2602,14 +2602,14 @@ cmd_qtdp (char *own_buf)
       struct tracepoint *tp = NULL;
 
       /* Pause all threads temporarily while we patch tracepoints.  */
-      pause_all (0);
+      target_pause_all (false);
 
       /* download_tracepoint will update global `tracepoints'
 	 list, so it is unsafe to leave threads in jump pad.  */
       stabilize_threads ();
 
       /* Freeze threads.  */
-      pause_all (1);
+      target_pause_all (true);
 
 
       if (tpoint->type != trap_tracepoint)
@@ -2658,7 +2658,7 @@ cmd_qtdp (char *own_buf)
 	    write_ok (own_buf);
 	}
 
-      unpause_all (1);
+      target_unpause_all (true);
       return;
     }
 
@@ -3220,7 +3220,7 @@ cmd_qtstart (char *packet)
   trace_debug ("Starting the trace");
 
   /* Pause all threads temporarily while we patch tracepoints.  */
-  pause_all (0);
+  target_pause_all (false);
 
   /* Get threads out of jump pads.  Safe to do here, since this is a
      top level command.  And, required to do here, since we're
@@ -3229,7 +3229,7 @@ cmd_qtstart (char *packet)
   stabilize_threads ();
 
   /* Freeze threads.  */
-  pause_all (1);
+  target_pause_all (true);
 
   /* Sync the fast tracepoints list in the inferior ftlib.  */
   if (agent_loaded_p ())
@@ -3370,7 +3370,7 @@ cmd_qtstart (char *packet)
       clear_installed_tracepoints ();
       if (*packet == '\0')
 	write_enn (packet);
-      unpause_all (1);
+      target_unpause_all (true);
       return;
     }
 
@@ -3418,7 +3418,7 @@ cmd_qtstart (char *packet)
 	error ("Error setting flush_trace_buffer breakpoint");
     }
 
-  unpause_all (1);
+  target_unpause_all (true);
 
   write_ok (packet);
 }
@@ -3445,7 +3445,7 @@ stop_tracing (void)
      when we're sure we can move all threads out of the jump pads).
      We can't now, since we may be getting here due to the inferior
      agent calling us.  */
-  pause_all (1);
+  target_pause_all (true);
 
   /* Stop logging. Tracepoints can still be hit, but they will not be
      recorded.  */
@@ -3522,7 +3522,7 @@ stop_tracing (void)
       flush_trace_buffer_bkpt = NULL;
     }
 
-  unpause_all (1);
+  target_unpause_all (true);
 }
 
 static int
@@ -3668,11 +3668,11 @@ cmd_qtstatus (char *packet)
 
   if (agent_loaded_p ())
     {
-      pause_all (1);
+      target_pause_all (true);
 
       upload_fast_traceframes ();
 
-      unpause_all (1);
+      target_unpause_all (true);
    }
 
   stop_reason_rsp = (char *) tracing_stop_reason;
@@ -6578,12 +6578,12 @@ upload_fast_traceframes (void)
 
   trace_debug ("Done uploading traceframes [%d]\n", curr_tbctrl_idx);
 
-  pause_all (1);
+  target_pause_all (true);
 
   delete_breakpoint (about_to_request_buffer_space_bkpt);
   about_to_request_buffer_space_bkpt = NULL;
 
-  unpause_all (1);
+  target_unpause_all (true);
 
   if (trace_buffer_is_full)
     stop_tracing ();
@@ -6861,13 +6861,13 @@ run_inferior_command (char *cmd, int len)
 
   trace_debug ("run_inferior_command: running: %s", cmd);
 
-  pause_all (0);
+  target_pause_all (false);
   uninsert_all_breakpoints ();
 
   err = agent_run_command (pid, (const char *) cmd, len);
 
   reinsert_all_breakpoints ();
-  unpause_all (0);
+  target_unpause_all (false);
 
   return err;
 }
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 9bffdaaf1ae..a06cea22fc8 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,8 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* pause_all */
-  NULL, /* unpause_all */
   NULL, /* stabilize_threads */
   NULL, /* install_fast_tracepoint_jump_pad */
   NULL, /* emit_ops */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 31/58] gdbserver: turn target ops 'supports_{fork,vfork,exec}_events' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (56 preceding siblings ...)
  2020-02-17 17:05 ` [PATCH v2 46/58] gdbserver: turn target op 'qxfer_libraries_svr4' into a method Tankut Baris Aktemur
@ 2020-02-17 17:05 ` Tankut Baris Aktemur
  2020-02-19  2:46 ` [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Simon Marchi
  2020-02-19 14:11 ` Pedro Alves
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's supports_fork_events,
	supports_vfork_events, and supports_exec_events ops into methods
	of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.
	(target_supports_fork_events): Update the macro.
	(target_supports_vfork_events): Update the macro.
	(target_supports_exec_events): Update the macro.
	* target.cc (process_target::supports_fork_events): Define.
	(process_target::supports_vfork_events): Define.
	(process_target::supports_exec_events): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_supports_fork_events): Turn into ...
	(linux_process_target::supports_fork_events): ... this.
	(linux_supports_vfork_events): Turn into ...
	(linux_process_target::supports_vfork_events): ... this.
	(linux_supports_exec_events): Turn into ...
	(linux_process_target::supports_exec_events): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 15 ++++++---------
 gdbserver/linux-low.h  |  6 ++++++
 gdbserver/lynx-low.cc  |  3 ---
 gdbserver/nto-low.cc   |  3 ---
 gdbserver/target.cc    | 18 ++++++++++++++++++
 gdbserver/target.h     | 27 ++++++++++++---------------
 gdbserver/win32-low.cc |  3 ---
 7 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 770cf472840..7c96b45ff16 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6342,24 +6342,24 @@ linux_process_target::supports_multi_process ()
 
 /* 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 ();
 }
@@ -7425,9 +7425,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  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,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 58730e2c0a3..f78ef78ad6f 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -365,6 +365,12 @@ public:
   int start_non_stop (bool enable) override;
 
   bool supports_multi_process () override;
+
+  bool supports_fork_events () override;
+
+  bool supports_vfork_events () override;
+
+  bool supports_exec_events () override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 897bc9e663f..088582b2609 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,9 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* supports_fork_events */
-  NULL,  /* supports_vfork_events */
-  NULL,  /* supports_exec_events */
   NULL,  /* handle_new_gdb_connection */
   NULL,  /* handle_monitor_command */
   NULL,  /* core_of_thread */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 11b290a20a3..0d1432b8bac 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,9 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* supports_fork_events */
-  NULL, /* supports_vfork_events */
-  NULL, /* supports_exec_events */
   NULL, /* handle_new_gdb_connection */
   NULL, /* handle_monitor_command */
   NULL, /* core_of_thread */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 485eecbee91..15d48427f31 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -553,3 +553,21 @@ process_target::supports_multi_process ()
 {
   return false;
 }
+
+bool
+process_target::supports_fork_events ()
+{
+  return false;
+}
+
+bool
+process_target::supports_vfork_events ()
+{
+  return false;
+}
+
+bool
+process_target::supports_exec_events ()
+{
+  return false;
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 52c80b848d0..ef2fd018463 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,15 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Returns true if fork events are supported.  */
-  int (*supports_fork_events) (void);
-
-  /* Returns true if vfork events are supported.  */
-  int (*supports_vfork_events) (void);
-
-  /* Returns true if exec events are supported.  */
-  int (*supports_exec_events) (void);
-
   /* Allows target to re-initialize connection-specific settings.  */
   void (*handle_new_gdb_connection) (void);
 
@@ -486,6 +477,15 @@ public:
 
   /* Returns true if the target supports multi-process debugging.  */
   virtual bool supports_multi_process ();
+
+  /* Returns true if fork events are supported.  */
+  virtual bool supports_fork_events ();
+
+  /* Returns true if vfork events are supported.  */
+  virtual bool supports_vfork_events ();
+
+  /* Returns true if exec events are supported.  */
+  virtual bool supports_exec_events ();
 };
 
 extern process_stratum_target *the_target;
@@ -504,16 +504,13 @@ void set_target_ops (process_stratum_target *);
 int kill_inferior (process_info *proc);
 
 #define target_supports_fork_events() \
-  (the_target->supports_fork_events ? \
-   (*the_target->supports_fork_events) () : 0)
+  the_target->pt->supports_fork_events ()
 
 #define target_supports_vfork_events() \
-  (the_target->supports_vfork_events ? \
-   (*the_target->supports_vfork_events) () : 0)
+  the_target->pt->supports_vfork_events ()
 
 #define target_supports_exec_events() \
-  (the_target->supports_exec_events ? \
-   (*the_target->supports_exec_events) () : 0)
+  the_target->pt->supports_exec_events ()
 
 #define target_handle_new_gdb_connection()		 \
   do							 \
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index ee7a0ea92a6..4cea682ee52 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,9 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* supports_fork_events */
-  NULL, /* supports_vfork_events */
-  NULL, /* supports_exec_events */
   NULL, /* handle_new_gdb_connection */
   NULL, /* handle_monitor_command */
   NULL, /* core_of_thread */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 36/58] gdbserver: turn target op 'process_qsupported' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (53 preceding siblings ...)
  2020-02-17 17:04 ` [PATCH v2 41/58] gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods Tankut Baris Aktemur
@ 2020-02-17 17:05 ` Tankut Baris Aktemur
  2020-02-17 17:05 ` [PATCH v2 51/58] gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into methods Tankut Baris Aktemur
                   ` (4 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's process_qsupported op into a method
	of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.
	(target_process_qsupported): Update the macro.
	* target.cc (process_target::process_qsupported): Define.

	Update the derived classes and callers below.

	* linux-low.cc (linux_target_ops): Update.
	(linux_process_qsupported): Turn into ...
	(linux_process_target::process_qsupported): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc |  5 ++---
 gdbserver/linux-low.h  |  2 ++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/target.cc    |  6 ++++++
 gdbserver/target.h     | 14 +++++---------
 gdbserver/win32-low.cc |  1 -
 7 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 6dd13129618..fbfb295b923 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6519,8 +6519,8 @@ linux_process_target::read_loadmap (const char *annex, CORE_ADDR offset,
 }
 #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);
@@ -7445,7 +7445,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_process_qsupported,
   linux_supports_tracepoints,
   linux_read_pc,
   linux_write_pc,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 9f4fdab33d5..5c75ae44ecd 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -384,6 +384,8 @@ public:
   int read_loadmap (const char *annex, CORE_ADDR offset,
 		    unsigned char *myaddr, unsigned int len) override;
 #endif
+
+  void process_qsupported (char **features, int count) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index b384d20a37b..c42a9b401e5 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* process_qsupported */
   NULL,  /* supports_tracepoints */
   NULL,  /* read_pc */
   NULL,  /* write_pc */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 70d218cb924..86863f67f72 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* process_qsupported */
   NULL, /* supports_tracepoints */
   NULL, /* read_pc */
   NULL, /* write_pc */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 26b9d8b6afe..49e4b01495c 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -602,3 +602,9 @@ process_target::read_loadmap (const char *annex, CORE_ADDR offset,
 {
   gdb_assert_not_reached ("target op read_loadmap not supported");
 }
+
+void
+process_target::process_qsupported (char **features, int count)
+{
+  /* Nop.  */
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index f69bd9d0e01..61f13e3a6f6 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,10 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Target specific qSupported support.  FEATURES is an array of
-     features with COUNT elements.  */
-  void (*process_qsupported) (char **features, int count);
-
   /* Return 1 if the target supports tracepoints, 0 (or leave the
      callback NULL) otherwise.  */
   int (*supports_tracepoints) (void);
@@ -489,6 +485,10 @@ public:
   /* Read loadmaps.  Read LEN bytes at OFFSET into a buffer at MYADDR.  */
   virtual int read_loadmap (const char *annex, CORE_ADDR offset,
 			    unsigned char *myaddr, unsigned int len);
+
+  /* Target specific qSupported support.  FEATURES is an array of
+     features with COUNT elements.  */
+  virtual void process_qsupported (char **features, int count);
 };
 
 extern process_stratum_target *the_target;
@@ -540,11 +540,7 @@ int kill_inferior (process_info *proc);
   the_target->pt->async (enable)
 
 #define target_process_qsupported(features, count)	\
-  do							\
-    {							\
-      if (the_target->process_qsupported)		\
-	the_target->process_qsupported (features, count); \
-    } while (0)
+  the_target->pt->process_qsupported (features, count)
 
 #define target_supports_catch_syscall()              	\
   (the_target->supports_catch_syscall ?			\
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 9fc882523b0..f068091dc98 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1852,7 +1852,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* process_qsupported */
   NULL, /* supports_tracepoints */
   NULL, /* read_pc */
   NULL, /* write_pc */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 46/58] gdbserver: turn target op 'qxfer_libraries_svr4' into a method
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (55 preceding siblings ...)
  2020-02-17 17:05 ` [PATCH v2 51/58] gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into methods Tankut Baris Aktemur
@ 2020-02-17 17:05 ` Tankut Baris Aktemur
  2020-02-17 17:05 ` [PATCH v2 31/58] gdbserver: turn target ops 'supports_{fork,vfork,exec}_events' into methods Tankut Baris Aktemur
                   ` (2 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's qxfer_libraries_svr4 op into a
	method of process_target.

	* target.h (struct process_stratum_target): Remove the target op.
	(class process_target): Add the target op.  Also add
	'supports_qxfer_libraries_svr4'.
	* target.cc (process_target::qxfer_libraries_svr4): Define.
	(process_target::supports_qxfer_libraries_svr4): Define.

	Update the derived classes and callers below.

	* server.cc (handle_qxfer_libraries_svr4): Update.
	(handle_query): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_qxfer_libraries_svr4): Define.
	(linux_qxfer_libraries_svr4): Turn into ...
	(linux_process_target::qxfer_libraries_svr4): ... this.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/linux-low.cc | 16 +++++++++++-----
 gdbserver/linux-low.h  |  7 +++++++
 gdbserver/lynx-low.cc  |  1 -
 gdbserver/nto-low.cc   |  1 -
 gdbserver/server.cc    |  8 +++++---
 gdbserver/target.cc    | 15 +++++++++++++++
 gdbserver/target.h     | 14 +++++++++-----
 gdbserver/win32-low.cc |  1 -
 8 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 72c66d647db..cab3c679d47 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6927,6 +6927,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.  */
@@ -6953,10 +6959,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];
@@ -7452,7 +7459,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  linux_qxfer_libraries_svr4,
   linux_supports_agent,
 #ifdef HAVE_LINUX_BTRACE
   linux_enable_btrace,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index ba02a06dedd..463e4e9b708 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -424,6 +424,13 @@ public:
   struct emit_ops *emit_ops () override;
 
   bool supports_disable_randomization () override;
+
+  bool supports_qxfer_libraries_svr4 () override;
+
+  int qxfer_libraries_svr4 (const char *annex,
+			    unsigned char *readbuf,
+			    unsigned const char *writebuf,
+			    CORE_ADDR offset, int len) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index b5fd49f6fa8..74e7de526f7 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,7 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* qxfer_libraries_svr4 */
   NULL,  /* support_agent */
   NULL,  /* enable_btrace */
   NULL,  /* disable_btrace */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 81436e27945..037a053183d 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,7 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
   NULL, /* enable_btrace */
   NULL, /* disable_btrace */
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 448089fd47c..61346e3ce5b 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1574,10 +1574,12 @@ handle_qxfer_libraries_svr4 (const char *annex,
   if (writebuf != NULL)
     return -2;
 
-  if (current_thread == NULL || the_target->qxfer_libraries_svr4 == NULL)
+  if (current_thread == NULL
+      || !the_target->pt->supports_qxfer_libraries_svr4 ())
     return -1;
 
-  return the_target->qxfer_libraries_svr4 (annex, readbuf, writebuf, offset, len);
+  return the_target->pt->qxfer_libraries_svr4 (annex, readbuf, writebuf,
+					       offset, len);
 }
 
 /* Handle qXfer:osadata:read.  */
@@ -2364,7 +2366,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
       if (target_supports_catch_syscall ())
 	strcat (own_buf, ";QCatchSyscalls+");
 
-      if (the_target->qxfer_libraries_svr4 != NULL)
+      if (the_target->pt->supports_qxfer_libraries_svr4 ())
 	strcat (own_buf, ";qXfer:libraries-svr4:read+"
 		";augmented-libraries-svr4-read+");
       else
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index fa9c9bbb36a..fa04bd011b5 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -705,3 +705,18 @@ process_target::supports_disable_randomization ()
 {
   return false;
 }
+
+bool
+process_target::supports_qxfer_libraries_svr4 ()
+{
+  return false;
+}
+
+int
+process_target::qxfer_libraries_svr4 (const char *annex,
+				      unsigned char *readbuf,
+				      unsigned const char *writebuf,
+				      CORE_ADDR offset, int len)
+{
+  gdb_assert_not_reached ("target op qxfer_libraries_svr4 not supported");
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 04c842d83bc..fe0a7df5794 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,11 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Read solib info on SVR4 platforms.  */
-  int (*qxfer_libraries_svr4) (const char *annex, unsigned char *readbuf,
-			       unsigned const char *writebuf,
-			       CORE_ADDR offset, int len);
-
   /* Return true if target supports debugging agent.  */
   int (*supports_agent) (void);
 
@@ -493,6 +488,15 @@ public:
 
   /* Returns true if the target supports disabling randomization.  */
   virtual bool supports_disable_randomization ();
+
+  /* Return true if the qxfer_libraries_svr4 op is supported.  */
+  virtual bool supports_qxfer_libraries_svr4 ();
+
+  /* Read solib info on SVR4 platforms.  */
+  virtual int qxfer_libraries_svr4 (const char *annex,
+				    unsigned char *readbuf,
+				    unsigned const char *writebuf,
+				    CORE_ADDR offset, int len);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 7522a54e593..54d7fde89b6 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,7 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* qxfer_libraries_svr4 */
   NULL, /* support_agent */
   NULL, /* enable_btrace */
   NULL, /* disable_btrace */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [PATCH v2 51/58] gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into methods
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (54 preceding siblings ...)
  2020-02-17 17:05 ` [PATCH v2 36/58] gdbserver: turn target op 'process_qsupported' into a method Tankut Baris Aktemur
@ 2020-02-17 17:05 ` Tankut Baris Aktemur
  2020-02-17 17:05 ` [PATCH v2 46/58] gdbserver: turn target op 'qxfer_libraries_svr4' into a method Tankut Baris Aktemur
                   ` (3 subsequent siblings)
  59 siblings, 0 replies; 66+ messages in thread
From: Tankut Baris Aktemur @ 2020-02-17 17:05 UTC (permalink / raw)
  To: gdb-patches; +Cc: palves

gdbserver/ChangeLog:
2020-02-10  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	Turn process_stratum_target's multifs_open, multifs_readlink,
	multifs_unlink ops into methods of process_target.

	* target.h (struct process_stratum_target): Remove the target ops.
	(class process_target): Add the target ops.  Also add
	'supports_multifs'.
	* target.cc: Include "fcntl.h", "unistd.h", "sys/types.h", and
	"sys/stat.h".
	(process_target::supports_multifs): Define.
	(process_target::multifs_open): Define.
	(process_target::multifs_readlink): Define.
	(process_target::multifs_unlink): Define.

	Update the derived classes and callers below.

	* hostio.cc (handle_setfs): Update.
	(handle_open): Update.
	(handle_unlink): Update.
	(handle_readlink): Update.
	* linux-low.cc (linux_target_ops): Update.
	(linux_process_target::supports_multifs): Define.
	(linux_process_target::multifs_open): Define.
	(linux_process_target::multifs_readlink): Define.
	(linux_process_target::multifs_unlink): Define.
	* linux-low.h (class linux_process_target): Update.
	* lynx-low.cc (lynx_target_ops): Update.
	* nto-low.cc (nto_target_ops): Update.
	* win32-low.cc (win32_target_ops): Update.
---
 gdbserver/hostio.cc    | 22 ++++++++++-----------
 gdbserver/linux-low.cc | 29 +++++++++++++++++++++++++---
 gdbserver/linux-low.h  | 10 ++++++++++
 gdbserver/lynx-low.cc  |  3 ---
 gdbserver/nto-low.cc   |  3 ---
 gdbserver/target.cc    | 30 ++++++++++++++++++++++++++++
 gdbserver/target.h     | 44 ++++++++++++++++++++++--------------------
 gdbserver/win32-low.cc |  3 ---
 8 files changed, 99 insertions(+), 45 deletions(-)

diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index a3b32cd0fdc..6223b24a887 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -272,9 +272,7 @@ handle_setfs (char *own_buf)
      then there's no point in GDB sending "vFile:setfs:" packets.  We
      reply with an empty packet (i.e. we pretend we don't understand
      "vFile:setfs:") and that should stop GDB sending any more.  */
-  if (the_target->multifs_open == NULL
-      && the_target->multifs_unlink == NULL
-      && the_target->multifs_readlink == NULL)
+  if (!the_target->pt->supports_multifs ())
     {
       own_buf[0] = '\0';
       return;
@@ -321,9 +319,9 @@ handle_open (char *own_buf)
 
   /* We do not need to convert MODE, since the fileio protocol
      uses the standard values.  */
-  if (hostio_fs_pid != 0 && the_target->multifs_open != NULL)
-    fd = the_target->multifs_open (hostio_fs_pid, filename,
-				   flags, mode);
+  if (hostio_fs_pid != 0)
+    fd = the_target->pt->multifs_open (hostio_fs_pid, filename,
+				       flags, mode);
   else
     fd = open (filename, flags, mode);
 
@@ -541,8 +539,8 @@ handle_unlink (char *own_buf)
       return;
     }
 
-  if (hostio_fs_pid != 0 && the_target->multifs_unlink != NULL)
-    ret = the_target->multifs_unlink (hostio_fs_pid, filename);
+  if (hostio_fs_pid != 0)
+    ret = the_target->pt->multifs_unlink (hostio_fs_pid, filename);
   else
     ret = unlink (filename);
 
@@ -571,10 +569,10 @@ handle_readlink (char *own_buf, int *new_packet_len)
       return;
     }
 
-  if (hostio_fs_pid != 0 && the_target->multifs_readlink != NULL)
-    ret = the_target->multifs_readlink (hostio_fs_pid, filename,
-					linkname,
-					sizeof (linkname) - 1);
+  if (hostio_fs_pid != 0)
+    ret = the_target->pt->multifs_readlink (hostio_fs_pid, filename,
+					    linkname,
+					    sizeof (linkname) - 1);
   else
     ret = readlink (filename, linkname, sizeof (linkname) - 1);
 
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index a3d0bd98f54..398c5fc6a82 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -6449,6 +6449,32 @@ 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
 {
@@ -7479,9 +7505,6 @@ linux_get_hwcap2 (int wordsize)
 static linux_process_target the_linux_target;
 
 static process_stratum_target linux_target_ops = {
-  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,
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index af5892e767a..9fd2bc0ea35 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -452,6 +452,16 @@ public:
   bool supports_pid_to_exec_file () override;
 
   char *pid_to_exec_file (int pid) override;
+
+  bool supports_multifs () override;
+
+  int multifs_open (int pid, const char *filename, int flags,
+		    mode_t mode) override;
+
+  int multifs_unlink (int pid, const char *filename) override;
+
+  ssize_t multifs_readlink (int pid, const char *filename, char *buf,
+			    size_t bufsiz) override;
 };
 
 #define get_thread_lwp(thr) ((struct lwp_info *) (thread_target_data (thr)))
diff --git a/gdbserver/lynx-low.cc b/gdbserver/lynx-low.cc
index 5e23713cfaf..ad669c8e9d7 100644
--- a/gdbserver/lynx-low.cc
+++ b/gdbserver/lynx-low.cc
@@ -735,9 +735,6 @@ static lynx_process_target the_lynx_target;
 /* The LynxOS target_ops vector.  */
 
 static process_stratum_target lynx_target_ops = {
-  NULL,  /* multifs_open */
-  NULL,  /* multifs_unlink */
-  NULL,  /* multifs_readlink */
   NULL,  /* breakpoint_kind_from_pc */
   NULL,  /* sw_breakpoint_from_kind */
   NULL,  /* thread_name */
diff --git a/gdbserver/nto-low.cc b/gdbserver/nto-low.cc
index 9a798bf6ec1..1140b5b6d49 100644
--- a/gdbserver/nto-low.cc
+++ b/gdbserver/nto-low.cc
@@ -947,9 +947,6 @@ nto_sw_breakpoint_from_kind (int kind, int *size)
 static nto_process_target the_nto_target;
 
 static process_stratum_target nto_target_ops = {
-  NULL, /* multifs_open */
-  NULL, /* multifs_unlink */
-  NULL, /* multifs_readlink */
   NULL, /* breakpoint_kind_from_pc */
   nto_sw_breakpoint_from_kind,
   NULL, /* thread_name */
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index 3787e94ad55..4c92fa6f89d 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -22,6 +22,10 @@
 #include "tracepoint.h"
 #include "gdbsupport/byte-vector.h"
 #include "hostio.h"
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 process_stratum_target *the_target;
 
@@ -771,3 +775,29 @@ process_target::pid_to_exec_file (int pid)
 {
   gdb_assert_not_reached ("target op pid_to_exec_file not supported");
 }
+
+bool
+process_target::supports_multifs ()
+{
+  return false;
+}
+
+int
+process_target::multifs_open (int pid, const char *filename,
+			      int flags, mode_t mode)
+{
+  return open (filename, flags, mode);
+}
+
+int
+process_target::multifs_unlink (int pid, const char *filename)
+{
+  return unlink (filename);
+}
+
+ssize_t
+process_target::multifs_readlink (int pid, const char *filename,
+				  char *buf, size_t bufsiz)
+{
+  return readlink (filename, buf, bufsiz);
+}
diff --git a/gdbserver/target.h b/gdbserver/target.h
index d728646d274..bf653a4d08a 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -70,27 +70,6 @@ class process_target;
    shared code.  */
 struct process_stratum_target
 {
-  /* Multiple-filesystem-aware open.  Like open(2), but operating in
-     the filesystem as it appears to process PID.  Systems where all
-     processes share a common filesystem should set this to NULL.
-     If NULL, the caller should fall back to open(2).  */
-  int (*multifs_open) (int pid, const char *filename,
-		       int flags, mode_t mode);
-
-  /* Multiple-filesystem-aware unlink.  Like unlink(2), but operates
-     in the filesystem as it appears to process PID.  Systems where
-     all processes share a common filesystem should set this to NULL.
-     If NULL, the caller should fall back to unlink(2).  */
-  int (*multifs_unlink) (int pid, const char *filename);
-
-  /* Multiple-filesystem-aware readlink.  Like readlink(2), but
-     operating in the filesystem as it appears to process PID.
-     Systems where all processes share a common filesystem should
-     set this to NULL.  If NULL, the caller should fall back to
-     readlink(2).  */
-  ssize_t (*multifs_readlink) (int pid, const char *filename,
-			       char *buf, size_t bufsiz);
-
   /* Return the breakpoint kind for this target based on PC.  The PCPTR is
      adjusted to the real memory location in case a flag (e.g., the Thumb bit on
      ARM) was present in the PC.  */
@@ -501,6 +480,29 @@ public:
      string should be copied into a buffer by the client if the string
      will not be immediately used, or if it must persist.  */
   virtual char *pid_to_exec_file (int pid);
+
+  /* Return true if any of the multifs ops is supported.  */
+  virtual bool supports_multifs ();
+
+  /* Multiple-filesystem-aware open.  Like open(2), but operating in
+     the filesystem as it appears to process PID.  Systems where all
+     processes share a common filesystem should not override this.
+     The default behavior is to use open(2).  */
+  virtual int multifs_open (int pid, const char *filename,
+			    int flags, mode_t mode);
+
+  /* Multiple-filesystem-aware unlink.  Like unlink(2), but operates
+     in the filesystem as it appears to process PID.  Systems where
+     all processes share a common filesystem should not override this.
+     The default behavior is to use unlink(2).  */
+  virtual int multifs_unlink (int pid, const char *filename);
+
+  /* Multiple-filesystem-aware readlink.  Like readlink(2), but
+     operating in the filesystem as it appears to process PID.
+     Systems where all processes share a common filesystem should
+     not override this.  The default behavior is to use readlink(2).  */
+  virtual ssize_t multifs_readlink (int pid, const char *filename,
+				    char *buf, size_t bufsiz);
 };
 
 extern process_stratum_target *the_target;
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 3b1f7d33f40..eb51a857b25 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1858,9 +1858,6 @@ win32_sw_breakpoint_from_kind (int kind, int *size)
 static win32_process_target the_win32_target;
 
 static process_stratum_target win32_target_ops = {
-  NULL, /* multifs_open */
-  NULL, /* multifs_unlink */
-  NULL, /* multifs_readlink */
   NULL, /* breakpoint_kind_from_pc */
   win32_sw_breakpoint_from_kind,
   NULL, /* thread_name */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (57 preceding siblings ...)
  2020-02-17 17:05 ` [PATCH v2 31/58] gdbserver: turn target ops 'supports_{fork,vfork,exec}_events' into methods Tankut Baris Aktemur
@ 2020-02-19  2:46 ` Simon Marchi
  2020-02-20 17:04   ` Tom Tromey
  2020-02-19 14:11 ` Pedro Alves
  59 siblings, 1 reply; 66+ messages in thread
From: Simon Marchi @ 2020-02-19  2:46 UTC (permalink / raw)
  To: Tankut Baris Aktemur, gdb-patches; +Cc: palves

On 2020-02-17 11:57 a.m., Tankut Baris Aktemur wrote:
> Hello,
> 
> This is v2 of the series that was posted at
> 
>   https://sourceware.org/ml/gdb-patches/2020-02/msg00313.html
> 
> This revision makes the following updates to the previous version:
> 
> 1. Pedro's comments have been addressed.
> 
> 2. The series has been rebased on the current master.
> 
> 3. The win32-low target has been built (but not tested) via
> cross-compilation (my thanks to Christian for the tips).  There were a
> couple problems detected -- I fixed them.
> 
> I am in the process of using buildbot to test on a wide range of
> available targets (assuming a series of this size will be accepted by
> buildbot).  However, I'm afraid I won't be able to build and test
> nto-low and lynx-low.

Do your best for those.  As far as I know there is no publicly / freely
available toolchain for those, so there's not much we can do.

Pedro already went over it, so I won't review it again (there are so many
patches to review!), but I wanted to say thanks for doing this, the series
look very well made and split in incremental steps.

Simon

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 24/58] gdbserver: turn target op 'read_offsets' into a method
  2020-02-17 17:01 ` [PATCH v2 24/58] gdbserver: turn target op 'read_offsets' into a method Tankut Baris Aktemur
@ 2020-02-19 14:09   ` Pedro Alves
  0 siblings, 0 replies; 66+ messages in thread
From: Pedro Alves @ 2020-02-19 14:09 UTC (permalink / raw)
  To: Tankut Baris Aktemur, gdb-patches

On 2/17/20 4:57 PM, Tankut Baris Aktemur wrote:
> +bool
> +linux_process_target::supports_read_offsets ()
> +{
> +#if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
> +    && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
> +    && defined(PT_TEXT_END_ADDR)
> +  return true;
> +#else
> +  return false;
> +#endif
> +}
> +
>  /* Under uClinux, programs are loaded at non-zero offsets, which we need
>     to tell gdb about.  */
>  
> -static int
> -linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
> +int
> +linux_process_target::read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
>  {
> +#if defined(__UCLIBC__) && defined(HAS_NOMMU)	      \
> +    && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \
> +    && defined(PT_TEXT_END_ADDR)

I think it would be nice to write this whole condition once, like:

#if (defined (__UCLIBC__)
     && defined (HAS_NOMMU) \
     && defined (PT_TEXT_ADDR) 
     && defined (PT_DATA_ADDR) \
     && defined (PT_TEXT_END_ADDR))
# define SUPPORTS_READ_OFFSETS
#endif

and then use '#ifdef SUPPORTS_READ_OFFSETS' in both spots.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class
  2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
                   ` (58 preceding siblings ...)
  2020-02-19  2:46 ` [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Simon Marchi
@ 2020-02-19 14:11 ` Pedro Alves
  2020-02-20 16:03   ` Aktemur, Tankut Baris
  2020-02-20 17:02   ` Tom Tromey
  59 siblings, 2 replies; 66+ messages in thread
From: Pedro Alves @ 2020-02-19 14:11 UTC (permalink / raw)
  To: Tankut Baris Aktemur, gdb-patches

On 2/17/20 4:57 PM, Tankut Baris Aktemur wrote:
> Hello,
> 
> This is v2 of the series that was posted at
> 
>   https://sourceware.org/ml/gdb-patches/2020-02/msg00313.html
> 
> This revision makes the following updates to the previous version:
> 
> 1. Pedro's comments have been addressed.

Thank you.

I went over the series again, and I just had one minor comment to
patch #24.  Otherwise this all looks great to me.  Please push.

Thanks again for doing all this.

Pedro Alves

^ permalink raw reply	[flat|nested] 66+ messages in thread

* RE: [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class
  2020-02-19 14:11 ` Pedro Alves
@ 2020-02-20 16:03   ` Aktemur, Tankut Baris
  2020-02-20 17:02   ` Tom Tromey
  1 sibling, 0 replies; 66+ messages in thread
From: Aktemur, Tankut Baris @ 2020-02-20 16:03 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On Wednesday, February 19, 2020 3:11 PM, Pedro Alves wrote:
> 
> I went over the series again, and I just had one minor comment to
> patch #24.  Otherwise this all looks great to me.  Please push.
> 
> Thanks again for doing all this.
> 
> Pedro Alves

Thanks for your review.  I noticed one thing in Patch #43
(https://sourceware.org/ml/gdb-patches/2020-02/msg00668.html)
It introduced this function:

+bool
+linux_process_target::supports_fast_tracepoints ()
+{
+  return true;
+}

This is the correct definition based on the current behavior because 
linux-low's install_fast_tracepoint_jump_pad target op is non-null
-- it directly forwards the request to the_low_target. However, this would
lead to a segfault if the_low_target does not provide an implementation
for the install_fast_tracepoint_jump_pad linux_target_op.

I've changed the definition to

+bool
+linux_process_target::supports_fast_tracepoints ()
+{
+  return the_low_target.install_fast_tracepoint_jump_pad != nullptr;
+}

I'll push with this fix (and the fix for patch #24).

Thanks.
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class
  2020-02-19 14:11 ` Pedro Alves
  2020-02-20 16:03   ` Aktemur, Tankut Baris
@ 2020-02-20 17:02   ` Tom Tromey
  2020-02-21  8:08     ` Aktemur, Tankut Baris
  1 sibling, 1 reply; 66+ messages in thread
From: Tom Tromey @ 2020-02-20 17:02 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Tankut Baris Aktemur, gdb-patches

Pedro> Thanks again for doing all this.

I'd like to echo Simon's and Pedro's thanks.  This is super.

Tom

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class
  2020-02-19  2:46 ` [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Simon Marchi
@ 2020-02-20 17:04   ` Tom Tromey
  0 siblings, 0 replies; 66+ messages in thread
From: Tom Tromey @ 2020-02-20 17:04 UTC (permalink / raw)
  To: Simon Marchi; +Cc: Tankut Baris Aktemur, gdb-patches, palves

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> However, I'm afraid I won't be able to build and test
>> nto-low and lynx-low.

Simon> Do your best for those.  As far as I know there is no publicly / freely
Simon> available toolchain for those, so there's not much we can do.

IIUC there isn't a C++ compiler for LynxOS and so gdbserver can't be
built there any more.  If this is actually the case, we could remove it.

Tom

^ permalink raw reply	[flat|nested] 66+ messages in thread

* RE: [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class
  2020-02-20 17:02   ` Tom Tromey
@ 2020-02-21  8:08     ` Aktemur, Tankut Baris
  0 siblings, 0 replies; 66+ messages in thread
From: Aktemur, Tankut Baris @ 2020-02-21  8:08 UTC (permalink / raw)
  To: Tom Tromey, Pedro Alves; +Cc: gdb-patches

On Thursday, February 20, 2020 6:02 PM, Tom Tromey wrote:
> 
> I'd like to echo Simon's and Pedro's thanks.  This is super.
> 
> Tom

Thank you, too, for the acknowledgment.

Note: A similar transformation to convert linux-XYZ-low targets into classes
that derive from linux_process_target is under preparation.

-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2020-02-21  8:08 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 17:01 [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 15/58] gdbserver: turn target op 'look_up_symbols' into a method Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 09/58] gdbserver: turn target op 'thread_alive' " Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 03/58] gdbserver: turn target op 'post_create_inferior' " Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 02/58] gdbserver: turn target op 'create_inferior' " Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 27/58] gdbserver: turn target op 'qxfer_osdata' " Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 13/58] gdbserver: turn prepare_to_access_memory & done_accessing_memory into methods Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 08/58] gdbserver: turn target op 'join' into a method Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 10/58] gdbserver: turn target op 'resume' " Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 14/58] gdbserver: turn target ops 'read_memory' and 'write_memory' into methods Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 12/58] gdbserver: turn target ops 'fetch_registers' and 'store_registers' " Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 07/58] gdbserver: turn target op 'mourn' into a method Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 05/58] gdbserver: turn target op 'kill' " Tankut Baris Aktemur
2020-02-17 16:59 ` [PATCH v2 16/58] gdbserver: turn target op 'request_interrupt' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 42/58] gdbserver: turn target op 'stabilize_threads' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 04/58] gdbserver: turn target op 'attach' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 30/58] gdbserver: turn target op 'supports_multi_process' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 01/58] gdbserver: start turning the target ops vector into a class Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 24/58] gdbserver: turn target op 'read_offsets' into a method Tankut Baris Aktemur
2020-02-19 14:09   ` Pedro Alves
2020-02-17 17:01 ` [PATCH v2 43/58] gdbserver: turn fast tracepoint target ops into methods Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 23/58] gdbserver: turn target ops 'stopped_by_watchpoint' and 'stopped_data_address' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 44/58] gdbserver: turn target op 'emit_ops' into a method Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 53/58] gdbserver: turn target ops 'thread_name' and 'thread_handle' into methods Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 37/58] gdbserver: turn target op 'supports_tracepoints' into a method Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 35/58] gdbserver: turn target op 'read_loadmap' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 56/58] gdbserver: turn target op 'get_ipa_tdesc_idx' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 57/58] gdbserver: simply copy the pointer in 'set_target_ops' Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 21/58] gdbserver: turn target op '{supports_}stopped_by_hw_breakpoint' into a method Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 45/58] gdbserver: turn target op 'supports_disable_randomization' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 17/58] gdbserver: turn target op 'read_auxv' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 47/58] gdbserver: turn target op 'supports_agent' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 39/58] gdbserver: turn target op 'thread_stopped' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 20/58] gdbserver: turn target op '{supports_}stopped_by_sw_breakpoint' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 28/58] gdbserver: turn target op 'qxfer_siginfo' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 40/58] gdbserver: turn target op 'get_tib_address' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 34/58] gdbserver: turn target op 'core_of_thread' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 11/58] gdbserver: turn target op 'wait' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 06/58] gdbserver: turn target op 'detach' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 26/58] gdbserver: turn target op 'hostio_last_error' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 33/58] gdbserver: turn target op 'handle_monitor_command' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 19/58] gdbserver: turn target ops 'insert_point' and 'remove_point' into methods Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 25/58] gdbserver: turn target op 'get_tls_address' into a method Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 32/58] gdbserver: turn target op 'handle_new_gdb_connection' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 52/58] gdbserver: turn breakpoint kind-related target ops into methods Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 22/58] gdbserver: turn target op 'supports_hardware_single_step' into a method Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 54/58] gdbserver: turn target op 'supports_software_single_step' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 55/58] gdbserver: turn target op 'supports_catch_syscall' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 29/58] gdbserver: turn non-stop and async target ops into methods Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 38/58] gdbserver: turn target ops 'read_pc' and 'write_pc' " Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 18/58] gdbserver: turn target op 'supports_z_point_type' into a method Tankut Baris Aktemur
2020-02-17 17:01 ` [PATCH v2 49/58] gdbserver: turn target op 'supports_range_stepping' " Tankut Baris Aktemur
2020-02-17 17:04 ` [PATCH v2 50/58] gdbserver: turn target op 'pid_to_exec_file' " Tankut Baris Aktemur
2020-02-17 17:04 ` [PATCH v2 48/58] gdbserver: turn btrace-related target ops into methods Tankut Baris Aktemur
2020-02-17 17:04 ` [PATCH v2 58/58] gdbserver: finish turning the target ops vector into a class Tankut Baris Aktemur
2020-02-17 17:04 ` [PATCH v2 41/58] gdbserver: turn target ops 'pause_all' and 'unpause_all' into methods Tankut Baris Aktemur
2020-02-17 17:05 ` [PATCH v2 36/58] gdbserver: turn target op 'process_qsupported' into a method Tankut Baris Aktemur
2020-02-17 17:05 ` [PATCH v2 51/58] gdbserver: turn target ops 'multifs_{open, readlink, unlink}' into methods Tankut Baris Aktemur
2020-02-17 17:05 ` [PATCH v2 46/58] gdbserver: turn target op 'qxfer_libraries_svr4' into a method Tankut Baris Aktemur
2020-02-17 17:05 ` [PATCH v2 31/58] gdbserver: turn target ops 'supports_{fork,vfork,exec}_events' into methods Tankut Baris Aktemur
2020-02-19  2:46 ` [PATCH v2 00/58] Turn gdbserver's process_stratum_target into a class Simon Marchi
2020-02-20 17:04   ` Tom Tromey
2020-02-19 14:11 ` Pedro Alves
2020-02-20 16:03   ` Aktemur, Tankut Baris
2020-02-20 17:02   ` Tom Tromey
2020-02-21  8:08     ` Aktemur, Tankut Baris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).