Switch over to using socketpair for local debugserver connections as they are twice...
authorGreg Clayton <gclayton@apple.com>
Fri, 12 Aug 2016 16:46:18 +0000 (16:46 +0000)
committerGreg Clayton <gclayton@apple.com>
Fri, 12 Aug 2016 16:46:18 +0000 (16:46 +0000)
commitc6c420fca14d9eac716c2099514bcfcaea94809c
tree22239e938218c4fa3d60d967aa4fff42936121eb
parent623c4c1572ab07864ad9efd37e672eca60707675
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
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/tools/debugserver/source/debugserver.cpp