From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14308 invoked by alias); 22 Sep 2007 02:31:39 -0000 Received: (qmail 14300 invoked by uid 22791); 22 Sep 2007 02:31:38 -0000 X-Spam-Check-By: sourceware.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 22 Sep 2007 02:31:36 +0000 Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 38C1165154 for ; Sat, 22 Sep 2007 02:31:34 +0000 (UTC) From: Mike Frysinger Reply-To: Mike Frysinger , Mike Frysinger To: gdb-patches@sourceware.org Subject: [patch] early abort if child spawning failed Date: Sat, 22 Sep 2007 02:31:00 -0000 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_v5H9GIcqr7xWc7I" Message-Id: <200709212231.11507.vapier@gentoo.org> 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: 2007-09/txt/msg00287.txt.bz2 --Boundary-00=_v5H9GIcqr7xWc7I Content-Type: multipart/signed; boundary="nextPart1246755.0I0Gm0Eu3H"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart1246755.0I0Gm0Eu3H Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 610 if you use gdbserver to listen on a port and the specified program fails to= =20 launch properly, the server process will continue on to the accept() call a= nd=20 sit there forever ... you cant control+c the process as the signals are tak= en=20 over which means you have to connect with gdb to force the server to re-che= ck=20 itself and then abort ... all in all, a pita for a simple typo. the attached patch checks the status field immediately after launch rather= =20 than falling down into the main loop and waiting for the remote debugger to= =20 connect for the status to get properly checked. -mike --nextPart1246755.0I0Gm0Eu3H Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. Content-length: 827 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.7 (GNU/Linux) iQIVAwUARvR+b0FjO5/oN/WBAQJJbBAAsfWXXZNM3I1xoRvAnimfxA46Fk9hrft9 3txPHZcEcKZ+PMgdy5ZK9oBAWKblRwYayUpgVDHta5SIS1BWVzlu9GrYpV/r9DUh K2aEWfwXS7OvEQ6nnL6dYbCcbLMElRgLMILxOZu1E0qNvMTX4APoaGSTI6S6qLcV UZYVbAdckW65jsobTJmn4l5RBvqJlVCtbL6Rjn5/iHOe7yoAMU9964L/gCXjxaZz pHjSheOecbRymiAwDSB1J5F2ZPU0FNBAjJNpIJrVj87k3PK7ohkOKLmf384Lb9WV CDVON1BA9ZNrb2+btpBChnug36E8K1O/DeKexAKlWFzG2+nipxsfCKFPerxuNLo0 H0INmXHFSVRx6iwWAYbLCMyphB5/L5z4HrNTPl9g9HoWdUxjpBfEtRcTYMdRoZV7 1VPOTuXsEym8E+VV6u7Bc3e9NrZhyskRmgkAqUluVSkeggajkX3J3ezxx0j1QvfK BUrVotQ6J48XX87Ut7hU/WOpnh+aM58tdKO2QAsuahftnwA0sp8hX+XD6EoF4o5U M92qxZ2Rw+WJPEh9U43sdIl5fmj6tYhlaoj8Cv8gEvVRYXLJ2pEimDagDCxA/76j sx3mrpFU50PP6DAZX/MV3QtxnQ2j9iDD45QLiKD41n/mV48AixRjzdMtKpTnm9b6 mEXh7tCj1BU= =Typu -----END PGP SIGNATURE----- --nextPart1246755.0I0Gm0Eu3H-- --Boundary-00=_v5H9GIcqr7xWc7I Content-Type: text/x-diff; charset="us-ascii"; name="gdbserver-check-initial-startup.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gdbserver-check-initial-startup.patch" Content-length: 997 2007-09-21 Mike Frysinger * server.c (main): Check status after start_inferior. Index: server.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.c,v retrieving revision 1.56 diff -u -p -r1.56 server.c --- server.c 23 Aug 2007 18:08:48 -0000 1.56 +++ server.c 22 Sep 2007 02:30:10 -0000 @@ -900,9 +900,14 @@ main (int argc, char *argv[]) /* Wait till we are at first instruction in program. */ signal = start_inferior (&argv[2], &status); + if (status == 'W' || status == 'X') + { + fprintf (stderr, "Aborting server; child exited with %i\n", signal); + exit (signal); + } + /* We are now (hopefully) stopped at the first instruction of - the target process. This assumes that the target process was - successfully created. */ + the target process. */ /* Don't report shared library events on the initial connection, even if some libraries are preloaded. */ --Boundary-00=_v5H9GIcqr7xWc7I--