This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC v2 13/38] Add target_ops argument to to_fileio_pwrite


2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_fileio_pwrite>: Add argument.
	* target.c (target_fileio_pwrite): Add argument.
	* remote.c (remote_hostio_pwrite): Add 'self' argument.
	(remote_file_put): Update.
	* inf-child.c (inf_child_fileio_pwrite): Add 'self' argument.

Add target_ops argument to to_fileio_pread

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_fileio_pread>: Add argument.
	* target.c (target_fileio_pread): Add argument.
	* remote.c (remote_hostio_pread): Add 'self' argument.
	(remote_bfd_iovec_pread, remote_file_get): Update.
	* inf-child.c (inf_child_fileio_pread): Add 'self' argument.

Add target_ops argument to to_fileio_close

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_fileio_close>: Add argument.
	* target.c (target_fileio_close): Add argument.
	* remote.c (remote_hostio_close): Add 'self' argument.
	(remote_hostio_close_cleanup): Update.
	(remote_bfd_iovec_close, remote_file_put, remote_file_get):
	Update.
	* inf-child.c (inf_child_fileio_close): Add 'self' argument.

Add target_ops argument to to_fileio_unlink

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_fileio_unlink>: Add argument.
	* target.c (target_fileio_unlink): Add argument.
	* remote.c (remote_hostio_unlink): Add 'self' argument.
	(remote_file_delete): Update.
	* inf-child.c (inf_child_fileio_unlink): Add 'self' argument.

Add target_ops argument to to_fileio_readlink

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_fileio_readlink>: Add argument.
	* target.c (target_fileio_readlink): Add argument.
	* remote.c (remote_hostio_readlink): Add 'self' argument.
	* inf-child.c (inf_child_fileio_readlink): Add 'self' argument.

Add target_ops argument to to_trace_init

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_trace_init>: Add argument.
	(target_trace_init): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_trace_init): Add 'self' argument.

Add target_ops argument to to_download_tracepoint

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_download_tracepoint>: Add
	argument.
	(target_download_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_download_tracepoint): Add 'self' argument.

Add target_ops argument to to_can_download_tracepoint

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_can_download_tracepoint>: Add
	argument.
	(target_can_download_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_can_download_tracepoint): Add 'self' argument.

Add target_ops argument to to_download_trace_state_variable

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_download_trace_state_variable>:
	Add argument.
	(target_download_trace_state_variable): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_download_trace_state_variable): Add 'self'
	argument.

Add target_ops argument to to_enable_tracepoint

2014-02-06  Tom Tromey  <tromey@redhat.com>

	* target.h (struct target_ops) <to_enable_tracepoint>: Add
	argument.
	(target_enable_tracepoint): Add argument.
	* target.c (update_current_target): Update.
	* remote.c (remote_enable_tracepoint): Add 'self' argument.
---
 gdb/ChangeLog   | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/inf-child.c | 14 ++++++----
 gdb/remote.c    | 46 +++++++++++++++++++-------------
 gdb/target.c    | 20 +++++++-------
 gdb/target.h    | 37 +++++++++++++++-----------
 5 files changed, 150 insertions(+), 48 deletions(-)

