GDBSERVER: Listen on a unix domain (instead of TCP) socket if requested.

When invoking gdbserver, if the COMM parameter takes the form "unix::/path/name"
then a local (unix) domain socket will be created with that name and gdbserver
will listen for connections on that.

    gdb/
    * NEWS: Mention new feature.

    gdb/gdbserver/
    * configure.ac (AC_CHECK_HEADERS): Add sys/un.h.
    * configure: Regenerate.
    * remote-utils.c (remote_prepare): Create a local socket if requested.
     (remote_open):  Don't attempt to open a file if it's a socket.
     (handle_accept_event): Display the name of the socket on connection.

   gdb/common/
   * netstuff.c (parse_connection_spec)[prefixes]: New member for local domain sockets.
This commit is contained in:
John Darrington
2018-09-22 12:35:41 +02:00
parent 2849d19feb
commit f19c7ff839
4 changed files with 131 additions and 52 deletions

View File

@@ -56,6 +56,7 @@ parse_connection_spec_without_prefix (std::string spec, struct addrinfo *hint)
&& (spec[0] == '['
|| std::count (spec.begin (),
spec.end (), ':') > 1)));
bool is_unix = hint->ai_family == AF_UNIX;
if (is_ipv6)
{
@@ -109,6 +110,12 @@ parse_connection_spec_without_prefix (std::string spec, struct addrinfo *hint)
if (ret.host_str.empty ())
ret.host_str = "localhost";
if (is_unix && ret.host_str != "localhost")
error (_("The host name must be empty or 'localhost' for a unix domain socket."));
if (is_unix && ret.port_str.empty ())
error (_("A path name must be specified for a unix domain socket."));
return ret;
}
@@ -138,6 +145,7 @@ parse_connection_spec (const char *spec, struct addrinfo *hint)
{ "tcp4:", AF_INET, SOCK_STREAM },
{ "udp6:", AF_INET6, SOCK_DGRAM },
{ "tcp6:", AF_INET6, SOCK_STREAM },
{ "unix:", AF_LOCAL, SOCK_STREAM },
};
for (const host_prefix prefix : prefixes)