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/include/lldb/Breakpoint/WatchpointLocation.h b/include/lldb/Breakpoint/WatchpointLocation.h
index 84a8558..01e13d1 100644
--- a/include/lldb/Breakpoint/WatchpointLocation.h
+++ b/include/lldb/Breakpoint/WatchpointLocation.h
@@ -29,7 +29,7 @@
{
public:
- WatchpointLocation (lldb::addr_t m_addr, size_t size, bool hardware);
+ WatchpointLocation (lldb::addr_t addr, size_t size, bool hardware = true);
~WatchpointLocation ();
diff --git a/include/lldb/Breakpoint/WatchpointLocationList.h b/include/lldb/Breakpoint/WatchpointLocationList.h
index 5e77df8..74c8475 100644
--- a/include/lldb/Breakpoint/WatchpointLocationList.h
+++ b/include/lldb/Breakpoint/WatchpointLocationList.h
@@ -174,6 +174,15 @@
GetDescription (Stream *s,
lldb::DescriptionLevel level);
+ //------------------------------------------------------------------
+ /// Sets the passed in Locker to hold the Watchpoint Location List mutex.
+ ///
+ /// @param[in] locker
+ /// The locker object that is set.
+ //------------------------------------------------------------------
+ void
+ GetListMutex (lldb_private::Mutex::Locker &locker);
+
protected:
typedef std::map<lldb::addr_t, lldb::WatchpointLocationSP> addr_map;
diff --git a/include/lldb/Interpreter/OptionGroupWatchpoint.h b/include/lldb/Interpreter/OptionGroupWatchpoint.h
index e9aba96..695b372 100644
--- a/include/lldb/Interpreter/OptionGroupWatchpoint.h
+++ b/include/lldb/Interpreter/OptionGroupWatchpoint.h
@@ -46,7 +46,7 @@
OptionParsingStarting (CommandInterpreter &interpreter);
// Note:
- // eWatchRead == LLDB_WATCH_TYPE_EREAD; and
+ // eWatchRead == LLDB_WATCH_TYPE_READ; and
// eWatchWrite == LLDB_WATCH_TYPE_WRITE
typedef enum WatchType {
eWatchInvalid = 0,
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;
}
diff --git a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
index 8d945ca..2f00c0f 100644
--- a/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
+++ b/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
@@ -481,7 +481,7 @@
if (kret != KERN_SUCCESS)
return;
- DBG debug_state = m_state.context.dbg;
+ DBG &debug_state = m_state.context.dbg;
bool need_reset = false;
uint32_t i, num = NumSupportedHardwareWatchpoints();
for (i = 0; i < num; ++i)
@@ -650,13 +650,13 @@
size_and_rw_bits(size, read, write) << (16+4*hw_index));
switch (hw_index) {
case 0:
- debug_state.__dr0 == addr; break;
+ debug_state.__dr0 = addr; break;
case 1:
- debug_state.__dr1 == addr; break;
+ debug_state.__dr1 = addr; break;
case 2:
- debug_state.__dr2 == addr; break;
+ debug_state.__dr2 = addr; break;
case 3:
- debug_state.__dr3 == addr; break;
+ debug_state.__dr3 = addr; break;
default:
assert(0 && "invalid hardware register index, must be one of 0, 1, 2, or 3");
}
@@ -669,13 +669,13 @@
debug_state.__dr7 &= ~(3 << (2*hw_index));
switch (hw_index) {
case 0:
- debug_state.__dr0 == 0; break;
+ debug_state.__dr0 = 0; break;
case 1:
- debug_state.__dr1 == 0; break;
+ debug_state.__dr1 = 0; break;
case 2:
- debug_state.__dr2 == 0; break;
+ debug_state.__dr2 = 0; break;
case 3:
- debug_state.__dr3 == 0; break;
+ debug_state.__dr3 = 0; break;
default:
assert(0 && "invalid hardware register index, must be one of 0, 1, 2, or 3");
}
@@ -759,7 +759,7 @@
// Check to make sure we have the needed hardware support
uint32_t i = 0;
- DBG debug_state = m_state.context.dbg;
+ DBG &debug_state = m_state.context.dbg;
for (i = 0; i < num_hw_watchpoints; ++i)
{
if (IsWatchpointVacant(debug_state, i))
@@ -794,7 +794,7 @@
const uint32_t num_hw_points = NumSupportedHardwareWatchpoints();
if (kret == KERN_SUCCESS)
{
- DBG debug_state = m_state.context.dbg;
+ DBG &debug_state = m_state.context.dbg;
if (hw_index < num_hw_points && !IsWatchpointVacant(debug_state, hw_index))
{
// Modify our local copy of the debug state, first.
@@ -820,7 +820,7 @@
DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::GetHardwareWatchpointHit() GetDBGState() => 0x%8.8x.", kret);
if (kret == KERN_SUCCESS)
{
- DBG debug_state = m_state.context.dbg;
+ DBG &debug_state = m_state.context.dbg;
uint32_t i, num = NumSupportedHardwareWatchpoints();
for (i = 0; i < num; ++i)
{