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;
bool ArchitectureWasSpecified() const { return !m_arch_str.empty(); }
- const char *GetArchitectureName() {
- return (m_arch_str.empty() ? nullptr : m_arch_str.c_str());
- }
+ llvm::StringRef GetArchitectureName() const { return m_arch_str; }
protected:
std::string m_arch_str; // Save the arch triple in case a platform is
/// @return
/// An error object that indicates success or failure
//------------------------------------------------------------------
- Error CreateTarget(Debugger &debugger, const char *user_exe_path,
- const char *triple_cstr, bool get_dependent_modules,
+ Error CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path,
+ llvm::StringRef triple_str, bool get_dependent_modules,
const OptionGroupPlatform *platform_options,
lldb::TargetSP &target_sp);
/// Same as the function above, but used when you already know the
/// platform you will be using
//------------------------------------------------------------------
- Error CreateTarget(Debugger &debugger, const char *user_exe_path,
+ Error CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path,
const ArchSpec &arch, bool get_dependent_modules,
lldb::PlatformSP &platform_sp, lldb::TargetSP &target_sp);
private:
lldb::TargetSP GetDummyTarget(lldb_private::Debugger &debugger);
- Error CreateDummyTarget(Debugger &debugger, const char *specified_arch_name,
+ Error CreateDummyTarget(Debugger &debugger,
+ llvm::StringRef specified_arch_name,
lldb::TargetSP &target_sp);
- Error CreateTargetInternal(Debugger &debugger, const char *user_exe_path,
- const char *triple_cstr, bool get_dependent_files,
+ Error CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path,
+ llvm::StringRef triple_str,
+ bool get_dependent_files,
const OptionGroupPlatform *platform_options,
lldb::TargetSP &target_sp, bool is_dummy_target);
- Error CreateTargetInternal(Debugger &debugger, const char *user_exe_path,
+ Error CreateTargetInternal(Debugger &debugger, llvm::StringRef user_exe_path,
const ArchSpec &arch, bool get_dependent_modules,
lldb::PlatformSP &platform_sp,
lldb::TargetSP &target_sp, bool is_dummy_target);
Error error;
const bool add_dependent_modules = true;
error = m_opaque_sp->GetTargetList().CreateTarget(
- *m_opaque_sp, filename, nullptr, add_dependent_modules, nullptr,
- target_sp);
+ *m_opaque_sp, filename, "", add_dependent_modules, nullptr, target_sp);
if (error.Success()) {
m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get());
Error error;
error = m_interpreter.GetDebugger().GetTargetList().CreateTarget(
- m_interpreter.GetDebugger(), nullptr, nullptr, false,
+ m_interpreter.GetDebugger(), "", "", false,
nullptr, // No platform options
new_target_sp);
target = new_target_sp.get();
Debugger &debugger = m_interpreter.GetDebugger();
TargetSP target_sp;
- const char *arch_cstr = m_arch_option.GetArchitectureName();
+ llvm::StringRef arch_cstr = m_arch_option.GetArchitectureName();
const bool get_dependent_files =
m_add_dependents.GetOptionValue().GetCurrentValue();
Error error(debugger.GetTargetList().CreateTarget(
TargetSP new_target_sp;
ArchSpec emptyArchSpec;
- error = debugger.GetTargetList().CreateTarget(
- debugger, NULL, emptyArchSpec, false, m_remote_platform_sp,
- new_target_sp);
+ error = debugger.GetTargetList().CreateTarget(debugger, "", emptyArchSpec,
+ false, m_remote_platform_sp,
+ new_target_sp);
target = new_target_sp.get();
} else
error.Clear();
log->Printf("PlatformLinux::%s creating new target", __FUNCTION__);
TargetSP new_target_sp;
- error = debugger.GetTargetList().CreateTarget(
- debugger, nullptr, nullptr, false, nullptr, new_target_sp);
+ error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
+ nullptr, new_target_sp);
if (error.Fail()) {
if (log)
log->Printf("PlatformLinux::%s failed to create new target: %s",
TargetSP new_target_sp;
ArchSpec emptyArchSpec;
- error = debugger.GetTargetList().CreateTarget(
- debugger, NULL, emptyArchSpec, false, m_remote_platform_sp,
- new_target_sp);
+ error = debugger.GetTargetList().CreateTarget(debugger, "", emptyArchSpec,
+ false, m_remote_platform_sp,
+ new_target_sp);
target = new_target_sp.get();
} else
error.Clear();
if (target == NULL) {
TargetSP new_target_sp;
- error = debugger.GetTargetList().CreateTarget(debugger, NULL, NULL, false,
+ error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
NULL, new_target_sp);
target = new_target_sp.get();
if (log)
FileSpec emptyFileSpec;
ArchSpec emptyArchSpec;
- error = debugger.GetTargetList().CreateTarget(
- debugger, nullptr, nullptr, false, nullptr, new_target_sp);
+ error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
+ nullptr, new_target_sp);
target = new_target_sp.get();
}
if (target == NULL) {
TargetSP new_target_sp;
- error = debugger.GetTargetList().CreateTarget(
- debugger, NULL, NULL, false, NULL, new_target_sp);
+ error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
+ NULL, new_target_sp);
target = new_target_sp.get();
} else
error.Clear();
if (target == NULL) {
TargetSP new_target_sp;
- error = debugger.GetTargetList().CreateTarget(
- debugger, NULL, NULL, false, NULL, new_target_sp);
+ error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
+ NULL, new_target_sp);
target = new_target_sp.get();
} else
error.Clear();
if (!target) {
TargetSP new_target_sp;
- error = debugger.GetTargetList().CreateTarget(
- debugger, nullptr, nullptr, false, nullptr, new_target_sp);
+ error = debugger.GetTargetList().CreateTarget(debugger, "", "", false,
+ nullptr, new_target_sp);
target = new_target_sp.get();
}
m_target_list.clear();
}
-Error TargetList::CreateTarget(Debugger &debugger, const char *user_exe_path,
- const char *triple_cstr,
+Error TargetList::CreateTarget(Debugger &debugger,
+ llvm::StringRef user_exe_path,
+ llvm::StringRef triple_str,
bool get_dependent_files,
const OptionGroupPlatform *platform_options,
TargetSP &target_sp) {
- return CreateTargetInternal(debugger, user_exe_path, triple_cstr,
+ return CreateTargetInternal(debugger, user_exe_path, triple_str,
get_dependent_files, platform_options, target_sp,
false);
}
-Error TargetList::CreateTarget(Debugger &debugger, const char *user_exe_path,
+Error TargetList::CreateTarget(Debugger &debugger,
+ llvm::StringRef user_exe_path,
const ArchSpec &specified_arch,
bool get_dependent_files,
PlatformSP &platform_sp, TargetSP &target_sp) {
}
Error TargetList::CreateTargetInternal(
- Debugger &debugger, const char *user_exe_path, const char *triple_cstr,
- bool get_dependent_files, const OptionGroupPlatform *platform_options,
- TargetSP &target_sp, bool is_dummy_target) {
+ Debugger &debugger, llvm::StringRef user_exe_path,
+ llvm::StringRef triple_str, bool get_dependent_files,
+ const OptionGroupPlatform *platform_options, TargetSP &target_sp,
+ bool is_dummy_target) {
Error error;
PlatformSP platform_sp;
// This is purposely left empty unless it is specified by triple_cstr.
// If not initialized via triple_cstr, then the currently selected platform
// will set the architecture correctly.
- const ArchSpec arch(triple_cstr);
- if (triple_cstr && triple_cstr[0]) {
+ const ArchSpec arch(triple_str);
+ if (!triple_str.empty()) {
if (!arch.IsValid()) {
- error.SetErrorStringWithFormat("invalid triple '%s'", triple_cstr);
+ error.SetErrorStringWithFormat("invalid triple '%s'",
+ triple_str.str().c_str());
return error;
}
}
}
}
- if (user_exe_path && user_exe_path[0]) {
+ if (!user_exe_path.empty()) {
ModuleSpecList module_specs;
ModuleSpec module_spec;
module_spec.GetFileSpec().SetFile(user_exe_path, true);
}
Error TargetList::CreateDummyTarget(Debugger &debugger,
- const char *specified_arch_name,
+ llvm::StringRef specified_arch_name,
lldb::TargetSP &target_sp) {
PlatformSP host_platform_sp(Platform::GetHostPlatform());
return CreateTargetInternal(
}
Error TargetList::CreateTargetInternal(Debugger &debugger,
- const char *user_exe_path,
+ llvm::StringRef user_exe_path,
const ArchSpec &specified_arch,
bool get_dependent_files,
lldb::PlatformSP &platform_sp,
arch = specified_arch;
FileSpec file(user_exe_path, false);
- if (!file.Exists() && user_exe_path && user_exe_path[0] == '~') {
+ if (!file.Exists() && user_exe_path.startswith("~")) {
// we want to expand the tilde but we don't want to resolve any symbolic
// links
// so we can't use the FileSpec constructor's resolve flag
if (file.GetFileType() == FileSpec::eFileTypeDirectory)
user_exe_path_is_bundle = true;
- if (file.IsRelative() && user_exe_path) {
+ if (file.IsRelative() && !user_exe_path.empty()) {
// Ignore paths that start with "./" and "../"
- if (!((user_exe_path[0] == '.' && user_exe_path[1] == '/') ||
- (user_exe_path[0] == '.' && user_exe_path[1] == '.' &&
- user_exe_path[2] == '/'))) {
+ if (!user_exe_path.startswith("./") && !user_exe_path.startswith("../")) {
char cwd[PATH_MAX];
if (getcwd(cwd, sizeof(cwd))) {
std::string cwd_user_exe_path(cwd);
// Set argv0 with what the user typed, unless the user specified a
// directory. If the user specified a directory, then it is probably a
// bundle that was resolved and we need to use the resolved bundle path
- if (user_exe_path) {
+ if (!user_exe_path.empty()) {
// Use exactly what the user typed as the first argument when we exec or
// posix_spawn
if (user_exe_path_is_bundle && resolved_bundle_exe_path[0]) {