[Lldb-commits] [lldb] r140633 - in /lldb/trunk: include/lldb/API/SBTarget.h include/lldb/Breakpoint/WatchpointLocationList.h include/lldb/Target/Target.h scripts/Python/interface/SBTarget.i scripts/Python/modify-python-lldb.py source/API/SBTarget.cpp source/Target/Target.cpp test/python_api/default-constructor/sb_target.py test/python_api/watchpoint/TestWatchpointLocationIter.py
Johnny Chen
johnny.chen at apple.com
Tue Sep 27 13:29:45 PDT 2011
Author: johnny
Date: Tue Sep 27 15:29:45 2011
New Revision: 140633
URL: http://llvm.org/viewvc/llvm-project?rev=140633&view=rev
Log:
Add SBTarget::GetLastCreatedWatchpointLocation() API and export to the Python interface.
Also add rich comparison methods (__eq__ and __ne__) for SBWatchpointLocation.
Modify TestWatchpointLocationIter.py to exercise the new APIs.
Add fuzz testings for the recently added SBTarget APIs related to watchpoint manipulations.
Modified:
lldb/trunk/include/lldb/API/SBTarget.h
lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/scripts/Python/interface/SBTarget.i
lldb/trunk/scripts/Python/modify-python-lldb.py
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/test/python_api/default-constructor/sb_target.py
lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py
Modified: lldb/trunk/include/lldb/API/SBTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBTarget.h (original)
+++ lldb/trunk/include/lldb/API/SBTarget.h Tue Sep 27 15:29:45 2011
@@ -448,6 +448,9 @@
GetNumWatchpointLocations () const;
lldb::SBWatchpointLocation
+ GetLastCreatedWatchpointLocation ();
+
+ lldb::SBWatchpointLocation
GetWatchpointLocationAtIndex (uint32_t idx) const;
bool
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Tue Sep 27 15:29:45 2011
@@ -187,6 +187,7 @@
size_t
GetSize() const
{
+ Mutex::Locker locker(m_mutex);
return m_address_to_location.size();
}
Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Sep 27 15:29:45 2011
@@ -298,6 +298,12 @@
size_t size,
uint32_t type);
+ lldb::WatchpointLocationSP
+ GetLastCreatedWatchpointLocation ()
+ {
+ return m_last_created_watchpoint_location;
+ }
+
WatchpointLocationList &
GetWatchpointLocationList()
{
@@ -866,6 +872,7 @@
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.
Modified: lldb/trunk/scripts/Python/interface/SBTarget.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBTarget.i?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBTarget.i (original)
+++ lldb/trunk/scripts/Python/interface/SBTarget.i Tue Sep 27 15:29:45 2011
@@ -439,6 +439,9 @@
GetNumWatchpointLocations () const;
lldb::SBWatchpointLocation
+ GetLastCreatedWatchpointLocation ();
+
+ lldb::SBWatchpointLocation
GetWatchpointLocationAtIndex (uint32_t idx) const;
bool
Modified: lldb/trunk/scripts/Python/modify-python-lldb.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/modify-python-lldb.py (original)
+++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue Sep 27 15:29:45 2011
@@ -199,11 +199,12 @@
#
# 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):
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Tue Sep 27 15:29:45 2011
@@ -871,19 +871,40 @@
{
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;
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Sep 27 15:29:45 2011
@@ -167,6 +167,7 @@
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 @@
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;
}
Modified: lldb/trunk/test/python_api/default-constructor/sb_target.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/default-constructor/sb_target.py?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/test/python_api/default-constructor/sb_target.py (original)
+++ lldb/trunk/test/python_api/default-constructor/sb_target.py Tue Sep 27 15:29:45 2011
@@ -40,6 +40,14 @@
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()
Modified: lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py?rev=140633&r1=140632&r2=140633&view=diff
==============================================================================
--- lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py (original)
+++ lldb/trunk/test/python_api/watchpoint/TestWatchpointLocationIter.py Tue Sep 27 15:29:45 2011
@@ -65,7 +65,9 @@
# 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)
More information about the lldb-commits
mailing list