Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] early abort if child spawning failed
@ 2007-09-22  2:31 Mike Frysinger
  2007-09-22  3:58 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Frysinger @ 2007-09-22  2:31 UTC (permalink / raw)
  To: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 596 bytes --]

if you use gdbserver to listen on a port and the specified program fails to 
launch properly, the server process will continue on to the accept() call and 
sit there forever ... you cant control+c the process as the signals are taken 
over which means you have to connect with gdb to force the server to re-check 
itself and then abort ... all in all, a pita for a simple typo.

the attached patch checks the status field immediately after launch rather 
than falling down into the main loop and waiting for the remote debugger to 
connect for the status to get properly checked.
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

[-- Attachment #2: gdbserver-check-initial-startup.patch --]
[-- Type: text/x-diff, Size: 997 bytes --]

2007-09-21  Mike Frysinger  <vapier@gentoo.org>

	* 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.  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-09-22  4:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-22  2:31 [patch] early abort if child spawning failed Mike Frysinger
2007-09-22  3:58 ` Daniel Jacobowitz
2007-09-22  4:18   ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox