diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py b/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py index 9b3bbae16467..54463c56827a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py @@ -38,19 +38,20 @@ class AttachResumeTestCase(TestBase): self.setAsync(True) listener = self.dbg.GetListener() + process = self.dbg.GetSelectedTarget().GetProcess() self.runCmd("c") - lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) self.runCmd("process interrupt") - lldbutil.expect_state_changes(self, listener, [lldb.eStateStopped]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped]) # be sure to continue/interrupt/continue (r204504) self.runCmd("c") - lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) self.runCmd("process interrupt") - lldbutil.expect_state_changes(self, listener, [lldb.eStateStopped]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped]) # Second interrupt should have no effect. self.expect("process interrupt", patterns=["Process is not running"], error=True) @@ -59,7 +60,7 @@ class AttachResumeTestCase(TestBase): self.runCmd("br set -f main.cpp -l %u" % (line_number('main.cpp', '// Set breakpoint here'))) self.runCmd("c") - lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning, lldb.eStateStopped]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning, lldb.eStateStopped]) self.expect('br list', 'Breakpoint not hit', substrs = ['hit count = 1']) @@ -67,8 +68,8 @@ class AttachResumeTestCase(TestBase): self.expect("expr debugger_flag = false", substrs=[" = false"]); self.runCmd("c") - lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) # make sure to detach while in running state (r204759) self.runCmd("detach") - lldbutil.expect_state_changes(self, listener, [lldb.eStateDetached]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateDetached]) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py index a6a33d7af61f..160a3eff7846 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py @@ -89,11 +89,11 @@ class ThreadStateTestCase(TestBase): # Kill the process self.runCmd("process kill") - def wait_for_running_event(self): + def wait_for_running_event(self, process): listener = self.dbg.GetListener() if lldb.remote_platform: - lldbutil.expect_state_changes(self, listener, [lldb.eStateConnected]) - lldbutil.expect_state_changes(self, listener, [lldb.eStateRunning]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateConnected]) + lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning]) def thread_state_after_continue_test(self): """Test thread state after continue.""" @@ -117,7 +117,7 @@ class ThreadStateTestCase(TestBase): # Continue, the inferior will go into an infinite loop waiting for 'g_test' to change. self.dbg.SetAsync(True) self.runCmd("continue") - self.wait_for_running_event() + self.wait_for_running_event(process) # Check the thread state. It should be running. self.assertFalse(thread.IsStopped(), "Thread state is \'stopped\' when it should be running.") diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py index 021ae2db8f46..45e9bb407d15 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbutil.py +++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -750,14 +750,15 @@ def print_stacktraces(process, string_buffer = False): if string_buffer: return output.getvalue() -def expect_state_changes(test, listener, states, timeout = 5): +def expect_state_changes(test, listener, process, states, timeout = 5): """Listens for state changed events on the listener and makes sure they match what we expect. Stop-and-restart events (where GetRestartedFromEvent() returns true) are ignored.""" for expected_state in states: def get_next_event(): event = lldb.SBEvent() - if not listener.WaitForEvent(timeout, event): + if not listener.WaitForEventForBroadcasterWithType(timeout, process.GetBroadcaster(), + lldb.SBProcess.eBroadcastBitStateChanged, event): test.fail("Timed out while waiting for a transition to state %s" % lldb.SBDebugger.StateAsCString(expected_state)) return event