diff --git a/lldb/include/lldb/Target/FileAction.h b/lldb/include/lldb/Target/FileAction.h index 277c9513fabe..81122ec68798 100644 --- a/lldb/include/lldb/Target/FileAction.h +++ b/lldb/include/lldb/Target/FileAction.h @@ -40,7 +40,7 @@ public: int GetActionArgument() const { return m_arg; } - const char *GetPath() const; + llvm::StringRef GetPath() const; const FileSpec &GetFileSpec() const; diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index a6282fe038ef..2c420dd08a60 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -137,16 +137,16 @@ public: uint32_t GetMaximumMemReadSize() const; FileSpec GetStandardInputPath() const; - - void SetStandardInputPath(const char *path); - + FileSpec GetStandardErrorPath() const; FileSpec GetStandardOutputPath() const; - void SetStandardOutputPath(const char *path); + void SetStandardInputPath(llvm::StringRef path); + void SetStandardOutputPath(llvm::StringRef path); + void SetStandardErrorPath(llvm::StringRef path); - FileSpec GetStandardErrorPath() const; - - void SetStandardErrorPath(const char *path); + void SetStandardInputPath(const char *path) = delete; + void SetStandardOutputPath(const char *path) = delete; + void SetStandardErrorPath(const char *path) = delete; bool GetBreakpointsConsultPlatformAvoidList(); diff --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp b/lldb/source/Host/windows/ProcessLauncherWindows.cpp index ef3656af41fd..aa572706c6bc 100644 --- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp +++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp @@ -124,7 +124,7 @@ ProcessLauncherWindows::GetStdioHandle(const ProcessLaunchInfo &launch_info, secattr.nLength = sizeof(SECURITY_ATTRIBUTES); secattr.bInheritHandle = TRUE; - const char *path = action->GetPath(); + llvm::StringRef path = action->GetPath(); DWORD access = 0; DWORD share = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; DWORD create = 0; diff --git a/lldb/source/Target/FileAction.cpp b/lldb/source/Target/FileAction.cpp index 46678b11f3a9..7c2567ebea2d 100644 --- a/lldb/source/Target/FileAction.cpp +++ b/lldb/source/Target/FileAction.cpp @@ -29,7 +29,7 @@ void FileAction::Clear() { m_file_spec.Clear(); } -const char *FileAction::GetPath() const { return m_file_spec.GetCString(); } +llvm::StringRef FileAction::GetPath() const { return m_file_spec.GetCString(); } const FileSpec &FileAction::GetFileSpec() const { return m_file_spec; } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 25a383212980..ee7eab71c6a6 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3817,10 +3817,9 @@ FileSpec TargetProperties::GetStandardInputPath() const { return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx); } -void TargetProperties::SetStandardInputPath(const char *p) { +void TargetProperties::SetStandardInputPath(llvm::StringRef path) { const uint32_t idx = ePropertyInputPath; - m_collection_sp->SetPropertyAtIndexAsString( - nullptr, idx, llvm::StringRef::withNullAsEmpty(p)); + m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path); } FileSpec TargetProperties::GetStandardOutputPath() const { @@ -3828,10 +3827,9 @@ FileSpec TargetProperties::GetStandardOutputPath() const { return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx); } -void TargetProperties::SetStandardOutputPath(const char *p) { +void TargetProperties::SetStandardOutputPath(llvm::StringRef path) { const uint32_t idx = ePropertyOutputPath; - m_collection_sp->SetPropertyAtIndexAsString( - nullptr, idx, llvm::StringRef::withNullAsEmpty(p)); + m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path); } FileSpec TargetProperties::GetStandardErrorPath() const { @@ -3839,6 +3837,11 @@ FileSpec TargetProperties::GetStandardErrorPath() const { return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx); } +void TargetProperties::SetStandardErrorPath(llvm::StringRef path) { + const uint32_t idx = ePropertyErrorPath; + m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path); +} + LanguageType TargetProperties::GetLanguage() const { OptionValueLanguage *value = m_collection_sp->GetPropertyAtIndexAsOptionValueLanguage( @@ -3862,12 +3865,6 @@ const char *TargetProperties::GetExpressionPrefixContentsAsCString() { return nullptr; } -void TargetProperties::SetStandardErrorPath(const char *p) { - const uint32_t idx = ePropertyErrorPath; - m_collection_sp->SetPropertyAtIndexAsString( - nullptr, idx, llvm::StringRef::withNullAsEmpty(p)); -} - bool TargetProperties::GetBreakpointsConsultPlatformAvoidList() { const uint32_t idx = ePropertyBreakpointUseAvoidList; return m_collection_sp->GetPropertyAtIndexAsBoolean( @@ -3963,23 +3960,17 @@ void TargetProperties::SetProcessLaunchInfo( const FileAction *input_file_action = launch_info.GetFileActionForFD(STDIN_FILENO); if (input_file_action) { - const char *input_path = input_file_action->GetPath(); - if (input_path) - SetStandardInputPath(input_path); + SetStandardInputPath(input_file_action->GetPath()); } const FileAction *output_file_action = launch_info.GetFileActionForFD(STDOUT_FILENO); if (output_file_action) { - const char *output_path = output_file_action->GetPath(); - if (output_path) - SetStandardOutputPath(output_path); + SetStandardOutputPath(output_file_action->GetPath()); } const FileAction *error_file_action = launch_info.GetFileActionForFD(STDERR_FILENO); if (error_file_action) { - const char *error_path = error_file_action->GetPath(); - if (error_path) - SetStandardErrorPath(error_path); + SetStandardErrorPath(error_file_action->GetPath()); } SetDetachOnError(launch_info.GetFlags().Test(lldb::eLaunchFlagDetachOnError)); SetDisableASLR(launch_info.GetFlags().Test(lldb::eLaunchFlagDisableASLR));