Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Abhay Kandpal <abhay@linux.ibm.com>, gdb-patches@sourceware.org
Cc: Ulrich.Weigand@de.ibm.com, eliz@gnu.org, cel@linux.ibm.com,
	abhay.k@ibm.com, Abhay Kandpal <abhay@linux.ibm.com>
Subject: Re: [PATCH v4 2/2] gdb: add stat64 and fstat64 to the F-packet file-i/o protocol
Date: Tue, 03 Nov 2026 17:31:13 +0000	[thread overview]
Message-ID: <874idx7rfi.fsf@redhat.com> (raw)
In-Reply-To: <20261029092124.233055-3-abhay@linux.ibm.com>

Abhay Kandpal <abhay@linux.ibm.com> writes:

> The previous patch widened the stat fields returned by the vFile
> packets, using a qSupported feature to keep old and new GDB and
> gdbserver compatible.  The F-packet file-i/o protocol has the same
> problem: the Fstat and Ffstat calls write struct fio_stat into target
> memory, in which st_dev, st_ino, st_nlink, st_rdev and the three
> timestamps are 4 bytes, so those values are truncated on a 64-bit
> host.
>
> The F-packet calls cannot use qSupported, since the buffer is read

I find this discussion on qSupported here a little distracting.  I agree
with the conclusion that this paragraph reaches, that there's no benefit
to using qSupported here, but I disagree with the "cannot use
qSupported" claim.

Right now, a remote target that wants to use the file-i/o (F-packet)
mechanism will be running code that does <whatever>.  At some point it
will do a syscall which the gdbserver will intercept.  The syscall is
translated into an F-packet.  It's gdbserver which gets to decide which
F-packet stat or stat64 to send, so why can the stub not be influenced
or controlled by the existing qSupported feature?

I mean, if you are talking to a GDB that we know (thanks to qSupported)
will only have the stat F-packet, then translating 'stat' syscalls into
'stat64' F-packets seems like a bad plan.  Better (surely) to send of
the 'stat' F-packet and hope that we don't hit any overflow?

But I do understand that we cannot make use of the qSupported knowledge
to mangle the buffer sizes on the remote end as GDB writes directly back
into the target.

I'm not sure I'm really arguing that any code needs to change, I'm just
arguing that the "The F-packet calls cannot use qSupported, " part (to
me) adds confusion as the real situation is more complex that the text
indicates.  I think just dropping that part would actually be clearer.
Or expanding the explanation to explain the limitations of qSupported in
this area.  But I'd just drop it I think.

> diff --git a/gdb/remote-fileio.c b/gdb/remote-fileio.c
> index a65db27d04e..c24c3c2ab9f 100644
> --- a/gdb/remote-fileio.c
> +++ b/gdb/remote-fileio.c
> @@ -791,14 +791,39 @@ remote_fileio_func_unlink (remote_target *remote, char *buf)
>      remote_fileio_return_success (remote, ret);
>  }
>  
> +/* Write ST into target memory at ADDR, using the struct fio_stat
> +   layout or, if WIDE, the struct fio_stat_wide layout.  Return 0 on
> +   success, or an errno value.  */

This comment is wrong.  See target_write_memory, but it's 0 on success,
-1 on error, not a POSIX errno.

With those two fixes:

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


      reply	other threads:[~2026-11-03 17:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29  9:21 [PATCH v4 0/2] Widen the stat fields in the remote protocol Abhay Kandpal
2026-10-29  9:21 ` [PATCH v4 1/2] gdbserver: widen the stat fields returned by the vFile packets Abhay Kandpal
2026-10-29 16:56   ` Ulrich Weigand
2026-11-02  6:29     ` Abhay Kandpal
2026-11-03 16:27   ` Andrew Burgess
2026-10-29  9:21 ` [PATCH v4 2/2] gdb: add stat64 and fstat64 to the F-packet file-i/o protocol Abhay Kandpal
2026-11-03 17:31   ` Andrew Burgess [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874idx7rfi.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=abhay.k@ibm.com \
    --cc=abhay@linux.ibm.com \
    --cc=cel@linux.ibm.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox