public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Tom Tromey <tom@tromey.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH 3/3] gdb, gdbserver: introduce the 'x' RSP packet for binary memory read
Date: Wed, 20 Mar 2024 17:32:00 +0000	[thread overview]
Message-ID: <DM4PR11MB7303F9291DB645E063B7829BC4332@DM4PR11MB7303.namprd11.prod.outlook.com> (raw)
In-Reply-To: <87o7bagqil.fsf@tromey.com>

Hi Tom,

On Tuesday, March 19, 2024 5:01 PM, Tom Tromey wrote:
> >>>>> Aktemur, Tankut Baris <tankut.baris.aktemur@intel.com> writes:
> 
> >> I think the probing idea is that you simply try the 'x' command the
> >> first time it is needed.  If remote sends an empty response (not an 'E'
> >> response), then the packet isn't supported, so you disable it and retry
> >> with 'm'.
> >>
> >> This is documented in the Overview node:
> 
> > Yes, I get this idea, and the 'X' packet actually uses it.  My concern there is
> > that (1) sending this packet with an arbitrary address and length 0 seems too
> > artificial; (2) using the proposed reply format, the target would send an empty reply
> > both when it does not recognize the packet and when it recognizes because the length
> > argument in the probe is 0 (the same problem would exist with the 'm', 'p', 'g' packets
> > if we were to probe them).  This would not be an issue if we decide to force the reply
> > to always start with a marker character, as suggested in Ciaran's email.
> 
> I definitely think that gdb should not send an 'x' packet with an
> arbitrary address and a length of 0.
> 
> Instead the idea is that if the packet is not explicitly forbidden
> (either via a gdb command or by previous probe failure), just attempt to
> use this packet for the first memory read.

You mean, just as "x\0", without any arguments?  (Please also see the end
of the email about this)

> If the remote reports the packet as unsupported, fall back to the 'm'
> packet and carry on.
> 
> I think the docs should be explicit about what a 0-length read means.

I agree that the document should be clear for this.

> I tend to think this should just be an error.

My first reaction would be that it depends on the given address.  If the
address is accessible, it seems viable that a zero-length read is trivially
a success, akin to defining an empty string.  If the address is not
accessible, however, it would be an error.  So, a zero-length read attempt
could also be considered as a probe to check if the address is accessible
by the context.

Checking the code, I see in `target_write_memory`:

  /* GDB may send X packets with LEN==0, for probing packet support.
     If we let such a request go through, then buffer.data() below may
     return NULL, which may confuse target implementations.  Handle it
     here to avoid lower levels having to care about this case.  */
  if (len == 0)
    return 0;

(A return value of 0 denotes success, by the way.)
And then in `read_inferior_memory`:

  /* At the time of writing, GDB only sends write packets with LEN==0,
     not read packets (see comment in target_write_memory), but it
     doesn't hurt to prevent problems if it ever does, or we're
     connected to some client other than GDB that does.  */
  if (len == 0)
    return 0;

I had mentioned `check_binary_download` in a previous email.  In that function
GDB probes for 'X' using the first memory address it receives with a length
of 0.  From that perspective, the address is arbitrary, and I, too, find that
unpleasant.

Because of these reasons, I had preferred not probing and chose announcing
the support instead.  But if probing is still the desired approach, how about this:

We can send a plain "x\0" packet, with no arguments.  Because this doesn't conform
to the format, it would be an error, but that's sufficient to indicate that
the server supports the packet.  Would that be ok?

> I also prefer Ciaran's idea for the response packet.  I didn't realize
> other packets already did this or perhaps I would have suggested it.

Ok, thank you.  I'll make the reply start with a marker character in the next
revision.

> thanks,
> Tom

Regards
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2024-03-20 17:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 15:35 [PATCH 0/3] Introduce the 'x' RSP packet Tankut Baris Aktemur
2024-03-13 15:35 ` [PATCH 1/3] gdbserver: allow suppressing the next putpkt remote-debug log Tankut Baris Aktemur
2024-03-13 19:10   ` Tom Tromey
2024-03-14 10:36     ` Aktemur, Tankut Baris
2024-03-13 15:35 ` [PATCH 2/3] rsp: add 'E' to escaped characters Tankut Baris Aktemur
2024-03-13 19:17   ` Tom Tromey
2024-03-13 15:35 ` [PATCH 3/3] gdb, gdbserver: introduce the 'x' RSP packet for binary memory read Tankut Baris Aktemur
2024-03-13 15:50   ` Luis Machado
2024-03-13 18:21     ` Aktemur, Tankut Baris
2024-03-14 10:01       ` Luis Machado
2024-03-13 15:58   ` Eli Zaretskii
2024-03-13 19:27   ` Tom Tromey
2024-03-14 10:36     ` Aktemur, Tankut Baris
2024-03-14 12:46       ` Tom Tromey
2024-03-15  9:59         ` Aktemur, Tankut Baris
2024-03-19 16:01           ` Tom Tromey
2024-03-20 17:32             ` Aktemur, Tankut Baris [this message]
2024-03-20 20:12               ` Tom Tromey
2024-04-05 13:05             ` Andrew Burgess
2024-04-05 14:09               ` Tom Tromey
2024-04-08 21:36                 ` Andrew Burgess
2024-03-14 12:34     ` Aktemur, Tankut Baris
2024-03-14 13:07 ` [PATCH v2 0/4] Introduce the 'x' RSP packet Tankut Baris Aktemur
2024-03-14 13:07   ` [PATCH v2 1/4] doc: fine-tune the documentation of the 'm' " Tankut Baris Aktemur
2024-03-14 15:06     ` Eli Zaretskii
2024-03-14 13:07   ` [PATCH v2 2/4] gdbserver: allow suppressing the next putpkt remote-debug log Tankut Baris Aktemur
2024-03-14 13:07   ` [PATCH v2 3/4] rsp: add 'E' to escaped characters Tankut Baris Aktemur
2024-03-14 13:46     ` Ciaran Woodward
2024-03-14 15:19       ` Aktemur, Tankut Baris
2024-04-05 12:59         ` Andrew Burgess
2024-03-14 15:07     ` Eli Zaretskii
2024-03-14 13:07   ` [PATCH v2 4/4] gdb, gdbserver: introduce the 'x' RSP packet for binary memory read Tankut Baris Aktemur
2024-04-09  7:48   ` [PATCH v3 0/3] Introduce the 'x' RSP packet Tankut Baris Aktemur
2024-04-09  7:48     ` [PATCH v3 1/3] doc: fine-tune the documentation of the 'm' " Tankut Baris Aktemur
2024-04-09  9:27       ` Eli Zaretskii
2024-04-09  7:48     ` [PATCH v3 2/3] gdbserver: allow suppressing the next putpkt remote-debug log Tankut Baris Aktemur
2024-04-09  7:48     ` [PATCH v3 3/3] gdb, gdbserver: introduce the 'x' RSP packet for binary memory read Tankut Baris Aktemur

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=DM4PR11MB7303F9291DB645E063B7829BC4332@DM4PR11MB7303.namprd11.prod.outlook.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).