m_option_data.m_batch = true;
}
- if (args.hasArg(OPT_core)) {
- SBFileSpec file(optarg);
- if (file.Exists()) {
- m_option_data.m_core_file = optarg;
- } else {
+ if (auto *arg = args.getLastArg(OPT_core)) {
+ auto arg_value = arg->getValue();
+ SBFileSpec file(arg_value);
+ if (!file.Exists()) {
error.SetErrorStringWithFormat(
- "file specified in --core (-c) option doesn't exist: '%s'", optarg);
+ "file specified in --core (-c) option doesn't exist: '%s'",
+ arg_value);
return error;
}
+ m_option_data.m_core_file = arg_value;
}
if (args.hasArg(OPT_editor)) {
}
if (auto *arg = args.getLastArg(OPT_file)) {
- auto optarg = arg->getValue();
- SBFileSpec file(optarg);
+ auto arg_value = arg->getValue();
+ SBFileSpec file(arg_value);
if (file.Exists()) {
- m_option_data.m_args.push_back(optarg);
+ m_option_data.m_args.push_back(arg_value);
} else if (file.ResolveExecutableLocation()) {
char path[PATH_MAX];
file.GetPath(path, sizeof(path));
m_option_data.m_args.push_back(path);
} else {
error.SetErrorStringWithFormat(
- "file specified in --file (-f) option doesn't exist: '%s'", optarg);
+ "file specified in --file (-f) option doesn't exist: '%s'",
+ arg_value);
return error;
}
}
if (auto *arg = args.getLastArg(OPT_arch)) {
- auto optarg = arg->getValue();
- if (!m_debugger.SetDefaultArchitecture(optarg)) {
+ auto arg_value = arg->getValue();
+ if (!m_debugger.SetDefaultArchitecture(arg_value)) {
error.SetErrorStringWithFormat(
- "invalid architecture in the -a or --arch option: '%s'", optarg);
+ "invalid architecture in the -a or --arch option: '%s'", arg_value);
return error;
}
}
if (auto *arg = args.getLastArg(OPT_script_language)) {
- auto optarg = arg->getValue();
- m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(optarg);
+ auto arg_value = arg->getValue();
+ m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(arg_value);
}
if (args.hasArg(OPT_no_use_colors)) {
}
if (auto *arg = args.getLastArg(OPT_reproducer)) {
- auto optarg = arg->getValue();
- SBFileSpec file(optarg);
+ auto arg_value = arg->getValue();
+ SBFileSpec file(arg_value);
if (file.Exists()) {
- SBError repro_error = m_debugger.ReplayReproducer(optarg);
+ SBError repro_error = m_debugger.ReplayReproducer(arg_value);
if (repro_error.Fail())
return repro_error;
} else {
error.SetErrorStringWithFormat("file specified in --reproducer "
"(-z) option doesn't exist: '%s'",
- optarg);
+ arg_value);
return error;
}
}
}
if (auto *arg = args.getLastArg(OPT_attach_name)) {
- auto optarg = arg->getValue();
- m_option_data.m_process_name = optarg;
+ auto arg_value = arg->getValue();
+ m_option_data.m_process_name = arg_value;
}
if (args.hasArg(OPT_wait_for)) {
}
if (auto *arg = args.getLastArg(OPT_attach_pid)) {
- auto optarg = arg->getValue();
+ auto arg_value = arg->getValue();
char *remainder;
- m_option_data.m_process_pid = strtol(optarg, &remainder, 0);
- if (remainder == optarg || *remainder != '\0') {
+ m_option_data.m_process_pid = strtol(arg_value, &remainder, 0);
+ if (remainder == arg_value || *remainder != '\0') {
error.SetErrorStringWithFormat(
- "Could not convert process PID: \"%s\" into a pid.", optarg);
+ "Could not convert process PID: \"%s\" into a pid.", arg_value);
return error;
}
}
if (auto *arg = args.getLastArg(OPT_repl_language)) {
- auto optarg = arg->getValue();
+ auto arg_value = arg->getValue();
m_option_data.m_repl_lang =
- SBLanguageRuntime::GetLanguageTypeFromString(optarg);
+ SBLanguageRuntime::GetLanguageTypeFromString(arg_value);
if (m_option_data.m_repl_lang == eLanguageTypeUnknown) {
error.SetErrorStringWithFormat("Unrecognized language name: \"%s\"",
- optarg);
+ arg_value);
return error;
}
}
if (auto *arg = args.getLastArg(OPT_repl)) {
- auto optarg = arg->getValue();
+ auto arg_value = arg->getValue();
m_option_data.m_repl = true;
- if (optarg && optarg[0])
- m_option_data.m_repl_options = optarg;
+ if (arg_value && arg_value[0])
+ m_option_data.m_repl_options = arg_value;
else
m_option_data.m_repl_options.clear();
}
for (auto *arg : args.filtered(OPT_source_on_crash, OPT_one_line_on_crash,
OPT_source, OPT_source_before_file,
OPT_one_line, OPT_one_line_before_file)) {
+ auto arg_value = arg->getValue();
if (arg->getOption().matches(OPT_source_on_crash)) {
- auto optarg = arg->getValue();
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash, true,
- error);
+ m_option_data.AddInitialCommand(arg_value, eCommandPlacementAfterCrash,
+ true, error);
if (error.Fail())
return error;
}
if (arg->getOption().matches(OPT_one_line_on_crash)) {
- auto optarg = arg->getValue();
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterCrash,
+ m_option_data.AddInitialCommand(arg_value, eCommandPlacementAfterCrash,
false, error);
if (error.Fail())
return error;
}
if (arg->getOption().matches(OPT_source)) {
- auto optarg = arg->getValue();
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, true,
- error);
+ m_option_data.AddInitialCommand(arg_value, eCommandPlacementAfterFile,
+ true, error);
if (error.Fail())
return error;
}
if (arg->getOption().matches(OPT_source_before_file)) {
- auto optarg = arg->getValue();
- m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile, true,
- error);
+ m_option_data.AddInitialCommand(arg_value, eCommandPlacementBeforeFile,
+ true, error);
if (error.Fail())
return error;
}
if (arg->getOption().matches(OPT_one_line)) {
- auto optarg = arg->getValue();
- m_option_data.AddInitialCommand(optarg, eCommandPlacementAfterFile, false,
- error);
+ m_option_data.AddInitialCommand(arg_value, eCommandPlacementAfterFile,
+ false, error);
if (error.Fail())
return error;
}
if (arg->getOption().matches(OPT_one_line_before_file)) {
- auto optarg = arg->getValue();
- m_option_data.AddInitialCommand(optarg, eCommandPlacementBeforeFile,
+ m_option_data.AddInitialCommand(arg_value, eCommandPlacementBeforeFile,
false, error);
if (error.Fail())
return error;