diff options
author | Johnny Chen <johnny.chen@apple.com> | 2012-06-04 23:19:54 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2012-06-04 23:19:54 +0000 |
commit | b90827e66c6576a229b9018ba8400a2e3e300d02 (patch) | |
tree | 982b29230add06d804c9c61b0299fd05fd992d3e /lldb/source/Commands/CommandObjectWatchpoint.cpp | |
parent | 188d830405a47a6c1b5c87f85cd46bce587c2ec7 (diff) | |
download | llvm-b90827e66c6576a229b9018ba8400a2e3e300d02.zip llvm-b90827e66c6576a229b9018ba8400a2e3e300d02.tar.gz llvm-b90827e66c6576a229b9018ba8400a2e3e300d02.tar.bz2 |
rdar://problem/11584012
Refactorings of watchpoint creation APIs so that SBTarget::WatchAddress(), SBValue::Watch(), and SBValue::WatchPointee()
now take an additional 'SBError &error' parameter (at the end) to contain the reason if there is some failure in the
operation. Update 'watchpoint set variable/expression' commands to take advantage of that.
Update existing test cases to reflect the API change and add test cases to verify that the SBError mechanism works for
SBTarget::WatchAddress() by passing an invalid watch_size.
llvm-svn: 157964
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpoint.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectWatchpoint.cpp | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 591b8ec..04d8789 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -59,20 +59,6 @@ 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. @@ -1013,11 +999,6 @@ 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); @@ -1031,7 +1012,8 @@ CommandObjectWatchpointSetVariable::Execute // Now it's time to create the watchpoint. uint32_t watch_type = m_option_watchpoint.watch_type; - Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type).get(); + error.Clear(); + Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get(); if (wp) { if (var_sp && var_sp->GetDeclaration().GetFile()) { StreamString ss; @@ -1047,7 +1029,8 @@ CommandObjectWatchpointSetVariable::Execute } else { result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n", addr, size); - CheckIfWatchpointsExhausted(target, result); + if (error.AsCString(NULL)) + result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); } @@ -1221,15 +1204,11 @@ 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 = target->CreateWatchpoint(addr, size, watch_type).get(); + Error error; + Watchpoint *wp = target->CreateWatchpoint(addr, size, watch_type, error).get(); if (wp) { if (var_sp && var_sp->GetDeclaration().GetFile()) { StreamString ss; @@ -1245,7 +1224,8 @@ CommandObjectWatchpointSetExpression::ExecuteRawCommandString } else { result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%llx, size=%lu).\n", addr, size); - CheckIfWatchpointsExhausted(target, result); + if (error.AsCString(NULL)) + result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); } |