summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step')
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/TestVSCode_step.py78
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/main.cpp16
3 files changed, 99 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/Makefile b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/Makefile
new file mode 100644
index 00000000000..314f1cb2f07
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/TestVSCode_step.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/TestVSCode_step.py
new file mode 100644
index 00000000000..3a9e18b189e
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/TestVSCode_step.py
@@ -0,0 +1,78 @@
+"""
+Test lldb-vscode setBreakpoints request
+"""
+
+from __future__ import print_function
+
+import unittest2
+import vscode
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbvscode_testcase
+import os
+
+
+class TestVSCode_step(lldbvscode_testcase.VSCodeTestCaseBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIfWindows
+ @no_debug_info_test
+ def test_step(self):
+ '''
+ Tests the stepping in/out/over in threads.
+ '''
+ program = self.getBuildArtifact("a.out")
+ self.build_and_launch(program)
+ source = 'main.cpp'
+ # source_path = os.path.join(os.getcwd(), source)
+ breakpoint1_line = line_number(source, '// breakpoint 1')
+ lines = [breakpoint1_line]
+ # Set breakoint in the thread function so we can step the threads
+ breakpoint_ids = self.set_source_breakpoints(source, lines)
+ self.assertTrue(len(breakpoint_ids) == len(lines),
+ "expect correct number of breakpoints")
+ self.continue_to_breakpoints(breakpoint_ids)
+ threads = self.vscode.get_threads()
+ for thread in threads:
+ if 'reason' in thread:
+ reason = thread['reason']
+ if reason == 'breakpoint':
+ # We have a thread that is stopped at our breakpoint.
+ # Get the value of "x" and get the source file and line.
+ # These will help us determine if we are stepping
+ # correctly. If we step a thread correctly we will verify
+ # the correct falue for x as it progresses through the
+ # program.
+ tid = thread['id']
+ x1 = self.get_local_as_int('x', threadId=tid)
+ (src1, line1) = self.get_source_and_line(threadId=tid)
+
+ # Now step into the "recurse()" function call again and
+ # verify, using the new value of "x" and the source file
+ # and line if we stepped correctly
+ self.stepIn(threadId=tid, waitForStop=True)
+ x2 = self.get_local_as_int('x', threadId=tid)
+ (src2, line2) = self.get_source_and_line(threadId=tid)
+ self.assertTrue(x1 == x2 + 1, 'verify step in variable')
+ self.assertTrue(line2 < line1, 'verify step in line')
+ self.assertTrue(src1 == src2, 'verify step in source')
+
+ # Now step out and verify
+ self.stepOut(threadId=tid, waitForStop=True)
+ x3 = self.get_local_as_int('x', threadId=tid)
+ (src3, line3) = self.get_source_and_line(threadId=tid)
+ self.assertTrue(x1 == x3, 'verify step out variable')
+ self.assertTrue(line3 >= line1, 'verify step out line')
+ self.assertTrue(src1 == src3, 'verify step in source')
+
+ # Step over and verify
+ self.stepOver(threadId=tid, waitForStop=True)
+ x4 = self.get_local_as_int('x', threadId=tid)
+ (src4, line4) = self.get_source_and_line(threadId=tid)
+ self.assertTrue(x4 == x3, 'verify step over variable')
+ self.assertTrue(line4 > line3, 'verify step over line')
+ self.assertTrue(src1 == src4, 'verify step over source')
+ # only step one thread that is at the breakpoint and stop
+ break
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/main.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/main.cpp
new file mode 100644
index 00000000000..2fd06311387
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/step/main.cpp
@@ -0,0 +1,16 @@
+#include <thread>
+
+int function(int x) {
+ if ((x % 2) == 0)
+ return function(x-1) + x; // breakpoint 1
+ else
+ return x;
+}
+
+int main(int argc, char const *argv[]) {
+ std::thread thread1(function, 2);
+ std::thread thread2(function, 4);
+ thread1.join();
+ thread2.join();
+ return 0;
+}
OpenPOWER on IntegriCloud