omjavaid created this revision.
omjavaid added reviewers: tberghammer, labath.
omjavaid added a subscriber: lldb-commits.
Herald added subscribers: rengolin, aemerson.
This patch takes a few corrective measures to make sure we display meaningful
reason against a watchpoint creation failure.
This is particularly important for the targets where we get to know dynamically
about the availability of hardware watchpoint resources.
We are trying to check whether we have sufficient hardware watchpoint slots
available before we go ahead and create a new watchpoint.
http://reviews.llvm.org/D21164
Files:
source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
source/Target/Target.cpp
Index: source/Target/Target.cpp
===================================================================
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -712,9 +712,20 @@
if (rc.Success())
{
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",
+ if (num_supported_hardware_watchpoints == 0)
+ {
+ error.SetErrorStringWithFormat ("Target supports (%u) hardware
watchpoint slots.\n",
+ num_supported_hardware_watchpoints);
+ return false;
+ }
+ else if (num_current_watchpoints >= num_supported_hardware_watchpoints)
+ {
+ error.SetErrorStringWithFormat("All (%u) hardware watchpoint slots
already in use.\n",
num_supported_hardware_watchpoints);
+ return false;
+ }
+ else
+ return true;
}
return false;
}
@@ -750,6 +761,9 @@
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 +812,9 @@
// 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
Index: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -544,7 +544,7 @@
error = ReadHardwareDebugInfo ();
if (error.Fail())
- return LLDB_INVALID_INDEX32;
+ return 0;
return m_max_hwp_supported;
}
Index: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -592,7 +592,7 @@
error = ReadHardwareDebugInfo ();
if (error.Fail())
- return LLDB_INVALID_INDEX32;
+ return 0;
return m_max_hwp_supported;
}
Index: source/Target/Target.cpp
===================================================================
--- source/Target/Target.cpp
+++ source/Target/Target.cpp
@@ -712,9 +712,20 @@
if (rc.Success())
{
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",
+ if (num_supported_hardware_watchpoints == 0)
+ {
+ error.SetErrorStringWithFormat ("Target supports (%u) hardware watchpoint slots.\n",
+ num_supported_hardware_watchpoints);
+ return false;
+ }
+ else if (num_current_watchpoints >= num_supported_hardware_watchpoints)
+ {
+ error.SetErrorStringWithFormat("All (%u) hardware watchpoint slots already in use.\n",
num_supported_hardware_watchpoints);
+ return false;
+ }
+ else
+ return true;
}
return false;
}
@@ -750,6 +761,9 @@
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 +812,9 @@
// 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
Index: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -544,7 +544,7 @@
error = ReadHardwareDebugInfo ();
if (error.Fail())
- return LLDB_INVALID_INDEX32;
+ return 0;
return m_max_hwp_supported;
}
Index: source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
===================================================================
--- source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -592,7 +592,7 @@
error = ReadHardwareDebugInfo ();
if (error.Fail())
- return LLDB_INVALID_INDEX32;
+ return 0;
return m_max_hwp_supported;
}
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits