[Lldb-commits] [lldb] r139666 - in /lldb/trunk: include/lldb/Breakpoint/WatchpointLocation.h include/lldb/Breakpoint/WatchpointLocationList.h include/lldb/Interpreter/OptionGroupWatchpoint.h source/Breakpoint/WatchpointLocation.cpp source/Breakpoint/WatchpointLocationList.cpp source/Target/Target.cpp tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Johnny Chen johnny.chen at apple.com
Tue Sep 13 16:29:31 PDT 2011


Author: johnny
Date: Tue Sep 13 18:29:31 2011
New Revision: 139666

URL: http://llvm.org/viewvc/llvm-project?rev=139666&view=rev
Log:
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.

Modified:
    lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
    lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
    lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h
    lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
    lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp
    lldb/trunk/source/Target/Target.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp

Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h?rev=139666&r1=139665&r2=139666&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocation.h Tue Sep 13 18:29:31 2011
@@ -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 ();
 

Modified: lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h?rev=139666&r1=139665&r2=139666&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/WatchpointLocationList.h Tue Sep 13 18:29:31 2011
@@ -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;
 

Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h?rev=139666&r1=139665&r2=139666&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupWatchpoint.h Tue Sep 13 18:29:31 2011
@@ -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,

Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=139666&r1=139665&r2=139666&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Tue Sep 13 18:29:31 2011
@@ -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,

Modified: lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp?rev=139666&r1=139665&r2=139666&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocationList.cpp Tue Sep 13 18:29:31 2011
@@ -188,3 +188,8 @@
     }
 }
 
+void
+WatchpointLocationList::GetListMutex (Mutex::Locker &locker)
+{
+    return locker.Reset (m_mutex.GetMutex());
+}

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=139666&r1=139665&r2=139666&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Sep 13 18:29:31 2011
@@ -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;
 }
 

Modified: lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp?rev=139666&r1=139665&r2=139666&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp Tue Sep 13 18:29:31 2011
@@ -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)
         {





More information about the lldb-commits mailing list