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/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/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