From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44147 invoked by alias); 31 Aug 2018 16:01:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 44011 invoked by uid 89); 31 Aug 2018 16:01:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 Aug 2018 16:01:01 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E27578182D20; Fri, 31 Aug 2018 16:00:59 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE9201010422; Fri, 31 Aug 2018 16:00:55 +0000 (UTC) Subject: Re: [PATCH] Allow remote debugging over a local domain socket To: John Darrington , gdb-patches@sourceware.org References: <874lfd5gjt.fsf@tromey.com> <20180831101818.9175-1-john@darrington.wattle.id.au> From: Pedro Alves Message-ID: <61e78be6-4976-6a28-90d2-e515c0afc2f3@redhat.com> Date: Fri, 31 Aug 2018 16:01:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180831101818.9175-1-john@darrington.wattle.id.au> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-08/txt/msg00874.txt.bz2 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