[Lldb-commits] [lldb] [Support] [lldb] Fix thread jump #45326 (PR #135778)
John Harrison via lldb-commits
lldb-commits at lists.llvm.org
Tue May 13 15:08:31 PDT 2025
================
@@ -62,6 +65,71 @@ def test(self):
substrs=["error"],
)
+ def test_jump_offset(self):
+ """Test Thread Jump by negative or positive offset"""
+ exe = self.getBuildArtifact("a.out")
+ file_name = "main.cpp"
+ self.runCmd(f"target create {exe}", CURRENT_EXECUTABLE_SET)
+
+ pos_jump = line_number(file_name, "// jump_offset 1")
+ neg_jump = line_number(file_name, "// jump_offset 2")
+ pos_breakpoint = line_number(file_name, "// breakpoint 1")
+ neg_breakpoint = line_number(file_name, "// breakpoint 2")
+ pos_jump_offset = pos_jump - pos_breakpoint
+ neg_jump_offset = neg_jump - neg_breakpoint
+
+ var_1, var_1_value = ("var_1", "10")
+ var_2, var_2_value = ("var_2", "40")
+ var_3, var_3_value = ("var_3", "10")
+
+ # create pos_breakpoint and neg_breakpoint
+ lldbutil.run_break_set_by_file_and_line(
+ self, file_name, pos_breakpoint, num_expected_locations=1
+ )
+ lldbutil.run_break_set_by_file_and_line(
+ self, file_name, neg_breakpoint, num_expected_locations=1
+ )
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ # test positive jump
+ # The stop reason of the thread should be breakpoint 1.
+ self.expect(
+ "thread list",
+ STOPPED_DUE_TO_BREAKPOINT + " 1",
+ substrs=[
+ "stopped",
+ f"{file_name}:{pos_breakpoint}",
+ "stop reason = breakpoint 1",
+ ],
+ )
+
+ self.runCmd(f"thread jump --by +{pos_jump_offset}")
----------------
ashgti wrote:
If the `+` prefix is optional, should we also test that this works without the prefix?
https://github.com/llvm/llvm-project/pull/135778
More information about the lldb-commits
mailing list