From patchwork Tue Sep 6 18:56:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 15362 Received: (qmail 24443 invoked by alias); 6 Sep 2016 18:57:17 -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 24409 invoked by uid 89); 6 Sep 2016 18:57:15 -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, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=rfa, Presently, Hx-languages-length:2428, answered X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 06 Sep 2016 18:57:05 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtp id 1bhLYO-0007Yl-69 from Sandra_Loosemore@mentor.com for gdb-patches@sourceware.org; Tue, 06 Sep 2016 11:57:04 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 6 Sep 2016 11:57:01 -0700 To: From: Sandra Loosemore Subject: [patch, rfa] tweak to defaulted_query logic to fix gdb.mi test errors Message-ID: <57CF117B.5040106@codesourcery.com> Date: Tue, 6 Sep 2016 12:56:59 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) This patch moves the check for deprecated_query_hook before input-not-from-terminal check in defaulted_query, instead of after it. Presently, the only thing that uses deprecated_query_hook is the MI backend, which uses it to suppress the question entirely, so that the current behavior leads to the situation where nothing is printed when the input is a terminal but there is a message otherwise, which is somewhat odd. The specific problem this patch solves is a testing issue with gdbserver. mi_gdb_target_load says: mi_gdb_test "kill" ".*" "" and if the test harness is not running GDB from a terminal we get: Expecting: ^(kill[ ]+)?(.*[ ]+[(]gdb[)] [ ]*) kill &"kill\n" ~"Kill the program being debugged? (y or n) [answered Y; input not from terminal]\n" ERROR: Got interactive prompt. because it is tripping over the "\\(y or n\\) " pattern in mi_gdb_test. Of course mi_gdb_test could be fixed to recognize the "input not from terminal" message as valid, but I don't think that's the intended MI behavior. I think this is a bug in GDB, not the testsuite. OK to commit? -Sandra diff --git a/gdb/utils.c b/gdb/utils.c index 5188828..b1e08a6 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1292,6 +1292,16 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args) if (!confirm || server_command) return def_value; + if (deprecated_query_hook) + { + int res; + + old_chain = make_cleanup_restore_target_terminal (); + res = deprecated_query_hook (ctlstr, args); + do_cleanups (old_chain); + return res; + } + /* 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 @@ -1314,16 +1324,6 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args) return def_value; } - if (deprecated_query_hook) - { - int res; - - old_chain = make_cleanup_restore_target_terminal (); - res = deprecated_query_hook (ctlstr, args); - do_cleanups (old_chain); - return res; - } - /* Format the question outside of the loop, to avoid reusing args. */ question = xstrvprintf (ctlstr, args); old_chain = make_cleanup (xfree, question);