From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125845 invoked by alias); 10 Feb 2017 18:07:27 -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 125821 invoked by uid 89); 10 Feb 2017 18:07:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*f:sk:85ae4ad, UIs, H*i:sk:85ae4ad, sk:pseudo- 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 ESMTP; Fri, 10 Feb 2017 18:07:16 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 3B0A36AAE6; Fri, 10 Feb 2017 18:07:16 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1AI7Dtc029058; Fri, 10 Feb 2017 13:07:14 -0500 Subject: Re: [PATCH] Don't send queries to the MI interpreter To: Simon Marchi References: <20170210163650.10334-1-simon.marchi@ericsson.com> <89904751-7015-b272-98c1-33e786f7c356@redhat.com> <85ae4ad9-acdc-c9ba-6606-a7ac2abc7e2e@redhat.com> Cc: Simon Marchi , gdb-patches@sourceware.org From: Pedro Alves Message-ID: <0d8bd42f-5964-1ac7-414a-754540db2e95@redhat.com> Date: Fri, 10 Feb 2017 18:07:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <85ae4ad9-acdc-c9ba-6606-a7ac2abc7e2e@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-02/txt/msg00268.txt.bz2 On 02/10/2017 05:44 PM, Pedro Alves wrote: > OK, I found the branch. Pushed here now: > > https://github.com/palves/gdb/commits/palves/console-pagination And re-reading the branch again, I noticed this hunk: @@ -1255,7 +1258,9 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args) way, important error messages don't get lost when talking to GDB over a pipe. */ if (current_ui->instream != current_ui->stdin_stream - || !input_interactive_p (current_ui)) + || !input_interactive_p (current_ui) + /* We can't handle nested queries. */ + || current_ui != main_ui) { old_chain = make_cleanup_restore_target_terminal (); @@ -2045,36 +2050,48 @@ begin_line (void) } } This is similar to your patch, but it handles something your version doesn't, I think. That is the case of handling the secondary channel being a CLI interpreter, not an MI one, and that UI having been started on a terminal. Until we put each UI/interpreter on its own thread, with its own event loop, we can't handle multiple UIs querying simultaneously. Picture this situation: Do this first on UI #1: (gdb) handle SIGINT SIGINT is used by the debugger. Are you sure you want to change it? (y or n) And then this on UI #2: (gdb) handle SIGTRAP SIGTRAP is used by the debugger. Are you sure you want to change it? (y or n) Now answer "yes" on UI #1. What happens? GDB incorrectly changes SIGTRAP, not SIGINT, and probably gets the UIs messed up. Why? Because we'd have this in pseudo-backtrace: #0 gdb_readline_wrapper #1 defaulted_query // for UI #2 #2 handle_command #3 execute_command ("handle SIGTRAP" .... #4 stdin_event_handler // input on UI #2 #5 gdb_do_one_event #7 gdb_readline_wrapper #8 defaulted_query // for UI #1 #9 handle_command #10 execute_command ("handle SIGINT" .... #11 stdin_event_handler // input on UI #1 #12 gdb_do_one_event #13 gdb_readline_wrapper So answering "yes", returns the read input to the query in frame #1... So that hunk addresses this by only allowing queries on the main UI, similarly to how we only enable readline on the main UI. So I think that to support multiple queries like that the simplest / most natural would be to make each UI above run on its own thread, so that each would have its own independent stack/frames. Thanks, Pedro Alves