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]

Re: [RFC 14/32] Add target_ops argument to to_fileio_pwrite


Looks fine.

On 01/13/2014 07:12 PM, Tom Tromey wrote:
> 2014-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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-01-08  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 7a65bfe..061a46a 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 1370c5d..b81501d 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -9818,7 +9818,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 ();
> @@ -9846,7 +9847,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 ();
> @@ -9885,7 +9887,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;
> @@ -9903,7 +9905,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;
> @@ -9923,7 +9926,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;
> @@ -10024,7 +10028,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);
>  }
>  
>  
> @@ -10061,7 +10065,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;
> @@ -10078,7 +10082,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.  */
> @@ -10189,7 +10194,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)
> @@ -10208,7 +10214,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)
> @@ -10250,7 +10256,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;
> @@ -10265,7 +10272,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)
> @@ -10282,7 +10289,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);
>  
> @@ -10453,7 +10461,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);
> @@ -10524,7 +10532,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
>  
> @@ -10701,7 +10709,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;
> @@ -10729,7 +10737,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;
> @@ -10751,7 +10760,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 5c886dc..0ef4cdc 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -845,19 +845,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 *))
> @@ -3327,7 +3327,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)
> @@ -3357,7 +3357,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)
> @@ -3385,7 +3385,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,
> @@ -3410,7 +3410,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,
> @@ -3436,7 +3436,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 d28bfd3..31a4ce9 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -705,27 +705,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.  */
> @@ -734,20 +738,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);
> @@ -1737,19 +1744,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)
> 


-- 
Pedro Alves


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