* [PATCH] gdbserver: support Unix domain sockets
@ 2016-03-10 0:05 Yunlian Jiang
2016-03-10 17:35 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Yunlian Jiang @ 2016-03-10 0:05 UTC (permalink / raw)
To: gdb-patches
This patch enables gdbserver to use Unix domain sockets if
the TCP sockets is not allowed to use. Wit this patch, user can
use "gdbserver +debug-socket --attach 123" to use Unix domain
sockets.
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index e751473..b00960d 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -62,6 +62,10 @@
#include <winsock2.h>
#endif
+#ifndef USE_WIN32API
+#include <sys/un.h>
+#endif
+
#if __QNX__
#include <sys/iomgr.h>
#endif /* __QNX__ */
@@ -288,6 +292,49 @@ remote_open (char *name)
{
char *port_str;
+ /* Enable gdbserver to use Unix domain sockets if applications aren't
+ allowed to bind to localhost TCP sockets.
+ Typical usage is "gdbserver +debug-socket --attach 123" */
+ if (name[0] == '+')
+ {
+#ifdef USE_WIN32API
+ error ("Only <host>:<port> is supported on this platform.");
+#else
+ struct sockaddr_un sockaddr;
+ socklen_t sockaddrlen;
+
+ listen_desc = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (listen_desc == -1)
+ perror_with_name ("Can't create Unix domain socket");
+
+ /* Skip the initial '+'. */
+ name++;
+
+ memset (&sockaddr, 0, sizeof sockaddr);
+ sockaddr.sun_family = AF_UNIX;
+ snprintf(sockaddr.sun_path, sizeof (sockaddr.sun_path), "%s", name);
+ sockaddrlen = sizeof (sockaddr.sun_family) +
+ strlen (sockaddr.sun_path) + 1;
+
+ unlink (sockaddr.sun_path);
+
+ if (bind (listen_desc, (struct sockaddr *) &sockaddr, sockaddrlen)
+ || listen (listen_desc, 1))
+ perror_with_name ("Can't bind Unix domain socket");
+
+ fprintf (stderr, "Listening on Unix domain socket '%s'\n",
+ sockaddr.sun_path);
+ fflush (stderr);
+
+ /* Register the event loop handler. */
+ add_file_handler (listen_desc, handle_accept_event, NULL);
+
+ transport_is_reliable = 1;
+#endif
+
+ return;
+ }
+
port_str = strchr (name, ':');
#ifdef USE_WIN32API
if (port_str == NULL)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdbserver: support Unix domain sockets
2016-03-10 0:05 [PATCH] gdbserver: support Unix domain sockets Yunlian Jiang
@ 2016-03-10 17:35 ` Pedro Alves
2016-03-14 15:02 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2016-03-10 17:35 UTC (permalink / raw)
To: Yunlian Jiang, gdb-patches
On 03/10/2016 12:04 AM, Yunlian Jiang wrote:
> This patch enables gdbserver to use Unix domain sockets if
> the TCP sockets is not allowed to use. Wit this patch, user can
> use "gdbserver +debug-socket --attach 123" to use Unix domain
> sockets.
Thanks.
This is larger than what we can accept without a copyright
assignment with the FSF -- I looked at the records and
couldn't find one. Let me know if you'd like to get that started.
We'll also need, at least:
- A gdb manual update.
- A gdbserver --help update
- NEWS entry
- ChangeLog entry
See [1] for more details.
A couple offhand questions:
- How do you plan on using this from the gdb side?
- Is there a reason for picking "+" over some other way / syntax?
[1] http://sourceware.org/gdb/wiki/ContributionChecklist
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gdbserver: support Unix domain sockets
2016-03-10 17:35 ` Pedro Alves
@ 2016-03-14 15:02 ` Pedro Alves
0 siblings, 0 replies; 3+ messages in thread
From: Pedro Alves @ 2016-03-14 15:02 UTC (permalink / raw)
To: Yunlian Jiang, gdb-patches
On 03/10/2016 05:35 PM, Pedro Alves wrote:
> This is larger than what we can accept without a copyright
> assignment with the FSF -- I looked at the records and
> couldn't find one. Let me know if you'd like to get that started.
Sorry, I notice now that I got confused here -- you're already covered
by Google's blanket copyright assignment.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-14 15:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-10 0:05 [PATCH] gdbserver: support Unix domain sockets Yunlian Jiang
2016-03-10 17:35 ` Pedro Alves
2016-03-14 15:02 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).