// Get command object for the first command argument. Only search built-in
// command dictionary.
StringList matches;
- cmd_obj =
- m_interpreter.GetCommandObject(command.GetArgumentAtIndex(0), &matches);
- bool is_alias_command =
- m_interpreter.AliasExists(command.GetArgumentAtIndex(0));
- std::string alias_name = command.GetArgumentAtIndex(0);
+ auto command_name = command[0].ref;
+ cmd_obj = m_interpreter.GetCommandObject(command_name, &matches);
if (cmd_obj != nullptr) {
StringList matches;
sub_cmd_obj->GenerateHelpText(result);
- if (is_alias_command) {
+ if (m_interpreter.AliasExists(command_name)) {
StreamString sstr;
- m_interpreter.GetAlias(alias_name)->GetAliasExpansion(sstr);
+ m_interpreter.GetAlias(command_name)->GetAliasExpansion(sstr);
result.GetOutputStream().Printf("\n'%s' is an abbreviation for %s\n",
- alias_name.c_str(), sstr.GetData());
+ command[0].c_str(), sstr.GetData());
}
} else if (matches.GetSize() > 0) {
Stream &output_strm = result.GetOutputStream();
// Maybe the user is asking for help about a command argument rather than
// a command.
const CommandArgumentType arg_type =
- CommandObject::LookupArgumentName(command.GetArgumentAtIndex(0));
+ CommandObject::LookupArgumentName(command_name);
if (arg_type != eArgTypeLastArg) {
Stream &output_strm = result.GetOutputStream();
CommandObject::GetArgumentHelp(output_strm, arg_type, m_interpreter);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
StreamString error_msg_stream;
- GenerateAdditionalHelpAvenuesMessage(&error_msg_stream,
- command.GetArgumentAtIndex(0),
- m_interpreter.GetCommandPrefix(), "");
+ GenerateAdditionalHelpAvenuesMessage(&error_msg_stream, command_name,
+ m_interpreter.GetCommandPrefix(),
+ "");
result.AppendError(error_msg_stream.GetString());
result.SetStatus(eReturnStatusFailed);
}
input, cursor_index, cursor_char_position, match_start_point,
max_return_elements, word_complete, matches);
} else {
- CommandObject *cmd_obj =
- m_interpreter.GetCommandObject(input.GetArgumentAtIndex(0));
+ CommandObject *cmd_obj = m_interpreter.GetCommandObject(input[0].ref);
// The command that they are getting help on might be ambiguous, in which
// case we should complete that,
Options *GetOptions() override { return &m_options; }
- // int
- // HandleArgumentCompletion (Args &input,
- // int &cursor_index,
- // int &cursor_char_position,
- // OptionElementVector &opt_element_vector,
- // int match_start_point,
- // int max_return_elements,
- // bool &word_complete,
- // StringList &matches)
- // {
- // std::string completion_str (input.GetArgumentAtIndex(cursor_index));
- // completion_str.erase (cursor_char_position);
- //
- // if (cursor_index == 1)
- // {
- // //
- // Log::AutoCompleteChannelName (completion_str.c_str(), matches);
- // }
- // return matches.GetSize();
- // }
- //
-
class CommandOptions : public Options {
public:
CommandOptions() : Options(), log_file(), log_options(0) {}
}
// Store into a std::string since we're about to shift the channel off.
- std::string channel = args.GetArgumentAtIndex(0);
+ const std::string channel = args[0].ref;
args.Shift(); // Shift off the channel
char log_file[PATH_MAX];
if (m_options.log_file)
Log::Callbacks log_callbacks;
- const std::string channel = args.GetArgumentAtIndex(0);
+ const std::string channel = args[0].ref;
args.Shift(); // Shift off the channel
if (Log::GetLogChannelCallbacks(ConstString(channel), log_callbacks)) {
log_callbacks.disable(args.GetConstArgumentVector(),
result.SetStatus(eReturnStatusFailed);
if (args.GetArgumentCount() == 1) {
- llvm::StringRef sub_command = args.GetArgumentAtIndex(0);
+ auto sub_command = args[0].ref;
if (sub_command.equals_lower("enable")) {
Timer::SetDisplayDepth(UINT32_MAX);
result.SetStatus(eReturnStatusSuccessFinishResult);
}
} else if (args.GetArgumentCount() == 2) {
- llvm::StringRef sub_command = args.GetArgumentAtIndex(0);
- llvm::StringRef param = args.GetArgumentAtIndex(1);
+ auto sub_command = args[0].ref;
+ auto param = args[1].ref;
if (sub_command.equals_lower("enable")) {
uint32_t depth;
}
if (argc > 0)
- addr = Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(0),
+ addr = Args::StringToAddress(&m_exe_ctx, command[0].ref,
LLDB_INVALID_ADDRESS, &error);
if (addr == LLDB_INVALID_ADDRESS) {
}
if (argc == 2) {
- lldb::addr_t end_addr =
- Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1),
- LLDB_INVALID_ADDRESS, nullptr);
+ lldb::addr_t end_addr = Args::StringToAddress(
+ &m_exe_ctx, command[1].ref, LLDB_INVALID_ADDRESS, nullptr);
if (end_addr == LLDB_INVALID_ADDRESS) {
result.AppendError("invalid end address expression.");
result.AppendError(error.AsCString());
}
Error error;
- lldb::addr_t low_addr =
- Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(0),
- LLDB_INVALID_ADDRESS, &error);
+ lldb::addr_t low_addr = Args::StringToAddress(&m_exe_ctx, command[0].ref,
+ LLDB_INVALID_ADDRESS, &error);
if (low_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
result.AppendError("invalid low address");
return false;
}
- lldb::addr_t high_addr =
- Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(1),
- LLDB_INVALID_ADDRESS, &error);
+ lldb::addr_t high_addr = Args::StringToAddress(
+ &m_exe_ctx, command[1].ref, LLDB_INVALID_ADDRESS, &error);
if (high_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
result.AppendError("invalid high address");
return false;
size_t item_byte_size = byte_size_value.GetCurrentValue();
Error error;
- lldb::addr_t addr =
- Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(0),
- LLDB_INVALID_ADDRESS, &error);
+ lldb::addr_t addr = Args::StringToAddress(&m_exe_ctx, command[0].ref,
+ LLDB_INVALID_ADDRESS, &error);
if (addr == LLDB_INVALID_ADDRESS) {
result.AppendError("invalid address expression\n");
int64_t sval64;
bool success = false;
const size_t num_value_args = command.GetArgumentCount();
- for (size_t i = 0; i < num_value_args; ++i) {
- const char *value_str = command.GetArgumentAtIndex(i);
-
+ for (auto &entry : command) {
switch (m_format_options.GetFormat()) {
case kNumFormats:
case eFormatFloat: // TODO: add support for floats soon
case eFormatHexUppercase:
case eFormatPointer:
// Decode hex bytes
- uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 16, &success);
- if (!success) {
+ if (entry.ref.getAsInteger(16, uval64)) {
result.AppendErrorWithFormat(
- "'%s' is not a valid hex string value.\n", value_str);
+ "'%s' is not a valid hex string value.\n", entry.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
} else if (!UIntValueIsValidForSize(uval64, item_byte_size)) {
break;
case eFormatBoolean:
- uval64 = Args::StringToBoolean(
- llvm::StringRef::withNullAsEmpty(value_str), false, &success);
+ uval64 = Args::StringToBoolean(entry.ref, false, &success);
if (!success) {
result.AppendErrorWithFormat(
- "'%s' is not a valid boolean string value.\n", value_str);
+ "'%s' is not a valid boolean string value.\n", entry.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
}
break;
case eFormatBinary:
- uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 2, &success);
- if (!success) {
+ if (entry.ref.getAsInteger(2, uval64)) {
result.AppendErrorWithFormat(
- "'%s' is not a valid binary string value.\n", value_str);
+ "'%s' is not a valid binary string value.\n", entry.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
} else if (!UIntValueIsValidForSize(uval64, item_byte_size)) {
case eFormatCharArray:
case eFormatChar:
- case eFormatCString:
- if (value_str[0]) {
- size_t len = strlen(value_str);
- // Include the NULL for C strings...
- if (m_format_options.GetFormat() == eFormatCString)
- ++len;
- Error error;
- if (process->WriteMemory(addr, value_str, len, error) == len) {
- addr += len;
- } else {
- result.AppendErrorWithFormat("Memory write to 0x%" PRIx64
- " failed: %s.\n",
- addr, error.AsCString());
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
+ case eFormatCString: {
+ if (entry.ref.empty())
+ break;
+
+ size_t len = entry.ref.size();
+ // Include the NULL for C strings...
+ if (m_format_options.GetFormat() == eFormatCString)
+ ++len;
+ Error error;
+ if (process->WriteMemory(addr, entry.c_str(), len, error) == len) {
+ addr += len;
+ } else {
+ result.AppendErrorWithFormat("Memory write to 0x%" PRIx64
+ " failed: %s.\n",
+ addr, error.AsCString());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
}
break;
-
+ }
case eFormatDecimal:
- sval64 = StringConvert::ToSInt64(value_str, INT64_MAX, 0, &success);
- if (!success) {
+ if (entry.ref.getAsInteger(0, sval64)) {
result.AppendErrorWithFormat(
- "'%s' is not a valid signed decimal value.\n", value_str);
+ "'%s' is not a valid signed decimal value.\n", entry.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
} else if (!SIntValueIsValidForSize(sval64, item_byte_size)) {
break;
case eFormatUnsigned:
- uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 0, &success);
- if (!success) {
+
+ if (!entry.ref.getAsInteger(0, uval64)) {
result.AppendErrorWithFormat(
"'%s' is not a valid unsigned decimal string value.\n",
- value_str);
+ entry.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
} else if (!UIntValueIsValidForSize(uval64, item_byte_size)) {
break;
case eFormatOctal:
- uval64 = StringConvert::ToUInt64(value_str, UINT64_MAX, 8, &success);
- if (!success) {
+ if (entry.ref.getAsInteger(8, uval64)) {
result.AppendErrorWithFormat(
- "'%s' is not a valid octal string value.\n", value_str);
+ "'%s' is not a valid octal string value.\n", entry.c_str());
result.SetStatus(eReturnStatusFailed);
return false;
} else if (!UIntValueIsValidForSize(uval64, item_byte_size)) {
}
Error error;
- lldb::addr_t addr =
- Args::StringToAddress(&m_exe_ctx, command.GetArgumentAtIndex(0),
- LLDB_INVALID_ADDRESS, &error);
+ lldb::addr_t addr = Args::StringToAddress(&m_exe_ctx, command[0].ref,
+ LLDB_INVALID_ADDRESS, &error);
if (addr == LLDB_INVALID_ADDRESS) {
result.AppendError("invalid address expression");
m_cmd_name.c_str(), m_cmd_syntax.c_str());
result.SetStatus(eReturnStatusFailed);
} else {
- const char *load_addr_cstr = command.GetArgumentAtIndex(0);
+ auto load_addr_str = command[0].ref;
if (command.GetArgumentCount() == 1) {
- load_addr = Args::StringToAddress(&m_exe_ctx, load_addr_cstr,
+ load_addr = Args::StringToAddress(&m_exe_ctx, load_addr_str,
LLDB_INVALID_ADDRESS, &error);
if (error.Fail() || load_addr == LLDB_INVALID_ADDRESS) {
result.AppendErrorWithFormat(
- "invalid address argument \"%s\": %s\n", load_addr_cstr,
+ "invalid address argument \"%s\": %s\n", command[0].c_str(),
error.AsCString());
result.SetStatus(eReturnStatusFailed);
}