[Lldb-commits] [lldb] [lldb] Ignore the top byte in address_ranges_helper.py (PR #185802)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 10 21:58:18 PDT 2026
https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/185802
Update address_ranges_helper.py to work when running under ARM's Memory Tagging Extension (MTE), which relies on Top Byte Ignore (TBI) to store a tag in the most significant part of the address. The helper was doing pointer arithmetic on addresses, which requires stripping the top byte.
This fixes TestFindInMemory.py and TestFindRangesInMemory.py when running the LLDB test suite with MTE.
>From 4b1697f14ee20042b2e4fd0d58dc5b630bf3e33f Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Tue, 10 Mar 2026 21:52:44 -0700
Subject: [PATCH] [lldb] Ignore the top byte in address_ranges_helper.py
Update address_ranges_helper.py to work when running under ARM's Memory
Tagging Extension (MTE), which relies on Top Byte Ignore (TBI) to store
a tag in the most significant part of the address. The helper was doing
pointer arithmetic on addresses, which requires stripping the top byte.
This fixes TestFindInMemory.py and TestFindRangesInMemory.py when
running the LLDB test suite with MTE.
---
.../find_in_memory/address_ranges_helper.py | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
index 102f2b0edd4c6..fb2753731b162 100644
--- a/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
+++ b/lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
@@ -5,6 +5,12 @@
ALIGNED_INSTANCE_PATTERN_HEAP = "i_am_unaligned_string_on_the_heap"
UNALIGNED_INSTANCE_PATTERN_HEAP = ALIGNED_INSTANCE_PATTERN_HEAP[1:]
+TBI_MASK = 0xFF00000000000000
+
+
+def strip_tbi(addr):
+ return addr & ~TBI_MASK
+
def GetAlignedRange(test_base, shrink=False):
frame = test_base.thread.GetSelectedFrame()
@@ -31,21 +37,20 @@ def GetRangeFromAddrValue(test_base, addr, shrink=False):
If 'shrink' is True, the address range will be reduced to not exceed 2K.
"""
region = lldb.SBMemoryRegionInfo()
+ addr_val = strip_tbi(addr.GetValueAsUnsigned())
test_base.assertTrue(
- test_base.process.GetMemoryRegionInfo(
- addr.GetValueAsUnsigned(), region
- ).Success(),
+ test_base.process.GetMemoryRegionInfo(addr_val, region).Success(),
)
test_base.assertTrue(region.IsReadable())
test_base.assertFalse(region.IsExecutable())
- base = region.GetRegionBase()
- end = region.GetRegionEnd()
+ base = strip_tbi(region.GetRegionBase())
+ end = strip_tbi(region.GetRegionEnd())
if shrink:
- addr2 = addr.GetValueAsUnsigned()
- addr2 -= addr2 % 512
+ addr2 = addr_val
+ addr2 -= addr_val % 512
base = max(base, addr2 - 1024)
end = min(end, addr2 + 1024)
More information about the lldb-commits
mailing list