DavidSpickett updated this revision to Diff 401904.
DavidSpickett added a comment.

Fix "to to" in comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117299/new/

https://reviews.llvm.org/D117299

Files:
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/test/API/linux/aarch64/tagged_memory_access/Makefile
  
lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
  lldb/test/API/linux/aarch64/tagged_memory_access/main.c
  lldb/test/API/linux/aarch64/tagged_memory_read/Makefile
  
lldb/test/API/linux/aarch64/tagged_memory_read/TestAArch64LinuxTaggedMemoryRead.py
  lldb/test/API/linux/aarch64/tagged_memory_read/main.c

Index: lldb/test/API/linux/aarch64/tagged_memory_access/main.c
===================================================================
--- lldb/test/API/linux/aarch64/tagged_memory_access/main.c
+++ lldb/test/API/linux/aarch64/tagged_memory_access/main.c
@@ -5,11 +5,15 @@
   return (char *)((size_t)ptr | (tag << 56));
 }
 
-int main(int argc, char const *argv[]) {
-  char buf[32];
+// Global to zero init
+char buf[32];
 
+int main(int argc, char const *argv[]) {
   char *ptr1 = set_non_address_bits(buf, 0x34);
   char *ptr2 = set_non_address_bits(buf, 0x56);
 
+  // Target value for "memory find"
+  buf[15] = '?';
+
   return 0; // Set break point at this line.
 }
Index: lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
===================================================================
--- lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
+++ lldb/test/API/linux/aarch64/tagged_memory_access/TestAArch64LinuxTaggedMemoryAccess.py
@@ -1,6 +1,9 @@
 """
-Test that "memory read" removes non address bits from
-memory read arguments.
+Test that "memory read" and "memory find" remove non address bits from
+address arguments.
+
+These tests use the top byte ignore feature of AArch64. Which Linux
+always enables.
 """
 
 
@@ -17,10 +20,7 @@
 
     NO_DEBUG_INFO_TESTCASE = True
 
-    # AArch64 Linux always enables top byte ignore
-    @skipUnlessArch("aarch64")
-    @skipUnlessPlatform(["linux"])
-    def test_tagged_memory_read(self):
+    def setup_test(self):
         self.build()
         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
@@ -37,6 +37,11 @@
             substrs=['stopped',
                      'stop reason = breakpoint'])
 
+    @skipUnlessArch("aarch64")
+    @skipUnlessPlatform(["linux"])
+    def test_tagged_memory_read(self):
+        self.setup_test()
+
         # If we do not remove non address bits, this can fail in two ways.
         # 1. We attempt to read much more than 16 bytes, probably more than
         #    the default 1024 byte read size. Which will error.
@@ -53,3 +58,26 @@
         # Would fail if we don't remove non address bits because 0x56... > 0x34...
         self.expect("memory read ptr2 ptr1+16", patterns=[tagged_addr_pattern], matching=False)
         self.expect("memory read", patterns=[tagged_addr_pattern], matching=False)
+
+    @skipUnlessArch("aarch64")
+    @skipUnlessPlatform(["linux"])
+    def test_tagged_memory_find(self):
+        self.setup_test()
+
+        # If memory find doesn't remove non-address bits one of two
+        # things happen.
+        # 1. It tries to search a gigantic amount of memory.
+        #    We're not going to test for this because a failure
+        #    would take a very long time and perhaps even find the
+        #    target value randomly.
+        # 2. It thinks high address <= low address, which we check below.
+
+        self.runCmd("memory find -s '?' ptr2 ptr1+32")
+
+        self.assertTrue(self.res.Succeeded())
+        out = self.res.GetOutput()
+        # memory find does not fail when it doesn't find the data.
+        # First check we actually got something.
+        self.assertRegexpMatches(out, "data found at location: 0x[0-9A-Fa-f]+")
+        # Then that the location found does not display the tag bits.
+        self.assertNotRegexpMatches(out, "data found at location: 0x(34|56)[0-9A-Fa-f]+")
Index: lldb/test/API/linux/aarch64/tagged_memory_read/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/linux/aarch64/tagged_memory_read/Makefile
@@ -1,3 +0,0 @@
-C_SOURCES := main.c
-
-include Makefile.rules
Index: lldb/source/Commands/CommandObjectMemory.cpp
===================================================================
--- lldb/source/Commands/CommandObjectMemory.cpp
+++ lldb/source/Commands/CommandObjectMemory.cpp
@@ -1035,6 +1035,12 @@
       return false;
     }
 
+    ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI();
+    if (abi) {
+      low_addr = abi->FixDataAddress(low_addr);
+      high_addr = abi->FixDataAddress(high_addr);
+    }
+
     if (high_addr <= low_addr) {
       result.AppendError(
           "starting address must be smaller than ending address");
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to