From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5968 invoked by alias); 6 May 2016 12:45:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5527 invoked by uid 89); 6 May 2016 12:45:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 06 May 2016 12:45:16 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4F6747AE97 for ; Fri, 6 May 2016 12:35:26 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u46CZ5IJ017259 for ; Fri, 6 May 2016 08:35:25 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v3 22/34] Fix for spurious prompts in secondary UIs Date: Fri, 06 May 2016 12:45:00 -0000 Message-Id: <1462538104-19109-23-git-send-email-palves@redhat.com> In-Reply-To: <1462538104-19109-1-git-send-email-palves@redhat.com> References: <1462538104-19109-1-git-send-email-palves@redhat.com> X-SW-Source: 2016-05/txt/msg00127.txt.bz2 Running mi-break.exp with MI on a secondary UI reveals that MI emits spurious prompts compared MI running as primary UI: -exec-continue ^running *running,thread-id="all" (gdb) =breakpoint-modified,bkpt={number="9",type="breakpoint",disp="keep",enabled="y",func="callee2",line="39",script={"set $i=0","while $i<10","print $i","set $i=$i+1","end","continue"}} ~"\n" ~"Breakpoint 9, callee2 (intarg=2, strarg=0x400730 \"A string argument.\") at ...src/gdb/testsuite/gdb.mi/basics.c:39\n" ~"39\t callee3 (strarg);\n" *stopped,reason="breakpoint-hit",disp="keep",bkptno="9",frame={addr="0x00000000004005dd",func="callee2",... *running,thread-id="all" >> (gdb) =breakpoint-modified,bkpt={number="9",... ~"\n" ~"Breakpoint 9, callee2 (intarg=2, strarg=0x400730 \"A string argument.\") at ...src/gdb/testsuite/gdb.mi/basics.c:39\n" ~"39\t callee3 (strarg);\n" *stopped,reason="breakpoint-hit",disp="keep",bkptno="9",... *running,thread-id="all" ~"[Inferior 1 (process 12639) exited normally]\n" =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1",exit-code="0" *stopped,reason="exited-normally" FAIL: gdb.mi/mi-break.exp: intermediate stop and continue FAIL: gdb.mi/mi-break.exp: test hitting breakpoint with commands (timeout) Note the line marked >> above. The test sets a breakpoint that runs "continue", a foreground command. When we get to run the "continue", we've already emitted the *stopped event on the MI UI, and set its prompt state to PROMPT_NEEDED (this is done from within normal_stop). Since inferior events are always handled with the main UI as current UI, breakpoint commands always run with the main UI as current UI too. This means that the "continue" ends up always disabling the prompt on the main UI, instead of the UI that had just been done with synchronous execution. I think we'll want to extend this with a concept of "set of threads/inferiors a UI/interpreter is blocked waiting on", but I'm leaving that for a separate series. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * infcmd.c (prepare_execution_command): Use all_uis_on_sync_execution_starting. * infrun.c (all_uis_on_sync_execution_starting): New function. * infrun.h (all_uis_on_sync_execution_starting): Declare. --- gdb/infcmd.c | 2 +- gdb/infrun.c | 14 ++++++++++++++ gdb/infrun.h | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 813d11a..a1d4d5d 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -510,7 +510,7 @@ prepare_execution_command (struct target_ops *target, int background) simulate synchronous (fg) execution. Note no cleanup is necessary for this. stdin is re-enabled whenever an error reaches the top level. */ - async_disable_stdin (); + all_uis_on_sync_execution_starting (); } } diff --git a/gdb/infrun.c b/gdb/infrun.c index b9b32c9..cc793c3 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3877,6 +3877,20 @@ all_uis_check_sync_execution_done (void) } } +/* See infrun.h. */ + +void +all_uis_on_sync_execution_starting (void) +{ + struct switch_thru_all_uis state; + + SWITCH_THRU_ALL_UIS (state) + { + if (current_ui->prompt_state == PROMPT_NEEDED) + async_disable_stdin (); + } +} + /* A cleanup that restores the execution direction to the value saved in *ARG. */ diff --git a/gdb/infrun.h b/gdb/infrun.h index 01eff9a..39be375 100644 --- a/gdb/infrun.h +++ b/gdb/infrun.h @@ -238,4 +238,9 @@ extern void maybe_remove_breakpoints (void); ready for input). */ extern void all_uis_check_sync_execution_done (void); +/* If a UI was in sync execution mode, and hasn't displayed the prompt + yet, re-disable its prompt (a synchronous execution command was + started or re-started). */ +extern void all_uis_on_sync_execution_starting (void); + #endif /* INFRUN_H */ -- 2.5.5