Watchpoint WIP:
o WatchpointLocationList:
Add a GetListMutex() method.
o WatchpointLocation:
Fix Dump() method where there was an extra % in the format string.
o Target.cpp:
Add implementation to CreateWatchpointLocation() to create and enable a watchpoint.
o DNBArchImplX86_64.cpp:
Fix bugs in SetWatchpoint()/ClearWatchpoint() where '==' was used, instead of '=',
to assign/reset the data break address to a debug register.
Also fix bugs where a by reference debug_state should have been used, not by value.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@139666 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Breakpoint/WatchpointLocation.cpp b/source/Breakpoint/WatchpointLocation.cpp
index d2585b8..6e35418 100644
--- a/source/Breakpoint/WatchpointLocation.cpp
+++ b/source/Breakpoint/WatchpointLocation.cpp
@@ -85,7 +85,7 @@
if (s == NULL)
return;
- s->Printf("WatchpointLocation %u: tid = %4.4x addr = 0x%8.8llx size = %zu state = %s type = %s watchpoint (%s%s) hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p",
+ s->Printf("WatchpointLocation %u: addr = 0x%8.8llx size = %zu state = %s type = %s watchpoint (%s%s) hw_index = %i hit_count = %-4u ignore_count = %-4u callback = %8p baton = %8p",
GetID(),
(uint64_t)m_addr,
m_byte_size,
diff --git a/source/Breakpoint/WatchpointLocationList.cpp b/source/Breakpoint/WatchpointLocationList.cpp
index b6d7964..d04c7d2 100644
--- a/source/Breakpoint/WatchpointLocationList.cpp
+++ b/source/Breakpoint/WatchpointLocationList.cpp
@@ -188,3 +188,8 @@
}
}
+void
+WatchpointLocationList::GetListMutex (Mutex::Locker &locker)
+{
+ return locker.Reset (m_mutex.GetMutex());
+}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 7b6dcf7..1a4a7b0 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -341,7 +341,27 @@
if (size == 0)
return wp_loc_sp;
- // FIXME: Add implmenetation.
+ WatchpointLocationSP matched_sp = m_watchpoint_location_list.FindByAddress(addr);
+ if (matched_sp)
+ {
+ size_t old_size = wp_loc_sp->GetByteSize();
+ uint32_t old_type =
+ (wp_loc_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
+ (wp_loc_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
+ // Return an empty watchpoint location if the same one exists already.
+ if (size == old_size && type == old_type)
+ return wp_loc_sp;
+
+ // Nil the matched watchpoint location; we will be creating a new one.
+ m_process_sp->DisableWatchpoint(matched_sp.get());
+ m_watchpoint_location_list.Remove(matched_sp->GetID());
+ }
+
+ WatchpointLocation *new_loc = new WatchpointLocation(addr, size);
+ new_loc->SetWatchpointType(type);
+ wp_loc_sp.reset(new_loc);
+ m_watchpoint_location_list.Add(wp_loc_sp);
+ m_process_sp->EnableWatchpoint(wp_loc_sp.get());
return wp_loc_sp;
}