brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 76c885c Raw
62 lines · python
1"""2Make sure the stop reason of a thread that did not run3during an expression is not changed by running the expression4"""5 6 7import lldb8import lldbsuite.test.lldbutil as lldbutil9from lldbsuite.test.lldbtest import *10from lldbsuite.test.decorators import *11 12 13class TestStopReasonAfterExpression(TestBase):14    @skipIfWindows15    @expectedFailureAll(oslist=["freebsd"], bugnumber="llvm.org/pr48415")16    @expectedFlakeyNetBSD17    def test_thread_state_after_expr(self):18        self.build()19        self.main_source_file = lldb.SBFileSpec("main.cpp")20        self.do_test()21 22    def do_test(self):23        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(24            self, "Set a breakpoint here", self.main_source_file25        )26 27        self.assertEqual(bkpt.GetNumLocations(), 2, "Got two locations")28 29        # So now thread holds the main thread.  Continue to hit the30        # breakpoint again on the spawned thread:31 32        threads = lldbutil.continue_to_breakpoint(process, bkpt)33        self.assertEqual(len(threads), 1, "Hit the breakpoint the second time")34        other_thread = threads[0]35 36        self.assertNotEqual(37            thread.GetThreadID(), other_thread.GetThreadID(), "A different thread"38        )39        # Run an expression ONLY on other_thread.  Don't let thread run:40        options = lldb.SBExpressionOptions()41        options.SetTryAllThreads(False)42        options.SetStopOthers(True)43 44        result = thread.frames[0].EvaluateExpression(45            '(int) printf("Hello\\n")', options46        )47        self.assertSuccess(result.GetError(), "Expression failed")48 49        stop_reason = other_thread.GetStopReason()50 51        self.assertStopReason(52            stop_reason,53            lldb.eStopReasonBreakpoint,54            "Still records stopped at breakpoint: %s"55            % (lldbutil.stop_reason_to_str(stop_reason)),56        )57        self.assertEqual(58            other_thread.GetStopReasonDataAtIndex(0),59            1,60            "Still records stopped at right breakpoint",61        )62