This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 1/9] Introduce target_fileio_fstat
- From: Pedro Alves <palves at redhat dot com>
- To: Gary Benson <gbenson at redhat dot com>, gdb-patches at sourceware dot org
- Date: Wed, 01 Apr 2015 13:11:21 +0100
- Subject: Re: [PATCH 1/9] Introduce target_fileio_fstat
- Authentication-results: sourceware.org; auth=none
- References: <1426870087-32654-1-git-send-email-gbenson at redhat dot com> <1426870087-32654-2-git-send-email-gbenson at redhat dot com>
Looks good with the nits below addressed.
On 03/20/2015 04:47 PM, Gary Benson wrote:
> --- a/gdb/inf-child.c
> +++ b/gdb/inf-child.c
> @@ -374,6 +374,22 @@ inf_child_fileio_pread (struct target_ops *self,
> return ret;
> }
>
> +/* Get information about the file opened as FD and put it in SB.
> + Return 0, or -1 if an error occurs (and set *TARGET_ERRNO). */
Write something like "Implementation of to_fileio_fstat."
instead of duplicating the comment.
> +
> +static int
> +inf_child_fileio_fstat (struct target_ops *self, int fd,
> + struct stat *sb, int *target_errno)
> +{
> index bb901b5..44ede10 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -2848,6 +2848,27 @@ target_fileio_pread (int fd, gdb_byte *read_buf, int len,
> return ret;
> }
>
> +/* Get information about the file opened as FD on the target
> + and put it in SB. Return 0, or -1 if an error occurs (and
> + set *TARGET_ERRNO). */
Write:
/* See target.h. */
instead of duplicating the comment.
> +int
> +target_fileio_fstat (int fd, struct stat *sb, int *target_errno)
> +{
> + fileio_fh_t *fh = fileio_fd_to_fh (fd);
> + int ret = -1;
> +
> + if (is_closed_fileio_fh (fh->fd))
> + *target_errno = EBADF;
> + else
> + ret = fh->t->to_fileio_fstat (fh->t, fh->fd, sb, target_errno);
> +
> + if (targetdebug)
> + fprintf_unfiltered (gdb_stdlog,
> + "target_fileio_fstat (%d) = %d (%d)\n",
> + fd, ret, ret != -1 ? 0 : *target_errno);
> + return ret;
> +}
> +
> /* Close FD on the target. Return 0, or -1 if an error occurs
> (and set *TARGET_ERRNO). */
> int
> diff --git a/gdb/target.h b/gdb/target.h
> index c95e1a4..d2bd152 100644
> --- a/gdb/target.h
> +++ b/gdb/target.h
> @@ -846,6 +846,11 @@ struct target_ops
> int fd, gdb_byte *read_buf, int len,
> ULONGEST offset, int *target_errno);
>
> + /* Get information about the file opened as FD and put it in SB.
> + Return 0, or -1 if an error occurs (and set *TARGET_ERRNO). */
ITYM, "Return 0 on success, ..."
> + int (*to_fileio_fstat) (struct target_ops *,
> + int fd, struct stat *sb, int *target_errno);
> +
> +/* Get information about the file opened as FD on the target
> + and put it in SB. Return 0, or -1 if an error occurs (and
Likewise.
> + set *TARGET_ERRNO). */
> +extern int target_fileio_fstat (int fd, struct stat *sb,
> + int *target_errno);
Thanks,
Pedro Alves