aboutsummaryrefslogtreecommitdiff
path: root/gdb/common
diff options
context:
space:
mode:
authorJohn Darrington <john@darrington.wattle.id.au>2018-09-22 12:35:41 +0200
committerJohn Darrington <john@darrington.wattle.id.au>2018-10-23 16:09:31 +0200
commitf19c7ff839d7a32ebb48482ae7d318fb46ca823d (patch)
tree20fb679f8c570679427169092b674cd0a8199fc8 /gdb/common
parent2849d19feb458ade67cdcc6a82f0e7b1be99b46b (diff)
downloadgdb-f19c7ff839d7a32ebb48482ae7d318fb46ca823d.zip
gdb-f19c7ff839d7a32ebb48482ae7d318fb46ca823d.tar.gz
gdb-f19c7ff839d7a32ebb48482ae7d318fb46ca823d.tar.bz2
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.
Diffstat (limited to 'gdb/common')
-rw-r--r--gdb/common/netstuff.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/common/netstuff.c b/gdb/common/netstuff.c
index c1c401c..11182c1 100644
--- a/gdb/common/netstuff.c
+++ b/gdb/common/netstuff.c
@@ -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)