public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix double prompt output after run control MI commands with mi-async on (PR 20045)
@ 2016-05-05 20:29 Simon Marchi
  2016-05-17 18:36 ` Pedro Alves
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2016-05-05 20:29 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

When you use a run control command (-exec-run, -exec-continue,
-exec-next, ...) with mi-async on, an extra (gdb) prompt is displayed:

  -exec-continue
  ^running
  *running,thread-id="all"
  (gdb)
  (gdb)

It doesn't seem to be a big problem for front-ends, since this behavior
started in gdb 7.9 and we haven't heard anything about that.  However,
it caused me some trouble while writing a test for PR 20039 [1].

The problem comes from an extra (gdb) prompt that we write when running
in mi-async off mode to emulate a past buggy behavior.  When executing a
run control command synchronously, previous gdbs always printed a prompt
right away, even though they are not ready to accept new MI commands
until the target stops.  Only at this time should they display a prompt.
But to keep backwards compatibility apparently, we print it anyway.
Since commit 198297aaf, the condition that decides whether we should
print that "bogus" prompt or not has become true, even when running with
mi-async on.  Since we already print a prompt at the end of the
asynchronous command execution, it results in two prompts for one
command.

The proposed fix is to call target_can_async_p instead of
target_is_async_p, to make the condition:

  if (!target_can_async_p () || sync_execution)
    ... show prompt ...

That shows the prompt if we are emulating a synchronous command on top
of an asynchronous target (sync_execution) or if the target simply can't
run asynchronously (!target_can_async_p ()).

Note that this code is changed and this bug fixed by Pedro's separate
console series, but I think it would be nice to have it fixed in the
mean time.

I ran the gdb.mi directory of the testsuite with mi-async on and off, I
didn't see any regressions.

[1] https://sourceware.org/ml/gdb-patches/2016-05/msg00075.html
---
 gdb/mi/mi-interp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index b37dc96..0fe19af 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -998,7 +998,7 @@ mi_on_resume (ptid_t ptid)
 	 for MI3, and may be removed even earlier.  SYNC_EXECUTION is
 	 checked here because we only need to emit a prompt if a
 	 synchronous command was issued when the target is async.  */
-      if (!target_is_async_p () || sync_execution)
+      if (!target_can_async_p () || sync_execution)
 	fputs_unfiltered ("(gdb) \n", raw_stdout);
     }
   gdb_flush (raw_stdout);
-- 
2.8.2

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix double prompt output after run control MI commands with mi-async on (PR 20045)
  2016-05-05 20:29 [PATCH] Fix double prompt output after run control MI commands with mi-async on (PR 20045) Simon Marchi
@ 2016-05-17 18:36 ` Pedro Alves
  2016-05-18 14:22   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2016-05-17 18:36 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

OK.

I don't see a problem with putting this in 7.11.1.  It's a
regression after all.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix double prompt output after run control MI commands with mi-async on (PR 20045)
  2016-05-17 18:36 ` Pedro Alves
@ 2016-05-18 14:22   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2016-05-18 14:22 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 16-05-17 02:36 PM, Pedro Alves wrote:
> OK.
> 
> I don't see a problem with putting this in 7.11.1.  It's a
> regression after all.
> 
> Thanks,
> Pedro Alves
> 

Thanks, pushed to both master and gdb-7.11-branch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-18 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-05 20:29 [PATCH] Fix double prompt output after run control MI commands with mi-async on (PR 20045) Simon Marchi
2016-05-17 18:36 ` Pedro Alves
2016-05-18 14:22   ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).