[Lldb-commits] [lldb] r140071 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocationList.h source/Breakpoint/WatchpointLocationList.cpp
Johnny Chen
johnny.chen at apple.com
Mon Sep 19 14:53:51 PDT 2011
Author: johnny
Date: Mon Sep 19 16:53:51 2011
New Revision: 140071
URL: http://llvm.org/viewvc/llvm-project?rev=140071&view=rev
Log:
Add GetByIndex() methods to the WatchpointLocationList class to facilitate iteration
through the watchpoint locations by index.
Modified:
lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=140071&r1=140070&r2=140071&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Mon Sep 19 16:53:51 2011
@@ -114,6 +114,34 @@
FindIDByAddress (lldb::addr_t addr);
//------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint location with
+ /// index \a i.
+ ///
+ /// @param[in] i
+ /// The watchpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint location. May contain a NULL
+ /// pointer if the watchpoint location doesn't exist.
+ //------------------------------------------------------------------
+ lldb::WatchpointLocationSP
+ GetByIndex (uint32_t i);
+
+ //------------------------------------------------------------------
+ /// Returns a shared pointer to the watchpoint location with index
+ /// \a i, const version.
+ ///
+ /// @param[in] i
+ /// The watchpoint location index to seek for.
+ ///
+ /// @result
+ /// A shared pointer to the watchpoint location. May contain a NULL
+ /// pointer if the watchpoint location doesn't exist.
+ //------------------------------------------------------------------
+ const lldb::WatchpointLocationSP
+ GetByIndex (uint32_t i) const;
+
+ //------------------------------------------------------------------
/// Removes the watchpoint location given by \b watchID from this list.
///
/// @param[in] watchID
@@ -193,6 +221,7 @@
GetListMutex (lldb_private::Mutex::Locker &locker);
protected:
+ typedef std::vector<lldb::WatchpointLocationSP> collection;
typedef std::map<lldb::addr_t, lldb::WatchpointLocationSP> addr_map;
addr_map::iterator
@@ -201,6 +230,7 @@
addr_map::const_iterator
GetIDConstIterator(lldb::watch_id_t watchID) const;
+ collection m_locations;
addr_map m_address_to_location;
mutable Mutex m_mutex;
};
Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=140071&r1=140070&r2=140071&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Mon Sep 19 16:53:51 2011
@@ -14,13 +14,13 @@
// Project includes
#include "lldb/Breakpoint/WatchpointLocationList.h"
#include "lldb/Breakpoint/WatchpointLocation.h"
-#include "lldb/Core/ModuleList.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
WatchpointLocationList::WatchpointLocationList() :
+ m_locations (),
m_address_to_location (),
m_mutex (Mutex::eMutexTypeRecursive)
{
@@ -47,7 +47,15 @@
else
{
m_address_to_location[wp_addr] = wp_loc_sp;
+ collection::iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ if ((*pos)->GetLoadAddress() == wp_addr)
+ {
+ m_locations.erase(pos);
+ break;
+ }
}
+ m_locations.push_back(wp_loc_sp);
return wp_loc_sp->GetID();
}
@@ -141,6 +149,28 @@
return LLDB_INVALID_WATCH_ID;
}
+WatchpointLocationSP
+WatchpointLocationList::GetByIndex (uint32_t i)
+{
+ Mutex::Locker locker (m_mutex);
+ WatchpointLocationSP wp_loc_sp;
+ if (i < m_locations.size())
+ wp_loc_sp = m_locations[i];
+
+ return wp_loc_sp;
+}
+
+const WatchpointLocationSP
+WatchpointLocationList::GetByIndex (uint32_t i) const
+{
+ Mutex::Locker locker (m_mutex);
+ WatchpointLocationSP wp_loc_sp;
+ if (i < m_locations.size())
+ wp_loc_sp = m_locations[i];
+
+ return wp_loc_sp;
+}
+
bool
WatchpointLocationList::Remove (lldb::watch_id_t watch_id)
{
@@ -149,6 +179,13 @@
if (pos != m_address_to_location.end())
{
m_address_to_location.erase(pos);
+ collection::iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ if ((*pos)->GetID() == watch_id)
+ {
+ m_locations.erase(pos);
+ break;
+ }
return true;
}
return false;
More information about the lldb-commits
mailing list