Re: [PATCH v2 8/9] fix py-finish-breakpoint.exp with always-async

Doug Evans
2013-07-31T19:41:21Z

Tom Tromey writes:
> With target async enabled, py-finish-breakpoint.exp will trigger 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 ());
>
> execute_command has a comment explaining why it dispatches 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 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.
>
> Built and regtested on x86-64 Fedora 18.
>
> PR gdb/14135:
> * top.c (execute_command): Only dispatch events if command
> started target.
> ---
> gdb/top.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/top.c b/gdb/top.c
> index 33a78da..03038b6 100644
> --- a/gdb/top.c
> +++ b/gdb/top.c
> @@ -427,6 +427,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. */
> @@ -482,7 +484,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)
> --

Looks ok to me.