diff options
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 31 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/MacOSX/MachProcess.cpp | 16 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/debugserver.cpp | 2 |
3 files changed, 27 insertions, 22 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 2cc9e0aa3a1..8d3675d0b7d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1752,7 +1752,8 @@ ProcessGDBRemote::StartDebugserverProcess lldb_utility::PseudoTerminal pty; if (stdio_path == NULL) { - pass_stdio_path_to_debugserver = false; + if (! m_local_debugserver) + pass_stdio_path_to_debugserver = false; if (pty.OpenFirstAvailableMaster(O_RDWR|O_NOCTTY, NULL, 0)) { struct termios stdin_termios; @@ -1785,7 +1786,7 @@ ProcessGDBRemote::StartDebugserverProcess { debugserver_args.AppendArgument("-s"); // short for --stdio-path StreamString strm; - strm.Printf("'%s'", stdio_path); + strm.Printf("%s", stdio_path); debugserver_args.AppendArgument(strm.GetData()); // path to file to have inferior open as it's STDIO } } @@ -1880,19 +1881,19 @@ ProcessGDBRemote::StartDebugserverProcess if (error.Fail() || log) error.PutToLog(log, "::posix_spawnp ( pid => %i, path = '%s', file_actions = %p, attr = %p, argv = %p, envp = %p )", m_debugserver_pid, debugserver_path, NULL, &attr, inferior_argv, inferior_envp); -// if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID) -// { -// std::auto_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor (pty.ReleaseMasterFileDescriptor(), true)); -// if (conn_ap.get()) -// { -// m_stdio_communication.SetConnection(conn_ap.release()); -// if (m_stdio_communication.IsConnected()) -// { -// m_stdio_communication.SetReadThreadBytesReceivedCallback (STDIOReadThreadBytesReceived, this); -// m_stdio_communication.StartReadThread(); -// } -// } -// } + if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID) + { + std::auto_ptr<ConnectionFileDescriptor> conn_ap(new ConnectionFileDescriptor (pty.ReleaseMasterFileDescriptor(), true)); + if (conn_ap.get()) + { + m_stdio_communication.SetConnection(conn_ap.release()); + if (m_stdio_communication.IsConnected()) + { + m_stdio_communication.SetReadThreadBytesReceivedCallback (STDIOReadThreadBytesReceived, this); + m_stdio_communication.StartReadThread(); + } + } + } } else { diff --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp index ad7af1d91c4..c5c1e7f6f0c 100644 --- a/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp +++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.cpp @@ -1662,17 +1662,21 @@ MachProcess::PosixSpawnChildForPTraceDebugging if (stdio_path != NULL) { - err.SetError( ::posix_spawn_file_actions_addopen(&file_actions, STDERR_FILENO, stdio_path, O_RDWR, 0), DNBError::POSIX); + int slave_fd_err = open (stdio_path, O_RDWR, 0); + int slave_fd_in = open (stdio_path, O_RDONLY, 0); + int slave_fd_out = open (stdio_path, O_WRONLY, 0); + + err.SetError( ::posix_spawn_file_actions_adddup2(&file_actions, slave_fd_err, STDERR_FILENO), DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS)) - err.LogThreaded("::posix_spawn_file_actions_addopen ( &file_actions, filedes = STDERR_FILENO, path = '%s', oflag = O_RDWR, mode = 0 )", stdio_path); + err.LogThreaded("::posix_spawn_file_actions_adddup2 ( &file_actions, filedes = %d, newfiledes = STDERR_FILENO )", slave_fd_err); - err.SetError( ::posix_spawn_file_actions_addopen(&file_actions, STDIN_FILENO, stdio_path, O_RDONLY, 0), DNBError::POSIX); + err.SetError( ::posix_spawn_file_actions_adddup2(&file_actions, slave_fd_in, STDIN_FILENO), DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS)) - err.LogThreaded("::posix_spawn_file_actions_addopen ( &file_actions, filedes = STDIN_FILENO, path = '%s', oflag = O_RDONLY, mode = 0 )", stdio_path); + err.LogThreaded("::posix_spawn_file_actions_adddup2 ( &file_actions, filedes = %d, newfiledes = STDIN_FILENO )", slave_fd_in); - err.SetError( ::posix_spawn_file_actions_addopen(&file_actions, STDOUT_FILENO, stdio_path, O_WRONLY, 0), DNBError::POSIX); + err.SetError( ::posix_spawn_file_actions_adddup2(&file_actions, slave_fd_out, STDOUT_FILENO), DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS)) - err.LogThreaded("::posix_spawn_file_actions_addopen ( &file_actions, filedes = STDOUT_FILENO, path = '%s', oflag = O_WRONLY, mode = 0 )", stdio_path); + err.LogThreaded("::posix_spawn_file_actions_adddup2 ( &file_actions, filedes = %d, newfiledes = STDOUT_FILENO )", slave_fd_out); } err.SetError( ::posix_spawnp (&pid, path, &file_actions, &attr, (char * const*)argv, (char * const*)envp), DNBError::POSIX); if (err.Fail() || DNBLogCheckLogBit(LOG_PROCESS)) diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index dc50b63bb0d..a3cae284d4f 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -704,7 +704,7 @@ main (int argc, char *argv[]) RNBRunLoopMode start_mode = eRNBRunLoopModeExit; - while ((ch = getopt_long(argc, argv, "a:d:gi:vktl:f:w:x:r", g_long_options, &long_option_index)) != -1) + while ((ch = getopt_long(argc, argv, "a:d:gi:vktl:f:w:x:rs:", g_long_options, &long_option_index)) != -1) { DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", ch, (uint8_t)ch, |