diff --git a/lldb/include/lldb/Host/ProcessLaunchInfo.h b/lldb/include/lldb/Host/ProcessLaunchInfo.h --- a/lldb/include/lldb/Host/ProcessLaunchInfo.h +++ b/lldb/include/lldb/Host/ProcessLaunchInfo.h @@ -68,7 +68,7 @@ void SetWorkingDirectory(const FileSpec &working_dir); - const char *GetProcessPluginName() const; + llvm::StringRef GetProcessPluginName() const; void SetProcessPluginName(llvm::StringRef plugin); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -147,8 +147,8 @@ void SetResumeCount(uint32_t c) { m_resume_count = c; } - const char *GetProcessPluginName() const { - return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str()); + llvm::StringRef GetProcessPluginName() const { + return llvm::StringRef(m_plugin_name); } void SetProcessPluginName(llvm::StringRef plugin) { diff --git a/lldb/source/Host/common/ProcessLaunchInfo.cpp b/lldb/source/Host/common/ProcessLaunchInfo.cpp --- a/lldb/source/Host/common/ProcessLaunchInfo.cpp +++ b/lldb/source/Host/common/ProcessLaunchInfo.cpp @@ -126,8 +126,8 @@ m_working_dir = working_dir; } -const char *ProcessLaunchInfo::GetProcessPluginName() const { - return (m_plugin_name.empty() ? nullptr : m_plugin_name.c_str()); +llvm::StringRef ProcessLaunchInfo::GetProcessPluginName() const { + return llvm::StringRef(m_plugin_name); } void ProcessLaunchInfo::SetProcessPluginName(llvm::StringRef plugin) { diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -533,9 +533,9 @@ if (!target || error.Fail()) return process_sp; - const char *plugin_name = attach_info.GetProcessPluginName(); - process_sp = target->CreateProcess( - attach_info.GetListenerForProcess(debugger), plugin_name, nullptr, false); + process_sp = + target->CreateProcess(attach_info.GetListenerForProcess(debugger), + attach_info.GetProcessPluginName(), nullptr, false); process_sp->HijackProcessEvents(attach_info.GetHijackListener()); if (process_sp) diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3209,8 +3209,8 @@ assert(m_process_sp); } else { // Use a Process plugin to construct the process. - const char *plugin_name = launch_info.GetProcessPluginName(); - CreateProcess(launch_info.GetListener(), plugin_name, nullptr, false); + CreateProcess(launch_info.GetListener(), + launch_info.GetProcessPluginName(), nullptr, false); } // Since we didn't have a platform launch the process, launch it here. @@ -3371,14 +3371,14 @@ } else { if (state != eStateConnected) { SaveScriptedLaunchInfo(attach_info); - const char *plugin_name = attach_info.GetProcessPluginName(); + llvm::StringRef plugin_name = attach_info.GetProcessPluginName(); process_sp = CreateProcess(attach_info.GetListenerForProcess(GetDebugger()), plugin_name, nullptr, false); - if (process_sp == nullptr) { - error.SetErrorStringWithFormat( - "failed to create process using plugin %s", - (plugin_name) ? plugin_name : "null"); + if (!process_sp) { + error.SetErrorStringWithFormatv( + "failed to create process using plugin '{0}'", + plugin_name.empty() ? "" : plugin_name); return error; } }