summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
diff options
context:
space:
mode:
authorChaoren Lin <chaorenl@google.com>2015-05-29 19:52:29 +0000
committerChaoren Lin <chaorenl@google.com>2015-05-29 19:52:29 +0000
commitd3173f34e8546a96b8d0df0d9de133f88f10c127 (patch)
tree5e778446085cbd4a4d43fc3b488b3ac6ff17f2b5 /lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
parent375432e4d8f50212bca3d9228e349b5a00f770d7 (diff)
downloadbcm5719-llvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.tar.gz
bcm5719-llvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.zip
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
Diffstat (limited to 'lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp')
-rw-r--r--lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp91
1 files changed, 44 insertions, 47 deletions
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
index 82ce0c75495..4b4080dddbe 100644
--- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
+++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
@@ -50,9 +50,9 @@ ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener, UnixSignalsSP &un
{
// FIXME: Putting this code in the ctor and saving the byte order in a
// member variable is a hack to avoid const qual issues in GetByteOrder.
- lldb::ModuleSP module = GetTarget().GetExecutableModule();
- if (module && module->GetObjectFile())
- m_byte_order = module->GetObjectFile()->GetByteOrder();
+ lldb::ModuleSP module = GetTarget().GetExecutableModule();
+ if (module && module->GetObjectFile())
+ m_byte_order = module->GetObjectFile()->GetByteOrder();
}
ProcessPOSIX::~ProcessPOSIX()
@@ -138,27 +138,24 @@ ProcessPOSIX::WillLaunch(Module* module)
return error;
}
-const char *
-ProcessPOSIX::GetFilePath(const lldb_private::FileAction *file_action, const char *default_path,
- const char *dbg_pts_path)
+FileSpec
+ProcessPOSIX::GetFileSpec(const lldb_private::FileAction *file_action,
+ const FileSpec &default_file_spec,
+ const FileSpec &dbg_pts_file_spec)
{
- const char *path = NULL;
+ FileSpec file_spec{};
- if (file_action)
+ if (file_action && file_action->GetAction() == FileAction::eFileActionOpen)
{
- if (file_action->GetAction() == FileAction::eFileActionOpen)
- {
- path = file_action->GetPath();
- // By default the stdio paths passed in will be pseudo-terminal
- // (/dev/pts). If so, convert to using a different default path
- // instead to redirect I/O to the debugger console. This should
- // also handle user overrides to /dev/null or a different file.
- if (!path || (dbg_pts_path &&
- ::strncmp(path, dbg_pts_path, ::strlen(dbg_pts_path)) == 0))
- path = default_path;
- }
+ file_spec = file_action->GetFileSpec();
+ // By default the stdio paths passed in will be pseudo-terminal
+ // (/dev/pts). If so, convert to using a different default path
+ // instead to redirect I/O to the debugger console. This should
+ // also handle user overrides to /dev/null or a different file.
+ if (!file_spec || file_spec == dbg_pts_file_spec)
+ file_spec = default_file_spec;
}
- return path;
+ return file_spec;
}
Error
@@ -168,46 +165,46 @@ ProcessPOSIX::DoLaunch (Module *module,
Error error;
assert(m_monitor == NULL);
- const char* working_dir = launch_info.GetWorkingDirectory();
- if (working_dir) {
- FileSpec WorkingDir(working_dir, true);
- if (!WorkingDir || WorkingDir.GetFileType() != FileSpec::eFileTypeDirectory)
- {
- error.SetErrorStringWithFormat("No such file or directory: %s", working_dir);
- return error;
- }
+ FileSpec working_dir = launch_info.GetWorkingDirectory();
+ if (working_dir &&
+ (!working_dir.ResolvePath() ||
+ working_dir.GetFileType() != FileSpec::eFileTypeDirectory))
+ {
+ error.SetErrorStringWithFormat("No such file or directory: %s",
+ working_dir.GetCString());
+ return error;
}
SetPrivateState(eStateLaunching);
const lldb_private::FileAction *file_action;
- // Default of NULL will mean to use existing open file descriptors
- const char *stdin_path = NULL;
- const char *stdout_path = NULL;
- const char *stderr_path = NULL;
+ // Default of empty will mean to use existing open file descriptors
+ FileSpec stdin_file_spec{};
+ FileSpec stdout_file_spec{};
+ FileSpec stderr_file_spec{};
- const char * dbg_pts_path = launch_info.GetPTY().GetSlaveName(NULL,0);
+ const FileSpec dbg_pts_file_spec{launch_info.GetPTY().GetSlaveName(NULL,0), false};
file_action = launch_info.GetFileActionForFD (STDIN_FILENO);
- stdin_path = GetFilePath(file_action, stdin_path, dbg_pts_path);
+ stdin_file_spec = GetFileSpec(file_action, stdin_file_spec, dbg_pts_file_spec);
file_action = launch_info.GetFileActionForFD (STDOUT_FILENO);
- stdout_path = GetFilePath(file_action, stdout_path, dbg_pts_path);
+ stdout_file_spec = GetFileSpec(file_action, stdout_file_spec, dbg_pts_file_spec);
file_action = launch_info.GetFileActionForFD (STDERR_FILENO);
- stderr_path = GetFilePath(file_action, stderr_path, dbg_pts_path);
-
- m_monitor = new ProcessMonitor (this,
- module,
- launch_info.GetArguments().GetConstArgumentVector(),
- launch_info.GetEnvironmentEntries().GetConstArgumentVector(),
- stdin_path,
- stdout_path,
- stderr_path,
- working_dir,
- launch_info,
- error);
+ stderr_file_spec = GetFileSpec(file_action, stderr_file_spec, dbg_pts_file_spec);
+
+ m_monitor = new ProcessMonitor(this,
+ module,
+ launch_info.GetArguments().GetConstArgumentVector(),
+ launch_info.GetEnvironmentEntries().GetConstArgumentVector(),
+ stdin_file_spec,
+ stdout_file_spec,
+ stderr_file_spec,
+ working_dir,
+ launch_info,
+ error);
m_module = module;
OpenPOWER on IntegriCloud