From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches@sourceware.org, "Metzger,
Markus T" <markus.t.metzger@intel.com>
Subject: Re: [patch] Fix remote.c incorrectly using pop_target (wrt btrace)
Date: Fri, 15 Mar 2013 22:29:00 -0000 [thread overview]
Message-ID: <20130315195451.GB19841@host2.jankratochvil.net> (raw)
In-Reply-To: <513EFD81.6050401@codesourcery.com>
On Tue, 12 Mar 2013 11:03:45 +0100, Yao Qi wrote:
> On 03/12/2013 01:28 AM, Jan Kratochvil wrote:
> >@@ -4348,7 +4344,7 @@ remote_open_1 (char *name, int from_tty,
> > /* Pop the partially set up target - unless something else did
> > already before throwing the exception. */
> > if (remote_desc != NULL)
> >- pop_target ();
> >+ remote_unpush_target ();
>
> Since it is in remote_open_1, the remote target or exteneded-remote
> target is just pushed and top most, so pop_target should be fine
> here. It is not necessary to change it to remote_unpush_target.
OK; but one should remove pop_target later, there remain only few uses of it.
When its use is not incorrect it is at least fragile/dangerous.
> Is it what we want? When GDB is in record-btrace target, and get
> some errors in communication, both record-btrace and remote target
> should be popped from the stack.
It causes on killed gdbserver:
(gdb) stepi
You can't do that when your target is `record-btrace'
(gdb) _
As btrace target then no longer has methods it expects underneath.
So I have changed remote_unpush_target below.
Testing of this patch generally requires:
[patch+7.6] Fix 7.5 regression crashing GDB if gdbserver dies
http://sourceware.org/ml/gdb-patches/2013-03/msg00691.html
Message-ID: <20130315195359.GA19841@host2.jankratochvil.net>
No regressions on {x86_64,x86_64-m32,i686}-fedora19pre-linux-gnu and with
gdbserver.
Thanks,
Jan
gdb/
2013-03-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* remote.c (remote_unpush_target): New function.
(remote_open_1): Remove two pop_target calls, update one comment, add
comment to target_preopen call. Replace pop_target call by
remote_unpush_target call.
(interrupt_query, readchar, getpkt_or_notif_sane_1): Replace
pop_target calls by remote_unpush_target calls.
diff --git a/gdb/remote.c b/gdb/remote.c
index 21d86f7..207180d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4188,6 +4188,14 @@ remote_query_supported (void)
}
}
+/* Remove any of the remote.c targets from target stack. Upper targets depend
+ on it so remove them first. */
+
+static void
+remote_unpush_target (void)
+{
+ pop_all_targets_above (process_stratum - 1, 0);
+}
static void
remote_open_1 (char *name, int from_tty,
@@ -4205,30 +4213,18 @@ remote_open_1 (char *name, int from_tty,
wait_forever_enabled_p = 1;
/* If we're connected to a running target, target_preopen will kill it.
- But if we're connected to a target system with no running process,
- then we will still be connected when it returns. Ask this question
- first, before target_preopen has a chance to kill anything. */
+ Ask this question first, before target_preopen has a chance to kill
+ anything. */
if (remote_desc != NULL && !have_inferiors ())
{
- if (!from_tty
- || query (_("Already connected to a remote target. Disconnect? ")))
- pop_target ();
- else
+ if (from_tty
+ && !query (_("Already connected to a remote target. Disconnect? ")))
error (_("Still connected."));
}
+ /* Here the possibly existing remote target gets unpushed. */
target_preopen (from_tty);
- unpush_target (target);
-
- /* This time without a query. If we were connected to an
- extended-remote target and target_preopen killed the running
- process, we may still be connected. If we are starting "target
- remote" now, the extended-remote target will not have been
- removed by unpush_target. */
- if (remote_desc != NULL && !have_inferiors ())
- pop_target ();
-
/* Make sure we send the passed signals list the next time we resume. */
xfree (last_pass_packet);
last_pass_packet = NULL;
@@ -4348,7 +4344,7 @@ remote_open_1 (char *name, int from_tty,
/* Pop the partially set up target - unless something else did
already before throwing the exception. */
if (remote_desc != NULL)
- pop_target ();
+ remote_unpush_target ();
if (target_async_permitted)
wait_forever_enabled_p = 1;
throw_exception (ex);
@@ -5096,7 +5092,7 @@ interrupt_query (void)
if (query (_("Interrupted while waiting for the program.\n\
Give up (and stop debugging it)? ")))
{
- pop_target ();
+ remote_unpush_target ();
deprecated_throw_reason (RETURN_QUIT);
}
}
@@ -7051,11 +7047,11 @@ readchar (int timeout)
switch ((enum serial_rc) ch)
{
case SERIAL_EOF:
- pop_target ();
+ remote_unpush_target ();
error (_("Remote connection closed"));
/* no return */
case SERIAL_ERROR:
- pop_target ();
+ remote_unpush_target ();
perror_with_name (_("Remote communication error. "
"Target disconnected."));
/* no return */
@@ -7579,7 +7575,7 @@ getpkt_or_notif_sane_1 (char **buf, long *sizeof_buf, int forever,
if (forever) /* Watchdog went off? Kill the target. */
{
QUIT;
- pop_target ();
+ remote_unpush_target ();
error (_("Watchdog timeout has expired. Target detached."));
}
if (remote_debug)
next prev parent reply other threads:[~2013-03-15 19:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-11 17:29 Jan Kratochvil
2013-03-11 17:46 ` Joel Brobecker
2013-03-12 10:05 ` Yao Qi
2013-03-15 22:29 ` Jan Kratochvil [this message]
2013-03-18 2:09 ` Yao Qi
2013-03-22 19:28 ` Pedro Alves
2013-03-22 20:31 ` [commit+7.6] " Jan Kratochvil
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=20130315195451.GB19841@host2.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=markus.t.metzger@intel.com \
--cc=yao@codesourcery.com \
/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