Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* gdbserver with reversed arguments goes into an infinite loop
@ 2006-12-13  9:58 Denis PILAT
  2006-12-13 13:37 ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Denis PILAT @ 2006-12-13  9:58 UTC (permalink / raw)
  To: gdb-patches

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);







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

end of thread, other threads:[~2007-01-03  9:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-13  9:58 gdbserver with reversed arguments goes into an infinite loop Denis PILAT
2006-12-13 13:37 ` Daniel Jacobowitz
2006-12-13 15:46   ` Denis PILAT
2006-12-30 15:45     ` Daniel Jacobowitz
2007-01-03  9:08       ` Denis PILAT

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