From d3173f34e8546a96b8d0df0d9de133f88f10c127 Mon Sep 17 00:00:00 2001 From: Chaoren Lin Date: Fri, 29 May 2015 19:52:29 +0000 Subject: Refactor many file functions to use FileSpec over strings. Summary: This should solve the issue of sending denormalized paths over gdb-remote if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the server handle any denormalization. Reviewers: ovyalov, zturner, vharron, clayborg Reviewed By: clayborg Subscribers: tberghammer, emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D9728 llvm-svn: 238604 --- .../source/Host/android/ProcessLauncherAndroid.cpp | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'lldb/source/Host/android/ProcessLauncherAndroid.cpp') diff --git a/lldb/source/Host/android/ProcessLauncherAndroid.cpp b/lldb/source/Host/android/ProcessLauncherAndroid.cpp index 16c1d9b5888..24eebc8c030 100644 --- a/lldb/source/Host/android/ProcessLauncherAndroid.cpp +++ b/lldb/source/Host/android/ProcessLauncherAndroid.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/android/ProcessLauncherAndroid.h" @@ -19,9 +20,9 @@ using namespace lldb; using namespace lldb_private; static bool -DupDescriptor(const char *path, int fd, int flags) +DupDescriptor(const FileSpec &file_spec, int fd, int flags) { - int target_fd = ::open(path, flags, 0666); + int target_fd = ::open(file_spec.GetCString(), flags, 0666); if (target_fd == -1) return false; @@ -63,23 +64,23 @@ ProcessLauncherAndroid::LaunchProcess(const ProcessLaunchInfo &launch_info, Erro else if (pid == 0) { if (const lldb_private::FileAction *file_action = launch_info.GetFileActionForFD(STDIN_FILENO)) { - const char* path = file_action->GetPath(); - if (path && ::strlen(path)) - if (!DupDescriptor(path, STDIN_FILENO, O_RDONLY)) + FileSpec file_spec = file_action->GetFileSpec(); + if (file_spec) + if (!DupDescriptor(file_spec, STDIN_FILENO, O_RDONLY)) exit(-1); } if (const lldb_private::FileAction *file_action = launch_info.GetFileActionForFD(STDOUT_FILENO)) { - const char* path = file_action->GetPath(); - if (path && ::strlen(path)) - if (!DupDescriptor(path, STDOUT_FILENO, O_WRONLY | O_CREAT | O_TRUNC)) + FileSpec file_spec = file_action->GetFileSpec(); + if (file_spec) + if (!DupDescriptor(file_spec, STDOUT_FILENO, O_WRONLY | O_CREAT | O_TRUNC)) exit(-1); } if (const lldb_private::FileAction *file_action = launch_info.GetFileActionForFD(STDERR_FILENO)) { - const char* path = file_action->GetPath(); - if (path && ::strlen(path)) - if (!DupDescriptor(path, STDERR_FILENO, O_WRONLY | O_CREAT | O_TRUNC)) + FileSpec file_spec = file_action->GetFileSpec(); + if (file_spec) + if (!DupDescriptor(file_spec, STDERR_FILENO, O_WRONLY | O_CREAT | O_TRUNC)) exit(-1); } @@ -90,10 +91,10 @@ ProcessLauncherAndroid::LaunchProcess(const ProcessLaunchInfo &launch_info, Erro FixupEnvironment(env); const char **envp = env.GetConstArgumentVector(); - const char *working_dir = launch_info.GetWorkingDirectory(); - if (working_dir != nullptr && working_dir[0]) + FileSpec working_dir = launch_info.GetWorkingDirectory(); + if (working_dir) { - if (::chdir(working_dir) != 0) + if (::chdir(working_dir.GetCString()) != 0) exit(-1); } -- cgit v1.2.3