diff options
author | Johnny Chen <johnny.chen@apple.com> | 2012-05-23 22:34:34 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2012-05-23 22:34:34 +0000 |
commit | f9ef60d2369f0798e8b939ce1798a7a4f0234b40 (patch) | |
tree | e44c2a3fd3b7139748eab88d8480f146a2361883 | |
parent | 5ad41dab52dac54714ca5cefa64595f4edd12048 (diff) | |
download | bcm5719-llvm-f9ef60d2369f0798e8b939ce1798a7a4f0234b40.tar.gz bcm5719-llvm-f9ef60d2369f0798e8b939ce1798a7a4f0234b40.zip |
Add SBProcess::GetNumSupportedHardwareWatchpoints() API and export it through the Python scripting bridge.
Add/modify some test cases.
llvm-svn: 157353
-rw-r--r-- | lldb/include/lldb/API/SBProcess.h | 3 | ||||
-rw-r--r-- | lldb/scripts/Python/interface/SBProcess.i | 3 | ||||
-rw-r--r-- | lldb/source/API/SBProcess.cpp | 23 | ||||
-rw-r--r-- | lldb/test/python_api/default-constructor/sb_process.py | 1 | ||||
-rw-r--r-- | lldb/test/python_api/process/TestProcessAPI.py | 25 |
5 files changed, 55 insertions, 0 deletions
diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 5bff8774714..f8ad2946a00 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -188,6 +188,9 @@ public: GetDescription (lldb::SBStream &description); uint32_t + GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; + + uint32_t LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); lldb::SBError diff --git a/lldb/scripts/Python/interface/SBProcess.i b/lldb/scripts/Python/interface/SBProcess.i index 2069adf2de0..049d2a1364a 100644 --- a/lldb/scripts/Python/interface/SBProcess.i +++ b/lldb/scripts/Python/interface/SBProcess.i @@ -282,6 +282,9 @@ public: GetDescription (lldb::SBStream &description); uint32_t + GetNumSupportedHardwareWatchpoints (lldb::SBError &error) const; + + uint32_t LoadImage (lldb::SBFileSpec &image_spec, lldb::SBError &error); lldb::SBError diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 813b41c4637..67027a6d9a5 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -1001,6 +1001,29 @@ SBProcess::GetDescription (SBStream &description) } 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()); diff --git a/lldb/test/python_api/default-constructor/sb_process.py b/lldb/test/python_api/default-constructor/sb_process.py index ce4c5c6bd5c..38ee86f1ec7 100644 --- a/lldb/test/python_api/default-constructor/sb_process.py +++ b/lldb/test/python_api/default-constructor/sb_process.py @@ -44,5 +44,6 @@ def fuzz_obj(obj): obj.LoadImage(lldb.SBFileSpec(), error) obj.UnloadImage(0) obj.Clear() + obj.GetNumSupportedHardwareWatchpoints(error) for thread in obj: print thread diff --git a/lldb/test/python_api/process/TestProcessAPI.py b/lldb/test/python_api/process/TestProcessAPI.py index 95c964c8b04..4718b278619 100644 --- a/lldb/test/python_api/process/TestProcessAPI.py +++ b/lldb/test/python_api/process/TestProcessAPI.py @@ -63,6 +63,12 @@ class ProcessAPITestCase(TestBase): 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 @@ class ProcessAPITestCase(TestBase): 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 |