diff options
author | Johnny Chen <johnny.chen@apple.com> | 2012-02-09 18:44:27 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2012-02-09 18:44:27 +0000 |
commit | acdde195fb2c7a7255de96bb454bee25d2d3575a (patch) | |
tree | 90f4cf49a68963b490b262258251e37f919f5dcc /lldb/source/Commands/CommandObjectWatchpoint.cpp | |
parent | 940a550f0d356a9752c441ce8c556cb843accb83 (diff) | |
download | llvm-acdde195fb2c7a7255de96bb454bee25d2d3575a.zip llvm-acdde195fb2c7a7255de96bb454bee25d2d3575a.tar.gz llvm-acdde195fb2c7a7255de96bb454bee25d2d3575a.tar.bz2 |
Add error handling for missing option terminator "--" and a test scenario for it.
Also fix a logic error for a missing return stmt. Oops.
llvm-svn: 150195
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpoint.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectWatchpoint.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp index 150d712..ce6b71e 100644 --- a/lldb/source/Commands/CommandObjectWatchpoint.cpp +++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp @@ -1129,11 +1129,11 @@ CommandObjectWatchpointSetExpression::ExecuteRawCommandString return false; } - bool no_dash_w = !m_option_watchpoint.watch_type_specified; - bool no_dash_x = (m_option_watchpoint.watch_size == 0); + bool with_dash_w = m_option_watchpoint.watch_type_specified; + bool with_dash_x = (m_option_watchpoint.watch_size != 0); // If no '-w' is specified, default to '-w read_write'. - if (no_dash_w) + if (!with_dash_w) { m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchReadWrite; } @@ -1149,7 +1149,15 @@ CommandObjectWatchpointSetExpression::ExecuteRawCommandString // We will process the raw command string to rid of the '-w', '-x', or '--' llvm::StringRef raw_expr_str(raw_command); - std::string expr_str = StripOptionTerminator(raw_expr_str, !no_dash_w, !no_dash_x).str(); + std::string expr_str = StripOptionTerminator(raw_expr_str, with_dash_w, with_dash_x).str(); + + // Sanity check for when the user forgets to terminate the option strings with a '--'. + if ((with_dash_w || with_dash_w) && expr_str.empty()) + { + result.GetErrorStream().Printf("error: did you forget to enter the option terminator string \"--\"?\n"); + result.SetStatus(eReturnStatusFailed); + return false; + } // Use expression evaluation to arrive at the address to watch. const bool coerce_to_id = true; @@ -1167,6 +1175,7 @@ CommandObjectWatchpointSetExpression::ExecuteRawCommandString result.GetErrorStream().Printf("error: expression evaluation of address to watch failed\n"); result.GetErrorStream().Printf("expression evaluated: %s\n", expr_str.c_str()); result.SetStatus(eReturnStatusFailed); + return false; } // Get the address to watch. @@ -1176,8 +1185,8 @@ CommandObjectWatchpointSetExpression::ExecuteRawCommandString result.SetStatus(eReturnStatusFailed); return false; } - size = no_dash_x ? target->GetArchitecture().GetAddressByteSize() - : m_option_watchpoint.watch_size; + size = with_dash_x ? m_option_watchpoint.watch_size + : target->GetArchitecture().GetAddressByteSize(); // Now it's time to create the watchpoint. uint32_t watch_type = m_option_watchpoint.watch_type; |