From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27299 invoked by alias); 30 Dec 2006 15:45:40 -0000 Received: (qmail 27291 invoked by uid 22791); 30 Dec 2006 15:45:39 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sat, 30 Dec 2006 15:45:35 +0000 Received: from drow by nevyn.them.org with local (Exim 4.63) (envelope-from ) id 1H0gOr-0004LA-1r; Sat, 30 Dec 2006 10:45:33 -0500 Date: Sat, 30 Dec 2006 15:45:00 -0000 From: Daniel Jacobowitz To: Denis PILAT Cc: gdb-patches Subject: Re: gdbserver with reversed arguments goes into an infinite loop Message-ID: <20061230154533.GC15107@nevyn.them.org> Mail-Followup-To: Denis PILAT , gdb-patches References: <457FCEB6.4060008@st.com> <20061213133737.GA2633@nevyn.them.org> <45802031.2020402@st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45802031.2020402@st.com> User-Agent: Mutt/1.5.13 (2006-08-11) X-IsSubscribed: yes 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 X-SW-Source: 2006-12/txt/msg00360.txt.bz2 On Wed, Dec 13, 2006 at 04:45:53PM +0100, Denis PILAT wrote: > But may be it would be better to open only character device (S_ISCHR > macro) than excluding ordinary files (S_ISREG macro). It's up to you ! Good idea. FIFOs are OK too. I've committed a nicer version of this. > I took this opportunity to remove a warning on a strncpy() usage. Why did it warn? I omitted this bit, because I don't see any reason (or any warning). > I'm wondering about the compilation of this code under windows. I never > compiled a gdbserver on windows, is there any gdbserver hosted under > windows ? If you were working against HEAD, you'd see that there was now - but we don't support serial ports there, so it's not a problem. It's all #ifdef'd out. -- Daniel Jacobowitz CodeSourcery 2006-12-30 Denis PILAT Daniel Jacobowitz * remote-utils.c (remote_open): Check the type of specified serial port devices before opening them. * server.c (main): Kill the inferior if an error occurs during the first remote_open. Index: remote-utils.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/remote-utils.c,v retrieving revision 1.34 diff -u -p -r1.34 remote-utils.c --- remote-utils.c 16 Nov 2006 15:08:25 -0000 1.34 +++ remote-utils.c 30 Dec 2006 15:23:37 -0000 @@ -52,6 +52,8 @@ #if HAVE_ARPA_INET_H #include #endif +#include +#include #if USE_WIN32API #include @@ -94,13 +96,25 @@ remote_open (char *name) #if defined(F_SETFL) && defined (FASYNC) int save_fcntl_flags; #endif - - if (!strchr (name, ':')) + char *port_str; + + port_str = strchr (name, ':'); + if (port_str == NULL) { #ifdef USE_WIN32API error ("Only : is supported on this platform."); #else - remote_desc = open (name, O_RDWR); + struct stat statbuf; + + if (stat (name, &statbuf) == 0 + && (S_ISCHR (statbuf.st_mode) || S_ISFIFO (statbuf.st_mode))) + remote_desc = open (name, O_RDWR); + else + { + errno = EINVAL; + remote_desc = -1; + } + if (remote_desc < 0) perror_with_name ("Could not open remote device"); Index: server.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.c,v retrieving revision 1.42 diff -u -p -r1.42 server.c --- server.c 16 Nov 2006 15:08:25 -0000 1.42 +++ server.c 30 Dec 2006 15:23:37 -0000 @@ -614,6 +614,13 @@ main (int argc, char *argv[]) } } + if (setjmp (toplevel)) + { + fprintf (stderr, "Killing inferior\n"); + kill_inferior (); + exit (1); + } + while (1) { remote_open (argv[1]);