[Lldb-commits] [lldb] r139724 - in /lldb/trunk/source: Breakpoint/WatchpointLocation.cpp Target/Target.cpp

Johnny Chen johnny.chen at apple.com
Wed Sep 14 13:23:45 PDT 2011


Author: johnny
Date: Wed Sep 14 15:23:45 2011
New Revision: 139724

URL: http://llvm.org/viewvc/llvm-project?rev=139724&view=rev
Log:
Add logging to Target::CreateWatchpointLocation() and fix some bug of using the wrong variable.
Plus simplify WatchpointLocation::Dump() output.

Modified:
    lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/source/Breakpoint/WatchpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/WatchpointLocation.cpp?rev=139724&r1=139723&r2=139724&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/WatchpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/WatchpointLocation.cpp Wed Sep 14 15:23:45 2011
@@ -85,15 +85,13 @@
     if (s == NULL)
         return;
 
-    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",
+    s->Printf("WatchpointLocation %u: addr = 0x%8.8llx  size = %zu  state = %s  type = %s%s  hit_count = %-4u  ignore_count = %-4u  callback = %8p baton = %8p",
             GetID(),
             (uint64_t)m_addr,
             m_byte_size,
             m_enabled ? "enabled " : "disabled",
-            IsHardware() ? "hardware" : "software",
             m_watch_read ? "r" : "",
             m_watch_write ? "w" : "",
-            GetHardwareIndex(),
             GetHitCount(),
             GetIgnoreCount(),
             m_callback,

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=139724&r1=139723&r2=139724&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Wed Sep 14 15:23:45 2011
@@ -333,6 +333,11 @@
 WatchpointLocationSP
 Target::CreateWatchpointLocation(lldb::addr_t addr, size_t size, uint32_t type)
 {
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+    if (log)
+        log->Printf("Target::%s (addr = 0x%8.8llx size = %zu type = %u)\n",
+                    __FUNCTION__, addr, size, type);
+
     WatchpointLocationSP wp_loc_sp;
     bool process_is_valid = m_process_sp && m_process_sp->IsAlive();
     if (!process_is_valid)
@@ -348,10 +353,10 @@
     WatchpointLocationSP matched_sp = m_watchpoint_location_list.FindByAddress(addr);
     if (matched_sp)
     {
-        size_t old_size = wp_loc_sp->GetByteSize();
+        size_t old_size = matched_sp->GetByteSize();
         uint32_t old_type =
-            (wp_loc_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
-            (wp_loc_sp->WatchpointWrite() ? LLDB_WATCH_TYPE_WRITE : 0);
+            (matched_sp->WatchpointRead() ? LLDB_WATCH_TYPE_READ : 0) |
+            (matched_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;
@@ -362,10 +367,22 @@
     }
 
     WatchpointLocation *new_loc = new WatchpointLocation(addr, size);
+    if (!new_loc)
+        printf("WatchpointLocation ctor failed, out of memory?\n");
+
     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());
+    Error rc = m_process_sp->EnableWatchpoint(wp_loc_sp.get());
+    if (rc.Success())
+        wp_loc_sp->SetEnabled(true);
+        
+    if (log)
+            log->Printf("Target::%s (creation of watchpoint %s with id = %u)\n",
+                        __FUNCTION__,
+                        rc.Success() ? "succeeded" : "failed",
+                        wp_loc_sp->GetID());
+
     return wp_loc_sp;
 }
 





More information about the lldb-commits mailing list