From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126622 invoked by alias); 10 Feb 2017 19:06:23 -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 126598 invoked by uid 89); 10 Feb 2017 19:06:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 spammy=too!, pressing X-HELO: sesbmg23.ericsson.net Received: from sesbmg23.ericsson.net (HELO sesbmg23.ericsson.net) (193.180.251.37) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Feb 2017 19:06:12 +0000 Received: from ESESSHC019.ericsson.se (Unknown_Domain [153.88.183.75]) by (Symantec Mail Security) with SMTP id 0F.B1.27784.12F0E985; Fri, 10 Feb 2017 20:06:10 +0100 (CET) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 10 Feb 2017 20:06:08 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [142.133.48.238] (192.75.88.130) by DB4PR07MB394.eurprd07.prod.outlook.com (10.141.236.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.5; Fri, 10 Feb 2017 19:06:04 +0000 Subject: Re: [PATCH] Don't send queries to the MI interpreter To: Pedro Alves , Simon Marchi References: <20170210163650.10334-1-simon.marchi@ericsson.com> <89904751-7015-b272-98c1-33e786f7c356@redhat.com> <85ae4ad9-acdc-c9ba-6606-a7ac2abc7e2e@redhat.com> <0d8bd42f-5964-1ac7-414a-754540db2e95@redhat.com> CC: From: Simon Marchi Message-ID: <71cf7c59-8b3c-595d-b4ec-69f44ae3d6fc@ericsson.com> Date: Fri, 10 Feb 2017 19:06:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <0d8bd42f-5964-1ac7-414a-754540db2e95@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MWHPR10CA0005.namprd10.prod.outlook.com (10.172.48.15) To DB4PR07MB394.eurprd07.prod.outlook.com (10.141.236.17) X-MS-Office365-Filtering-Correlation-Id: e9467fb0-9dc9-4001-522f-08d451e7dd08 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB4PR07MB394; X-Microsoft-Exchange-Diagnostics: 1;DB4PR07MB394;3:iSN53aIeP94j5+W68Hfod9fXQchuCAO8T7KilAIvAE10p3KBGznIWn7kxr7TQ+6bDGLRJH92sMv2/CFoq2U/RXbzQVHb/uekX8KoPHFBd4Wzvzic+WzpCZXsvMu7/uJUUTVWn15bX5a8HlD5c0bS0PaIAufX1xPa1/AfeQTAIz8YdBfEH8cUZZ66gRsuds2u50HHcxhzGOqxEav5zb5Gfabu9J8iJnkEGAzH3eMmHg7zzTuftn/8b/jnOKKvxj3FxpFeii+KxxopDynjrmjAvQ==;25:KQXHYalc3uRffD3OcIT1tajx/VPE6B7v8pU0Z4gZrJq9ncmCXTV5V8Exn6VJ2Ri4OQnNzBcrtqpXbMOnWATMIxVfTbKyswbQhCPbQ2ek6/w+sa+v1s2T1HzaMWvdI6+0cgUoah+fgfv9EokX1Pq+P/SIotfFSP1XX39hj8cKeSpyOnSKt8a+QARy4g8riiKidvzVg1O/X8vWUfTTIC7ZImlZq9dJR2qphXrwuMwcCAGNs0RptE59I8EwZHHCuBxnPMOVAH/zx9o/2SXhWAh59Soiq6urg1aNFFkFXuaebXIDWsKbzPLWdVUgxN7QmymDUTGmuGEq6wM/j1MS8QUgUR42wZam2lsmgMYt7xPc762R0aYTZFPyaxbUKs2VYkFepBJgWeNWmGOyVD6cGAkjJ5q9ouocOBf4jzAweBqyyogv+1uEgteX+jCIvk8S6l1E18MYIwJrMY75hFZYSVKPmA== X-Microsoft-Exchange-Diagnostics: 1;DB4PR07MB394;31:VkfGqdP7D8wZQDoJNQFS1aS2125D9OpNJEfZcjAyOSz9SZpTaMyzc7MJiSuIXrfMUIk8KxSJ7Qu+GbcJZV1QA2jWr3Wcv8WFHrVAOTcVSlT+U/leco+cte83bWLAnh7NSuyl87Wfl/Vcx/qSeiRnZv8zxkDVkLoBYuS6khdK0480v8siPYRNOFU7m6JOwS2+VSFdqqYnuUaB95tiROVCSOCzgOX66VFo16g2Ct2I3nBGWROhAe4SG78H7vuFBxixh9psz2phL4VndxeS4xcazY9oTkQB6HWWeCaELCN68IE=;20:1Tk3gJ3FDEWq5V8VSmmAAxPZJWu73dZMuqXNW23GnIst9SpFVcEjpUDV5pxghyrAlT8JInH+iU7KNLGbdlrCv9SyOV2zF1xe46X8A99R7ojwph3TxrOihQEjJvfx7XCR9hQ0YfQooWbUetgZ+UanrSZUdEXMr2nQ8XufTLeJemMh1JcL1lc/jWcJN3m37ZZC/6n0MtJs0VrHboZmLNNtNM/Xhpp5KB4V99Rm/q+JkjEBZ11DuVJ0q5K5/g1Mx60P/N7FUbWTSA97Oa82nK7LZtODiVyxiu4ISxYqJQyqzP7eQFD0ULL9KXEXF9cXrwXwcbhnDXM82v9Qn5a5upwmHDrCDL9/YDvVP98SYIEOnSwaPHtBddOkrLmNBiejzGwxa9pXI8Ay62OFf0w+hNbUgCh6V1RWy2DOuEqwOhjzzueFTuv/1SyQVytNhG7383eBFP7XTADQzFZrGGDW2/puqj+G12ow+MVCIwNEF7sEdqgsflbjrJZO6yeZs17N9C++ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(166708455590820); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(20161123558025)(6072148);SRVR:DB4PR07MB394;BCL:0;PCL:0;RULEID:;SRVR:DB4PR07MB394; X-Microsoft-Exchange-Diagnostics: 1;DB4PR07MB394;4:2kj791VpDIwCvnIu8IS/6fICMGE+Rvhdm+s4kA5f2Sv2aYIbHcuJn3kiOZZOSNCXXfozmuTr059E2Vm7tuMo0VwVJQtVcQEE8Rrn84Tru+mZDCCQl7hukjaQVOXvhowAcGlME2NDS2d12r0LKANf5VCZqzgT0gtm2KXjMDLOcvxkm3zV6xQd62ggrPnNPc7Uj8yAubgDOak/QNeVsl5al8JyCJOZiWXT6a5xWSRXCxBhw7tGWJdMh+VRhKR9rUOWEv8EOeSp1LC+LrGsk+fOqjG/YOf3DO52Pj88mwo5pbY/GfpwBX7jpq25mDQIo3WJixmANs+KUu6Fdmohz7YBzWGErjwhsoftBRQJOMLFhkLlqfTJ2i8CmQzoV0DHvU47elZgcgxr9D1CKO1Jfs4zN5jnIWnL5gO5JVIsUQ+k7fhFGf0VLDRfrxMQ2BwROCh6bjzyE/DrZwH+v9R1QPDuZ6XUCBkzSSu/4EKOzIX/e+cckvOLytef1ERckOjFDSV+k5N4oJQHtNf25ST/mfDC07ynZuBC4Zvy87/1aG9e0JNINy5cbKRjkOg7hXqWm2JcMSNVVfn1n89Ug9ef+iyQnOT4W6YW+ygGfWAxkDvGLU3gtmf8YvtCumonsmqqSG2SjS+ao5K/Yi/5WmlR71Ffvw== X-Forefront-PRVS: 0214EB3F68 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(39450400003)(377424004)(24454002)(377454003)(51444003)(199003)(189002)(97736004)(189998001)(65826007)(36756003)(50466002)(38730400002)(83506001)(33646002)(6666003)(230700001)(90366009)(65956001)(6486002)(65806001)(305945005)(7736002)(25786008)(4001350100001)(6116002)(3846002)(5660300001)(4326007)(2906002)(53546003)(92566002)(6246003)(54356999)(76176999)(101416001)(229853002)(6306002)(66066001)(50986999)(31686004)(86362001)(68736007)(42186005)(47776003)(31696002)(93886004)(105586002)(81156014)(81166006)(8676002)(106356001)(2950100002)(53936002)(64126003)(23746002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB4PR07MB394;H:[142.133.48.238];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DB4PR07MB394;23:Y5CBEB0yqujLL/QtlIKg/UUdvhUyWaNORWMqb/?= =?Windows-1252?Q?t3TuBsBcFtp4/zFZTGBb8yE3/81+/zkfA4IRSJhW/B5jcUmDTSce98ml?= =?Windows-1252?Q?LaIbPcC+RBaghKbma3SJZyGHDYg9DYrkhfED9Xsw59G/AHVsPUpLPREP?= =?Windows-1252?Q?SZhPL8HYDw1JTeYLTB8FbtfvUSJrlRgYo4S2IjLUpr9db1A1QRm1XZo7?= =?Windows-1252?Q?fPEmaAJI0gcCSn6WswSAhd7Q1PU+vvEE1s7iuIGocmVTzLvf9sckQyM0?= =?Windows-1252?Q?BU14aP9/FRUG7THijs024YKYEjtNNVZCo7sPc7lGcsHEIwJOTBg5vohg?= =?Windows-1252?Q?krtlEfla3oiaz+aGtP3OLbgdyWKp0Bp9TsgyRnT/lP5o6pXtha541Iwp?= =?Windows-1252?Q?5c1wJjZ6Jvx1s46FFrETOIDsxDjs+E6hxkFvf/AO2An9B3DbO6mNxlzK?= =?Windows-1252?Q?yuQxw8YWEfBerYAnv+dUlqt17OS9AJmFNlBLEXR01ewRhnBm0mKpOZpC?= =?Windows-1252?Q?85+yh9qW95CJ9icvowmr+zX9dGqEUoQSW7zvtemsxaSbh3FFFFUHU7BT?= =?Windows-1252?Q?/aKgzH+2C/RymhZGvPyTtWb+QX/EO8Wv/4yOh6Wgv0IsrNt1unZG82pC?= =?Windows-1252?Q?nQS7rXzXxN/fCd/WL1d1n7rufmleefzpMrVE8vbyYiWAFrKi3p+DfG94?= =?Windows-1252?Q?uClLiuRdJ6paOkJHuUjv2AhIlOmSAMQsoZ7uQlCy8O4MbmZDbW0shV9Y?= =?Windows-1252?Q?Fz4PvePgT0FFh9vRM+JWkeq8szjowErZuvtROCr1fZL9+j7x/TmonYWF?= =?Windows-1252?Q?EjPbFwi7xjaRrXhnxep/YTI0HLyURjjRyU9DGfcEKAAdLK2/Whp+Pdyb?= =?Windows-1252?Q?L9ggJS4MfCpT73bza7cIwwAeES0/ek2fySOKm4+g/f0MtGxiPEaNtcRK?= =?Windows-1252?Q?tGNtxXdHzpLdtaCo/ZGF63qNGJLhXF/tVrzwAzVSCTXd+ltkHZIW9cLL?= =?Windows-1252?Q?RXVgRSKHYekmIxPZvywI6+QlGqosm4U4xrj9kJxDYXZl4rnPReQnKJjz?= =?Windows-1252?Q?U5/Qfbr6z4BEN5KaRVIsobWCMgIqXwgnZvzjWKSRZakzmZG8RuWPId0k?= =?Windows-1252?Q?rpZucUdxCryw+VE6fliu9lLnzykKEba+PzNMGsWHT+76Fkelk7fua1P8?= =?Windows-1252?Q?5Cl7FjWN0fF2P7LtfwyfgVSsI2ZoX4W8SxENdRoyottyG89Pe2XbUSZG?= =?Windows-1252?Q?snKi5E/E+w2ZVv31bhEYfqhekp77z/SCVOPYQATim1+7qyt4rLGUNiqz?= =?Windows-1252?Q?qlKnEHZnp6TaxPXm5HuCQN2jMtdI9yYSusr4Kt/AvYG7HWS2OMovE4V7?= =?Windows-1252?Q?3HHXZ8kyA5CH7iHMzYzl4gSICo7JB1QcgGzYt+n37LvyiLaburkrCHrr?= =?Windows-1252?Q?JMktmlTLxtXpiRimJCSWBXV792QqkhZi5RURQfzx3lTjrMxJGCvU78L5?= =?Windows-1252?Q?tSm5SVAlW4hny66UG6diFssPwBtADh9sc4evE+U3EF08NNCg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;DB4PR07MB394;6:eGPyJBltZv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mStXEdza3Mva/rl2nZDSlKPxlj5djKnDPGY/vEsyXErA08YiK5sGjZmAIBtx8iiDGIcRuwSK3ay//y3LCtZNQK0wBwKo0UMp01yLnwSAljzEP12eTlVIUD4mdXH+rh6aoTL12xlECHd2ppLNYwWX2RNmvUeIkuZkDL79f4gvdMJlBZciuU1Plf4IwmRzvPw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2017 19:06:04.2906 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR07MB394 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00272.txt.bz2 On 17-02-10 01:07 PM, Pedro Alves wrote: > 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. Indeed, it crashes too! (gdb) handle SIGINT SIGINT is used by the debugger. Are you sure you want to change it? (y or n) y y readline: readline_callback_read_char() called with no handler! [1] 15931 abort (core dumped) ./gdb -nx test -ex "new-ui console /dev/pts/27" -ex "start" -ex "b main" > 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. The idea of only allowing queries on the main UI was also brought up in discussions here. I initially thought it was a bit too arbitrary, and that we would want some on secondary UIs. However, realistically, the only use case of new-ui we know about so far is CLI as the main UI and MI as a secondary UI. Plus, since there won't be readline on secondary CLI UIs, they will already be "dumbed" down, so I think it's fine to not have queries as well... So I think your suggestion is good, at least until we discover that people use multiple CLI UIs at the same time. Note that we can trigger the same bug you mentioned higher with pagination. For example, I have a huge list of breakpoints and I do "info break" on UI #1 then on UI #2. Pressing enter on UI #1 unblocks UI #2, and the following enter crashes GDB. So should we also say that pagination is only allowed on the main UI for the same reasons? > 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. Indeed. That represents a tremendous amount of work I imagine, putting the proper locking mechanisms in place... And if you are holding a lock while the query is issued, it would still block some other things.