Make Options::SetOptionValue take a StringRef.

llvm-svn: 286723
This commit is contained in:
Zachary Turner 2016-11-12 16:56:47 +00:00
parent c351fb1607
commit fe11483b57
31 changed files with 325 additions and 439 deletions

View File

@ -192,8 +192,7 @@ public:
/// @see Args::ParseOptions (Options&)
/// @see man getopt_long_only
//------------------------------------------------------------------
// TODO: Make this function take a StringRef.
virtual Error SetOptionValue(uint32_t option_idx, const char *option_arg,
virtual Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) = 0;
//------------------------------------------------------------------
@ -344,7 +343,6 @@ public:
virtual Error SetOptionValue(uint32_t option_idx,
llvm::StringRef option_value,
ExecutionContext *execution_context) = 0;
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
virtual void OptionParsingStarting(ExecutionContext *execution_context) = 0;
@ -403,7 +401,7 @@ public:
bool DidFinalize() { return m_did_finalize; }
Error SetOptionValue(uint32_t option_idx, const char *option_arg,
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override;
void OptionParsingStarting(ExecutionContext *execution_context) override;

View File

@ -214,12 +214,7 @@ public:
return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
}
void SetProcessPluginName(const char *plugin) {
if (plugin && plugin[0])
m_plugin_name.assign(plugin);
else
m_plugin_name.clear();
}
void SetProcessPluginName(llvm::StringRef plugin) { m_plugin_name = plugin; }
void Clear() {
ProcessInstanceInfo::Clear();
@ -285,7 +280,7 @@ public:
~ProcessLaunchCommandOptions() 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;
void OptionParsingStarting(ExecutionContext *execution_context) override {

View File

@ -69,7 +69,7 @@ public:
const char *GetProcessPluginName() const;
void SetProcessPluginName(const char *plugin);
void SetProcessPluginName(llvm::StringRef plugin);
const FileSpec &GetShell() const;

View File

@ -55,7 +55,7 @@ CommandObjectArgs::CommandOptions::CommandOptions(
CommandObjectArgs::CommandOptions::~CommandOptions() = default;
Error CommandObjectArgs::CommandOptions::SetOptionValue(
uint32_t option_idx, const char *option_arg,
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Error error;

View File

@ -27,7 +27,7 @@ public:
~CommandOptions() override;
Error SetOptionValue(uint32_t option_idx, const char *option_arg,
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override;
void OptionParsingStarting(ExecutionContext *execution_context) override;

View File

@ -178,11 +178,10 @@ 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;
llvm::StringRef option_strref(option_arg ? option_arg : "");
switch (short_option) {
case 'a': {
@ -199,14 +198,11 @@ public:
m_func_name_type_mask |= eFunctionNameTypeBase;
break;
case 'C': {
bool success;
m_column = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
case 'C':
if (option_arg.getAsInteger(0, m_column))
error.SetErrorStringWithFormat("invalid column number: %s",
option_arg);
option_arg.str().c_str());
break;
}
case 'c':
m_condition.assign(option_arg);
@ -217,8 +213,7 @@ public:
break;
case 'E': {
LanguageType language =
Language::GetLanguageTypeFromString(option_strref);
LanguageType language = Language::GetLanguageTypeFromString(option_arg);
switch (language) {
case eLanguageTypeC89:
@ -243,12 +238,12 @@ public:
case eLanguageTypeUnknown:
error.SetErrorStringWithFormat(
"Unknown language type: '%s' for exception breakpoint",
option_arg);
option_arg.str().c_str());
break;
default:
error.SetErrorStringWithFormat(
"Unsupported language type: '%s' for exception breakpoint",
option_arg);
option_arg.str().c_str());
}
} break;
@ -263,10 +258,11 @@ public:
case 'h': {
bool success;
m_catch_bp = Args::StringToBoolean(option_strref, true, &success);
m_catch_bp = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat(
"Invalid boolean value for on-catch option: '%s'", option_arg);
"Invalid boolean value for on-catch option: '%s'",
option_arg.str().c_str());
} break;
case 'H':
@ -274,16 +270,15 @@ public:
break;
case 'i':
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
if (option_arg.getAsInteger(0, m_ignore_count))
error.SetErrorStringWithFormat("invalid ignore count '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'K': {
bool success;
bool value;
value = Args::StringToBoolean(option_strref, true, &success);
value = Args::StringToBoolean(option_arg, true, &success);
if (value)
m_skip_prologue = eLazyBoolYes;
else
@ -292,29 +287,27 @@ public:
if (!success)
error.SetErrorStringWithFormat(
"Invalid boolean value for skip prologue option: '%s'",
option_arg);
option_arg.str().c_str());
} break;
case 'l': {
bool success;
m_line_num = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
case 'l':
if (option_arg.getAsInteger(0, m_line_num))
error.SetErrorStringWithFormat("invalid line number: %s.",
option_arg);
option_arg.str().c_str());
break;
}
case 'L':
m_language = Language::GetLanguageTypeFromString(option_strref);
m_language = Language::GetLanguageTypeFromString(option_arg);
if (m_language == eLanguageTypeUnknown)
error.SetErrorStringWithFormat(
"Unknown language type: '%s' for breakpoint", option_arg);
"Unknown language type: '%s' for breakpoint",
option_arg.str().c_str());
break;
case 'm': {
bool success;
bool value;
value = Args::StringToBoolean(option_strref, true, &success);
value = Args::StringToBoolean(option_arg, true, &success);
if (value)
m_move_to_nearest_code = eLazyBoolYes;
else
@ -323,7 +316,7 @@ public:
if (!success)
error.SetErrorStringWithFormat(
"Invalid boolean value for move-to-nearest-code option: '%s'",
option_arg);
option_arg.str().c_str());
break;
}
@ -338,11 +331,11 @@ public:
break;
case 'N': {
if (BreakpointID::StringIsBreakpointName(option_strref, error))
if (BreakpointID::StringIsBreakpointName(option_arg, error))
m_breakpoint_names.push_back(option_arg);
else
error.SetErrorStringWithFormat("Invalid breakpoint name: %s",
option_arg);
option_arg.str().c_str());
break;
}
@ -359,8 +352,8 @@ public:
break;
case 'O':
m_exception_extra_args.AppendArgument(llvm::StringRef("-O"));
m_exception_extra_args.AppendArgument(option_strref);
m_exception_extra_args.AppendArgument("-O");
m_exception_extra_args.AppendArgument(option_arg);
break;
case 'p':
@ -385,11 +378,9 @@ public:
break;
case 't':
m_thread_id =
StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
if (option_arg.getAsInteger(0, m_thread_id))
error.SetErrorStringWithFormat("invalid thread id string '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'T':
@ -398,17 +389,17 @@ public:
case 'w': {
bool success;
m_throw_bp = Args::StringToBoolean(option_strref, true, &success);
m_throw_bp = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat(
"Invalid boolean value for on-throw option: '%s'", option_arg);
"Invalid boolean value for on-throw option: '%s'",
option_arg.str().c_str());
} break;
case 'x':
m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
if (option_arg.getAsInteger(0, m_thread_index))
error.SetErrorStringWithFormat("invalid thread index string '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'X':
@ -853,17 +844,14 @@ 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;
switch (short_option) {
case 'c':
if (option_arg != nullptr)
m_condition.assign(option_arg);
else
m_condition.clear();
m_condition = option_arg;
m_condition_passed = true;
break;
case 'd':
@ -878,48 +866,39 @@ public:
m_enable_value = true;
break;
case 'i':
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
if (option_arg.getAsInteger(0, m_ignore_count))
error.SetErrorStringWithFormat("invalid ignore count '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'o': {
bool value, success;
value = Args::StringToBoolean(
llvm::StringRef::withNullAsEmpty(option_arg), false, &success);
value = Args::StringToBoolean(option_arg, false, &success);
if (success) {
m_one_shot_passed = true;
m_one_shot = value;
} else
error.SetErrorStringWithFormat(
"invalid boolean value '%s' passed for -o option", option_arg);
"invalid boolean value '%s' passed for -o option",
option_arg.str().c_str());
} break;
case 't':
if (option_arg[0] == '\0') {
m_thread_id = LLDB_INVALID_THREAD_ID;
m_thread_id_passed = true;
} else {
m_thread_id =
StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
if (option_arg.getAsInteger(0, m_thread_id))
error.SetErrorStringWithFormat("invalid thread id string '%s'",
option_arg);
option_arg.str().c_str());
else
m_thread_id_passed = true;
}
break;
case 'T':
if (option_arg != nullptr)
m_thread_name.assign(option_arg);
else
m_thread_name.clear();
m_thread_name = option_arg;
m_name_passed = true;
break;
case 'q':
if (option_arg != nullptr)
m_queue_name.assign(option_arg);
else
m_queue_name.clear();
m_queue_name = option_arg;
m_queue_passed = true;
break;
case 'x':
@ -927,10 +906,9 @@ public:
m_thread_index = UINT32_MAX;
m_thread_index_passed = true;
} else {
m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
if (option_arg.getAsInteger(0, m_thread_index))
error.SetErrorStringWithFormat("invalid thread index string '%s'",
option_arg);
option_arg.str().c_str());
else
m_thread_index_passed = true;
}
@ -1327,7 +1305,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;
@ -1474,7 +1452,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;
@ -1485,7 +1463,7 @@ public:
break;
case 'l':
m_line_num = StringConvert::ToUInt32(option_arg, 0);
option_arg.getAsInteger(0, m_line_num);
break;
default:
@ -1633,7 +1611,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;
@ -1773,29 +1751,29 @@ public:
return llvm::makeArrayRef(g_breakpoint_name_options);
}
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const int short_option = g_breakpoint_name_options[option_idx].short_option;
switch (short_option) {
case 'N':
if (BreakpointID::StringIsBreakpointName(option_value, error) &&
if (BreakpointID::StringIsBreakpointName(option_arg, error) &&
error.Success())
m_name.SetValueFromString(option_value);
m_name.SetValueFromString(option_arg);
break;
case 'B':
if (m_breakpoint.SetValueFromString(option_value).Fail())
if (m_breakpoint.SetValueFromString(option_arg).Fail())
error.SetErrorStringWithFormat(
"unrecognized value \"%s\" for breakpoint",
option_value.str().c_str());
option_arg.str().c_str());
break;
case 'D':
if (m_use_dummy.SetValueFromString(option_value).Fail())
if (m_use_dummy.SetValueFromString(option_arg).Fail())
error.SetErrorStringWithFormat(
"unrecognized value \"%s\" for use-dummy",
option_value.str().c_str());
option_arg.str().c_str());
break;
default:
@ -1805,7 +1783,6 @@ public:
}
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_name.Clear();
@ -2116,7 +2093,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;
@ -2246,7 +2223,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;

