From: dje@google.com (Doug Evans)
To: gdb-patches@sourceware.org
Subject: [RFA] Don't kill inferior if there's a typo in the specified port.
Date: Fri, 10 Apr 2009 23:18:00 -0000 [thread overview]
Message-ID: <20090410231814.40469846AB@localhost> (raw)
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);
}
next reply other threads:[~2009-04-10 23:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-10 23:18 Doug Evans [this message]
2009-04-11 15:03 ` Pedro Alves
2009-04-13 18:49 ` Doug Evans
2009-04-30 21:51 ` Doug Evans
2009-04-30 22:16 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090410231814.40469846AB@localhost \
--to=dje@google.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox