diff options
-rw-r--r-- | lldb/include/lldb/API/SBTarget.h | 3 | ||||
-rw-r--r-- | lldb/include/lldb/Breakpoint/WatchpointLocationList.h | 1 | ||||
-rw-r--r-- | lldb/include/lldb/Target/Target.h | 7 | ||||
-rw-r--r-- | lldb/scripts/Python/interface/SBTarget.i | 3 | ||||
-rw-r--r-- | lldb/scripts/Python/modify-python-lldb.py | 11 | ||||
-rw-r--r-- | lldb/source/API/SBTarget.cpp | 25 | ||||
-rw-r--r-- | lldb/source/Target/Target.cpp | 6 | ||||
-rw-r--r-- | lldb/test/python_api/default-constructor/sb_target.py | 8 | ||||
-rw-r--r-- | lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py | 4 |
9 files changed, 59 insertions, 9 deletions
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h index 023e5e7a5b6..97dc66b5925 100644 --- a/lldb/include/lldb/API/SBTarget.h +++ b/lldb/include/lldb/API/SBTarget.h @@ -448,6 +448,9 @@ public: GetNumWatchpointLocations () const; lldb::SBWatchpointLocation + GetLastCreatedWatchpointLocation (); + + lldb::SBWatchpointLocation GetWatchpointLocationAtIndex (uint32_t idx) const; bool diff --git a/lldb/include/lldb/Breakpoint/WatchpointLocationList.h b/lldb/include/lldb/Breakpoint/WatchpointLocationList.h index 07991593b3c..84b3f3c9d07 100644 --- a/lldb/include/lldb/Breakpoint/WatchpointLocationList.h +++ b/lldb/include/lldb/Breakpoint/WatchpointLocationList.h @@ -187,6 +187,7 @@ public: size_t GetSize() const { + Mutex::Locker locker(m_mutex); return m_address_to_location.size(); } diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 53e7596dbe0..835def27485 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -298,6 +298,12 @@ public: size_t size, uint32_t type); + lldb::WatchpointLocationSP + GetLastCreatedWatchpointLocation () + { + return m_last_created_watchpoint_location; + } + WatchpointLocationList & GetWatchpointLocationList() { @@ -866,6 +872,7 @@ protected: BreakpointList m_internal_breakpoint_list; lldb::BreakpointSP m_last_created_breakpoint; WatchpointLocationList m_watchpoint_location_list; + lldb::WatchpointLocationSP m_last_created_watchpoint_location; // We want to tightly control the process destruction process so // we can correctly tear down everything that we need to, so the only // class that knows about the process lifespan is this target class. diff --git a/lldb/scripts/Python/interface/SBTarget.i b/lldb/scripts/Python/interface/SBTarget.i index 3bf14b1010a..6feb2167b16 100644 --- a/lldb/scripts/Python/interface/SBTarget.i +++ b/lldb/scripts/Python/interface/SBTarget.i @@ -439,6 +439,9 @@ public: GetNumWatchpointLocations () const; lldb::SBWatchpointLocation + GetLastCreatedWatchpointLocation (); + + lldb::SBWatchpointLocation GetWatchpointLocationAtIndex (uint32_t idx) const; bool diff --git a/lldb/scripts/Python/modify-python-lldb.py b/lldb/scripts/Python/modify-python-lldb.py index 462467734cd..ac523be956d 100644 --- a/lldb/scripts/Python/modify-python-lldb.py +++ b/lldb/scripts/Python/modify-python-lldb.py @@ -199,11 +199,12 @@ d = { 'SBBreakpoint': ('GetNumLocations', 'GetLocationAtIndex'), # # This dictionary defines a mapping from classname to equality method name(s). # -e = { 'SBAddress': ['GetFileAddress', 'GetModule'], - 'SBBreakpoint': ['GetID'], - 'SBFileSpec': ['GetFilename', 'GetDirectory'], - 'SBModule': ['GetFileSpec', 'GetUUIDString'], - 'SBType': ['GetByteSize', 'GetName'] +e = { 'SBAddress': ['GetFileAddress', 'GetModule'], + 'SBBreakpoint': ['GetID'], + 'SBWatchpointLocation': ['GetID'], + 'SBFileSpec': ['GetFilename', 'GetDirectory'], + 'SBModule': ['GetFileSpec', 'GetUUIDString'], + 'SBType': ['GetByteSize', 'GetName'] } def list_to_frag(list): diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index fa074b24737..f4ad92dc027 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -871,19 +871,40 @@ SBTarget::GetNumWatchpointLocations () const { if (m_opaque_sp) { - // The breakpoint list is thread safe, no need to lock + // The watchpoint location list is thread safe, no need to lock return m_opaque_sp->GetWatchpointLocationList().GetSize(); } return 0; } SBWatchpointLocation +SBTarget::GetLastCreatedWatchpointLocation () +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBWatchpointLocation sb_watchpoint_location; + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + sb_watchpoint_location = m_opaque_sp->GetLastCreatedWatchpointLocation(); + } + + if (log) + { + log->Printf ("SBTarget(%p)::GetLastCreateWatchpointLocation () => SBWatchpointLocation(%p)", + m_opaque_sp.get(), sb_watchpoint_location.get()); + } + + return sb_watchpoint_location; +} + +SBWatchpointLocation SBTarget::GetWatchpointLocationAtIndex (uint32_t idx) const { SBWatchpointLocation sb_watchpoint_location; if (m_opaque_sp) { - // The breakpoint list is thread safe, no need to lock + // The watchpoint location list is thread safe, no need to lock *sb_watchpoint_location = m_opaque_sp->GetWatchpointLocationList().GetByIndex(idx); } return sb_watchpoint_location; diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 6a742c28e59..7209382c789 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -167,6 +167,7 @@ Target::Destroy() m_breakpoint_list.RemoveAll(notify); m_internal_breakpoint_list.RemoveAll(notify); m_last_created_breakpoint.reset(); + m_last_created_watchpoint_location.reset(); m_search_filter_sp.reset(); m_image_search_paths.Clear(notify); m_scratch_ast_context_ap.reset(); @@ -452,7 +453,10 @@ Target::CreateWatchpointLocation(lldb::addr_t addr, size_t size, uint32_t type) rc.Success() ? "succeeded" : "failed", wp_loc_sp->GetID()); - if (rc.Fail()) wp_loc_sp.reset(); + if (rc.Fail()) + wp_loc_sp.reset(); + else + m_last_created_watchpoint_location = wp_loc_sp; return wp_loc_sp; } diff --git a/lldb/test/python_api/default-constructor/sb_target.py b/lldb/test/python_api/default-constructor/sb_target.py index 36db20fd3f0..e1a5db63cf3 100644 --- a/lldb/test/python_api/default-constructor/sb_target.py +++ b/lldb/test/python_api/default-constructor/sb_target.py @@ -40,6 +40,14 @@ def fuzz_obj(obj): obj.EnableAllBreakpoints() obj.DisableAllBreakpoints() obj.DeleteAllBreakpoints() + obj.GetNumWatchpointLocations() + obj.GetLastCreatedWatchpointLocation() + obj.GetWatchpointLocationAtIndex(0) + obj.WatchpointLocationDelete(0) + obj.FindWatchpointLocationByID(0) + obj.EnableAllWatchpointLocations() + obj.DisableAllWatchpointLocations() + obj.DeleteAllWatchpointLocations() obj.GetBroadcaster() obj.GetDescription(lldb.SBStream(), lldb.eDescriptionLevelBrief) obj.Clear() diff --git a/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py b/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py index d54c2105333..fdaa04a18d0 100644 --- a/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py +++ b/lldb/test/python_api/watchpoint/TestWatchpointLocationIter.py @@ -65,7 +65,9 @@ class WatchpointLocationIteratorTestCase(TestBase): # There should be only 1 watchpoint location under the target. self.assertTrue(target.GetNumWatchpointLocations() == 1) - wp_loc = target.GetWatchpointLocationAtIndex(0) + wp_loc = target.GetWatchpointLocationAtIndex(0) + last_created = target.GetLastCreatedWatchpointLocation() + self.assertTrue(wp_loc == last_created) self.assertTrue(wp_loc.IsEnabled()) watch_id = wp_loc.GetID() self.assertTrue(watch_id != 0) |