summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2016-09-01 00:09:59 +0000
committerEnrico Granata <egranata@apple.com>2016-09-01 00:09:59 +0000
commit7eef5fa14756629dfb0682650a06ea4f2fe19593 (patch)
tree8f8126d9d24d277fc534676ae05bcdf6719332a0 /lldb/packages/Python/lldbsuite/test
parentf1382fc71eef026f20608e1e8e5633ef6b428a96 (diff)
downloadbcm5719-llvm-7eef5fa14756629dfb0682650a06ea4f2fe19593.tar.gz
bcm5719-llvm-7eef5fa14756629dfb0682650a06ea4f2fe19593.zip
Change "memory find" over to using a variation of the Boyer–Moore search algorithm
Fixes rdar://15455621 (and adds a test case for this command which - surprisingly and sadly - was not there originally) llvm-svn: 280327
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/memory/find/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py59
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp17
3 files changed, 81 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/Makefile
new file mode 100644
index 00000000000..314f1cb2f07
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py
new file mode 100644
index 00000000000..f7507c73c94
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/TestMemoryFind.py
@@ -0,0 +1,59 @@
+"""
+Test the 'memory find' command.
+"""
+
+from __future__ import print_function
+
+
+
+import os, time
+import re
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class MemoryFindTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ # Find the line number to break inside main().
+ self.line = line_number('main.cpp', '// break here')
+
+ def test_memory_find(self):
+ """Test the 'memory find' command."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Break in main() aftre the variables are assigned values.
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+ substrs = ['stopped', 'stop reason = breakpoint'])
+
+ # The breakpoint should have a hit count of 1.
+ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+ substrs = [' resolved, hit count = 1'])
+
+ # Test the memory find commands.
+
+ self.expect('memory find -s "in const" `stringdata` `stringdata+(int)strlen(stringdata)`',
+ substrs = ['data found at location: 0x', '69 6e 20 63', 'in const'])
+
+ self.expect('memory find -e "(uint8_t)0x22" `&bytedata[0]` `&bytedata[15]`',
+ substrs = ['data found at location: 0x', '22 33 44 55 66'])
+
+ self.expect('memory find -e "(uint8_t)0x22" `&bytedata[0]` `&bytedata[2]`',
+ substrs = ['data not found within the range.'])
+
+ self.expect('memory find -s "nothere" `stringdata` `stringdata+5`',
+ substrs = ['data not found within the range.'])
+
+ self.expect('memory find -s "nothere" `stringdata` `stringdata+10`',
+ substrs = ['data not found within the range.'])
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp
new file mode 100644
index 00000000000..250f359c76e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/find/main.cpp
@@ -0,0 +1,17 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+#include <stdio.h>
+#include <stdint.h>
+
+int main (int argc, char const *argv[])
+{
+ const char* stringdata = "hello world; I like to write text in const char pointers";
+ uint8_t bytedata[] = {0xAA,0xBB,0xCC,0xDD,0xEE,0xFF,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99};
+ return 0; // break here
+}
OpenPOWER on IntegriCloud