summaryrefslogtreecommitdiff
path: root/source/Commands/CommandObjectWatchpoint.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-28 11:09:23 +0000
commitf73363f1dd94996356cefbf24388f561891acf0b (patch)
treee3c31248bdb36eaec5fd833490d4278162dba2a0 /source/Commands/CommandObjectWatchpoint.cpp
parent160ee69dd7ae18978f4068116777639ea98dc951 (diff)
Notes
Diffstat (limited to 'source/Commands/CommandObjectWatchpoint.cpp')
-rw-r--r--source/Commands/CommandObjectWatchpoint.cpp72
1 files changed, 22 insertions, 50 deletions
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index 9c84c992e715..96ae18b35743 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -74,8 +74,8 @@ static int32_t WithRSAIndex(llvm::StringRef Arg) {
return -1;
}
-// Return true if wp_ids is successfully populated with the watch ids.
-// False otherwise.
+// Return true if wp_ids is successfully populated with the watch ids. False
+// otherwise.
bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
Target *target, Args &args, std::vector<uint32_t> &wp_ids) {
// Pre-condition: args.GetArgumentCount() > 0.
@@ -111,8 +111,8 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
if (!second.empty())
StrRefArgs.push_back(second);
}
- // Now process the canonical list and fill in the vector of uint32_t's.
- // If there is any error, return false and the client should ignore wp_ids.
+ // Now process the canonical list and fill in the vector of uint32_t's. If
+ // there is any error, return false and the client should ignore wp_ids.
uint32_t beg, end, id;
size_t size = StrRefArgs.size();
bool in_range = false;
@@ -838,7 +838,7 @@ protected:
VariableList &variable_list) {
Target *target = static_cast<Target *>(baton);
if (target) {
- return target->GetImages().FindGlobalVariables(ConstString(name), true,
+ return target->GetImages().FindGlobalVariables(ConstString(name),
UINT32_MAX, variable_list);
}
return 0;
@@ -848,8 +848,8 @@ protected:
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
StackFrame *frame = m_exe_ctx.GetFramePtr();
- // If no argument is present, issue an error message. There's no way to set
- // a watchpoint.
+ // If no argument is present, issue an error message. There's no way to
+ // set a watchpoint.
if (command.GetArgumentCount() <= 0) {
result.GetErrorStream().Printf("error: required argument missing; "
"specify your program variable to watch "
@@ -863,8 +863,8 @@ protected:
m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite;
}
- // We passed the sanity check for the command.
- // Proceed to set the watchpoint now.
+ // We passed the sanity check for the command. Proceed to set the
+ // watchpoint now.
lldb::addr_t addr = 0;
size_t size = 0;
@@ -1026,7 +1026,7 @@ Examples:
Options *GetOptions() override { return &m_option_group; }
protected:
- bool DoExecute(const char *raw_command,
+ bool DoExecute(llvm::StringRef raw_command,
CommandReturnObject &result) override {
auto exe_ctx = GetCommandInterpreter().GetExecutionContext();
m_option_group.NotifyOptionParsingStarting(
@@ -1035,46 +1035,18 @@ protected:
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
StackFrame *frame = m_exe_ctx.GetFramePtr();
- Args command(raw_command);
- const char *expr = nullptr;
- if (raw_command[0] == '-') {
- // We have some options and these options MUST end with --.
- const char *end_options = nullptr;
- const char *s = raw_command;
- while (s && s[0]) {
- end_options = ::strstr(s, "--");
- if (end_options) {
- end_options += 2; // Get past the "--"
- if (::isspace(end_options[0])) {
- expr = end_options;
- while (::isspace(*expr))
- ++expr;
- break;
- }
- }
- s = end_options;
- }
+ OptionsWithRaw args(raw_command);
- if (end_options) {
- Args args(llvm::StringRef(raw_command, end_options - raw_command));
- if (!ParseOptions(args, result))
- return false;
-
- Status error(m_option_group.NotifyOptionParsingFinished(&exe_ctx));
- if (error.Fail()) {
- result.AppendError(error.AsCString());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- }
- }
+ llvm::StringRef expr = args.GetRawPart();
- if (expr == nullptr)
- expr = raw_command;
+ if (args.HasArgs())
+ if (!ParseOptionsAndNotify(args.GetArgs(), result, m_option_group,
+ exe_ctx))
+ return false;
- // If no argument is present, issue an error message. There's no way to set
- // a watchpoint.
- if (command.GetArgumentCount() == 0) {
+ // If no argument is present, issue an error message. There's no way to
+ // set a watchpoint.
+ if (raw_command.trim().empty()) {
result.GetErrorStream().Printf("error: required argument missing; "
"specify an expression to evaulate into "
"the address to watch for\n");
@@ -1087,8 +1059,8 @@ protected:
m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite;
}
- // We passed the sanity check for the command.
- // Proceed to set the watchpoint now.
+ // We passed the sanity check for the command. Proceed to set the
+ // watchpoint now.
lldb::addr_t addr = 0;
size_t size = 0;
@@ -1107,7 +1079,7 @@ protected:
if (expr_result != eExpressionCompleted) {
result.GetErrorStream().Printf(
"error: expression evaluation of address to watch failed\n");
- result.GetErrorStream().Printf("expression evaluated: %s\n", expr);
+ result.GetErrorStream() << "expression evaluated: \n" << expr << "\n";
result.SetStatus(eReturnStatusFailed);
return false;
}