From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19026 invoked by alias); 13 Dec 2006 09:58:40 -0000 Received: (qmail 19018 invoked by uid 22791); 13 Dec 2006 09:58:39 -0000 X-Spam-Check-By: sourceware.org Received: from lon-del-02.spheriq.net (HELO lon-del-02.spheriq.net) (195.46.50.98) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 13 Dec 2006 09:58:29 +0000 Received: from lon-out-01.spheriq.net ([195.46.50.129]) by lon-del-02.spheriq.net with ESMTP id kBD9wQwx010881 for ; Wed, 13 Dec 2006 09:58:26 GMT Received: from lon-cus-01.spheriq.net (lon-cus-01.spheriq.net [195.46.50.37]) by lon-out-01.spheriq.net with ESMTP id kBD9wPLM020582 for ; Wed, 13 Dec 2006 09:58:25 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by lon-cus-01.spheriq.net with ESMTP id kBD9wKbB011509 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Wed, 13 Dec 2006 09:58:21 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 5C3DBDA44 for ; Wed, 13 Dec 2006 09:58:19 +0000 (GMT) Received: from mail1.cro.st.com (mail1.cro.st.com [164.129.40.131]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7CCE247327 for ; Wed, 13 Dec 2006 09:58:17 +0000 (GMT) Received: from [164.129.44.95] (crx595.cro.st.com [164.129.44.95]) by mail1.cro.st.com (MOS 3.5.8-GR) with ESMTP id CJF04618 (AUTH "denis pilat"); Wed, 13 Dec 2006 10:58:14 +0100 (CET) Message-ID: <457FCEB6.4060008@st.com> Date: Wed, 13 Dec 2006 09:58:00 -0000 From: Denis PILAT User-Agent: Thunderbird 1.5.0.8 (X11/20061025) MIME-Version: 1.0 To: gdb-patches Subject: gdbserver with reversed arguments goes into an infinite loop Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/msg00171.txt.bz2 I've found that if you revert the argument of gdbserver, means writing the program's name before the COMM argument, it goes into an infinite loop, and as the CTRL+C does not work, you have to kill the process from an other shell. In gdbserver/server.c, the loop in question does the remote_open on the wrong passed argument (argv[1]) which unfortunately is the binary file you'd expect to open so remote_open does not exit on error. I think either we could check that we pass correct argument before using start_inferior(), this is executing before the loop. The bellow patch is in that sense. Or we find a way to exit the loop by adding a test in it. May be by adding something in remote_open to let it fail. I'd like your opinion about that Thanks -- Denis Pilat / STMicroelectronics Index: server.c =================================================================== --- server.c (revision 544) +++ server.c (working copy) @@ -408,6 +408,13 @@ main (int argc, char *argv[]) if (pid == 0) { + if (access (argv[2], F_OK) != 0) + { + fprintf (stderr, "File %s does not exist.\n",argv[2]); + gdbserver_usage (); + exit (0); + } + /* Wait till we are at first instruction in program. */ signal = start_inferior (&argv[2], &status);