View File

@ -280,11 +280,10 @@ are no syntax errors may indicate that a function was declared but never called.
~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 'o':
@ -294,8 +293,7 @@ are no syntax errors may indicate that a function was declared but never called.
case 's':
m_script_language = (lldb::ScriptLanguage)Args::StringToOptionEnum(
llvm::StringRef::withNullAsEmpty(option_arg),
g_breakpoint_add_options[option_idx].enum_values,
option_arg, g_breakpoint_add_options[option_idx].enum_values,
eScriptLanguageNone, error);
if (m_script_language == eScriptLanguagePython ||
@ -308,10 +306,11 @@ are no syntax errors may indicate that a function was declared but never called.
case 'e': {
bool success = false;
m_stop_on_error = Args::StringToBoolean(option_strref, false, &success);
m_stop_on_error = Args::StringToBoolean(option_arg, false, &success);
if (!success)
error.SetErrorStringWithFormat(
"invalid value for stop-on-error: \"%s\"", option_arg);
"invalid value for stop-on-error: \"%s\"",
option_arg.str().c_str());
} break;
case 'F':
@ -511,7 +510,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;

View File

@ -66,29 +66,26 @@ protected:
~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;
llvm::StringRef option_strref =
llvm::StringRef::withNullAsEmpty(option_arg);
switch (short_option) {
case 'c':
error =
m_count.SetValueFromString(option_strref, eVarSetOperationAssign);
error = m_count.SetValueFromString(option_arg, eVarSetOperationAssign);
break;
case 's':
if (option_arg && strcmp("end", option_arg) == 0) {
if (option_arg == "end") {
m_start_idx.SetCurrentValue(UINT64_MAX);
m_start_idx.SetOptionWasSet();
} else
error = m_start_idx.SetValueFromString(option_strref,
error = m_start_idx.SetValueFromString(option_arg,
eVarSetOperationAssign);
break;
case 'e':
error = m_stop_idx.SetValueFromString(option_strref,
eVarSetOperationAssign);
error =
m_stop_idx.SetValueFromString(option_arg, eVarSetOperationAssign);
break;
case 'C':
m_clear.SetCurrentValue(true);
@ -259,24 +256,22 @@ protected:
~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;
llvm::StringRef option_strref =
llvm::StringRef::withNullAsEmpty(option_arg);
switch (short_option) {
case 'e':
error = m_stop_on_error.SetValueFromString(option_strref);
error = m_stop_on_error.SetValueFromString(option_arg);
break;
case 'c':
error = m_stop_on_continue.SetValueFromString(option_strref);
error = m_stop_on_continue.SetValueFromString(option_arg);
break;
case 's':
error = m_silent_run.SetValueFromString(option_strref);
error = m_silent_run.SetValueFromString(option_arg);
break;
default:
@ -401,7 +396,6 @@ protected:
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_help.Clear();
@ -1229,7 +1223,7 @@ private:
~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;
@ -1498,7 +1492,7 @@ protected:
~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;
@ -1630,32 +1624,32 @@ protected:
~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;
switch (short_option) {
case 'f':
if (option_arg)
m_funct_name.assign(option_arg);
if (!option_arg.empty())
m_funct_name = option_arg;
break;
case 'c':
if (option_arg)
m_class_name.assign(option_arg);
if (!option_arg.empty())
m_class_name = option_arg;
break;
case 'h':
if (option_arg)
m_short_help.assign(option_arg);
if (!option_arg.empty())
m_short_help = option_arg;
break;
case 's':
m_synchronicity =
(ScriptedCommandSynchronicity)Args::StringToOptionEnum(
llvm::StringRef::withNullAsEmpty(option_arg),
GetDefinitions()[option_idx].enum_values, 0, error);
option_arg, GetDefinitions()[option_idx].enum_values, 0, error);
if (!error.Success())
error.SetErrorStringWithFormat(
"unrecognized value for synchronicity '%s'", option_arg);
"unrecognized value for synchronicity '%s'",
option_arg.str().c_str());
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",

View File

@ -72,31 +72,28 @@ CommandObjectDisassemble::CommandOptions::CommandOptions()
CommandObjectDisassemble::CommandOptions::~CommandOptions() = default;
Error CommandObjectDisassemble::CommandOptions::SetOptionValue(
uint32_t option_idx, const char *option_arg,
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Error error;
const int short_option = m_getopt_table[option_idx].val;
bool success;
switch (short_option) {
case 'm':
show_mixed = true;
break;
case 'C':
num_lines_context = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
if (option_arg.getAsInteger(0, num_lines_context))
error.SetErrorStringWithFormat("invalid num context lines string: \"%s\"",
option_arg);
option_arg.str().c_str());
break;
case 'c':
num_instructions = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
if (option_arg.getAsInteger(0, num_instructions))
error.SetErrorStringWithFormat(
"invalid num of instructions string: \"%s\"", option_arg);
"invalid num of instructions string: \"%s\"",
option_arg.str().c_str());
break;
case 'b':

View File

@ -32,7 +32,7 @@ public:
~CommandOptions() override;
Error SetOptionValue(uint32_t option_idx, const char *option_arg,
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override;
void OptionParsingStarting(ExecutionContext *execution_context) override;

View File

@ -36,7 +36,6 @@ public:
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
ExecutionContext *execution_context) override;
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override;

View File

@ -77,7 +77,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;
@ -87,24 +87,20 @@ public:
break;
case 'a': {
bool success = false;
address = StringConvert::ToUInt64(option_arg, 0, 0, &success);
if (!success) {
address.emplace();
if (option_arg.getAsInteger(0, *address)) {
address.reset();
error.SetErrorStringWithFormat("invalid address argument '%s'",
option_arg);
option_arg.str().c_str());
}
} break;
case 'o': {
bool success = false;
offset = StringConvert::ToSInt64(option_arg, 0, 0, &success);
if (!success) {
offset.emplace();
if (option_arg.getAsInteger(0, *offset)) {
offset.reset();
error.SetErrorStringWithFormat("invalid offset argument '%s'",
option_arg);
option_arg.str().c_str());
}
} break;
@ -268,18 +264,17 @@ 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;
bool success = false;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
case 'r':
relative_frame_offset =
StringConvert::ToSInt32(option_arg, INT32_MIN, 0, &success);
if (!success)
if (option_arg.getAsInteger(0, relative_frame_offset)) {
relative_frame_offset = INT32_MIN;
error.SetErrorStringWithFormat("invalid frame offset argument '%s'",
option_arg);
option_arg.str().c_str());
}
break;
default:

View File

@ -45,7 +45,7 @@ public:
~CommandOptions() override {}
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;

View File

@ -116,7 +116,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;

View File

@ -110,7 +110,6 @@ public:
}
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_num_per_line.Clear();
@ -942,7 +941,6 @@ public:
}
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_expr.Clear();
@ -1238,7 +1236,6 @@ public:
}
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_infile.Clear();

