diff options
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump')
4 files changed, 127 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/Makefile new file mode 100644 index 00000000000..6e962b97209 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/Makefile @@ -0,0 +1,3 @@ +ENABLE_THREADS := YES +CXX_SOURCES := main.cpp other.cpp +include Makefile.rules diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py new file mode 100644 index 00000000000..2035435442f --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py @@ -0,0 +1,78 @@ +""" +Test jumping to different places. +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class ThreadJumpTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def test(self): + """Test thread jump handling.""" + self.build(dictionary=self.getBuildFlags()) + exe = self.getBuildArtifact("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', + 'main.cpp:{}'.format( + self.mark3), + 'stop reason = breakpoint 1']) + + # Try the int path, force it to return 'a' + self.do_min_test(self.mark3, self.mark1, "i", "4") + # Try the int path, force it to return 'b' + self.do_min_test(self.mark3, self.mark2, "i", "5") + # Try the double path, force it to return 'a' + self.do_min_test(self.mark4, self.mark1, "j", "7") + # Expected to fail on powerpc64le architecture + if not self.isPPC64le(): + # Try the double path, force it to return 'b' + self.do_min_test(self.mark4, self.mark2, "j", "8") + + # 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): + # jump to the start marker + self.runCmd("j %i" % start) + self.runCmd("thread step-in") # step into the min fn + # jump to the branch we're interested in + self.runCmd("j %i" % jump) + 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/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp new file mode 100644 index 00000000000..e0580bd2542 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/main.cpp @@ -0,0 +1,34 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// 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/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp new file mode 100644 index 00000000000..3ce9ad6548b --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/thread/jump/other.cpp @@ -0,0 +1,12 @@ +//===-- other.cpp -----------------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +int otherfn() +{ + return 4; // other marker +} |