[Lldb-commits] [lldb] r127055 - in /lldb/trunk: source/API/SBProcess.cpp test/lldbutil.py test/python_api/process/TestProcessAPI.py

Johnny Chen johnny.chen at apple.com
Fri Mar 4 17:20:11 PST 2011


Author: johnny
Date: Fri Mar  4 19:20:11 2011
New Revision: 127055

URL: http://llvm.org/viewvc/llvm-project?rev=127055&view=rev
Log:
Add a test case ProcessAPITestCase.test_remote_launch() which tests SBProcess.RemoteLaunch()
API with a process not in eStateConnected, and checks that the remote launch failed.

Modify SBProcess::RemoteLaunch()/RemoteAttachToProcessWithID()'s log statements to fix a
crasher when logging is turned on.

Modified:
    lldb/trunk/source/API/SBProcess.cpp
    lldb/trunk/test/lldbutil.py
    lldb/trunk/test/python_api/process/TestProcessAPI.py

Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=127055&r1=127054&r2=127055&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Fri Mar  4 19:20:11 2011
@@ -141,7 +141,7 @@
     if (log) {
         SBStream sstr;
         error.GetDescription (sstr);
-        log->Printf ("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s", error.get(), sstr.GetData());
+        log->Printf ("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s", m_opaque_sp.get(), error.get(), sstr.GetData());
     }
     
     return error.Success();
@@ -171,7 +171,7 @@
     if (log) {
         SBStream sstr;
         error.GetDescription (sstr);
-        log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%d) => SBError (%p): %s", error.get(), sstr.GetData());
+        log->Printf ("SBProcess(%p)::RemoteAttachToProcessWithID (%d) => SBError (%p): %s", m_opaque_sp.get(), pid, error.get(), sstr.GetData());
     }
 
     return error.Success();

Modified: lldb/trunk/test/lldbutil.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbutil.py?rev=127055&r1=127054&r2=127055&view=diff
==============================================================================
--- lldb/trunk/test/lldbutil.py (original)
+++ lldb/trunk/test/lldbutil.py Fri Mar  4 19:20:11 2011
@@ -162,6 +162,8 @@
         return "invalid"
     elif enum == lldb.eStateUnloaded:
         return "unloaded"
+    elif enum == lldb.eStateConnected:
+        return "connected"
     elif enum == lldb.eStateAttaching:
         return "attaching"
     elif enum == lldb.eStateLaunching:
@@ -181,7 +183,7 @@
     elif enum == lldb.eStateSuspended:
         return "suspended"
     else:
-        raise Exception("Unknown stopReason enum")
+        raise Exception("Unknown StateType enum")
 
 def StopReasonString(enum):
     """Returns the stopReason string given an enum."""
@@ -202,7 +204,7 @@
     elif enum == lldb.eStopReasonPlanComplete:
         return "plancomplete"
     else:
-        raise Exception("Unknown stopReason enum")
+        raise Exception("Unknown StopReason enum")
 
 def ValueTypeString(enum):
     """Returns the valueType string given an enum."""
@@ -223,7 +225,7 @@
     elif enum == lldb.eValueTypeConstResult:
         return "constant_result"
     else:
-        raise Exception("Unknown valueType enum")
+        raise Exception("Unknown ValueType enum")
 
 
 # ==================================================

Modified: lldb/trunk/test/python_api/process/TestProcessAPI.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/process/TestProcessAPI.py?rev=127055&r1=127054&r2=127055&view=diff
==============================================================================
--- lldb/trunk/test/python_api/process/TestProcessAPI.py (original)
+++ lldb/trunk/test/python_api/process/TestProcessAPI.py Fri Mar  4 19:20:11 2011
@@ -5,7 +5,7 @@
 import os, time
 import unittest2
 import lldb
-from lldbutil import get_stopped_thread
+from lldbutil import get_stopped_thread, StateTypeString
 from lldbtest import *
 
 class ProcessAPITestCase(TestBase):
@@ -51,6 +51,12 @@
         self.buildDwarf()
         self.access_my_int()
 
+    @python_api_test
+    def test_remote_launch(self):
+        """Test SBProcess.RemoteLaunch() API with a process not in eStateConnected, and it should fail."""
+        self.buildDefault()
+        self.remote_launch_should_fail()
+
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
@@ -230,6 +236,24 @@
         for i in new_bytes:
             print "byte:", i
 
+    def remote_launch_should_fail(self):
+        """Test SBProcess.RemoteLaunch() API with a process not in eStateConnected, and it should fail."""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        target = self.dbg.CreateTarget(exe)
+        self.assertTrue(target.IsValid(), VALID_TARGET)
+
+        # Launch the process, and do not stop at the entry point.
+        error = lldb.SBError()
+        process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, error)
+
+        print "process state:", StateTypeString(process.GetState())
+        self.assertTrue(process.GetState() != lldb.eStateConnected)
+
+        success = process.RemoteLaunch(None, None, None, None, None, None, 0, False, error)
+        self.assertTrue(not success, "RemoteLaunch() should fail for process state != eStateConnected")
+
 
 if __name__ == '__main__':
     import atexit





More information about the lldb-commits mailing list