View File

@ -667,22 +667,21 @@ protected:
~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;
char short_option = (char)m_getopt_table[option_idx].val;
bool success = false;
switch (short_option) {
case 'o':
m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
if (option_arg.getAsInteger(0, m_offset))
error.SetErrorStringWithFormat("invalid offset: '%s'",
option_arg.str().c_str());
break;
case 'c':
m_count = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
if (option_arg.getAsInteger(0, m_count))
error.SetErrorStringWithFormat("invalid offset: '%s'",
option_arg.str().c_str());
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
@ -762,17 +761,16 @@ protected:
~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;
char short_option = (char)m_getopt_table[option_idx].val;
bool success = false;
switch (short_option) {
case 'o':
m_offset = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
error.SetErrorStringWithFormat("invalid offset: '%s'", option_arg);
if (option_arg.getAsInteger(0, m_offset))
error.SetErrorStringWithFormat("invalid offset: '%s'",
option_arg.str().c_str());
break;
case 'd':
m_data.assign(option_arg);
@ -1272,59 +1270,60 @@ protected:
~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;
bool success = false;
uint32_t id = LLDB_INVALID_PROCESS_ID;
success = !option_arg.getAsInteger(0, id);
switch (short_option) {
case 'p':
match_info.GetProcessInfo().SetProcessID(StringConvert::ToUInt32(
option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
case 'p': {
match_info.GetProcessInfo().SetProcessID(id);
if (!success)
error.SetErrorStringWithFormat("invalid process ID string: '%s'",
option_arg);
option_arg.str().c_str());
break;
}
case 'P':
match_info.GetProcessInfo().SetParentProcessID(StringConvert::ToUInt32(
option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
match_info.GetProcessInfo().SetParentProcessID(id);
if (!success)
error.SetErrorStringWithFormat(
"invalid parent process ID string: '%s'", option_arg);
"invalid parent process ID string: '%s'",
option_arg.str().c_str());
break;
case 'u':
match_info.GetProcessInfo().SetUserID(
StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetUserID(success ? id : UINT32_MAX);
if (!success)
error.SetErrorStringWithFormat("invalid user ID string: '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'U':
match_info.GetProcessInfo().SetEffectiveUserID(
StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetEffectiveUserID(success ? id
: UINT32_MAX);
if (!success)
error.SetErrorStringWithFormat(
"invalid effective user ID string: '%s'", option_arg);
"invalid effective user ID string: '%s'",
option_arg.str().c_str());
break;
case 'g':
match_info.GetProcessInfo().SetGroupID(
StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetGroupID(success ? id : UINT32_MAX);
if (!success)
error.SetErrorStringWithFormat("invalid group ID string: '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'G':
match_info.GetProcessInfo().SetEffectiveGroupID(
StringConvert::ToUInt32(option_arg, UINT32_MAX, 0, &success));
match_info.GetProcessInfo().SetEffectiveGroupID(success ? id
: UINT32_MAX);
if (!success)
error.SetErrorStringWithFormat(
"invalid effective group ID string: '%s'", option_arg);
"invalid effective group ID string: '%s'",
option_arg.str().c_str());
break;
case 'a': {
@ -1515,17 +1514,16 @@ 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;
char short_option = (char)m_getopt_table[option_idx].val;
bool success = false;
switch (short_option) {
case 'p': {
lldb::pid_t pid = StringConvert::ToUInt32(
option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (!success || pid == LLDB_INVALID_PROCESS_ID) {
error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
if (option_arg.getAsInteger(0, pid)) {
error.SetErrorStringWithFormat("invalid process ID '%s'",
option_arg.str().c_str());
} else {
attach_info.SetProcessID(pid);
}
@ -1701,21 +1699,20 @@ public:
return llvm::makeArrayRef(g_platform_shell_options);
}
Error SetOptionValue(uint32_t option_idx, const char *option_value,
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) override {
Error error;
const char short_option = (char)GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 't': {
bool success;
timeout = StringConvert::ToUInt32(option_value, 10, 10, &success);
if (!success)
case 't':
timeout = 10;
if (option_arg.getAsInteger(10, timeout))
error.SetErrorStringWithFormat(
"could not convert \"%s\" to a numeric value.", option_value);
"could not convert \"%s\" to a numeric value.",
option_arg.str().c_str());
break;
}
default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);

View File

@ -337,21 +337,20 @@ 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;
bool success = false;
switch (short_option) {
case 'c':
attach_info.SetContinueOnceAttached(true);
break;
case 'p': {
lldb::pid_t pid = StringConvert::ToUInt32(
option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
if (!success || pid == LLDB_INVALID_PROCESS_ID) {
error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
lldb::pid_t pid;
if (option_arg.getAsInteger(0, pid)) {
error.SetErrorStringWithFormat("invalid process ID '%s'",
option_arg.str().c_str());
} else {
attach_info.SetProcessID(pid);
}
@ -604,18 +603,16 @@ protected:
~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;
bool success = false;
switch (short_option) {
case 'i':
m_ignore = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
if (option_arg.getAsInteger(0, m_ignore))
error.SetErrorStringWithFormat(
"invalid value for ignore option: \"%s\", should be a number.",
option_arg);
option_arg.str().c_str());
break;
default:
@ -755,20 +752,19 @@ 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 's':
bool tmp_result;
bool success;
tmp_result = Args::StringToBoolean(option_strref, false, &success);
tmp_result = Args::StringToBoolean(option_arg, false, &success);
if (!success)
error.SetErrorStringWithFormat("invalid boolean option: \"%s\"",
option_arg);
option_arg.str().c_str());
else {
if (tmp_result)
m_keep_stopped = eLazyBoolYes;
@ -859,7 +855,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;
@ -988,14 +984,14 @@ 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;
switch (short_option) {
case 'i':
do_install = true;
if (option_arg && option_arg[0])
if (!option_arg.empty())
install_path.SetFile(option_arg, false);
break;
default:
@ -1382,7 +1378,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;

View File

@ -294,7 +294,6 @@ protected:
}
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
// Instance variables to hold the values for command options.
OptionValueArray set_indexes;

View File

@ -101,7 +101,7 @@ insert-before or insert-after.");
~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;

View File

@ -59,30 +59,27 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
~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 = GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 'l':
start_line = StringConvert::ToUInt32(option_arg, 0);
if (start_line == 0)
if (option_arg.getAsInteger(0, start_line))
error.SetErrorStringWithFormat("invalid line number: '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'e':
end_line = StringConvert::ToUInt32(option_arg, 0);
if (end_line == 0)
if (option_arg.getAsInteger(0, end_line))
error.SetErrorStringWithFormat("invalid line number: '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'c':
num_lines = StringConvert::ToUInt32(option_arg, 0);
if (num_lines == 0)
if (option_arg.getAsInteger(0, num_lines))
error.SetErrorStringWithFormat("invalid line count: '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'f':
@ -686,23 +683,21 @@ class CommandObjectSourceList : public CommandObjectParsed {
~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 = GetDefinitions()[option_idx].short_option;
switch (short_option) {
case 'l':
start_line = StringConvert::ToUInt32(option_arg, 0);
if (start_line == 0)
if (option_arg.getAsInteger(0, start_line))
error.SetErrorStringWithFormat("invalid line number: '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'c':
num_lines = StringConvert::ToUInt32(option_arg, 0);
if (num_lines == 0)
if (option_arg.getAsInteger(0, num_lines))
error.SetErrorStringWithFormat("invalid line count: '%s'",
option_arg);
option_arg.str().c_str());
break;
case 'f':

View File

@ -1972,7 +1972,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;
@ -1980,8 +1980,8 @@ public:
switch (short_option) {
case 's':
m_sort_order = (SortOrder)Args::StringToOptionEnum(
llvm::StringRef::withNullAsEmpty(option_arg),
GetDefinitions()[option_idx].enum_values, eSortOrderNone, error);
option_arg, GetDefinitions()[option_idx].enum_values,
eSortOrderNone, error);
break;
default:
@ -2802,7 +2802,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;
@ -2814,8 +2814,7 @@ public:
LLDB_INVALID_ADDRESS, &error);
} else {
unsigned long width = 0;
if (option_arg)
width = strtoul(option_arg, nullptr, 0);
option_arg.getAsInteger(0, width);
m_format_array.push_back(std::make_pair(short_option, width));
}
return error;
@ -3166,7 +3165,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;
@ -3180,7 +3179,7 @@ public:
LLDB_INVALID_ADDRESS, &error);
if (m_addr == LLDB_INVALID_ADDRESS)
error.SetErrorStringWithFormat("invalid address string '%s'",
option_arg);
option_arg.str().c_str());
break;
}
@ -3466,7 +3465,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;
@ -3480,10 +3479,9 @@ public:
} break;
case 'o':
m_offset = StringConvert::ToUInt64(option_arg, LLDB_INVALID_ADDRESS);
if (m_offset == LLDB_INVALID_ADDRESS)
if (option_arg.getAsInteger(0, m_offset))
error.SetErrorStringWithFormat("invalid offset string '%s'",
option_arg);
option_arg.str().c_str());
break;
case 's':
@ -3501,10 +3499,9 @@ public:
break;
case 'l':
m_line_number = StringConvert::ToUInt32(option_arg, UINT32_MAX);
if (m_line_number == UINT32_MAX)
if (option_arg.getAsInteger(0, m_line_number))
error.SetErrorStringWithFormat("invalid line number string '%s'",
option_arg);
option_arg.str().c_str());
else if (m_line_number == 0)
error.SetErrorString("zero is an invalid line number");
m_type = eLookupTypeFileLine;
@ -4345,11 +4342,10 @@ public:
return llvm::makeArrayRef(g_target_stop_hook_add_options);
}
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;
bool success;
switch (short_option) {
case 'c':
@ -4358,20 +4354,18 @@ public:
break;
case 'e':
m_line_end = StringConvert::ToUInt32(option_arg, UINT_MAX, 0, &success);
if (!success) {
if (option_arg.getAsInteger(0, m_line_end)) {
error.SetErrorStringWithFormat("invalid end line number: \"%s\"",
option_arg);
option_arg.str().c_str());
break;
}
m_sym_ctx_specified = true;
break;
case 'l':
m_line_start = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success) {
if (option_arg.getAsInteger(0, m_line_start)) {
error.SetErrorStringWithFormat("invalid start line number: \"%s\"",
option_arg);
option_arg.str().c_str());
break;
}
m_sym_ctx_specified = true;
@ -4398,11 +4392,9 @@ public:
break;
case 't':
m_thread_id =
StringConvert::ToUInt64(option_arg, LLDB_INVALID_THREAD_ID, 0);
if (m_thread_id == LLDB_INVALID_THREAD_ID)
if (option_arg.getAsInteger(0, m_thread_id))
error.SetErrorStringWithFormat("invalid thread id string '%s'",
option_arg);
option_arg.str().c_str());
m_thread_specified = true;
break;
@ -4417,10 +4409,9 @@ public:
break;
case 'x':
m_thread_index = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_thread_id == UINT32_MAX)
if (option_arg.getAsInteger(0, m_thread_index))
error.SetErrorStringWithFormat("invalid thread index string '%s'",
option_arg);
option_arg.str().c_str());
m_thread_specified = true;
break;

View File

@ -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)
error.SetErrorStringWithFormat(
"invalid integer value for option '%c'", short_option);
if (input_count < -1)
int32_t input_count = 0;
if (option_arg.getAsInteger(0, m_count)) {
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)
error.SetErrorStringWithFormat(
"invalid integer value for option '%c'", short_option);
} else if (input_count < 0)
m_count = UINT32_MAX;
} break;
case 's':
if (option_arg.getAsInteger(0, m_start))
error.SetErrorStringWithFormat(
"invalid integer value for option '%c'", short_option);
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;

View File

@ -126,7 +126,7 @@ private:
~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;
void OptionParsingStarting(ExecutionContext *execution_context) override;
@ -320,7 +320,7 @@ private:
~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;
@ -328,11 +328,10 @@ private:
switch (short_option) {
case 'C':
m_cascade = Args::StringToBoolean(
llvm::StringRef::withNullAsEmpty(option_arg), true, &success);
m_cascade = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat("invalid value for cascade: %s",
option_arg);
option_arg.str().c_str());
break;
case 'P':
handwrite_python = true;
@ -599,7 +598,6 @@ private:
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
// Instance variables to hold the values for command options.
@ -770,7 +768,7 @@ protected:
~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;
@ -783,8 +781,7 @@ protected:
m_category = std::string(option_arg);
break;
case 'l':
m_language = Language::GetLanguageTypeFromString(
llvm::StringRef::withNullAsEmpty(option_arg));
m_language = Language::GetLanguageTypeFromString(option_arg);
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
@ -911,7 +908,7 @@ private:
~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;
@ -1027,19 +1024,17 @@ class CommandObjectTypeFormatterList : public CommandObjectParsed {
~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;
llvm::StringRef option_strref =
llvm::StringRef::withNullAsEmpty(option_arg);
switch (short_option) {
case 'w':
m_category_regex.SetCurrentValue(option_strref);
m_category_regex.SetCurrentValue(option_arg);
m_category_regex.SetOptionWasSet();
break;
case 'l':
error = m_category_language.SetValueFromString(option_strref);
error = m_category_language.SetValueFromString(option_arg);
if (error.Success())
m_category_language.SetOptionWasSet();
break;
@ -1249,7 +1244,7 @@ public:
#endif // LLDB_DISABLE_PYTHON
Error CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(
uint32_t option_idx, const char *option_arg,
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Error error;
const int short_option = m_getopt_table[option_idx].val;
@ -1257,11 +1252,10 @@ Error CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(
switch (short_option) {
case 'C':
m_flags.SetCascades(Args::StringToBoolean(
llvm::StringRef::withNullAsEmpty(option_arg), true, &success));
m_flags.SetCascades(Args::StringToBoolean(option_arg, true, &success));
if (!success)
error.SetErrorStringWithFormat("invalid value for cascade: %s",
option_arg);
option_arg.str().c_str());
break;
case 'e':
m_flags.SetDontShowChildren(false);
@ -1288,14 +1282,14 @@ Error CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(
m_regex = true;
break;
case 'n':
m_name.SetCString(option_arg);
m_name.SetString(option_arg);
break;
case 'o':
m_python_script = std::string(option_arg);
m_python_script = option_arg;
m_is_add_script = true;
break;
case 'F':
m_python_function = std::string(option_arg);
m_python_function = option_arg;
m_is_add_script = true;
break;
case 'P':
@ -1805,7 +1799,7 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
~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;
@ -1815,8 +1809,7 @@ class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
m_define_enabled.SetValueFromString(llvm::StringRef("true"));
break;
case 'l':
error = m_cate_language.SetValueFromString(
llvm::StringRef::withNullAsEmpty(option_arg));
error = m_cate_language.SetValueFromString(option_arg);
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
@ -1910,19 +1903,18 @@ class CommandObjectTypeCategoryEnable : public CommandObjectParsed {
~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;
switch (short_option) {
case 'l':
if (option_arg) {
m_language = Language::GetLanguageTypeFromString(
llvm::StringRef::withNullAsEmpty(option_arg));
if (!option_arg.empty()) {
m_language = Language::GetLanguageTypeFromString(option_arg);
if (m_language == lldb::eLanguageTypeUnknown)
error.SetErrorStringWithFormat("unrecognized language '%s'",
option_arg);
option_arg.str().c_str());
}
break;
default:
@ -2088,19 +2080,18 @@ class CommandObjectTypeCategoryDisable : public CommandObjectParsed {
~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;
switch (short_option) {
case 'l':
if (option_arg) {
m_language = Language::GetLanguageTypeFromString(
llvm::StringRef::withNullAsEmpty(option_arg));
if (!option_arg.empty()) {
m_language = Language::GetLanguageTypeFromString(option_arg);
if (m_language == lldb::eLanguageTypeUnknown)
error.SetErrorStringWithFormat("unrecognized language '%s'",
option_arg);
option_arg.str().c_str());
}
break;
default:
@ -2521,7 +2512,7 @@ private:
~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;
@ -2529,11 +2520,10 @@ private:
switch (short_option) {
case 'C':
m_cascade = Args::StringToBoolean(
llvm::StringRef::withNullAsEmpty(option_arg), true, &success);
m_cascade = Args::StringToBoolean(option_arg, true, &success);
if (!success)
error.SetErrorStringWithFormat("invalid value for cascade: %s",
option_arg);
option_arg.str().c_str());
break;
case 'c':
m_expr_paths.push_back(option_arg);
@ -2820,7 +2810,6 @@ protected:
return error;
}
Error SetOptionValue(uint32_t, const char *, ExecutionContext *) = delete;
void OptionParsingStarting(ExecutionContext *execution_context) override {
m_show_help = false;

View File

@ -197,7 +197,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;
@ -561,17 +561,16 @@ 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;
switch (short_option) {
case 'i':
m_ignore_count = StringConvert::ToUInt32(option_arg, UINT32_MAX, 0);
if (m_ignore_count == UINT32_MAX)
if (option_arg.getAsInteger(0, m_ignore_count))
error.SetErrorStringWithFormat("invalid ignore count '%s'",
option_arg);
option_arg.str().c_str());
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
@ -690,17 +689,14 @@ 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;
switch (short_option) {
case 'c':
if (option_arg != nullptr)
m_condition.assign(option_arg);
else
m_condition.clear();
m_condition = option_arg;
m_condition_passed = true;
break;
default:

View File

@ -318,7 +318,7 @@ are no syntax errors may indicate that a function was declared but never called.
~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;
@ -331,9 +331,8 @@ are no syntax errors may indicate that a function was declared but never called.
case 's':
m_script_language = (lldb::ScriptLanguage)Args::StringToOptionEnum(
llvm::StringRef::withNullAsEmpty(option_arg),
GetDefinitions()[option_idx].enum_values, eScriptLanguageNone,
error);
option_arg, GetDefinitions()[option_idx].enum_values,
eScriptLanguageNone, error);
m_use_script_language = (m_script_language == eScriptLanguagePython ||
m_script_language == eScriptLanguageDefault);
@ -341,11 +340,11 @@ are no syntax errors may indicate that a function was declared but never called.
case 'e': {
bool success = false;
m_stop_on_error = Args::StringToBoolean(
llvm::StringRef::withNullAsEmpty(option_arg), false, &success);
m_stop_on_error = Args::StringToBoolean(option_arg, false, &success);
if (!success)
error.SetErrorStringWithFormat(
"invalid value for stop-on-error: \"%s\"", option_arg);
"invalid value for stop-on-error: \"%s\"",
option_arg.str().c_str());
} break;
case 'F':

View File

@ -905,7 +905,7 @@ void OptionGroupOptions::Finalize() {
}
Error OptionGroupOptions::SetOptionValue(uint32_t option_idx,
const char *option_value,
llvm::StringRef option_value,
ExecutionContext *execution_context) {
// After calling OptionGroupOptions::Append(...), you must finalize the groups
// by calling OptionGroupOptions::Finlize()
@ -913,8 +913,8 @@ Error OptionGroupOptions::SetOptionValue(uint32_t option_idx,
Error error;
if (option_idx < m_option_infos.size()) {
error = m_option_infos[option_idx].option_group->SetOptionValue(
m_option_infos[option_idx].option_index,
llvm::StringRef::withNullAsEmpty(option_value), execution_context);
m_option_infos[option_idx].option_index, option_value,
execution_context);
} else {
error.SetErrorString("invalid option index"); // Shouldn't happen...

View File

@ -483,7 +483,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;

View File

@ -4155,23 +4155,23 @@ public:
~CommandOptions() override = default;
Error SetOptionValue(uint32_t option_idx, const char *option_val,
Error SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *exe_ctx) override {
Error err;
StreamString err_str;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
case 't':
if (!ParseReductionTypes(option_val, err_str))
if (!ParseReductionTypes(option_arg, err_str))
err.SetErrorStringWithFormat(
"Unable to deduce reduction types for %s: %s", option_val,
err_str.GetData());
"Unable to deduce reduction types for %s: %s",
option_arg.str().c_str(), err_str.GetData());
break;
case 'c': {
auto coord = RSCoordinate{};
if (!ParseCoordinate(option_val, coord))
if (!ParseCoordinate(option_arg, coord))
err.SetErrorStringWithFormat("unable to parse coordinate for %s",
option_val);
option_arg.str().c_str());
else {
m_have_coord = true;
m_coord = coord;
@ -4192,7 +4192,8 @@ public:
return llvm::makeArrayRef(g_renderscript_reduction_bp_set_options);
}
bool ParseReductionTypes(const char *option_val, StreamString &err_str) {
bool ParseReductionTypes(llvm::StringRef option_val,
StreamString &err_str) {
m_kernel_types = RSReduceBreakpointResolver::eKernelTypeNone;
const auto reduce_name_to_type = [](llvm::StringRef name) -> int {
return llvm::StringSwitch<int>(name)
@ -4215,7 +4216,7 @@ public:
assert(match_type_list.IsValid());
if (!match_type_list.Execute(llvm::StringRef(option_val), &match)) {
if (!match_type_list.Execute(option_val, &match)) {
err_str.PutCString(
"a comma-separated list of kernel types is required");
return false;
@ -4310,7 +4311,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 *exe_ctx) override {
Error err;
const int short_option = m_getopt_table[option_idx].val;
@ -4321,7 +4322,7 @@ public:
if (!ParseCoordinate(option_arg, coord))
err.SetErrorStringWithFormat(
"Couldn't parse coordinate '%s', should be in format 'x,y,z'.",
option_arg);
option_arg.str().c_str());
else {
m_have_coord = true;
m_coord = coord;
@ -4591,7 +4592,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 *exe_ctx) override {
Error err;
const int short_option = m_getopt_table[option_idx].val;
@ -4601,7 +4602,8 @@ public:
m_outfile.SetFile(option_arg, true);
if (m_outfile.Exists()) {
m_outfile.Clear();
err.SetErrorStringWithFormat("file already exists: '%s'", option_arg);
err.SetErrorStringWithFormat("file already exists: '%s'",
option_arg.str().c_str());
}
break;
default:
@ -4712,16 +4714,14 @@ 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 *exe_ctx) override {
Error err;
const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
case 'i':
bool success;
m_id = StringConvert::ToUInt32(option_arg, 0, 0, &success);
if (!success)
if (option_arg.getAsInteger(0, m_id))
err.SetErrorStringWithFormat("invalid integer value for option '%c'",
short_option);
break;

View File

@ -523,12 +523,11 @@ public:
m_filter_rules.clear();
}
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':
m_include_any_process = true;
@ -542,7 +541,7 @@ public:
break;
case 'b':
m_broadcast_events = Args::StringToBoolean(option_strref, true, nullptr);
m_broadcast_events = Args::StringToBoolean(option_arg, true, nullptr);
break;
case 'c':
@ -558,23 +557,23 @@ public:
break;
case 'e':
m_echo_to_stderr = Args::StringToBoolean(option_strref, false, nullptr);
m_echo_to_stderr = Args::StringToBoolean(option_arg, false, nullptr);
break;
case 'f':
return ParseFilterRule(option_strref);
return ParseFilterRule(option_arg);
case 'i':
m_include_info_level = true;
break;
case 'l':
m_live_stream = Args::StringToBoolean(option_strref, false, nullptr);
m_live_stream = Args::StringToBoolean(option_arg, false, nullptr);
break;
case 'n':
m_filter_fall_through_accepts =
Args::StringToBoolean(option_strref, true, nullptr);
Args::StringToBoolean(option_arg, true, nullptr);
break;
case 'r':

View File

@ -412,11 +412,10 @@ void ProcessInstanceInfo::DumpAsTableRow(Stream &s, Platform *platform,
}
Error ProcessLaunchCommandOptions::SetOptionValue(
uint32_t option_idx, const char *option_arg,
uint32_t option_idx, llvm::StringRef option_arg,
ExecutionContext *execution_context) {
Error error;
const int short_option = m_getopt_table[option_idx].val;
auto option_strref = llvm::StringRef::withNullAsEmpty(option_arg);
switch (short_option) {
case 's': // Stop at program entry point
@ -485,40 +484,38 @@ Error ProcessLaunchCommandOptions::SetOptionValue(
{
bool success;
const bool disable_aslr_arg =
Args::StringToBoolean(option_strref, true, &success);
Args::StringToBoolean(option_arg, true, &success);
if (success)
disable_aslr = disable_aslr_arg ? eLazyBoolYes : eLazyBoolNo;
else
error.SetErrorStringWithFormat(
"Invalid boolean value for disable-aslr option: '%s'",
option_arg ? option_arg : "<null>");
option_arg.empty() ? "<null>" : option_arg.str().c_str());
break;
}
case 'X': // shell expand args.
{
bool success;
const bool expand_args =
Args::StringToBoolean(option_strref, true, &success);
const bool expand_args = Args::StringToBoolean(option_arg, true, &success);
if (success)
launch_info.SetShellExpandArguments(expand_args);
else
error.SetErrorStringWithFormat(
"Invalid boolean value for shell-expand-args option: '%s'",
option_arg ? option_arg : "<null>");
option_arg.empty() ? "<null>" : option_arg.str().c_str());
break;
}
case 'c':
if (option_arg && option_arg[0])
if (!option_arg.empty())
launch_info.SetShell(FileSpec(option_arg, false));
else
launch_info.SetShell(HostInfo::GetDefaultShell());
break;
case 'v':
launch_info.GetEnvironmentEntries().AppendArgument(
llvm::StringRef::withNullAsEmpty(option_arg));
launch_info.GetEnvironmentEntries().AppendArgument(option_arg);
break;
default:

View File

@ -142,11 +142,8 @@ const char *ProcessLaunchInfo::GetProcessPluginName() const {
return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str());
}
void ProcessLaunchInfo::SetProcessPluginName(const char *plugin) {
if (plugin && plugin[0])
m_plugin_name.assign(plugin);
else
m_plugin_name.clear();
void ProcessLaunchInfo::SetProcessPluginName(llvm::StringRef plugin) {
m_plugin_name = plugin;
}
const FileSpec &ProcessLaunchInfo::GetShell() const { return m_shell; }