Author: omjavaid
Date: Mon Jun 27 07:35:41 2016
New Revision: 273869

URL: http://llvm.org/viewvc/llvm-project?rev=273869&view=rev
Log:
Improve watchpoint error reporting specially for arm/aarch64 targets

Differential revision: http://reviews.llvm.org/D21164


Modified:
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp?rev=273869&r1=273868&r2=273869&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
Mon Jun 27 07:35:41 2016
@@ -592,7 +592,7 @@ NativeRegisterContextLinux_arm::NumSuppo
     error = ReadHardwareDebugInfo ();
 
     if (error.Fail())
-        return LLDB_INVALID_INDEX32;
+        return 0;
 
     return m_max_hwp_supported;
 }

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp?rev=273869&r1=273868&r2=273869&view=diff
==============================================================================
--- 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
Mon Jun 27 07:35:41 2016
@@ -544,7 +544,7 @@ NativeRegisterContextLinux_arm64::NumSup
     error = ReadHardwareDebugInfo ();
 
     if (error.Fail())
-        return LLDB_INVALID_INDEX32;
+        return 0;
 
     return m_max_hwp_supported;
 }

Modified: lldb/trunk/source/Target/Target.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=273869&r1=273868&r2=273869&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Jun 27 07:35:41 2016
@@ -709,14 +709,13 @@ CheckIfWatchpointsExhausted(Target *targ
 {
     uint32_t num_supported_hardware_watchpoints;
     Error rc = 
target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
-    if (rc.Success())
+    if (num_supported_hardware_watchpoints == 0)
     {
-        uint32_t num_current_watchpoints = 
target->GetWatchpointList().GetSize();
-        if (num_current_watchpoints >= num_supported_hardware_watchpoints)
-            error.SetErrorStringWithFormat("number of supported hardware 
watchpoints (%u) has been reached",
-                                           num_supported_hardware_watchpoints);
+        error.SetErrorStringWithFormat ("Target supports (%u) hardware 
watchpoint slots.\n",
+                    num_supported_hardware_watchpoints);
+        return false;
     }
-    return false;
+    return true;
 }
 
 // See also Watchpoint::SetWatchpointType(uint32_t type) and
@@ -750,6 +749,9 @@ Target::CreateWatchpoint(lldb::addr_t ad
         error.SetErrorStringWithFormat ("invalid watchpoint type: %d", kind);
     }
 
+    if (!CheckIfWatchpointsExhausted (this, error))
+        return wp_sp;
+
     // Currently we only support one watchpoint per address, with total number
     // of watchpoints limited by the hardware which the inferior is running on.
 
@@ -798,11 +800,9 @@ Target::CreateWatchpoint(lldb::addr_t ad
         // Remove the said watchpoint from the list maintained by the target 
instance.
         m_watchpoint_list.Remove (wp_sp->GetID(), true);
         // See if we could provide more helpful error message.
-        if (!CheckIfWatchpointsExhausted(this, error))
-        {
-            if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
-                error.SetErrorStringWithFormat("watch size of %" PRIu64 " is 
not supported", (uint64_t)size);
-        }
+        if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
+            error.SetErrorStringWithFormat("watch size of %" PRIu64 " is not 
supported", (uint64_t)size);
+
         wp_sp.reset();
     }
     else


_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to