From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC v5 6/8] fix py-finish-breakpoint.exp with always-async
Date: Thu, 20 Mar 2014 18:28:00 -0000 [thread overview]
Message-ID: <532B333D.9050204@redhat.com> (raw)
In-Reply-To: <1393957974-4521-7-git-send-email-tromey@redhat.com>
Hi,
I somehow neglected to respond to your response to:
https://sourceware.org/ml/gdb-patches/2013-11/msg00298.html
at:
https://sourceware.org/ml/gdb-patches/2013-12/msg00349.html
I investigated this further in the direction of my comments,
and extended the commit log with the resulting details.
Here's what I pushed.
Thanks.
-----------------
From: Tom Tromey <tromey@redhat.com>
Fix py-finish-breakpoint.exp with target async.
With target async enabled, py-finish-breakpoint.exp triggers an
assertion failure.
The failure occurs because execute_command re-enters the event loop in
some circumstances, and in this case resets the sync_execution flag.
Then later GDB reaches this assertion in normal_stop:
gdb_assert (sync_execution || !target_can_async_p ());
In detail:
#1 - A synchronous execution command is run. sync_execution is set.
#2 - A python breakpoint is hit (TARGET_WAITKIND_STOPPED), and the
corresponding Python breakpoint's stop method is executed. When
and while python commands are executed, interpreter_async is
forced to 0.
#3 - The Python stop method happens to execute a not-execution-related
gdb command. In this case, "where 1".
#4 - Seeing that sync_execution is set, execute_command nests a new
event loop (although that wasn't necessary; this is the problem).
#5 - The linux-nat target's pipe in the event loop happens to be
marked. That's normal, due to this in linux_nat_wait:
/* If we requested any event, and something came out, assume there
may be more. If we requested a specific lwp or process, also
assume there may be more. */
The nested event loop thus immediately wakes up and calls
target_wait. No thread is actually executing in the inferior, so
the target returns TARGET_WAITKIND_NO_RESUMED.
#6 - normal_stop is reached. GDB prints "No unwaited-for children
left.", and resets the sync_execution flag (IOW, there are no
resumed threads left, so the synchronous command is considered
completed.) This is already bogus. We were handling a
breakpoint!
#7 - the nested event loop unwinds/ends. GDB is now back to handling
the python stop method (TARGET_WAITKIND_STOPPED), which decides
the breakpoint should stop. normal_stop is called for this
event. However, normal_stop actually works with the _last_
reported target status:
void
normal_stop (void)
{
struct target_waitstatus last;
ptid_t last_ptid;
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
...
get_last_target_status (&last_ptid, &last);
...
if (last.kind == TARGET_WAITKIND_NO_RESUMED)
{
gdb_assert (sync_execution || !target_can_async_p ());
target_terminal_ours_for_output ();
printf_filtered (_("No unwaited-for children left.\n"));
}
And due to the nesting in execute command, the last event is now
TARGET_WAITKIND_NO_RESUMED, not the actual breakpoint event being
handled. This could be seen to be broken in itself, but we can
leave fixing that for another pass. The assertion is reached, and
fails.
execute_command has a comment explaining when it should synchronously
wait for events:
/* If the interpreter is in sync mode (we're running a user
command's list, running command hooks or similars), and we
just ran a synchronous command that started the target, wait
for that command to end. */
However, the code did not follow this comment -- it didn't check to
see if the command actually started the target, just whether the
target was executing a sync command at this point.
This patch fixes the problem by noting whether the target was
executing in sync_execution mode before running the command, and then
augmenting the condition to test this as well.
2014-03-20 Tom Tromey <tromey@redhat.com>
PR gdb/14135
* top.c (execute_command): Only dispatch events if the command
started the target.
---
gdb/ChangeLog | 6 ++++++
gdb/top.c | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index acb25f8..1db0ee9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2014-03-20 Tom Tromey <tromey@redhat.com>
+ PR gdb/14135
+ * top.c (execute_command): Only dispatch events if the command
+ started the target.
+
+2014-03-20 Tom Tromey <tromey@redhat.com>
+
PR cli/15718
* infcall.c: Include event-top.h.
(run_inferior_call): Call async_disable_stdin if needed.
diff --git a/gdb/top.c b/gdb/top.c
index e1a1331..fa20025 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -406,6 +406,8 @@ execute_command (char *p, int from_tty)
{
const char *cmd = p;
char *arg;
+ int was_sync = sync_execution;
+
line = p;
/* If trace-commands is set then this will print this command. */
@@ -461,7 +463,7 @@ execute_command (char *p, int from_tty)
command's list, running command hooks or similars), and we
just ran a synchronous command that started the target, wait
for that command to end. */
- if (!interpreter_async && sync_execution)
+ if (!interpreter_async && !was_sync && sync_execution)
{
while (gdb_do_one_event () >= 0)
if (!sync_execution)
--
1.7.11.7
prev parent reply other threads:[~2014-03-20 18:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-04 18:33 [RFC v5 0/8] enable target-async by default Tom Tromey
2014-03-04 18:33 ` [RFC v5 5/8] make dprintf.exp pass in always-async mode Tom Tromey
2014-03-20 18:04 ` Pedro Alves
2014-03-04 18:33 ` [RFC v5 1/8] fix latent bugs in ui-out.c Tom Tromey
2014-03-17 19:16 ` Pedro Alves
2014-03-04 18:33 ` [RFC v5 2/8] PR gdb/13860: make -interpreter-exec console "list" behave more like "list" Tom Tromey
2014-03-18 16:04 ` [RFC v6] " Pedro Alves
2014-05-21 22:16 ` Pedro Alves
2014-03-04 18:33 ` [RFC v5 7/8] separate MI and target notions of async Tom Tromey
2014-03-04 18:40 ` Eli Zaretskii
2014-03-04 19:11 ` Tom Tromey
2014-05-23 20:45 ` Pedro Alves
2014-03-04 18:33 ` [RFC v5 3/8] PR gdb/13860: make "-exec-foo"'s MI output equal to "foo"'s MI output Tom Tromey
2014-03-04 18:33 ` [RFC v5 8/8] enable target-async by default Tom Tromey
2014-03-04 18:33 ` [RFC v5 4/8] PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s output in async mode Tom Tromey
2014-03-18 19:01 ` [RFC v6 " Pedro Alves
2014-05-21 22:37 ` Pedro Alves
2014-03-04 18:40 ` [RFC v5 6/8] fix py-finish-breakpoint.exp with always-async Tom Tromey
2014-03-20 18:28 ` Pedro Alves [this message]
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=532B333D.9050204@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.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