From 783550be6211b65de45c4c44eac339311f3ae1e2 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Thu, 21 Jan 2016 21:07:30 +0000 Subject: Remove assumptions that thread 0 is always the main thread. Starting with Windows 10, the Windows loader is itself multi-threaded, meaning that the loader spins up a few threads to do process initialization before it executes main. Windows delivers these notifications asynchronously and they can come out of order, so we can't be sure that the first thread we get a notification about is actually the zero'th thread. This patch fixes this by requesting the thread stopped at the breakpoint that was specified, rather than getting thread 0 and verifying that it is stopped at a breakpoint. Differential Revision: http://reviews.llvm.org/D16247 llvm-svn: 258432 --- .../Python/lldbsuite/test/python_api/frame/TestFrames.py | 10 ++++++---- .../test/python_api/frame/inlines/TestInlinedFrame.py | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/python_api/frame') diff --git a/lldb/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py b/lldb/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py index 7cc976fc6aa..d9c81eb7a54 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py @@ -49,7 +49,8 @@ class FrameAPITestCase(TestBase): from six import StringIO as SixStringIO session = SixStringIO() while process.GetState() == lldb.eStateStopped: - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) # Inspect at most 3 frames. numFrames = min(3, thread.GetNumFrames()) for i in range(numFrames): @@ -134,7 +135,8 @@ class FrameAPITestCase(TestBase): self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - thread = process.GetThreadAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) frame = thread.GetFrameAtIndex(0) if self.TraceOn(): print("frame:", frame) @@ -173,8 +175,8 @@ class FrameAPITestCase(TestBase): self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) - thread = process.GetThreadAtIndex(0) - self.assertTrue(thread) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) frameEntered = thread.GetFrameAtIndex(0) if self.TraceOn(): diff --git a/lldb/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py b/lldb/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py index d4cf8fe30cc..f66dcd0389c 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py @@ -60,7 +60,10 @@ class InlinedFrameAPITestCase(TestBase): # # outer_inline (argc); # - frame0 = process.GetThreadAtIndex(0).GetFrameAtIndex(0) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertIsNotNone(thread) + + frame0 = thread.GetFrameAtIndex(0) if frame0.IsInlined(): filename = frame0.GetLineEntry().GetFileSpec().GetFilename() self.assertTrue(filename == self.source) -- cgit v1.2.3