[Lldb-commits] [lldb] r157353 - in /lldb/trunk: include/lldb/API/SBProcess.h scripts/Python/interface/SBProcess.i source/API/SBProcess.cpp test/python_api/default-constructor/sb_process.py test/python_api/process/TestProcessAPI.py

Johnny Chen johnny.chen at apple.com
Wed May 23 15:34:34 PDT 2012


Author: johnny
Date: Wed May 23 17:34:34 2012
New Revision: 157353

URL: http://llvm.org/viewvc/llvm-project?rev=157353&view=rev
Log:
Add SBProcess::GetNumSupportedHardwareWatchpoints() API and export it through the Python scripting bridge.
Add/modify some test cases.

Modified:
    lldb/trunk/include/lldb/API/SBProcess.h
    lldb/trunk/scripts/Python/interface/SBProcess.i
    lldb/trunk/source/API/SBProcess.cpp
    lldb/trunk/test/python_api/default-constructor/sb_process.py
    lldb/trunk/test/python_api/process/TestProcessAPI.py

Modified: lldb/trunk/include/lldb/API/SBProcess.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=157353&r1=157352&r2=157353&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBProcess.h (original)
+++ lldb/trunk/include/lldb/API/SBProcess.h Wed May 23 17:34:34 2012
@@ -188,6 +188,9 @@
     GetDescription (lldb::SBStream &description);
 
     uint32_t
+    GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
+
+    uint32_t
     LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
     
     lldb::SBError

Modified: lldb/trunk/scripts/Python/interface/SBProcess.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBProcess.i?rev=157353&r1=157352&r2=157353&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBProcess.i (original)
+++ lldb/trunk/scripts/Python/interface/SBProcess.i Wed May 23 17:34:34 2012
@@ -282,6 +282,9 @@
     GetDescription (lldb::SBStream &description);
 
     uint32_t
+    GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const;
+
+    uint32_t
     LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error);
     
     lldb::SBError

Modified: lldb/trunk/source/API/SBProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=157353&r1=157352&r2=157353&view=diff
==============================================================================
--- lldb/trunk/source/API/SBProcess.cpp (original)
+++ lldb/trunk/source/API/SBProcess.cpp Wed May 23 17:34:34 2012
@@ -1001,6 +1001,29 @@
 }
 
 uint32_t
+SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const
+{
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    uint32_t num = 0;
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
+        sb_error.SetError(process_sp->GetWatchpointSupportInfo (num));
+        LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+        if (log)
+            log->Printf ("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u",
+                         process_sp.get(), num);
+    }
+    else
+    {
+        sb_error.SetErrorString ("SBProcess is invalid");
+    }
+    return num;
+}
+
+uint32_t
 SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error)
 {
     ProcessSP process_sp(GetSP());

Modified: lldb/trunk/test/python_api/default-constructor/sb_process.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_process.py?rev=157353&r1=157352&r2=157353&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_process.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_process.py Wed May 23 17:34:34 2012
@@ -44,5 +44,6 @@
     obj.LoadImage(lldb.SBFileSpec(), error)
     obj.UnloadImage(0)
     obj.Clear()
+    obj.GetNumSupportedHardwareWatchpoints(error)
     for thread in obj:
         print thread

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=157353&r1=157352&r2=157353&view=diff
==============================================================================
--- lldb/trunk/test/python_api/process/TestProcessAPI.py (original)
+++ lldb/trunk/test/python_api/process/TestProcessAPI.py Wed May 23 17:34:34 2012
@@ -63,6 +63,12 @@
         self.buildDefault()
         self.remote_launch_should_fail()
 
+    @python_api_test
+    def test_get_num_supported_hardware_watchpoints(self):
+        """Test SBProcess.GetNumSupportedHardwareWatchpoints() API with a process."""
+        self.buildDefault()
+        self.get_num_supported_hardware_watchpoints()
+
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
@@ -310,6 +316,25 @@
         success = process.RemoteLaunch(None, None, None, None, None, None, 0, False, error)
         self.assertTrue(not success, "RemoteLaunch() should fail for process state != eStateConnected")
 
+    def get_num_supported_hardware_watchpoints(self):
+        """Test SBProcess.GetNumSupportedHardwareWatchpoints() API with a process."""
+        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, os.getcwd())
+
+        error = lldb.SBError();
+        num = process.GetNumSupportedHardwareWatchpoints(error)
+        if self.TraceOn() and error.Success():
+            print "Number of supported hardware watchpoints: %d" % num
+
 
 if __name__ == '__main__':
     import atexit





More information about the lldb-commits mailing list