diff options
Diffstat (limited to 'lldb/source/Target')
| -rw-r--r-- | lldb/source/Target/Process.cpp | 9 | ||||
| -rw-r--r-- | lldb/source/Target/ProcessInfo.cpp | 7 | ||||
| -rw-r--r-- | lldb/source/Target/ProcessLaunchInfo.cpp | 8 |
3 files changed, 15 insertions, 9 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index f370676e73a..7837881fb82 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -416,6 +416,7 @@ Error ProcessLaunchCommandOptions::SetOptionValue( 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 @@ -484,7 +485,7 @@ Error ProcessLaunchCommandOptions::SetOptionValue( { bool success; const bool disable_aslr_arg = - Args::StringToBoolean(option_arg, true, &success); + Args::StringToBoolean(option_strref, true, &success); if (success) disable_aslr = disable_aslr_arg ? eLazyBoolYes : eLazyBoolNo; else @@ -497,7 +498,8 @@ Error ProcessLaunchCommandOptions::SetOptionValue( case 'X': // shell expand args. { bool success; - const bool expand_args = Args::StringToBoolean(option_arg, true, &success); + const bool expand_args = + Args::StringToBoolean(option_strref, true, &success); if (success) launch_info.SetShellExpandArguments(expand_args); else @@ -515,7 +517,8 @@ Error ProcessLaunchCommandOptions::SetOptionValue( break; case 'v': - launch_info.GetEnvironmentEntries().AppendArgument(option_arg); + launch_info.GetEnvironmentEntries().AppendArgument( + llvm::StringRef::withNullAsEmpty(option_arg)); break; default: diff --git a/lldb/source/Target/ProcessInfo.cpp b/lldb/source/Target/ProcessInfo.cpp index be537c1b313..4b02332f4d9 100644 --- a/lldb/source/Target/ProcessInfo.cpp +++ b/lldb/source/Target/ProcessInfo.cpp @@ -18,6 +18,8 @@ #include "lldb/Core/Stream.h" #include "lldb/Host/PosixApi.h" +#include "llvm/ADT/SmallString.h" + using namespace lldb; using namespace lldb_private; @@ -66,8 +68,9 @@ void ProcessInfo::SetExecutableFile(const FileSpec &exe_file, if (exe_file) { m_executable = exe_file; if (add_exe_file_as_first_arg) { - char filename[PATH_MAX]; - if (exe_file.GetPath(filename, sizeof(filename))) + llvm::SmallString<PATH_MAX> filename; + exe_file.GetPath(filename); + if (!filename.empty()) m_arguments.InsertArgumentAtIndex(0, filename); } } else { diff --git a/lldb/source/Target/ProcessLaunchInfo.cpp b/lldb/source/Target/ProcessLaunchInfo.cpp index 2f9e95ecc7b..e29c9bcc11b 100644 --- a/lldb/source/Target/ProcessLaunchInfo.cpp +++ b/lldb/source/Target/ProcessLaunchInfo.cpp @@ -344,13 +344,13 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell( return false; Args shell_arguments; std::string safe_arg; - shell_arguments.AppendArgument(shell_executable.c_str()); + shell_arguments.AppendArgument(shell_executable); const llvm::Triple &triple = GetArchitecture().GetTriple(); if (triple.getOS() == llvm::Triple::Win32 && !triple.isWindowsCygwinEnvironment()) - shell_arguments.AppendArgument("/C"); + shell_arguments.AppendArgument(llvm::StringRef("/C")); else - shell_arguments.AppendArgument("-c"); + shell_arguments.AppendArgument(llvm::StringRef("-c")); StreamString shell_command; if (will_debug) { @@ -428,7 +428,7 @@ bool ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell( shell_command.Printf(" %s", arg); } } - shell_arguments.AppendArgument(shell_command.GetString().c_str()); + shell_arguments.AppendArgument(shell_command.GetString()); m_executable = m_shell; m_arguments = shell_arguments; return true; |

