https://github.com/kendalharland updated https://github.com/llvm/llvm-project/pull/96687
>From b880f6d7951534fd90c3728fb9cabbe515295557 Mon Sep 17 00:00:00 2001 From: kendal <kendal@thebrowser.company> Date: Mon, 24 Jun 2024 13:42:20 -0700 Subject: [PATCH 1/2] Fix flake in TestZerothFrame.py This test is relying on the order of `process.threads` which is nondeterministic. By selecting the thread based on whether it is stopped at our breakpoint we can reliably select the correct one. --- .../unwind/zeroth_frame/TestZerothFrame.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py index f4e883d314644..d660844405e13 100644 --- a/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py +++ b/lldb/test/API/functionalities/unwind/zeroth_frame/TestZerothFrame.py @@ -40,28 +40,28 @@ def test(self): target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - bp1_line = line_number("main.c", "// Set breakpoint 1 here") - bp2_line = line_number("main.c", "// Set breakpoint 2 here") - - lldbutil.run_break_set_by_file_and_line( - self, "main.c", bp1_line, num_expected_locations=1 + main_dot_c = lldb.SBFileSpec("main.c") + bp1 = target.BreakpointCreateBySourceRegex( + "// Set breakpoint 1 here", main_dot_c ) - lldbutil.run_break_set_by_file_and_line( - self, "main.c", bp2_line, num_expected_locations=1 + bp2 = target.BreakpointCreateBySourceRegex( + "// Set breakpoint 2 here", main_dot_c ) process = target.LaunchSimple(None, None, self.get_process_working_directory()) self.assertTrue(process, VALID_PROCESS) - thread = process.GetThreadAtIndex(0) + thread = self.thread() + if self.TraceOn(): print("Backtrace at the first breakpoint:") for f in thread.frames: print(f) + # Check that we have stopped at correct breakpoint. self.assertEqual( - process.GetThreadAtIndex(0).frame[0].GetLineEntry().GetLine(), - bp1_line, + thread.frame[0].GetLineEntry().GetLine(), + bp1.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(), "LLDB reported incorrect line number.", ) @@ -70,7 +70,6 @@ def test(self): # 'continue' command. process.Continue() - thread = process.GetThreadAtIndex(0) if self.TraceOn(): print("Backtrace at the second breakpoint:") for f in thread.frames: @@ -78,7 +77,7 @@ def test(self): # Check that we have stopped at the breakpoint self.assertEqual( thread.frame[0].GetLineEntry().GetLine(), - bp2_line, + bp2.GetLocationAtIndex(0).GetAddress().GetLineEntry().GetLine(), "LLDB reported incorrect line number.", ) # Double-check with GetPCAddress() >From b579f4cf8a234331f0a8b2f276d438c22980a322 Mon Sep 17 00:00:00 2001 From: kendal <kendal@thebrowser.company> Date: Mon, 24 Jun 2024 14:01:31 -0700 Subject: [PATCH 2/2] Fix test assertions in TestDAP_stepInTargets.py --- .../stepInTargets/TestDAP_stepInTargets.py | 25 +++++++++++++------ .../API/tools/lldb-dap/stepInTargets/main.cpp | 6 ++--- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py index 6296f6554d07e..4b7caf99e95cc 100644 --- a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py +++ b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py @@ -55,14 +55,23 @@ def test_basic(self): self.assertEqual(len(step_in_targets), 3, "expect 3 step in targets") # Verify the target names are correct. - self.assertEqual(step_in_targets[0]["label"], "bar()", "expect bar()") - self.assertEqual(step_in_targets[1]["label"], "bar2()", "expect bar2()") - self.assertEqual( - step_in_targets[2]["label"], "foo(int, int)", "expect foo(int, int)" - ) + # The order of funcA and funcB may change depending on the compiler ABI. + funcA_target = None + funcB_target = None + for target in step_in_targets[0:2]: + if "funcB" in target["label"]: + funcB_target = target + elif "funcA" in target["label"]: + funcA_target = target + else: + self.fail(f"Unexpected step in target: {target}") + + self.assertIsNotNone(funcA_target, "expect funcA") + self.assertIsNotNone(funcB_target, "expect funcB") + self.assertIn("foo", step_in_targets[2]["label"], "expect foo") - # Choose to step into second target and verify that we are in bar2() - self.stepIn(threadId=tid, targetId=step_in_targets[1]["id"], waitForStop=True) + # Choose to step into second target and verify that we are in funcB() + self.stepIn(threadId=tid, targetId=funcB_target["id"], waitForStop=True) leaf_frame = self.dap_server.get_stackFrame() self.assertIsNotNone(leaf_frame, "expect a leaf frame") - self.assertEqual(leaf_frame["name"], "bar2()") + self.assertIn("funcB", leaf_frame["name"], "expect funcB") diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp b/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp index d3c3dbcc139ef..a48b79af0c760 100644 --- a/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp +++ b/lldb/test/API/tools/lldb-dap/stepInTargets/main.cpp @@ -1,11 +1,11 @@ int foo(int val, int extra) { return val + extra; } -int bar() { return 22; } +int funcA() { return 22; } -int bar2() { return 54; } +int funcB() { return 54; } int main(int argc, char const *argv[]) { - foo(bar(), bar2()); // set breakpoint here + foo(funcA(), funcB()); // set breakpoint here return 0; } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits