summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump
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/thread/jump
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/thread/jump')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py60
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp35
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp13
4 files changed, 113 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/Makefile
new file mode 100644
index 00000000000..b726fc3695f
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+ENABLE_THREADS := YES
+CXX_SOURCES := main.cpp other.cpp
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
new file mode 100644
index 00000000000..1c0b32dc6d9
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
@@ -0,0 +1,60 @@
+"""
+Test jumping to different places.
+"""
+
+from __future__ import print_function
+
+import use_lldb_suite
+
+import os, time
+import lldb
+from lldbtest import *
+import lldbutil
+
+class ThreadJumpTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test(self):
+ """Test thread jump handling."""
+ self.build(dictionary=self.getBuildFlags())
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+ # Find the line numbers for our breakpoints.
+ self.mark1 = line_number('main.cpp', '// 1st marker')
+ self.mark2 = line_number('main.cpp', '// 2nd marker')
+ self.mark3 = line_number('main.cpp', '// 3rd marker')
+ self.mark4 = line_number('main.cpp', '// 4th marker')
+ self.mark5 = line_number('other.cpp', '// other marker')
+
+ lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.mark3, num_expected_locations=1)
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # The stop reason of the thread should be breakpoint 1.
+ self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 1",
+ substrs = ['stopped',
+ '* thread #1',
+ 'stop reason = breakpoint 1'])
+
+ self.do_min_test(self.mark3, self.mark1, "i", "4"); # Try the int path, force it to return 'a'
+ self.do_min_test(self.mark3, self.mark2, "i", "5"); # Try the int path, force it to return 'b'
+ self.do_min_test(self.mark4, self.mark1, "j", "7"); # Try the double path, force it to return 'a'
+ self.do_min_test(self.mark4, self.mark2, "j", "8"); # Try the double path, force it to return 'b'
+
+ # Try jumping to another function in a different file.
+ self.runCmd("thread jump --file other.cpp --line %i --force" % self.mark5)
+ self.expect("process status",
+ substrs = ["at other.cpp:%i" % self.mark5])
+
+ # Try jumping to another function (without forcing)
+ self.expect("j main.cpp:%i" % self.mark1, COMMAND_FAILED_AS_EXPECTED, error = True,
+ substrs = ["error"])
+
+ def do_min_test(self, start, jump, var, value):
+ self.runCmd("j %i" % start) # jump to the start marker
+ self.runCmd("thread step-in") # step into the min fn
+ self.runCmd("j %i" % jump) # jump to the branch we're interested in
+ self.runCmd("thread step-out") # return out
+ self.runCmd("thread step-over") # assign to the global
+ self.expect("expr %s" % var, substrs = [value]) # check it
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp
new file mode 100644
index 00000000000..3497155a98f
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp
@@ -0,0 +1,35 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// This test verifies the correct handling of program counter jumps.
+
+int otherfn();
+
+template<typename T>
+T min(T a, T b)
+{
+ if (a < b)
+ {
+ return a; // 1st marker
+ } else {
+ return b; // 2nd marker
+ }
+}
+
+int main ()
+{
+ int i;
+ double j;
+ int min_i_a = 4, min_i_b = 5;
+ double min_j_a = 7.0, min_j_b = 8.0;
+ i = min(min_i_a, min_i_b); // 3rd marker
+ j = min(min_j_a, min_j_b); // 4th marker
+
+ return 0;
+}
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp
new file mode 100644
index 00000000000..8108a52c163
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp
@@ -0,0 +1,13 @@
+//===-- other.cpp -----------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int otherfn()
+{
+ return 4; // other marker
+}
OpenPOWER on IntegriCloud