Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [RFC v5 7/8] separate MI and target notions of async
Date: Fri, 23 May 2014 20:45:00 -0000	[thread overview]
Message-ID: <537FB35E.7090309@redhat.com> (raw)
In-Reply-To: <1393957974-4521-8-git-send-email-tromey@redhat.com>

On 03/04/2014 06:32 PM, Tom Tromey wrote:
> This separates the MI and target notions of "async".
> 
> Unlike the CLI, MI chose to treat target-async specially -- setting it
> changes the default behavior of commands.  So, we can't get rid of the
> option.  Instead we have to make it MI-only.
> 
> Rather than make the targets always async, this patch introduces a new
> "maint" parameter so that the gdb developer can control whether the
> target is async.  This makes it simpler to debug issues arising only
> in the synchronous mode; important because it sync mode seems unlikely
> to go away.
> 
> Note that "set target-async" also affects this new maint parameter.
> The rationale for this is that then one can easily run the test suite
> in the "maint set target-async off" mode and have tests which enable
> target-async continue to work properly.  This is unusual but, but it
> is a maint command after all, and this behavior is useful.

As discussed, v6 will not have this coupling.  the idea is that
"maint set target-async off" emulates a non-async-capable target,
so "maint set target-async off" + "set target-async on" + "c&"
should result in failure to run a background command, just like
e.g., if one tries "set target-async on" + "c&" on Windows.

In v6, I'm proposing adding an "set mi-async" option, and making
"set target-async" a deprecated alias for "set mi-async" going
forward, to avoid confusion.

> 
> The hardest part of this patch, to my surprise, was getting the MI
> prompt to work properly.  It was reasonably easy, and clean, to get
> close to what the test suite expects; but to fix the last remaining
> failure (mi-async.exp), I had to resort to a hack.

I think I found a cleaner way to do this.  v6 will include it.

>  /* Command implementations.  FIXME: Is this libgdb?  No.  This is the MI
>     layer that calls libgdb.  Any operation used in the below should be
>     formalized.  */
> @@ -260,6 +269,11 @@ exec_continue (char **argv, int argc)
>      {
>        struct cleanup *back_to = make_cleanup_restore_integer (&sched_multi);
>  
> +      /* If MI is in sync mode but the target is async, then
> +	 normal_stop enabled stdin.  We undo the change here.  */

This comment threw me off for a while.  It doesn't matter what
normal_stop did in a previous command.  The code below is actually
correct, in as much as we need to do that before all execution
commands.  We can now just call prepare_execution_command to
do it for us.

> +      if (!target_async_permitted && target_can_async_p ())
> +	async_disable_stdin ();


> diff --git a/gdb/testsuite/gdb.mi/mi-cli.exp b/gdb/testsuite/gdb.mi/mi-cli.exp
> index e158b7e..8cfab3b 100644
> --- a/gdb/testsuite/gdb.mi/mi-cli.exp
> +++ b/gdb/testsuite/gdb.mi/mi-cli.exp
> @@ -134,20 +134,9 @@ mi_gdb_test "500-stack-select-frame 0" \
>    {500\^done} \
>    "-stack-select-frame 0"
>  
> -# When a CLI command is entered in MI session, the respose is different in
> -# sync and async modes. In sync mode normal_stop is called when current
> -# interpreter is CLI. So:
> -#   - print_stop_reason prints stop reason in CLI uiout, and we don't show it
> -#     in MI
> -#   - The stop position is printed, and appears in MI 'console' channel.
> -#
> -# In async mode the stop event is processed when we're back to MI interpreter,
> -# so the stop reason is printed into MI uiout an.
> -if {$async} {
> -    set reason "end-stepping-range"
> -} else {
> -    set reason ""
> -}
> +# Allow a reason, or not.  Which we get depends at least on whether
> +# the target being tested supports async.
> +set reason ".*"

This patch gets rid of this in the opposite direction:

 https://sourceware.org/ml/gdb-patches/2014-05/msg00566.html

>  mi_execute_to "interpreter-exec console step" $reason "callee4" "" ".*basics.c" $line_callee4_next \
>      "" "check *stopped from CLI command"
> diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
> index 213073a..16c7951 100644
> --- a/gdb/testsuite/lib/mi-support.exp
> +++ b/gdb/testsuite/lib/mi-support.exp
> @@ -1096,7 +1096,9 @@ proc mi_expect_stop { reason func args file line extra test } {
>      }
>  
>      set r ""
> -    if { $reason != "" } {
> +    if { $reason == ".*" } {
> +	set r "(?:reason=\".*\",)?"
> +    } elseif { $reason != "" } {
>  	set r "reason=\"$reason\","
>      }
>  

And ends up no longer necessary.

v6 coming up...  Getting close.  :-)

-- 
Pedro Alves


  parent reply	other threads:[~2014-05-23 20:45 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 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:33 ` [RFC v5 8/8] enable target-async by default Tom Tromey
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 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 [this message]
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 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 5/8] make dprintf.exp pass in always-async mode Tom Tromey
2014-03-20 18:04   ` 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

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=537FB35E.7090309@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