[v5,8/8] gdb: Document qIsAddressTagged packet

Message ID 20240417210424.216374-9-gustavo.romero@linaro.org
State New
Headers
Series Add another way to check tagged addresses on remote targets |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Gustavo Romero April 17, 2024, 9:04 p.m. UTC
  This commit documents the qIsAddressTagged packet.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Reviewed-by: Eli Zaretskii <eliz@gnu.org>
---
 gdb/NEWS            | 10 ++++++++++
 gdb/doc/gdb.texinfo | 37 ++++++++++++++++++++++++++++++++++---
 2 files changed, 44 insertions(+), 3 deletions(-)
  

Comments

Eli Zaretskii April 18, 2024, 5:18 a.m. UTC | #1
> From: Gustavo Romero <gustavo.romero@linaro.org>
> Cc: luis.machado@arm.com,
> 	thiago.bauermann@linaro.org,
> 	eliz@gnu.org,
> 	tom@tromey.com,
> 	gustavo.romero@linaro.org
> Date: Wed, 17 Apr 2024 21:04:24 +0000
> 
> This commit documents the qIsAddressTagged packet.
> 
> Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
> Reviewed-by: Eli Zaretskii <eliz@gnu.org>
> ---
>  gdb/NEWS            | 10 ++++++++++
>  gdb/doc/gdb.texinfo | 37 ++++++++++++++++++++++++++++++++++---
>  2 files changed, 44 insertions(+), 3 deletions(-)

Thanks.

> diff --git a/gdb/NEWS b/gdb/NEWS
> index feb3a37393a..1693a7a15f8 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -192,6 +192,16 @@ QThreadOptions in qSupported
>    QThreadOptions packet, and the qSupported response can contain the
>    set of thread options the remote stub supports.
>  
> +qIsAddressTagged
> +  This new packet allows GDB to query the stub about a given address to check
> +  if it is tagged or not.  Many memory tagging-related GDB commands need to
> +  perform this check before they read/write the allocation tag related to an
> +  address.  Currently, however, this is done through a 'vFile' request to read
> +  the file /proc/<PID>/smaps and check if the address is in a region reported
> +  as memory tagged.  Since not all targets have a notion of what the smaps
> +  file is about, this new packet provides a more generic way to perform such
> +  a check.
> +
>  *** Changes in GDB 14

This part is OK.

> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -44093,6 +44093,35 @@ although this should not happen given @value{GDBN} will only send this packet
>  if the stub has advertised support for memory tagging via @samp{qSupported}.
>  @end table
>  
> +@item qIsAddressTagged:@var{address}
> +@cindex check if a given address is in a memory tagged region
> +@cindex @samp{qIsAddressTagged} packet

The index entries should come _before_ the @item, so that the
index-search commands of an Info reader place you on the line produced
from @item, not after that line.  Sorry I didn't mention that earlier.

OK with the above nit fixed.

Approved-By: Eli Zaretskii <eliz@gnu.org>
  

Patch

diff --git a/gdb/NEWS b/gdb/NEWS
index feb3a37393a..1693a7a15f8 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -192,6 +192,16 @@  QThreadOptions in qSupported
   QThreadOptions packet, and the qSupported response can contain the
   set of thread options the remote stub supports.
 
+qIsAddressTagged
+  This new packet allows GDB to query the stub about a given address to check
+  if it is tagged or not.  Many memory tagging-related GDB commands need to
+  perform this check before they read/write the allocation tag related to an
+  address.  Currently, however, this is done through a 'vFile' request to read
+  the file /proc/<PID>/smaps and check if the address is in a region reported
+  as memory tagged.  Since not all targets have a notion of what the smaps
+  file is about, this new packet provides a more generic way to perform such
+  a check.
+
 *** Changes in GDB 14
 
 * GDB now supports the AArch64 Scalable Matrix Extension 2 (SME2), which
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 82a617e9ad3..90b0b68a279 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -44093,6 +44093,35 @@  although this should not happen given @value{GDBN} will only send this packet
 if the stub has advertised support for memory tagging via @samp{qSupported}.
 @end table
 
+@item qIsAddressTagged:@var{address}
+@cindex check if a given address is in a memory tagged region
+@cindex @samp{qIsAddressTagged} packet
+@anchor {qIsAddressTagged}
+Check if address @var{address} is in a memory tagged region; if it is, it's
+said to be @dfn{tagged}.  The target is responsible for checking it, as this
+is architecture-specific.
+
+@var{address} is the address to be checked.
+
+Reply:
+@table @samp
+Replies to this packet should all be in two hex digit format, as follows:
+
+@item @samp{01}
+Address @var{address} is tagged.
+
+@item @samp{00}
+Address @var{address} is not tagged.
+
+@item E @var{nn}
+An error occurred whose code is @var{nn}.  This means that address could not
+be checked for some reason.
+
+@item @w{}
+An empty reply indicates that @samp{qIsAddressTagged} is not supported by the
+stub.
+@end table
+
 @item QMemTags:@var{start address},@var{length}:@var{type}:@var{tag bytes}
 @anchor{QMemTags}
 @cindex store memory tags
@@ -45141,9 +45170,11 @@  The remote stub supports and implements the required memory tagging
 functionality and understands the @samp{qMemTags} (@pxref{qMemTags}) and
 @samp{QMemTags} (@pxref{QMemTags}) packets.
 
-For AArch64 GNU/Linux systems, this feature also requires access to the
-@file{/proc/@var{pid}/smaps} file so memory mapping page flags can be inspected.
-This is done via the @samp{vFile} requests.
+For AArch64 GNU/Linux systems, this feature can require access to the
+@file{/proc/@var{pid}/smaps} file so memory mapping page flags can be
+inspected, if @samp{qIsAddressTagged} (@pxref{qIsAddressTagged}) packet
+is not supported by the stub.  Access to the @file{/proc/@var{pid}/smaps}
+file is done via @samp{vFile} requests.
 
 @end table