brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · db54efd Raw
58 lines · python
1"""2Test that if we hit a breakpoint on a lambda capture3on two threads at the same time we stop only for4the correct one.5"""6 7import lldb8import lldbsuite.test.lldbutil as lldbutil9from lldbsuite.test.decorators import *10from lldbsuite.test.lldbtest import *11 12 13class TestBreakOnLambdaCapture(TestBase):14    NO_DEBUG_INFO_TESTCASE = True15 16    def test_break_on_lambda_capture(self):17        self.build()18        self.main_source_file = lldb.SBFileSpec("main.cpp")19 20        (target, process, main_thread, _) = lldbutil.run_to_source_breakpoint(21            self, "First break", self.main_source_file22        )23 24        # FIXME: This is working around a separate bug. If you hit a breakpoint and25        # run an expression and it is the first expression you've ever run, on26        # Darwin that will involve running the ObjC runtime parsing code, and we'll27        # be in the middle of that when we do PerformAction on the other thread,28        # which will cause the condition expression to fail.  Calling another29        # expression first works around this.30        val_obj = main_thread.frame[0].EvaluateExpression("true")31        self.assertSuccess(val_obj.GetError(), "Ran our expression successfully")32        self.assertEqual(val_obj.value, "true", "Value was true.")33 34        bkpt = target.BreakpointCreateBySourceRegex(35            "Break here in the helper", self.main_source_file36        )37 38        bkpt.SetCondition("enable && usec == 1")39        process.Continue()40 41        # This is hard to test definitively, becuase it requires hitting42        # a breakpoint on multiple threads at the same time.  On Darwin, this43        # will happen pretty much ever time we continue.  What we are really44        # asserting is that we only ever stop on one thread, so we approximate that45        # by continuing 20 times and assert we only ever hit the first thread.  Either46        # this is a platform that only reports one hit at a time, in which case all47        # this code is unused, or we actually didn't hit the other thread.48 49        for idx in range(0, 20):50            process.Continue()51            for thread in process.threads:52                if thread.id == main_thread.id:53                    self.assertStopReason(54                        thread.stop_reason, lldb.eStopReasonBreakpoint55                    )56                else:57                    self.assertStopReason(thread.stop_reason, lldb.eStopReasonNone)58