diff options
| author | Greg Clayton <gclayton@apple.com> | 2016-08-12 16:46:18 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2016-08-12 16:46:18 +0000 |
| commit | c6c420fca14d9eac716c2099514bcfcaea94809c (patch) | |
| tree | 22239e938218c4fa3d60d967aa4fff42936121eb /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | |
| parent | 623c4c1572ab07864ad9efd37e672eca60707675 (diff) | |
| download | llvm-c6c420fca14d9eac716c2099514bcfcaea94809c.zip llvm-c6c420fca14d9eac716c2099514bcfcaea94809c.tar.gz llvm-c6c420fca14d9eac716c2099514bcfcaea94809c.tar.bz2 | |
Switch over to using socketpair for local debugserver connections as they are twice as fast as TCP sockets (on macOS at least).
This change opens a socket pair and passes the second socket pair file descriptor down to the debugserver binary using a new option: "--fd=N" where N is the file descriptor. This file descriptor gets passed via posix_spawn() so that there is no need to do any bind/listen or bind/accept calls and eliminates the hanshake unix socket that is used to pass the result of the actual port that ends up being used so it can save time on launch as well as being faster.
This is currently only enabled on __APPLE__ builds. Other OSs should try modifying the #define from ProcessGDBRemote.cpp but the first person will need to port the --fd option over to lldb-server. Any OSs that enable USE_SOCKETPAIR_FOR_LOCAL_CONNECTION in their native builds can use the socket pair stuff. The #define is Apple only right now, but looks like:
#if defined (__APPLE__)
#define USE_SOCKETPAIR_FOR_LOCAL_CONNECTION 1
#endif
<rdar://problem/27814880>
llvm-svn: 278524
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 14fe877..d194477 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -1091,7 +1091,8 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *url, Platform *platform, ProcessLaunchInfo &launch_info, uint16_t *port, - const Args& inferior_args) + const Args* inferior_args, + int pass_comm_fd) { Log *log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS)); if (log) @@ -1171,6 +1172,16 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *url, if (url) debugserver_args.AppendArgument(url); + if (pass_comm_fd >= 0) + { + StreamString fd_arg; + fd_arg.Printf("--fd=%i", pass_comm_fd); + debugserver_args.AppendArgument(fd_arg.GetData()); + // Send "pass_comm_fd" down to the inferior so it can use it to + // communicate back with this process + launch_info.AppendDuplicateFileAction(pass_comm_fd, pass_comm_fd); + } + // use native registers, not the GDB registers debugserver_args.AppendArgument("--native-regs"); @@ -1189,7 +1200,7 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *url, // port is null when debug server should listen on domain socket - // we're not interested in port value but rather waiting for debug server // to become available. - if ((port != nullptr && *port == 0) || port == nullptr) + if (pass_comm_fd == -1 && ((port != nullptr && *port == 0) || port == nullptr)) { if (url) { @@ -1304,10 +1315,10 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *url, } } while (has_env_var); - if (inferior_args.GetArgumentCount() > 0) + if (inferior_args && inferior_args->GetArgumentCount() > 0) { debugserver_args.AppendArgument ("--"); - debugserver_args.AppendArguments (inferior_args); + debugserver_args.AppendArguments (*inferior_args); } // Copy the current environment to the gdbserver/debugserver instance @@ -1337,8 +1348,7 @@ GDBRemoteCommunication::StartDebugserverProcess (const char *url, } error = Host::LaunchProcess(launch_info); - if (error.Success() && - launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) + if (error.Success() && (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) && pass_comm_fd == -1) { if (named_pipe_path.size() > 0) { |
