Honsik updated this revision to Diff 49258.
Honsik added a comment.

OK I have modified the PrivateResume to add the check and release the public 
running lock.


http://reviews.llvm.org/D17635

Files:
  
packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
  packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===================================================================
--- source/Target/Process.cpp
+++ source/Target/Process.cpp
@@ -3548,7 +3548,17 @@
                     StateAsCString(m_public_state.GetValue()),
                     StateAsCString(m_private_state.GetValue()));
 
-    Error error (WillResume());
+    Error error;
+    // Cannot resume already exited process. Public running lock is
+    // held when PrivateResume is entered
+    if (!IsAlive())
+    {
+        m_public_run_lock.SetStopped();
+        error.SetErrorString("Process is not alive");
+        return error;
+    }
+
+    error = WillResume();
     // Tell the process it is about to resume before the thread list
     if (error.Success())
     {
Index: packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
===================================================================
--- packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
+++ packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py
@@ -284,3 +284,40 @@
         if self.TraceOn() and error.Success():
             print("Number of supported hardware watchpoints: %d" % num)
 
+    @add_test_categories(['pyapi'])
+    def test_continue_after_process_exit(self):
+        """Test SBProcess.Continue() API after the process exits."""
+        self.build()
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target, VALID_TARGET)
+
+        breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line)
+        self.assertTrue(breakpoint, VALID_BREAKPOINT)
+
+        # Launch the process, and do not stop at the entry point.
+        process = target.LaunchSimple (None, None, self.get_process_working_directory())
+
+        thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+        self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint")
+        
+        frame = thread.GetFrameAtIndex(0)
+        le = frame.GetLineEntry()
+        self.assertTrue(le.IsValid(), "There should be valid line entry at breakpoint")
+        self.assertEqual(self.line, le.GetLine(), "There should be valid line number")
+        
+        # Continue the return out of main
+        err = process.Continue()
+        self.assertTrue(err.Success(), "Continue after breakpoint should be valid")
+        
+        # At this point, the inferior process should have exited.
+        self.assertEqual(lldb.eStateExited, process.GetState(), PROCESS_EXITED)
+        
+        # Continue after proces exited should fail with good message, try it multiple times
+        for i in range(2):
+            err = process.Continue()
+            self.assertTrue(err.Fail(), "Continue after exit shouldn't be valid")
+            self.assertIn("Process is not alive", err.GetCString())
+        
\ No newline at end of file
Index: packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
===================================================================
--- packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
+++ packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_case_sensitivity/TestBreakpointCaseSensitivity.py
@@ -25,7 +25,6 @@
         self.case_sensitivity_breakpoint(True)
 
     @skipIf(oslist=['windows']) # Skip for windows platforms
-    @expectedFailureAll() # Failing for unknown reason on non-Windows platforms.
     def test_breakpoint_doesnt_match_file_with_different_case(self):
         """Set breakpoint on file, shouldn't match files with different case on POSIX systems"""
         self.build()
@@ -86,15 +85,22 @@
                                                                    lldb.SBFileSpec(file))
         else:    
             breakpoint = self.target.BreakpointCreateByLocation(file, self.line)
+       
+        # breakpoint should be always created
+        self.assertTrue(breakpoint, VALID_BREAKPOINT + desc)
         
-        self.assertEqual(breakpoint and breakpoint.GetNumLocations() == 1,
-                    should_hit,
+        # check number of locations
+        self.assertEqual(breakpoint.GetNumLocations(),
+                    int(should_hit),
                     VALID_BREAKPOINT + desc)
+        
 
         # Get the breakpoint location from breakpoint after we verified that,
         # indeed, it has one location.
         location = breakpoint.GetLocationAtIndex(0)
-        self.assertEqual(location and location.IsEnabled(),
+        # location has to be converted to bool. If no location is present, GetLocationAtIndex returns None.
+        # Because None and xxxx = None, test will always fail (None != False and None != True)
+        self.assertEqual(bool(location) and location.IsEnabled(),
                     should_hit,
                     VALID_BREAKPOINT_LOCATION + desc)
         
@@ -113,9 +119,9 @@
             # check the breakpoint was not hit
             self.assertEqual(lldb.eStateExited, process.GetState())
             self.assertEqual(breakpoint.GetHitCount(), 0)
-
-        # let process finish
-        process.Continue()
         
         # cleanup
         self.target.BreakpointDelete(breakpoint.GetID())
+        # let process finish
+        process.Continue()
+        
\ No newline at end of file
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to