aboutsummaryrefslogtreecommitdiff
path: root/gdb/ser-uds.c
diff options
context:
space:
mode:
authorJohn Darrington <john@darrington.wattle.id.au>2018-10-13 18:12:01 +0200
committerJohn Darrington <john@darrington.wattle.id.au>2018-10-23 16:09:34 +0200
commit88f5cc8cf8606478832c7d0d7b74755f3f625015 (patch)
tree5992356e148c9913017faeaf56504692f730579d /gdb/ser-uds.c
parent0a163825df5e98ad55de13eb3d3534d875943047 (diff)
downloadgdb-88f5cc8cf8606478832c7d0d7b74755f3f625015.zip
gdb-88f5cc8cf8606478832c7d0d7b74755f3f625015.tar.gz
gdb-88f5cc8cf8606478832c7d0d7b74755f3f625015.tar.bz2
GDB: Remote target can now accept the form unix::/path/to/socket.
Allow target remote to use the unix::/path/to/socket syntax as well as just plain /path/to/socket gdb/ * ser-uds.c (uds_open): Use parse_connection_spec to deal with the comm form unix::/path/to/socket. * serial.c (serial_open): Consider the "unix:" prefix when deciding which interface to use.
Diffstat (limited to 'gdb/ser-uds.c')
-rw-r--r--gdb/ser-uds.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gdb/ser-uds.c b/gdb/ser-uds.c
index a98469f..acace25 100644
--- a/gdb/ser-uds.c
+++ b/gdb/ser-uds.c
@@ -23,6 +23,8 @@
#include <sys/socket.h>
#include <sys/un.h>
+#include <netdb.h>
+#include "netstuff.h"
#ifndef UNIX_PATH_MAX
#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *) NULL)->sun_path)
@@ -33,9 +35,21 @@
static int
uds_open (struct serial *scb, const char *name)
{
+ struct addrinfo hint;
+
+ memset (&hint, 0, sizeof (hint));
+ /* Assume no prefix will be passed, therefore we should use
+ AF_UNSPEC. */
+ hint.ai_family = AF_UNSPEC;
+ hint.ai_socktype = SOCK_STREAM;
+
+ parsed_connection_spec parsed = parse_connection_spec (name, &hint);
+
+ const char *socket_name = parsed.port_str.empty() ? name : parsed.port_str.c_str ();
+
struct sockaddr_un addr;
- if (strlen (name) > UNIX_PATH_MAX - 1)
+ if (strlen (socket_name) > UNIX_PATH_MAX - 1)
{
warning
(_("The socket name is too long. It may be no longer than %s bytes."),
@@ -45,7 +59,7 @@ uds_open (struct serial *scb, const char *name)
memset (&addr, 0, sizeof addr);
addr.sun_family = AF_UNIX;
- strncpy (addr.sun_path, name, UNIX_PATH_MAX - 1);
+ strncpy (addr.sun_path, socket_name, UNIX_PATH_MAX - 1);
int sock = socket (AF_UNIX, SOCK_STREAM, 0);