public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: John Darrington <john@darrington.wattle.id.au>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH] Allow remote debugging over a local domain socket
Date: Fri, 31 Aug 2018 16:01:00 -0000	[thread overview]
Message-ID: <61e78be6-4976-6a28-90d2-e515c0afc2f3@redhat.com> (raw)
In-Reply-To: <20180831101818.9175-1-john@darrington.wattle.id.au>

On 08/31/2018 11:18 AM, John Darrington wrote:
> Extend the "target remote"  and "target extended-remote" commands
> such that if the filename provided is a unix domain (AF_UNIX)
> socket, then it'll be treated as such, instead of trying to open
> it as if it were a character device.

What server are you using this against?  It'd be great to add
support for gdbserver as well.  Were you planning on doing it?
If we had that, then I think we could add unix domain socket testing
to gdb/testsuite/gdb.server/server-connect.exp (assuming it'd be easy
enough to create a socket from tcl).

> 
> gdb/ChangeLog:
> 	* gdb/NEWS:  Mention changed commands.
> 	* gdb/configure.ac (SER_HARDWIRE): Add ser-socket.o
> 	* gdb/ser-socket.c: New file.
> 	* gdb/ser-socket.h: New file.
> 	* gdb/Makefile.in: Add new files.
> 	* gdb/serial.c (serial_open): Check if filename is a socket
>           and lookup the appropriate interface accordingly.

Remove leading "gdb/" from all these entries.  The paths in the
entry are relative to the ChangeLog file.

> 	* gdb/doc/gdb.texinfo (Remote Connection Commands):  Describe
>           changed commands.

gdb/doc/ has its own ChangeLog file.  Move it there, and remove the
"gdb/doc/" prefix.  Update "Describe changed commands" to be a bit
more standalone, since it won't have the gdb/ changes context at
hand.

Also please fix the double-space, missing period, and check tab vs spaces
in the entry.


> +
> +
> +/* Open a AF_UNIX socket.  */
> +int
> +socket_open (struct serial *scb, const char *name)
> +{
> +  struct sockaddr_un addr;
> +
> +  memset (&addr, 0, sizeof addr);
> +  addr.sun_family = AF_UNIX;
> +#ifndef UNIX_MAX_PATH
> +# define UNIX_MAX_PATH 108
> +#endif

gdbserver/tracepoint.c does:

#ifndef UNIX_PATH_MAX
#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *) NULL)->sun_path)
#endif

> diff --git a/gdb/serial.c b/gdb/serial.c
> index fb2b212918..13b1af3873 100644
> --- a/gdb/serial.c
> +++ b/gdb/serial.c
> @@ -213,7 +213,15 @@ serial_open (const char *name)
>    else if (strchr (name, ':'))
>      ops = serial_interface_lookup ("tcp");
>    else
> -    ops = serial_interface_lookup ("hardwire");
> +    {
> +      /* Check to see if name is a socket.  If it is, then treat is
> +         as such.  Otherwise assume that it's a character device.  */
> +      struct stat sb;
> +      if (0 == stat (name, &sb) && ((sb.st_mode & S_IFMT) == S_IFSOCK))
> +	ops = serial_interface_lookup ("socket");
> +      else
> +	ops = serial_interface_lookup ("hardware");


Nit: maybe it's just me, but I find "socket" ambiguous -- is it
a unix domain socket, a tcp socket, a udp socket, other?
I'd have picked "unix" or "uds" instead, and likewise have
named the file ser-unix.c and functions unix_foo instead
of serial.  We already have ser-unix.c, but since this is
only for unix really, then we could add the new code in
that file instead?

Thanks,
Pedro Alves

  parent reply	other threads:[~2018-08-31 16:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29  7:05 Remote debugging over local domain sockets? John Darrington
2018-08-29 15:17 ` Tom Tromey
2018-08-29 15:28   ` John Darrington
2018-08-29 15:39     ` Tom Tromey
2018-08-31 10:18       ` [PATCH] Allow remote debugging over a local domain socket John Darrington
2018-08-31 14:59         ` Eli Zaretskii
2018-08-31 15:10           ` John Darrington
2018-08-31 17:50             ` Eli Zaretskii
2018-08-31 15:10         ` Tom Tromey
2018-08-31 15:12           ` John Darrington
2018-08-31 16:01         ` Pedro Alves [this message]
2018-08-31 16:40           ` John Darrington
2018-09-03 13:19             ` Pedro Alves
2018-09-03 18:49               ` John Darrington
2018-10-01 19:45                 ` Pedro Alves
2018-10-02 10:16                   ` John Darrington

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=61e78be6-4976-6a28-90d2-e515c0afc2f3@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=john@darrington.wattle.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).