[Lldb-commits] [lldb] r191041 - Make threading tests not depend on the currently selected thread

Daniel Malea daniel.malea at intel.com
Thu Sep 19 15:00:07 PDT 2013


Author: dmalea
Date: Thu Sep 19 17:00:07 2013
New Revision: 191041

URL: http://llvm.org/viewvc/llvm-project?rev=191041&view=rev
Log:
Make threading tests not depend on the currently selected thread
- tests are now anostic to the currently selected thread, as that is a frontend (i.e. driver) decision
- this is in preparation to a fix to POSIXThread::BreakNotify that will be committed shortly

Reviewed by: Matt Kopec


Modified:
    lldb/trunk/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
    lldb/trunk/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
    lldb/trunk/test/functionalities/thread/thread_exit/TestThreadExit.py

Modified: lldb/trunk/test/functionalities/thread/create_during_step/TestCreateDuringStep.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/thread/create_during_step/TestCreateDuringStep.py?rev=191041&r1=191040&r2=191041&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/thread/create_during_step/TestCreateDuringStep.py (original)
+++ lldb/trunk/test/functionalities/thread/create_during_step/TestCreateDuringStep.py Thu Sep 19 17:00:07 2013
@@ -85,7 +85,7 @@ class CreateDuringStepTestCase(TestBase)
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # This should create a breakpoint in the stepping thread.
-        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1)
+        self.bp_num = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1)
 
         # The breakpoint list should show 1 location.
         self.expect("breakpoint list -f", "Breakpoint location shown correctly",
@@ -117,17 +117,22 @@ class CreateDuringStepTestCase(TestBase)
         self.assertTrue(thread1.IsStopped(), "Thread 1 didn't stop during breakpoint")
         self.assertTrue(thread2.IsStopped(), "Thread 2 didn't stop during breakpoint")
 
-        # Keep stepping until we've reached our designated continue point
-        stepping_thread = process.GetSelectedThread()
+        # Find the thread that is stopped at the breakpoint
+        stepping_thread = None
+        for thread in process:
+            expected_bp_desc = "breakpoint %s." % self.bp_num
+            if expected_bp_desc in thread.GetStopDescription(100):
+                stepping_thread = thread
+                break
+        self.assertTrue(stepping_thread != None, "unable to find thread stopped at %s" % expected_bp_desc)
         current_line = self.breakpoint
+        # Keep stepping until we've reached our designated continue point
         while current_line != self.continuepoint:
-            self.runCmd(step_cmd)
-
-            # The thread creation may change the selected thread.
-            # If it does, we just change it back here.
             if stepping_thread != process.GetSelectedThread():
                 process.SetSelectedThread(stepping_thread)
 
+            self.runCmd(step_cmd)
+
             frame = stepping_thread.GetFrameAtIndex(0)
             current_line = frame.GetLineEntry().GetLine()
 

Modified: lldb/trunk/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/thread/exit_during_step/TestExitDuringStep.py?rev=191041&r1=191040&r2=191041&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/thread/exit_during_step/TestExitDuringStep.py (original)
+++ lldb/trunk/test/functionalities/thread/exit_during_step/TestExitDuringStep.py Thu Sep 19 17:00:07 2013
@@ -85,7 +85,7 @@ class ExitDuringStepTestCase(TestBase):
         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # This should create a breakpoint in the main thread.
-        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1)
+        self.bp_num = lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.breakpoint, num_expected_locations=1)
 
         # The breakpoint list should show 1 location.
         self.expect("breakpoint list -f", "Breakpoint location shown correctly",
@@ -119,17 +119,29 @@ class ExitDuringStepTestCase(TestBase):
         self.assertTrue(thread2.IsStopped(), "Thread 2 didn't stop during breakpoint")
         self.assertTrue(thread3.IsStopped(), "Thread 3 didn't stop during breakpoint")
 
-        # Keep stepping until we've reached our designated continue point
-        stepping_thread = process.GetSelectedThread()
+        # Find the thread that is stopped at the breakpoint
+        stepping_thread = None
+        for thread in process:
+            expected_bp_desc = "breakpoint %s." % self.bp_num
+            if expected_bp_desc in thread.GetStopDescription(100):
+                stepping_thread = thread
+                break
+        self.assertTrue(stepping_thread != None, "unable to find thread stopped at %s" % expected_bp_desc)
+
         current_line = self.breakpoint
         stepping_frame = stepping_thread.GetFrameAtIndex(0)
         self.assertTrue(current_line == stepping_frame.GetLineEntry().GetLine(), "Starting line for stepping doesn't match breakpoint line.")
-        while current_line != self.continuepoint:
-            self.runCmd(step_cmd)
 
+        # Keep stepping until we've reached our designated continue point
+        while current_line != self.continuepoint:
+            # Since we're using the command interpreter to issue the thread command
+            # (on the selected thread) we need to ensure the selected thread is the
+            # stepping thread.
             if stepping_thread != process.GetSelectedThread():
                 process.SetSelectedThread(stepping_thread)
 
+            self.runCmd(step_cmd)
+
             frame = stepping_thread.GetFrameAtIndex(0)
 
             current_line = frame.GetLineEntry().GetLine()

Modified: lldb/trunk/test/functionalities/thread/thread_exit/TestThreadExit.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/thread/thread_exit/TestThreadExit.py?rev=191041&r1=191040&r2=191041&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/thread/thread_exit/TestThreadExit.py (original)
+++ lldb/trunk/test/functionalities/thread/thread_exit/TestThreadExit.py Thu Sep 19 17:00:07 2013
@@ -81,7 +81,7 @@ class ThreadExitTestCase(TestBase):
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 2",
             substrs = ['stopped',
                        'thread #1',
-                       '* thread #2',
+                       'thread #2',
                        'stop reason = breakpoint 2',
                        'thread #3'])
 
@@ -96,7 +96,7 @@ class ThreadExitTestCase(TestBase):
         # The stop reason of the thread should be breakpoint 3.
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 3",
             substrs = ['stopped',
-                       '* thread #1',
+                       'thread #1',
                        'stop reason = breakpoint 3',
                        'thread #3',
                        ])
@@ -112,7 +112,7 @@ class ThreadExitTestCase(TestBase):
         # The stop reason of the thread should be breakpoint 4.
         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 4",
             substrs = ['stopped',
-                       '* thread #1',
+                       'thread #1',
                        'stop reason = breakpoint 4'])
 
         # Update the number of threads





More information about the lldb-commits mailing list