diff options
author | Johnny Chen <johnny.chen@apple.com> | 2011-09-22 18:04:58 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2011-09-22 18:04:58 +0000 |
commit | 01acfa76010b8db2e77016c144963c4dd70f1392 (patch) | |
tree | fe22f45023e31aec97f774b0feed7b08bb49c50c /source/Breakpoint | |
parent | 567e7f3ba16eb48cb9fd6a2f26f2f7269eb6983c (diff) | |
download | lldb-01acfa76010b8db2e77016c144963c4dd70f1392.tar.gz |
Add initial implementation of watchpoint commands for list, enable, disable, and delete.
Test cases to be added later.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@140322 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Breakpoint')
-rw-r--r-- | source/Breakpoint/WatchpointLocation.cpp | 41 | ||||
-rw-r--r-- | source/Breakpoint/WatchpointLocationList.cpp | 51 |
2 files changed, 41 insertions, 51 deletions
diff --git a/source/Breakpoint/WatchpointLocation.cpp b/source/Breakpoint/WatchpointLocation.cpp index e0c14edff..a0bbc037d 100644 --- a/source/Breakpoint/WatchpointLocation.cpp +++ b/source/Breakpoint/WatchpointLocation.cpp @@ -21,6 +21,7 @@ using namespace lldb_private; WatchpointLocation::WatchpointLocation (lldb::addr_t addr, size_t size, bool hardware) : StoppointLocation (GetNextID(), addr, size, hardware), m_enabled(0), + m_is_hardware(hardware), m_watch_read(0), m_watch_write(0), m_watch_was_read(0), @@ -58,28 +59,36 @@ WatchpointLocation::SetDeclInfo (std::string &str) } +bool +WatchpointLocation::IsHardware () const +{ + return m_is_hardware; +} + // RETURNS - true if we should stop at this breakpoint, false if we // should continue. bool WatchpointLocation::ShouldStop (StoppointCallbackContext *context) { - m_hit_count++; - - if (m_hit_count > m_ignore_count) - { - uint32_t access = 0; - if (m_watch_was_read) - access |= LLDB_WATCH_TYPE_READ; - if (m_watch_was_written) - access |= LLDB_WATCH_TYPE_WRITE; - - if (m_callback) - return m_callback(m_callback_baton, context, GetID(), access); - else - return true; - } - return false; + ++m_hit_count; + + if (!IsEnabled()) + return false; + + if (m_hit_count <= GetIgnoreCount()) + return false; + + uint32_t access = 0; + if (m_watch_was_read) + access |= LLDB_WATCH_TYPE_READ; + if (m_watch_was_written) + access |= LLDB_WATCH_TYPE_WRITE; + + if (m_callback) + return m_callback(m_callback_baton, context, GetID(), access); + else + return true; } void diff --git a/source/Breakpoint/WatchpointLocationList.cpp b/source/Breakpoint/WatchpointLocationList.cpp index 4e6dbb782..ac466fa4f 100644 --- a/source/Breakpoint/WatchpointLocationList.cpp +++ b/source/Breakpoint/WatchpointLocationList.cpp @@ -20,7 +20,6 @@ using namespace lldb; using namespace lldb_private; WatchpointLocationList::WatchpointLocationList() : - m_locations (), m_address_to_location (), m_mutex (Mutex::eMutexTypeRecursive) { @@ -41,21 +40,10 @@ WatchpointLocationList::Add (const WatchpointLocationSP &wp_loc_sp) addr_map::iterator iter = m_address_to_location.find(wp_addr); if (iter == m_address_to_location.end()) - { m_address_to_location.insert(iter, addr_map::value_type(wp_addr, wp_loc_sp)); - } 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(); } @@ -154,9 +142,12 @@ 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]; - + if (i < m_address_to_location.size()) + { + addr_map::const_iterator pos = m_address_to_location.begin(); + std::advance(pos, i); + wp_loc_sp = pos->second; + } return wp_loc_sp; } @@ -165,9 +156,12 @@ 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]; - + if (i < m_address_to_location.size()) + { + addr_map::const_iterator pos = m_address_to_location.begin(); + std::advance(pos, i); + wp_loc_sp = pos->second; + } return wp_loc_sp; } @@ -175,17 +169,10 @@ bool WatchpointLocationList::Remove (lldb::watch_id_t watch_id) { Mutex::Locker locker (m_mutex); - addr_map::iterator pos = GetIDIterator(watch_id); // Predicate + addr_map::iterator pos = GetIDIterator(watch_id); 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; @@ -205,6 +192,7 @@ WatchpointLocationList::GetHitCount () const bool WatchpointLocationList::ShouldStop (StoppointCallbackContext *context, lldb::watch_id_t watch_id) { + WatchpointLocationSP wp_loc_sp = FindByID (watch_id); if (wp_loc_sp) { @@ -245,14 +233,7 @@ void WatchpointLocationList::RemoveAll () { Mutex::Locker locker(m_mutex); - - addr_map::iterator pos, end = m_address_to_location.end(); - for (pos = m_address_to_location.begin(); pos != end; ++pos) - m_address_to_location.erase(pos); - - collection::iterator p, e = m_locations.end(); - for (p = m_locations.begin(); p != e; ++pos) - m_locations.erase(p); + m_address_to_location.clear(); } void |