public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [GDB,AArch64] Fix off-by-one when calculating tag granules.
@ 2021-05-11 13:20 Luis Machado
  2021-05-13 10:50 ` Alan Hayward
  2021-05-13 10:50 ` Alan Hayward
  0 siblings, 2 replies; 8+ messages in thread
From: Luis Machado @ 2021-05-11 13:20 UTC (permalink / raw)
  To: gdb-patches

When we want to fetch tags from a memory range, the last address in that
range is not included.

There is a off-by-one error in aarch64_mte_get_tag_granules, which this
patch fixes.

gdb/ChangeLog:

YYYY-MM-DD  Luis Machado  <luis.machado@linaro.org>

	* arch/aarch64-mte-linux.c (aarch64_mte_get_tag_granules): Don't
	include the last address in the range.
---
 gdb/arch/aarch64-mte-linux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gdb/arch/aarch64-mte-linux.c b/gdb/arch/aarch64-mte-linux.c
index 959c0247ed5..7c2ae9a7058 100644
--- a/gdb/arch/aarch64-mte-linux.c
+++ b/gdb/arch/aarch64-mte-linux.c
@@ -31,9 +31,10 @@ aarch64_mte_get_tag_granules (CORE_ADDR addr, size_t len, size_t granule_size)
   /* Start address */
   CORE_ADDR s_addr = align_down (addr, granule_size);
   /* End address */
-  CORE_ADDR e_addr = align_down (addr + len, granule_size);
+  CORE_ADDR e_addr = align_down (addr + len - 1, granule_size);
 
-  /* We always have at least 1 granule.  */
+  /* We always have at least 1 granule because len is non-zero at this
+     point.  */
   return 1 + (e_addr - s_addr) / granule_size;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-13 13:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 13:20 [PATCH] [GDB,AArch64] Fix off-by-one when calculating tag granules Luis Machado
2021-05-13 10:50 ` Alan Hayward
2021-05-13 10:56   ` Luis Machado
2021-05-13 11:24     ` Alan Hayward
2021-05-13 11:50       ` Luis Machado
2021-05-13 12:59         ` Alan Hayward
2021-05-13 13:15           ` Luis Machado
2021-05-13 10:50 ` Alan Hayward

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).