Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sandra Loosemore <sandra@codesourcery.com>
To: <gdb-patches@sourceware.org>
Subject: [patch, rfa] tweak to defaulted_query logic to fix gdb.mi test errors
Date: Tue, 06 Sep 2016 18:57:00 -0000	[thread overview]
Message-ID: <57CF117B.5040106@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

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


[-- Attachment #2: gdb-query-fsf.log --]
[-- Type: text/x-log, Size: 165 bytes --]

2016-09-06  Sandra Loosemore  <sandra@codesourcery.com>

	gdb/
	* utils.c (defaulted_query): Swap order of deprecated_query_hook
	and input-not-from-terminal cases.

[-- Attachment #3: gdb-query-fsf.patch --]
[-- Type: text/x-patch, Size: 1217 bytes --]

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);

             reply	other threads:[~2016-09-06 18:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 18:57 Sandra Loosemore [this message]
2016-10-18 16:09 ` Luis Machado
2016-10-18 20:17 ` Yao Qi
2016-10-18 20:24   ` Sandra Loosemore
2016-10-19  8:07     ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57CF117B.5040106@codesourcery.com \
    --to=sandra@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox