[Lldb-commits] [lldb] r287376 - Change CreateTarget and dependents to accept StringRef.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 18 12:44:46 PST 2016
Author: zturner
Date: Fri Nov 18 14:44:46 2016
New Revision: 287376
URL: http://llvm.org/viewvc/llvm-project?rev=287376&view=rev
Log:
Change CreateTarget and dependents to accept StringRef.
Modified:
lldb/trunk/include/lldb/Interpreter/OptionGroupArchitecture.h
lldb/trunk/include/lldb/Target/TargetList.h
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/Commands/CommandObjectProcess.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Target/Platform.cpp
lldb/trunk/source/Target/TargetList.cpp
Modified: lldb/trunk/include/lldb/Interpreter/OptionGroupArchitecture.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionGroupArchitecture.h?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/OptionGroupArchitecture.h (original)
+++ lldb/trunk/include/lldb/Interpreter/OptionGroupArchitecture.h Fri Nov 18 14:44:46 2016
@@ -33,7 +33,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;
@@ -41,9 +40,7 @@ public:
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
Modified: lldb/trunk/include/lldb/Target/TargetList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/TargetList.h?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/TargetList.h (original)
+++ lldb/trunk/include/lldb/Target/TargetList.h Fri Nov 18 14:44:46 2016
@@ -91,8 +91,8 @@ public:
/// @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);
@@ -102,7 +102,7 @@ public:
/// 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);
@@ -211,15 +211,17 @@ protected:
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);
Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Fri Nov 18 14:44:46 2016
@@ -603,8 +603,7 @@ SBTarget SBDebugger::CreateTarget(const
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());
Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Nov 18 14:44:46 2016
@@ -472,7 +472,7 @@ protected:
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();
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Nov 18 14:44:46 2016
@@ -278,7 +278,7 @@ protected:
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(
Modified: lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Fri Nov 18 14:44:46 2016
@@ -582,9 +582,9 @@ lldb::ProcessSP PlatformFreeBSD::Attach(
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();
Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Fri Nov 18 14:44:46 2016
@@ -565,8 +565,8 @@ PlatformLinux::DebugProcess(ProcessLaunc
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",
Modified: lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp Fri Nov 18 14:44:46 2016
@@ -520,9 +520,9 @@ lldb::ProcessSP PlatformNetBSD::Attach(P
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();
Modified: lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp Fri Nov 18 14:44:46 2016
@@ -629,7 +629,7 @@ lldb::ProcessSP PlatformPOSIX::Attach(Pr
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)
Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp Fri Nov 18 14:44:46 2016
@@ -474,8 +474,8 @@ lldb::ProcessSP PlatformWindows::Attach(
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();
}
Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Fri Nov 18 14:44:46 2016
@@ -505,8 +505,8 @@ lldb::ProcessSP PlatformRemoteGDBServer:
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();
@@ -592,8 +592,8 @@ lldb::ProcessSP PlatformRemoteGDBServer:
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();
Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Fri Nov 18 14:44:46 2016
@@ -1767,8 +1767,8 @@ lldb::ProcessSP Platform::ConnectProcess
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();
}
Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=287376&r1=287375&r2=287376&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Fri Nov 18 14:44:46 2016
@@ -55,17 +55,19 @@ TargetList::~TargetList() {
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) {
@@ -75,19 +77,21 @@ Error TargetList::CreateTarget(Debugger
}
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;
}
}
@@ -113,7 +117,7 @@ Error TargetList::CreateTargetInternal(
}
}
- 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);
@@ -306,7 +310,7 @@ lldb::TargetSP TargetList::GetDummyTarge
}
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(
@@ -315,7 +319,7 @@ Error TargetList::CreateDummyTarget(Debu
}
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,
@@ -341,7 +345,7 @@ Error TargetList::CreateTargetInternal(D
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
@@ -361,11 +365,9 @@ Error TargetList::CreateTargetInternal(D
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);
@@ -417,7 +419,7 @@ Error TargetList::CreateTargetInternal(D
// 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]) {
More information about the lldb-commits
mailing list