This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Don't kill inferior if there's a typo in the specified port.


Hi.

If there's a typo in the port gdbserver will kill the inferior.
This fixes that by calling detach_or_kill_inferior_callback
instead of kill_inferior_callback.

It also moves the status message to the callback;
it's only called when exiting gdb (and if that changes one can split
the function into silent/verbose versions).
An alternative is something like this:

-      fprintf (stderr, "Killing all inferiors\n");
+      fprintf (stderr, "Detaching or killing all inferiors\n");

but will that be confusing?
OTOH, if gdbserver ever gets used with 10's or 100's of processes,
exiting with one line per process may be a bit much.
OTOOH, the user might like to know what got detached and what got killed.
I don't know, but I can change the patch to do whatever y'all prefer.

Ok to check in?

2009-04-10  Doug Evans  <dje@google.com>

	Don't kill inferior if there's a typo in the specified port.
	* server.c (detach_or_kill_inferior_callback): Print whether we're
	detaching or killing.
	(main): Don't print "Killing all inferiors", leave message to
	detach_or_kill_inferior_callback, which we now call instead of
	kill_inferior_callback.

Index: gdbserver/server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.95
diff -u -p -u -p -r1.95 server.c]
--- gdbserver/server.c	1 Apr 2009 22:50:24 -0000	1.95
+++ gdbserver/server.c	10 Apr 2009 23:07:55 -0000
@@ -1808,6 +1808,11 @@ kill_inferior_callback (struct inferior_
   discard_queued_stop_replies (pid);
 }
 
+/* Callback for for_each_inferior to detach or kill the inferior,
+   depending on whether we attached to it or not.
+   We inform the user whether we're detaching or killing the process
+   as this is only called when gdbserver is about to exit.  */
+
 static void
 detach_or_kill_inferior_callback (struct inferior_list_entry *entry)
 {
@@ -1815,9 +1820,15 @@ detach_or_kill_inferior_callback (struct
   int pid = ptid_get_pid (process->head.id);
 
   if (process->attached)
-    detach_inferior (pid);
+    {
+      fprintf (stderr, "Detaching from %d\n", pid);
+      detach_inferior (pid);
+    }
   else
-    kill_inferior (pid);
+    {
+      fprintf (stderr, "Killing %d\n", pid);
+      kill_inferior (pid);
+    }
 
   discard_queued_stop_replies (pid);
 }
@@ -2015,9 +2026,8 @@ main (int argc, char *argv[])
 
   if (setjmp (toplevel))
     {
-      fprintf (stderr, "Killing all inferiors\n");
       for_each_inferior (&all_processes,
-			 kill_inferior_callback);
+			 detach_or_kill_inferior_callback);
       exit (1);
     }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]