aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectWatchpoint.cpp
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2012-06-04 20:08:23 +0000
committerJohnny Chen <johnny.chen@apple.com>2012-06-04 20:08:23 +0000
commit3cb41e82cbeb686af5c5feda1d5acdb4bf931945 (patch)
treee8480a8daa9451272f330073c4bf3ae813ef506e /lldb/source/Commands/CommandObjectWatchpoint.cpp
parent8d4688718b3754a87a968c89f0ea0a45256efdc1 (diff)
downloadllvm-3cb41e82cbeb686af5c5feda1d5acdb4bf931945.zip
llvm-3cb41e82cbeb686af5c5feda1d5acdb4bf931945.tar.gz
llvm-3cb41e82cbeb686af5c5feda1d5acdb4bf931945.tar.bz2
Give more explicit error messages when watchpoint creation command (watchpoint set) fails,
like number of supported hardware watchpoints reached or the watch size is not allowed. llvm-svn: 157948
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpoint.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectWatchpoint.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index 56b95ab..591b8ec 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -59,6 +59,20 @@ CheckTargetForWatchpointOperations(Target *target, CommandReturnObject &result)
return true;
}
+static void
+CheckIfWatchpointsExhausted(Target *target, CommandReturnObject &result)
+{
+ uint32_t num_supported_hardware_watchpoints;
+ Error error = target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
+ if (error.Success())
+ {
+ uint32_t num_current_watchpoints = target->GetWatchpointList().GetSize();
+ if (num_current_watchpoints >= num_supported_hardware_watchpoints)
+ result.AppendErrorWithFormat("Number of supported hardware watchpoints (%u) has been reached.\n",
+ num_supported_hardware_watchpoints);
+ }
+}
+
#include "llvm/ADT/StringRef.h"
// Equivalent class: {"-", "to", "To", "TO"} of range specifier array.
@@ -943,6 +957,7 @@ CommandObjectWatchpointSetVariable::Execute
CommandReturnObject &result
)
{
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
StackFrame *frame = exe_ctx.GetFramePtr();
if (frame == NULL)
@@ -998,6 +1013,11 @@ CommandObjectWatchpointSetVariable::Execute
// Find out the size of this variable.
size = m_option_watchpoint.watch_size == 0 ? valobj_sp->GetByteSize()
: m_option_watchpoint.watch_size;
+ if (!m_option_watchpoint.IsWatchSizeSupported(size))
+ {
+ result.GetErrorStream().Printf("Watch size of %lu is not supported\n", size);
+ return false;
+ }
}
} else {
const char *error_cstr = error.AsCString(NULL);
@@ -1011,7 +1031,7 @@ CommandObjectWatchpointSetVariable::Execute
// Now it's time to create the watchpoint.
uint32_t watch_type = m_option_watchpoint.watch_type;
- Watchpoint *wp = exe_ctx.GetTargetRef().CreateWatchpoint(addr, size, watch_type).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type).get();
if (wp) {
if (var_sp && var_sp->GetDeclaration().GetFile()) {
StreamString ss;
@@ -1027,6 +1047,7 @@ CommandObjectWatchpointSetVariable::Execute
} else {
result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
addr, size);
+ CheckIfWatchpointsExhausted(target, result);
result.SetStatus(eReturnStatusFailed);
}
@@ -1200,10 +1221,15 @@ CommandObjectWatchpointSetExpression::ExecuteRawCommandString
}
size = with_dash_x ? m_option_watchpoint.watch_size
: target->GetArchitecture().GetAddressByteSize();
+ if (!m_option_watchpoint.IsWatchSizeSupported(size))
+ {
+ result.GetErrorStream().Printf("Watch size of %lu is not supported\n", size);
+ return false;
+ }
// Now it's time to create the watchpoint.
uint32_t watch_type = m_option_watchpoint.watch_type;
- Watchpoint *wp = exe_ctx.GetTargetRef().CreateWatchpoint(addr, size, watch_type).get();
+ Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type).get();
if (wp) {
if (var_sp && var_sp->GetDeclaration().GetFile()) {
StreamString ss;
@@ -1219,6 +1245,7 @@ CommandObjectWatchpointSetExpression::ExecuteRawCommandString
} else {
result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n",
addr, size);
+ CheckIfWatchpointsExhausted(target, result);
result.SetStatus(eReturnStatusFailed);
}