summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectThread.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-11-12 16:56:47 +0000
committerZachary Turner <zturner@google.com>2016-11-12 16:56:47 +0000
commitfe11483b57c1dc6a6758725e6de0d6804ec59ed1 (patch)
treeaf50255449e1a57e1a528735cfa3458a5e9e66d2 /lldb/source/Commands/CommandObjectThread.cpp
parentc351fb16079ae8c88e868960829107a823a86246 (diff)
downloadbcm5719-llvm-fe11483b57c1dc6a6758725e6de0d6804ec59ed1.tar.gz
bcm5719-llvm-fe11483b57c1dc6a6758725e6de0d6804ec59ed1.zip
Make Options::SetOptionValue take a StringRef.
llvm-svn: 286723
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp98
1 files changed, 39 insertions, 59 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index e5662dd4478..bfed4ef48cc 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -161,36 +161,30 @@ public:
~CommandOptions() override = default;
- Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const int short_option = m_getopt_table[option_idx].val;
- auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
switch (short_option) {
case 'c': {
- bool success;
- int32_t input_count =
- StringConvert::ToSInt32(option_arg, -1, 0, &success);
- if (!success)
+ int32_t input_count = 0;
+ if (option_arg.getAsInteger(0, m_count)) {
+ m_count = UINT32_MAX;
error.SetErrorStringWithFormat(
"invalid integer value for option '%c'", short_option);
- if (input_count < -1)
+ } else if (input_count < 0)
m_count = UINT32_MAX;
- else
- m_count = input_count;
} break;
- case 's': {
- bool success;
- m_start = StringConvert::ToUInt32(option_arg, 0, 0, &success);
- if (!success)
+ case 's':
+ if (option_arg.getAsInteger(0, m_start))
error.SetErrorStringWithFormat(
"invalid integer value for option '%c'", short_option);
- } break;
+ break;
case 'e': {
bool success;
m_extended_backtrace =
- Args::StringToBoolean(option_strref, false, &success);
+ Args::StringToBoolean(option_arg, false, &success);
if (!success)
error.SetErrorStringWithFormat(
"invalid boolean value for option '%c'", short_option);
@@ -335,17 +329,15 @@ public:
~CommandOptions() override = default;
- Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const int short_option = m_getopt_table[option_idx].val;
- auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
switch (short_option) {
case 'a': {
bool success;
- bool avoid_no_debug =
- Args::StringToBoolean(option_strref, true, &success);
+ bool avoid_no_debug = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat(
"invalid boolean value for option '%c'", short_option);
@@ -357,8 +349,7 @@ public:
case 'A': {
bool success;
- bool avoid_no_debug =
- Args::StringToBoolean(option_strref, true, &success);
+ bool avoid_no_debug = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat(
"invalid boolean value for option '%c'", short_option);
@@ -369,9 +360,9 @@ public:
} break;
case 'c':
- m_step_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
- if (m_step_count == UINT32_MAX)
- error.SetErrorStringWithFormat("invalid step count '%s'", option_arg);
+ if (option_arg.getAsInteger(0, m_step_count))
+ error.SetErrorStringWithFormat("invalid step count '%s'",
+ option_arg.str().c_str());
break;
case 'C':
@@ -383,23 +374,18 @@ public:
OptionEnumValueElement *enum_values =
GetDefinitions()[option_idx].enum_values;
m_run_mode = (lldb::RunMode)Args::StringToOptionEnum(
- option_strref, enum_values, eOnlyDuringStepping, error);
+ option_arg, enum_values, eOnlyDuringStepping, error);
} break;
- case 'e': {
- if (strcmp(option_arg, "block") == 0) {
+ case 'e':
+ if (option_arg == "block") {
m_end_line_is_block_end = 1;
break;
}
- uint32_t tmp_end_line =
- StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
- if (tmp_end_line == UINT32_MAX)
+ if (option_arg.getAsInteger(0, m_end_line))
error.SetErrorStringWithFormat("invalid end line number '%s'",
- option_arg);
- else
- m_end_line = tmp_end_line;
+ option_arg.str().c_str());
break;
- } break;
case 'r':
m_avoid_regexp.clear();
@@ -921,7 +907,7 @@ public:
~CommandOptions() override = default;
- Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const int short_option = m_getopt_table[option_idx].val;
@@ -934,27 +920,24 @@ public:
m_until_addrs.push_back(tmp_addr);
} break;
case 't':
- m_thread_idx =
- StringConvert::ToUInt32(option_arg, LLDB_INVALID_INDEX32);
- if (m_thread_idx == LLDB_INVALID_INDEX32) {
+ if (option_arg.getAsInteger(0, m_thread_idx)) {
+ m_thread_idx = LLDB_INVALID_INDEX32;
error.SetErrorStringWithFormat("invalid thread index '%s'",
- option_arg);
+ option_arg.str().c_str());
}
break;
case 'f':
- m_frame_idx =
- StringConvert::ToUInt32(option_arg, LLDB_INVALID_FRAME_ID);
- if (m_frame_idx == LLDB_INVALID_FRAME_ID) {
+ if (option_arg.getAsInteger(0, m_frame_idx)) {
+ m_frame_idx = LLDB_INVALID_FRAME_ID;
error.SetErrorStringWithFormat("invalid frame index '%s'",
- option_arg);
+ option_arg.str().c_str());
}
break;
case 'm': {
OptionEnumValueElement *enum_values =
GetDefinitions()[option_idx].enum_values;
lldb::RunMode run_mode = (lldb::RunMode)Args::StringToOptionEnum(
- llvm::StringRef::withNullAsEmpty(option_arg), enum_values,
- eOnlyDuringStepping, error);
+ option_arg, enum_values, eOnlyDuringStepping, error);
if (error.Success()) {
if (run_mode == eAllThreads)
@@ -1339,7 +1322,7 @@ public:
m_json_stopinfo = false;
}
- Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
const int short_option = m_getopt_table[option_idx].val;
Error error;
@@ -1432,21 +1415,21 @@ public:
~CommandOptions() override = default;
- Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const int short_option = m_getopt_table[option_idx].val;
- auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
switch (short_option) {
case 'x': {
bool success;
- bool tmp_value = Args::StringToBoolean(option_strref, false, &success);
+ bool tmp_value = Args::StringToBoolean(option_arg, false, &success);
if (success)
m_from_expression = tmp_value;
else {
error.SetErrorStringWithFormat(
- "invalid boolean value '%s' for 'x' option", option_arg);
+ "invalid boolean value '%s' for 'x' option",
+ option_arg.str().c_str());
}
} break;
default:
@@ -1616,9 +1599,8 @@ public:
m_force = false;
}
- Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
- bool success;
const int short_option = m_getopt_table[option_idx].val;
Error error;
@@ -1629,14 +1611,12 @@ public:
return Error("only one source file expected.");
break;
case 'l':
- m_line_num = StringConvert::ToUInt32(option_arg, 0, 0, &success);
- if (!success || m_line_num == 0)
- return Error("invalid line number: '%s'.", option_arg);
+ if (option_arg.getAsInteger(0, m_line_num))
+ return Error("invalid line number: '%s'.", option_arg.str().c_str());
break;
case 'b':
- m_line_offset = StringConvert::ToSInt32(option_arg, 0, 0, &success);
- if (!success)
- return Error("invalid line offset: '%s'.", option_arg);
+ if (option_arg.getAsInteger(0, m_line_offset))
+ return Error("invalid line offset: '%s'.", option_arg.str().c_str());
break;
case 'a':
m_load_addr = Args::StringToAddress(execution_context, option_arg,
@@ -1764,7 +1744,7 @@ public:
~CommandOptions() override = default;
- Error SetOptionValue(uint32_t option_idx, const char *option_arg,
+ Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const int short_option = m_getopt_table[option_idx].val;
OpenPOWER on IntegriCloud