From patchwork Fri Feb 10 16:36:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 19215 Received: (qmail 51709 invoked by alias); 10 Feb 2017 16:37:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 50638 invoked by uid 89); 10 Feb 2017 16:37:20 -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, SPF_PASS autolearn=ham version=3.3.2 spammy=answered, onward, pipes, streams 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 16:37:09 +0000 Received: from ESESSHC020.ericsson.se (Unknown_Domain [153.88.183.78]) by (Symantec Mail Security) with SMTP id C5.21.27784.03CED985; Fri, 10 Feb 2017 17:37:07 +0100 (CET) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.78) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 10 Feb 2017 17:37:04 +0100 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxcz23q12-y4.ca.am.ericsson.se (192.75.88.130) by AMSPR07MB392.eurprd07.prod.outlook.com (10.242.22.21) 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 16:37:02 +0000 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH] Don't send queries to the MI interpreter Date: Fri, 10 Feb 2017 11:36:50 -0500 Message-ID: <20170210163650.10334-1-simon.marchi@ericsson.com> MIME-Version: 1.0 X-ClientProxiedBy: BN6PR14CA0016.namprd14.prod.outlook.com (10.173.157.154) To AMSPR07MB392.eurprd07.prod.outlook.com (10.242.22.21) X-MS-Office365-Filtering-Correlation-Id: c94dcf1c-d2da-4be7-29a6-08d451d30b2d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AMSPR07MB392; X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB392; 3:PubZCKQnh/eSYV5F4HgVMzIvmFSqQEr0ADi8+cX2oAxz0JydrwlLz82T5Y3Nw1H/RUQCHCVMrX6B3He6vnano3/KQUxwo9Ra2X8korjUzazdVXrplhaOF9SHn6TH+as0o28jGvYeF5tTy7+d+1N4leWZpHRpwdxnYiYDi44BiTFAdcT8LYKuMM25milw7YLMG9UmLVcYS/NMuj8zodRev6OQOc0DCb0kLkk2ZIRp1TdTGc2nUqb72qJROH9nvvrMvuawx1aewsEs3dh8bgzfAQ==; 25:MS3j8VRQgxKgmmL5zCNlfDi5U4FYwigHBieAwEFTaz2MGClNpP/rEGHhYw+diDCagKY/TcEuIovtkNMb/3rn+EHdkL0Z53OV9qYVZec/YHSwEoAsz3arHmIWwqJzqk2zDlVEanOzLOv9HcW/Ew596F1dU0AgTTGxKeQLDdi723HV1VgHX38qVpXyYnNb0sG9h1Wd1AXMIGDtJFESU7AIK+CCuKEXKncdmK060ja2iPGq07Xs8ni/Suhy6TNPHpwCWVmbMKeNGpDClN/0xpM4f77on6FpvPLNv/t/oJ7hLjhGgasY/QI+Aemb8rTnNd3Jbkhy/lkVPOBjlIoUOENyV3XPg3NX3jHmb6Hrp6qVpmsQDZTh2nwuZt83IUDVWeUNxvo/7yiKzYGpO8ux+srO2ItxDgN38PYwYpmhxIro6YmK7wiAzHLNkQ1Yrg1LE171qzIoFyTxxT6pXktDrKXHVg== X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB392; 31:0FscNBYodrPw0RwVwrh1ANewr9saSgbwQ1etN0wrHW3NqO/nLrNmIExUASQR2Yrzv6nlobksAJJaotY2cEj/fGNQT8JTVieFMCcefmcwCyFIYVOqx2ZpVw4ocBtt7aSwlzV3xGcfqlRMkb/BUM34BIcxqYHW0DAmyTG5IlIgNxzwDDekaY0C+/ifK7OfcfiAtfSHvWHEZ8nhm1pYbBBmV/EoBprMJAn0B+kSDMm00IfEIfuNw7eNx38USekn0n/8; 20:1u65Tts7YhljLlocp9sv+GnE3wGRAYr96VdaXxjEd6oHj7ivXy40CNaoBSDKSrH/8SHNvSyHXhkUnWRjI2szUfpsRPL+TMd78LxNQ6zEIta8Xz+ocbEFVukU4CsY+pbivWO6JLW0IAejKggbwQR6zf89Z0Qfg1Kf+xQQtq7WR3hgFsnu4Sc0ElZTq//78foAywskR778smd4x9dNE3jlGiPcoI8iDMl4eQdhfgwCxr0OIZncKTcdNfZPlDPzEYch/UqixJtkj9zUUQDISqgfC+b2aJWWzjD+WebmmYhV3OQG3VnBxpmYisGLvMz5OxHFT2iUCMQvFrDDBFeDdHzlLOG7MP0xSAUKBAg/CADPbgLS5/vS+qlC0ZB5abQXZ8PK0z1maJJH+te4VBnHEEMEkKa+3akdaOv9CQt5YAOwpEqewFwZZ8BeHBclIHa0KYq0GADtU/YGrxDZU+XZn4JkhOAO+aGTJZ2n1cRRwg6eKycJcQ08IeTllyW/tiF8HPzt X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(158342451672863); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123562025)(20161123560025)(20161123555025)(20161123558025)(20161123564025)(6072148); SRVR:AMSPR07MB392; BCL:0; PCL:0; RULEID:; SRVR:AMSPR07MB392; X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB392; 4:KmM1afqWU6xZBYbHbQF9P3I5UK4JSwQR3tsK9fsKwYhhQ99DqyeM1WJcuOrryX/INtneuxnxYgGmDGubi492N2BB48dB8Aqd6bwhiqANr7obIjlYqIB12GoHdOVu2444bgNroMZyykr74GZKQX3Zdt5EcQPa9LEb9MT20+FPv+uGyaSdOHuLGt7k+Al1RlOz9V2CxaBqVAFxy8/bzdU+KdhumQ4Iwta3ZoR3RKN19nkG/+2n/3NAoNVae3kHvIdzpuUyhidNnHV8aLdSXW8yTqKu9jTNnI0j4i3K7SunG9YVFjpE8TXm7CjV3lua9+5UCkcsNVKZnmxKY+lqzi05d+KabFvp/O0CpmD926kpRHkaNxLwoGUAW1LD0ALP2U1++N292HKtKsWYMyORCdNMrMESDwtjOARNLuPrrYdEl8AD6KynLtrxDNOgFS2OciRsSFQHLrwdhfqBEXH4i1ozpZ9hMwQmviS+drr32xEUoX7+tw0yUAwn7ESHxUNiCRIwh31C4rBJ6xoQSL5lNeyhoMq6P7HvIIPgpFNcZgjJf2W73lKjq8zb547J0Nkp+kMcLoo8JIcq6re3xJ6Ia9Tuxc8MCGvLbnXNSKYBOnjZScDzOTQVuWkHShYAa+QLVQ9g233bcNkPtgSeBx/WhFtvDA== X-Forefront-PRVS: 0214EB3F68 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(199003)(52314003)(54534003)(189002)(2906002)(189998001)(2351001)(4326007)(5003940100001)(8676002)(66066001)(50226002)(33646002)(81166006)(81156014)(101416001)(305945005)(7736002)(97736004)(50466002)(48376002)(53936002)(92566002)(47776003)(1076002)(450100001)(106356001)(105586002)(3846002)(6116002)(42186005)(6506006)(6486002)(50986999)(5660300001)(86362001)(25786008)(6666003)(36756003)(38730400002)(110136004)(6512007)(68736007)(6916009)(107886003); DIR:OUT; SFP:1101; SCL:1; SRVR:AMSPR07MB392; H:elxcz23q12-y4.ca.am.ericsson.se; 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: =?us-ascii?Q?1; AMSPR07MB392; 23:Rytw7Rm7g4EBpdSByx2OgOssA/cObia+J4GpIIMp+5?= =?us-ascii?Q?B5HTqCt2fH5cyPp4zx/zJ8h5oA6qox1W1sa+oJYJotBexzFsd4CBoJk7rW7x?= =?us-ascii?Q?BB4nljGB016AP7yHOudAoLNpGlvj3w+xc4wd0CyFOH2Oo2StXitdVbtMkwkn?= =?us-ascii?Q?a8/dPfeOrZZPJ5PTRL2YM9atz0dZArIUz5/C9tt5Pnv3BDhq+6D2P5AQe+RT?= =?us-ascii?Q?qCOuicYvdASnuMUDXT9hNTR7YWxUDJinnRCOfsfpfMGwwTdprjlP154tuxNl?= =?us-ascii?Q?Lqg426EtNaVNfXa0UAvD2gUt9sgnF1D6XPi0QuQMj0k1borwqO2/IlIyWptV?= =?us-ascii?Q?OCS7+2sYejOy2REVRe6xNayt0ueNV3CJlgv90Jlt93XsxE/n4ovdweY6u1jU?= =?us-ascii?Q?Y3lL3nZ8/i6AfikdhfaUcjPUwSXeUa7zRRfxZv80lxazMSOPSTS2mUOGCD/w?= =?us-ascii?Q?aC5tIdzrgR6YYNV3ilD8Uzt/i9B5m5Wa+XcXARsWFdg1qzpH84QwCnO7BSAu?= =?us-ascii?Q?AeYxFpcs9p6uAE79w9YjFMOdRzqyGVuue7LZFNoXrRo1NTNIxBmkNMuOoEPz?= =?us-ascii?Q?OzGGXL8Om+0InbBQbtmOqmCyXLzT+B1OQnM1NehUuzLfsKwa6DHUyklyCInf?= =?us-ascii?Q?IuDeQapgVwCVLacpdrpjrcY1B5Vgy8yipWquRnaDfSB4KTZT5cv8lJ4Ymekg?= =?us-ascii?Q?1Ej/NGLX665Hn8/1cCsfcusGcBXJOEqIHvoQptn679J/S29WwW35PaqjQt1w?= =?us-ascii?Q?30EyI+yPI/8WdvHHeLoGTYLb+lu7RfZYEOHS5L7a++NeNdBm9g9Cs2PaS5OT?= =?us-ascii?Q?ok2yYfZPhwNUEVhapec20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AfV3teB2D208Ae3vg0NfL08URzlrINUsrz+7Z0/DGTXEgHG2PAEJpMa5mBkAOylVeSMzHO7aXPoDQI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AMSPR07MB392; 7:+ieYr3qoBexbt/ijq+CweqB1I423Bt/l0LCGgv9Tm98+WOC+4rO54Z3GQRII694w1UiB9S1Vto4nGpEX95QkaDyk1qR+Vq65Prvac4gNdhW4t/VYQu7ODZKo+cFfxDxQ9jOL2J5vy3zwdEXU6CKLhO31sororITD9WYyjtYLrjapSK9M8Gx6dVVozP3+q/tH08+u4I2kFAhxFjChJN0n160H2Db/8FV3PW4lgYgjk/3EqAnYsrq7OaNMMLDLAWaOUJZKxq/gfO+D1D87V8sanwb3YdSNHHDwd1b6wMTFdckbfMYFYGXzGKgY5NF8wZv9c/NU1pU+AU8ghny9nsgkssVdxfJnEldVLH3Y5rnfMhLXKK/NRSQHad1rx/1sKk8hUD6EMZ5f1JpXZ8vb15I3OusoYu8Y/g0QT8A0RZ+qT9XsQUG2N8FfwToeT5RjFjSiw1G0Yor9NusDrdV4M24nVmuMFO/lBiaF85e3ObMKcx/tBQYFTJbO8MWWWYEo37zS+XDGeoZgHvtG31IE7aLCDQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2017 16:37:02.9165 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMSPR07MB392 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes We have a little problem in Eclipse CDT related to queries being sent on the MI channel. GDB sends queries on the MI stream and waits for an answer (y or n), but since CDT will never answer, it causes a deadlock. Note that this is only a problem when using MI as a side-channel (new-ui) on a dedicated tty. It doesn't happen if GDB's input/output streams are pipes, for example. In that case, the queries are auto-answered as they should. The situation can be triggered by modifying a variable value while replaying. Roughly, the steps are: - Start recording (record-full) - Step forward a bit - Step backwards a bit - Change a variable using the Variables view in the UI Changing the variable uses the -var-assign command. Modifying the memory while replaying causes the following query to be sent: ~"Because GDB is in replay mode, writing to memory will make the execution \ log unusable from this point onward. Write memory at address \ 0x7fffffffdabc?(y or n) " In the past, the query would get auto-answered because GDB would consider the input as non-interactive. The criterion for this is whether the input stream is a tty (ISATTY). Now that we create the MI channel with new-ui and pass it a tty (/dev/pts/X), GDB considers the input as interactive, so the query is not auto answered. I have a hard time defining what should be the right criteria for when we should or shouldn't query. I think we'll have to take into account what is the originating interpreter, CLI or MI. A special case is when we receive CLI through MI (either -interpreter-exec console or typing directly CLI commands): it's possible that it's a human at the other end, typing in a field in the front-end, which then forwards the commands to GDB. In that case, we could want to query, since the user is there to respond. However, it would be very fragile, as the front-end should not send any command in the mean time, not reply anything else than "y" or "n" and not wrap the user response in -interpreter-exec... Currently, we never query as a result of CLI-in-MI commands anyway, because deprecated_query_hook is set. So I think we should just keep this behaviour: queries resulting from CLI-in-MI commands get auto-answered. Conveniently, when using CLI in MI, the current_interpreter stays MI (unlike when using MI in CLI), so it allows to differentiate a CLI command from a CLI-in-MI command easily. So the criteria I came up with in order to decide whether we should not auto answer are: the input should be interactive (ISATTY is true) _and_ the originating interpreter should support queries. In practice, it means the only time we are going to query is when it's a CLI command typed in a CLI UI coming from a tty. Currently, CLI supports queries and MI doesn't. However, we could imagine that some day GDB could send the query to the front-end through MI, so that it displays a nice popup. That's a whole separate topic though, since it would require changing the MI paradigm a bit. gdb/ChangeLog: * interps.h (interp::supports_queries): New. * cli-interp.h (cli_interp_base::supports_queries): New. * cli-interp.c (cli_interp_base::supports_queries): New. * utils.c (defaulted_query): Don't query if the current interpreter doesn't support queries. --- gdb/cli/cli-interp.c | 6 ++++++ gdb/cli/cli-interp.h | 1 + gdb/interps.h | 4 ++++ gdb/utils.c | 5 ++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gdb/cli/cli-interp.c b/gdb/cli/cli-interp.c index 8712c75f39..709bfbbce3 100644 --- a/gdb/cli/cli-interp.c +++ b/gdb/cli/cli-interp.c @@ -356,6 +356,12 @@ cli_interp_base::supports_command_editing () return true; } +bool +cli_interp_base::supports_queries () +{ + return true; +} + static struct gdb_exception safe_execute_command (struct ui_out *command_uiout, char *command, int from_tty) { diff --git a/gdb/cli/cli-interp.h b/gdb/cli/cli-interp.h index de9da83347..f1e966fe77 100644 --- a/gdb/cli/cli-interp.h +++ b/gdb/cli/cli-interp.h @@ -31,6 +31,7 @@ public: void set_logging (ui_file_up logfile, bool logging_redirect) override; void pre_command_loop () override; bool supports_command_editing () override; + bool supports_queries () override; }; /* Make the output ui_file to use when logging is enabled. diff --git a/gdb/interps.h b/gdb/interps.h index 1b9580c118..d328163027 100644 --- a/gdb/interps.h +++ b/gdb/interps.h @@ -76,6 +76,10 @@ public: virtual bool supports_command_editing () { return false; } + /* Returns true if this interpreter supports queries. */ + virtual bool supports_queries () + { return false; } + /* This is the name in "-i=" and "set interpreter". */ const char *name; diff --git a/gdb/utils.c b/gdb/utils.c index 3dc2f03d61..ba1db8a45b 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1170,12 +1170,15 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args) if (!confirm || server_command) return def_value; + struct interp *interp = current_interpreter (); + /* If input isn't coming from the user directly, just say what question we're asking, and then answer the default automatically. This 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) + || !interp->supports_queries ()) { old_chain = make_cleanup_restore_target_terminal ();