summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Target/Process.h14
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp2
-rw-r--r--lldb/source/Target/Process.cpp42
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachProcess.cpp8
4 files changed, 34 insertions, 32 deletions
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 873cf41de22..57c41051641 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -520,12 +520,12 @@ public:
m_monitor_callback_baton (NULL),
m_monitor_signals (false)
{
- if (stderr_path)
+ if (stdin_path)
{
ProcessLaunchInfo::FileAction file_action;
const bool read = true;
- const bool write = true;
- if (file_action.Open(STDERR_FILENO, stderr_path, read, write))
+ const bool write = false;
+ if (file_action.Open(STDIN_FILENO, stdin_path, read, write))
AppendFileAction (file_action);
}
if (stdout_path)
@@ -536,12 +536,12 @@ public:
if (file_action.Open(STDOUT_FILENO, stdout_path, read, write))
AppendFileAction (file_action);
}
- if (stdin_path)
+ if (stderr_path)
{
ProcessLaunchInfo::FileAction file_action;
- const bool read = true;
- const bool write = false;
- if (file_action.Open(STDIN_FILENO, stdin_path, read, write))
+ const bool read = false;
+ const bool write = true;
+ if (file_action.Open(STDERR_FILENO, stderr_path, read, write))
AppendFileAction (file_action);
}
if (working_directory)
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index e5141c456e6..3cd0fba95d9 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -815,7 +815,7 @@ GDBRemoteCommunicationServer::Handle_QSetSTDERR (StringExtractorGDBRemote &packe
std::string path;
packet.GetHexByteString(path);
const bool read = true;
- const bool write = true;
+ const bool write = false;
if (file_action.Open(STDERR_FILENO, path.c_str(), read, write))
{
m_process_launch_info.AppendFileAction(file_action);
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index b26c78eeccb..f6c598b5e40 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -259,9 +259,9 @@ ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty)
{
if (m_flags.Test(eLaunchFlagDisableSTDIO))
{
- AppendSuppressFileAction (STDERR_FILENO, true , true );
- AppendSuppressFileAction (STDIN_FILENO , true , false);
- AppendSuppressFileAction (STDOUT_FILENO, false, true );
+ AppendSuppressFileAction (STDIN_FILENO , true, false);
+ AppendSuppressFileAction (STDOUT_FILENO, false, true);
+ AppendSuppressFileAction (STDERR_FILENO, false, true);
}
else
{
@@ -274,9 +274,9 @@ ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty)
const char *err_path = NULL;
if (target)
{
- in_path = target->GetStandardErrorPath();
- out_path = target->GetStandardInputPath();
- err_path = target->GetStandardOutputPath();
+ in_path = target->GetStandardInputPath();
+ out_path = target->GetStandardOutputPath();
+ err_path = target->GetStandardErrorPath();
}
if (default_to_use_pty && (!in_path && !out_path && !err_path))
@@ -288,13 +288,14 @@ ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty)
}
if (in_path)
- AppendOpenFileAction(STDERR_FILENO, in_path, true, true);
-
+ AppendOpenFileAction(STDIN_FILENO, in_path, true, false);
+
if (out_path)
- AppendOpenFileAction(STDIN_FILENO, out_path, true, false);
+ AppendOpenFileAction(STDOUT_FILENO, out_path, false, true);
if (err_path)
- AppendOpenFileAction(STDOUT_FILENO, err_path, false, true);
+ AppendOpenFileAction(STDERR_FILENO, err_path, false, true);
+
}
}
}
@@ -518,30 +519,31 @@ ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *op
launch_info.GetFlags().Set (eLaunchFlagStopAtEntry);
break;
- case 'e': // STDERR for read + write
+ case 'i': // STDIN for read only
{
ProcessLaunchInfo::FileAction action;
- if (action.Open(STDERR_FILENO, option_arg, true, true))
+ if (action.Open (STDIN_FILENO, option_arg, true, false))
launch_info.AppendFileAction (action);
}
break;
- case 'i': // STDIN for read only
+ case 'o': // Open STDOUT for write only
{
ProcessLaunchInfo::FileAction action;
- if (action.Open(STDIN_FILENO, option_arg, true, false))
+ if (action.Open (STDOUT_FILENO, option_arg, false, true))
launch_info.AppendFileAction (action);
}
break;
-
- case 'o': // Open STDOUT for write only
+
+ case 'e': // STDERR for write only
{
ProcessLaunchInfo::FileAction action;
- if (action.Open(STDOUT_FILENO, option_arg, false, true))
+ if (action.Open (STDERR_FILENO, option_arg, false, true))
launch_info.AppendFileAction (action);
}
break;
+
case 'p': // Process plug-in name
launch_info.SetProcessPluginName (option_arg);
break;
@@ -549,11 +551,11 @@ ProcessLaunchCommandOptions::SetOptionValue (uint32_t option_idx, const char *op
case 'n': // Disable STDIO
{
ProcessLaunchInfo::FileAction action;
- if (action.Open(STDERR_FILENO, "/dev/null", true, true))
+ if (action.Open (STDIN_FILENO, "/dev/null", true, false))
launch_info.AppendFileAction (action);
- if (action.Open(STDOUT_FILENO, "/dev/null", false, true))
+ if (action.Open (STDOUT_FILENO, "/dev/null", false, true))
launch_info.AppendFileAction (action);
- if (action.Open(STDIN_FILENO, "/dev/null", true, false))
+ if (action.Open (STDERR_FILENO, "/dev/null", false, true))
launch_info.AppendFileAction (action);
}
break;
diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
index d0d4c8d09be..40e25850b95 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp
@@ -1723,7 +1723,7 @@ MachProcess::PosixSpawnChildForPTraceDebugging
err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDOUT_FILENO, path=/dev/null)");
err.SetError( ::posix_spawn_file_actions_addopen (&file_actions, STDERR_FILENO, "/dev/null",
- O_RDWR | O_NOCTTY, 0), DNBError::POSIX);
+ O_WRONLY | O_NOCTTY, 0), DNBError::POSIX);
if (err.Fail() || DNBLogCheckLogBit (LOG_PROCESS))
err.LogThreaded ("::posix_spawn_file_actions_addopen (&file_actions, filedes=STDERR_FILENO, path=/dev/null)");
}
@@ -1733,9 +1733,9 @@ MachProcess::PosixSpawnChildForPTraceDebugging
if (stdout_path == NULL) stdout_path = "/dev/null";
if (stderr_path == NULL) stderr_path = "/dev/null";
- int slave_fd_err = open (stderr_path, O_NOCTTY | O_CREAT | O_RDWR , 0640);
- int slave_fd_in = open (stdin_path , O_NOCTTY | O_RDONLY);
- int slave_fd_out = open (stdout_path, O_NOCTTY | O_CREAT | O_WRONLY , 0640);
+ const int slave_fd_in = open (stdin_path , O_NOCTTY | O_RDONLY);
+ const int slave_fd_out = open (stdout_path, O_NOCTTY | O_CREAT | O_WRONLY , 0640);
+ const int slave_fd_err = open (stderr_path, O_NOCTTY | O_CREAT | O_WRONLY , 0640);
err.SetError( ::posix_spawn_file_actions_adddup2(&file_actions, slave_fd_err, STDERR_FILENO), DNBError::POSIX);
if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS))
OpenPOWER on IntegriCloud