summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/memory
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
committerZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
commitc432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch)
tree4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/functionalities/memory
parenta8a3bd210086b50242903ed95048fe5e53897878 (diff)
downloadbcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz
bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code structured into a bona-fide Python package. This has a number of benefits, but most notably the ability to more easily share Python code between different but related pieces of LLDB's Python infrastructure (for example, `scripts` can now share code with `test`). llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/memory')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/memory/read/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py91
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp18
3 files changed, 114 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/Makefile
new file mode 100644
index 00000000000..314f1cb2f07
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/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/read/TestMemoryRead.py b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
new file mode 100644
index 00000000000..085c9bdd989
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/TestMemoryRead.py
@@ -0,0 +1,91 @@
+"""
+Test the 'memory read' command.
+"""
+
+from __future__ import print_function
+
+import use_lldb_suite
+
+import os, time
+import re
+import lldb
+from lldbtest import *
+import lldbutil
+
+class MemoryReadTestCase(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', '// Set break point at this line.')
+
+ @expectedFailureAll("llvm.org/pr23139", oslist=["linux"], compiler="gcc", compiler_version=[">=","4.9"], archs=["i386"])
+ def test_memory_read(self):
+ """Test the 'memory read' command with plain and vector formats."""
+ 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 read commands.
+
+ # (lldb) memory read -f d -c 1 `&argc`
+ # 0x7fff5fbff9a0: 1
+ self.runCmd("memory read -f d -c 1 `&argc`")
+
+ # Find the starting address for variable 'argc' to verify later that the
+ # '--format uint32_t[] --size 4 --count 4' option increments the address
+ # correctly.
+ line = self.res.GetOutput().splitlines()[0]
+ items = line.split(':')
+ address = int(items[0], 0)
+ argc = int(items[1], 0)
+ self.assertTrue(address > 0 and argc == 1)
+
+ # (lldb) memory read --format uint32_t[] --size 4 --count 4 `&argc`
+ # 0x7fff5fbff9a0: {0x00000001}
+ # 0x7fff5fbff9a4: {0x00000000}
+ # 0x7fff5fbff9a8: {0x0ec0bf27}
+ # 0x7fff5fbff9ac: {0x215db505}
+ self.runCmd("memory read --format uint32_t[] --size 4 --count 4 `&argc`")
+ lines = self.res.GetOutput().splitlines()
+ for i in range(4):
+ if i == 0:
+ # Verify that the printout for argc is correct.
+ self.assertTrue(argc == int(lines[i].split(':')[1].strip(' {}'), 0))
+ addr = int(lines[i].split(':')[0], 0)
+ # Verify that the printout for addr is incremented correctly.
+ self.assertTrue(addr == (address + i*4))
+
+ # (lldb) memory read --format char[] --size 7 --count 1 `&my_string`
+ # 0x7fff5fbff990: {abcdefg}
+ self.expect("memory read --format char[] --size 7 --count 1 `&my_string`",
+ substrs = ['abcdefg'])
+
+ # (lldb) memory read --format 'hex float' --size 16 `&argc`
+ # 0x7fff5fbff5b0: error: unsupported byte size (16) for hex float format
+ self.expect("memory read --format 'hex float' --size 16 `&argc`",
+ substrs = ['unsupported byte size (16) for hex float format'])
+
+ self.expect("memory read --format 'float' --count 1 --size 8 `&my_double`",
+ substrs = ['1234.'])
+
+ # (lldb) memory read --format 'float' --count 1 --size 20 `&my_double`
+ # 0x7fff5fbff598: error: unsupported byte size (20) for float format
+ self.expect("memory read --format 'float' --count 1 --size 20 `&my_double`",
+ substrs = ['unsupported byte size (20) for float format'])
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
new file mode 100644
index 00000000000..b4d7809d27c
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/memory/read/main.cpp
@@ -0,0 +1,18 @@
+//===-- 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>
+
+int main (int argc, char const *argv[])
+{
+ char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0};
+ double my_double = 1234.5678;
+ printf("my_string=%s\n", my_string); // Set break point at this line.
+ printf("my_double=%g\n", my_double);
+ return 0;
+}
OpenPOWER on IntegriCloud