diff --git a/gdb/inf-child.c b/gdb/inf-child.c
index cd2aee6..054e279 100644
--- a/gdb/inf-child.c
+++ b/gdb/inf-child.c
@@ -257,7 +257,8 @@ inf_child_fileio_open (struct target_ops *self,
    Return the number of bytes written, or -1 if an error occurs
    (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
+inf_child_fileio_pwrite (struct target_ops *self,
+			 int fd, const gdb_byte *write_buf, int len,
 			 ULONGEST offset, int *target_errno)
 {
   int ret;
@@ -285,7 +286,8 @@ inf_child_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
    Return the number of bytes read, or -1 if an error occurs
    (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_pread (int fd, gdb_byte *read_buf, int len,
+inf_child_fileio_pread (struct target_ops *self,
+			int fd, gdb_byte *read_buf, int len,
 			ULONGEST offset, int *target_errno)
 {
   int ret;
@@ -312,7 +314,7 @@ inf_child_fileio_pread (int fd, gdb_byte *read_buf, int len,
 /* Close FD on the target.  Return 0, or -1 if an error occurs
    (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_close (int fd, int *target_errno)
+inf_child_fileio_close (struct target_ops *self, int fd, int *target_errno)
 {
   int ret;
 
@@ -326,7 +328,8 @@ inf_child_fileio_close (int fd, int *target_errno)
 /* Unlink FILENAME on the target.  Return 0, or -1 if an error
    occurs (and set *TARGET_ERRNO).  */
 static int
-inf_child_fileio_unlink (const char *filename, int *target_errno)
+inf_child_fileio_unlink (struct target_ops *self,
+			 const char *filename, int *target_errno)
 {
   int ret;
 
@@ -341,7 +344,8 @@ inf_child_fileio_unlink (const char *filename, int *target_errno)
    null-terminated string allocated via xmalloc, or NULL if an error
    occurs (and set *TARGET_ERRNO).  */
 static char *
-inf_child_fileio_readlink (const char *filename, int *target_errno)
+inf_child_fileio_readlink (struct target_ops *self,
+			   const char *filename, int *target_errno)
 {
   /* We support readlink only on systems that also provide a compile-time
      maximum path length (PATH_MAX), at least for now.  */
diff --git a/gdb/remote.c b/gdb/remote.c
index d5054c8..107fd5b 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -9873,7 +9873,8 @@ remote_hostio_open (struct target_ops *self,
    set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_pwrite (int fd, const gdb_byte *write_buf, int len,
+remote_hostio_pwrite (struct target_ops *self,
+		      int fd, const gdb_byte *write_buf, int len,
 		      ULONGEST offset, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
@@ -9901,7 +9902,8 @@ remote_hostio_pwrite (int fd, const gdb_byte *write_buf, int len,
    set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_pread (int fd, gdb_byte *read_buf, int len,
+remote_hostio_pread (struct target_ops *self,
+		     int fd, gdb_byte *read_buf, int len,
 		     ULONGEST offset, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
@@ -9940,7 +9942,7 @@ remote_hostio_pread (int fd, gdb_byte *read_buf, int len,
    (and set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_close (int fd, int *remote_errno)
+remote_hostio_close (struct target_ops *self, int fd, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
   char *p = rs->buf;
@@ -9958,7 +9960,8 @@ remote_hostio_close (int fd, int *remote_errno)
    occurs (and set *REMOTE_ERRNO).  */
 
 static int
-remote_hostio_unlink (const char *filename, int *remote_errno)
+remote_hostio_unlink (struct target_ops *self,
+		      const char *filename, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
   char *p = rs->buf;
@@ -9978,7 +9981,8 @@ remote_hostio_unlink (const char *filename, int *remote_errno)
    occurs (and set *REMOTE_ERRNO).  */
 
 static char *
-remote_hostio_readlink (const char *filename, int *remote_errno)
+remote_hostio_readlink (struct target_ops *self,
+			const char *filename, int *remote_errno)
 {
   struct remote_state *rs = get_remote_state ();
   char *p = rs->buf;
@@ -10079,7 +10083,7 @@ remote_hostio_close_cleanup (void *opaque)
   int fd = *(int *) opaque;
   int remote_errno;
 
-  remote_hostio_close (fd, &remote_errno);
+  remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno);
 }
 
 
@@ -10116,7 +10120,7 @@ remote_bfd_iovec_close (struct bfd *abfd, void *stream)
 
   /* Ignore errors on close; these may happen if the remote
      connection was already torn down.  */
-  remote_hostio_close (fd, &remote_errno);
+  remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno);
 
   /* Zero means success.  */
   return 0;
@@ -10133,7 +10137,8 @@ remote_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf,
   pos = 0;
   while (nbytes > pos)
     {
-      bytes = remote_hostio_pread (fd, (gdb_byte *) buf + pos, nbytes - pos,
+      bytes = remote_hostio_pread (find_target_at (process_stratum),
+				   fd, (gdb_byte *) buf + pos, nbytes - pos,
 				   offset + pos, &remote_errno);
       if (bytes == 0)
         /* Success, but no bytes, means end-of-file.  */
@@ -10244,7 +10249,8 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty)
       bytes += bytes_in_buffer;
       bytes_in_buffer = 0;
 
-      retcode = remote_hostio_pwrite (fd, buffer, bytes,
+      retcode = remote_hostio_pwrite (find_target_at (process_stratum),
+				      fd, buffer, bytes,
 				      offset, &remote_errno);
 
       if (retcode < 0)
@@ -10263,7 +10269,7 @@ remote_file_put (const char *local_file, const char *remote_file, int from_tty)
     }
 
   discard_cleanups (close_cleanup);
-  if (remote_hostio_close (fd, &remote_errno))
+  if (remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno))
     remote_hostio_error (remote_errno);
 
   if (from_tty)
@@ -10305,7 +10311,8 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty)
   offset = 0;
   while (1)
     {
-      bytes = remote_hostio_pread (fd, buffer, io_size, offset, &remote_errno);
+      bytes = remote_hostio_pread (find_target_at (process_stratum),
+				   fd, buffer, io_size, offset, &remote_errno);
       if (bytes == 0)
 	/* Success, but no bytes, means end-of-file.  */
 	break;
@@ -10320,7 +10327,7 @@ remote_file_get (const char *remote_file, const char *local_file, int from_tty)
     }
 
   discard_cleanups (close_cleanup);
-  if (remote_hostio_close (fd, &remote_errno))
+  if (remote_hostio_close (find_target_at (process_stratum), fd, &remote_errno))
     remote_hostio_error (remote_errno);
 
   if (from_tty)
@@ -10337,7 +10344,8 @@ remote_file_delete (const char *remote_file, int from_tty)
   if (!rs->remote_desc)
     error (_("command can only be used with remote target"));
 
-  retcode = remote_hostio_unlink (remote_file, &remote_errno);
+  retcode = remote_hostio_unlink (find_target_at (process_stratum),
+				  remote_file, &remote_errno);
   if (retcode == -1)
     remote_hostio_error (remote_errno);
 
@@ -10508,7 +10516,7 @@ remote_can_run_breakpoint_commands (struct target_ops *self)
 }
 
 static void
-remote_trace_init (void)
+remote_trace_init (struct target_ops *self)
 {
   putpkt ("QTinit");
   remote_get_noisy_reply (&target_buf, &target_buf_size);
@@ -10579,7 +10587,7 @@ remote_download_command_source (int num, ULONGEST addr,
 }
 
 static void
-remote_download_tracepoint (struct bp_location *loc)
+remote_download_tracepoint (struct target_ops *self, struct bp_location *loc)
 {
 #define BUF_SIZE 2048
 
@@ -10756,7 +10764,7 @@ remote_download_tracepoint (struct bp_location *loc)
 }
 
 static int
-remote_can_download_tracepoint (void)
+remote_can_download_tracepoint (struct target_ops *self)
 {
   struct remote_state *rs = get_remote_state ();
   struct trace_status *ts;
@@ -10784,7 +10792,8 @@ remote_can_download_tracepoint (void)
 
 
 static void
-remote_download_trace_state_variable (struct trace_state_variable *tsv)
+remote_download_trace_state_variable (struct target_ops *self,
+				      struct trace_state_variable *tsv)
 {
   struct remote_state *rs = get_remote_state ();
   char *p;
@@ -10806,7 +10815,8 @@ remote_download_trace_state_variable (struct trace_state_variable *tsv)
 }
 
 static void
-remote_enable_tracepoint (struct bp_location *location)
+remote_enable_tracepoint (struct target_ops *self,
+			  struct bp_location *location)
 {
   struct remote_state *rs = get_remote_state ();
   char addr_buf[40];
diff --git a/gdb/target.c b/gdb/target.c
index 37d44e8..b7f25ee 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -849,19 +849,19 @@ update_current_target (void)
 	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_trace_init,
-	    (void (*) (void))
+	    (void (*) (struct target_ops *))
 	    tcomplain);
   de_fault (to_download_tracepoint,
-	    (void (*) (struct bp_location *))
+	    (void (*) (struct target_ops *, struct bp_location *))
 	    tcomplain);
   de_fault (to_can_download_tracepoint,
-	    (int (*) (void))
+	    (int (*) (struct target_ops *))
 	    return_zero);
   de_fault (to_download_trace_state_variable,
-	    (void (*) (struct trace_state_variable *))
+	    (void (*) (struct target_ops *, struct trace_state_variable *))
 	    tcomplain);
   de_fault (to_enable_tracepoint,
-	    (void (*) (struct bp_location *))
+	    (void (*) (struct target_ops *, struct bp_location *))
 	    tcomplain);
   de_fault (to_disable_tracepoint,
 	    (void (*) (struct bp_location *))
@@ -3339,7 +3339,7 @@ target_fileio_pwrite (int fd, const gdb_byte *write_buf, int len,
     {
       if (t->to_fileio_pwrite != NULL)
 	{
-	  int ret = t->to_fileio_pwrite (fd, write_buf, len, offset,
+	  int ret = t->to_fileio_pwrite (t, fd, write_buf, len, offset,
 					 target_errno);
 
 	  if (targetdebug)
@@ -3369,7 +3369,7 @@ target_fileio_pread (int fd, gdb_byte *read_buf, int len,
     {
       if (t->to_fileio_pread != NULL)
 	{
-	  int ret = t->to_fileio_pread (fd, read_buf, len, offset,
+	  int ret = t->to_fileio_pread (t, fd, read_buf, len, offset,
 					target_errno);
 
 	  if (targetdebug)
@@ -3397,7 +3397,7 @@ target_fileio_close (int fd, int *target_errno)
     {
       if (t->to_fileio_close != NULL)
 	{
-	  int ret = t->to_fileio_close (fd, target_errno);
+	  int ret = t->to_fileio_close (t, fd, target_errno);
 
 	  if (targetdebug)
 	    fprintf_unfiltered (gdb_stdlog,
@@ -3422,7 +3422,7 @@ target_fileio_unlink (const char *filename, int *target_errno)
     {
       if (t->to_fileio_unlink != NULL)
 	{
-	  int ret = t->to_fileio_unlink (filename, target_errno);
+	  int ret = t->to_fileio_unlink (t, filename, target_errno);
 
 	  if (targetdebug)
 	    fprintf_unfiltered (gdb_stdlog,
@@ -3448,7 +3448,7 @@ target_fileio_readlink (const char *filename, int *target_errno)
     {
       if (t->to_fileio_readlink != NULL)
 	{
-	  char *ret = t->to_fileio_readlink (filename, target_errno);
+	  char *ret = t->to_fileio_readlink (t, filename, target_errno);
 
 	  if (targetdebug)
 	    fprintf_unfiltered (gdb_stdlog,
diff --git a/gdb/target.h b/gdb/target.h
index 72a811b..71454dc 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -710,27 +710,31 @@ struct target_ops
     /* Write up to LEN bytes from WRITE_BUF to FD on the target.
        Return the number of bytes written, or -1 if an error occurs
        (and set *TARGET_ERRNO).  */
-    int (*to_fileio_pwrite) (int fd, const gdb_byte *write_buf, int len,
+    int (*to_fileio_pwrite) (struct target_ops *,
+			     int fd, const gdb_byte *write_buf, int len,
 			     ULONGEST offset, int *target_errno);
 
     /* Read up to LEN bytes FD on the target into READ_BUF.
        Return the number of bytes read, or -1 if an error occurs
        (and set *TARGET_ERRNO).  */
-    int (*to_fileio_pread) (int fd, gdb_byte *read_buf, int len,
+    int (*to_fileio_pread) (struct target_ops *,
+			    int fd, gdb_byte *read_buf, int len,
 			    ULONGEST offset, int *target_errno);
 
     /* Close FD on the target.  Return 0, or -1 if an error occurs
        (and set *TARGET_ERRNO).  */
-    int (*to_fileio_close) (int fd, int *target_errno);
+    int (*to_fileio_close) (struct target_ops *, int fd, int *target_errno);
 
     /* Unlink FILENAME on the target.  Return 0, or -1 if an error
        occurs (and set *TARGET_ERRNO).  */
-    int (*to_fileio_unlink) (const char *filename, int *target_errno);
+    int (*to_fileio_unlink) (struct target_ops *,
+			     const char *filename, int *target_errno);
 
     /* Read value of symbolic link FILENAME on the target.  Return a
        null-terminated string allocated via xmalloc, or NULL if an error
        occurs (and set *TARGET_ERRNO).  */
-    char *(*to_fileio_readlink) (const char *filename, int *target_errno);
+    char *(*to_fileio_readlink) (struct target_ops *,
+				 const char *filename, int *target_errno);
 
 
     /* Implement the "info proc" command.  */
@@ -739,20 +743,23 @@ struct target_ops
     /* Tracepoint-related operations.  */
 
     /* Prepare the target for a tracing run.  */
-    void (*to_trace_init) (void);
+    void (*to_trace_init) (struct target_ops *);
 
     /* Send full details of a tracepoint location to the target.  */
-    void (*to_download_tracepoint) (struct bp_location *location);
+    void (*to_download_tracepoint) (struct target_ops *,
+				    struct bp_location *location);
 
     /* Is the target able to download tracepoint locations in current
        state?  */
-    int (*to_can_download_tracepoint) (void);
+    int (*to_can_download_tracepoint) (struct target_ops *);
 
     /* Send full details of a trace state variable to the target.  */
-    void (*to_download_trace_state_variable) (struct trace_state_variable *tsv);
+    void (*to_download_trace_state_variable) (struct target_ops *,
+					      struct trace_state_variable *tsv);
 
     /* Enable a tracepoint on the target.  */
-    void (*to_enable_tracepoint) (struct bp_location *location);
+    void (*to_enable_tracepoint) (struct target_ops *,
+				  struct bp_location *location);
 
     /* Disable a tracepoint on the target.  */
     void (*to_disable_tracepoint) (struct bp_location *location);
@@ -1764,19 +1771,19 @@ extern char *target_fileio_read_stralloc (const char *filename);
 /* Tracepoint-related operations.  */
 
 #define target_trace_init() \
-  (*current_target.to_trace_init) ()
+  (*current_target.to_trace_init) (&current_target)
 
 #define target_download_tracepoint(t) \
-  (*current_target.to_download_tracepoint) (t)
+  (*current_target.to_download_tracepoint) (&current_target, t)
 
 #define target_can_download_tracepoint() \
-  (*current_target.to_can_download_tracepoint) ()
+  (*current_target.to_can_download_tracepoint) (&current_target)
 
 #define target_download_trace_state_variable(tsv) \
-  (*current_target.to_download_trace_state_variable) (tsv)
+  (*current_target.to_download_trace_state_variable) (&current_target, tsv)
 
 #define target_enable_tracepoint(loc) \
-  (*current_target.to_enable_tracepoint) (loc)
+  (*current_target.to_enable_tracepoint) (&current_target, loc)
 
 #define target_disable_tracepoint(loc) \
   (*current_target.to_disable_tracepoint) (loc)
-- 
1.8.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]