This is the mail archive of the
mailing list for the GDB project.
[patch, rfa] tweak to defaulted_query logic to fix gdb.mi test errors
- From: Sandra Loosemore <sandra at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Tue, 6 Sep 2016 12:56:59 -0600
- Subject: [patch, rfa] tweak to defaulted_query logic to fix gdb.mi test errors
- Authentication-results: sourceware.org; auth=none
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
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:
~"Kill the program being debugged? (y or n) [answered Y; input not from
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?
2016-09-06 Sandra Loosemore <email@example.com>
* utils.c (defaulted_query): Swap order of deprecated_query_hook
and input-not-from-terminal cases.
diff --git a/gdb/utils.c b/gdb/utils.c
index 5188828..b1e08a6 100644
@@ -1292,6 +1292,16 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args)
if (!confirm || server_command)
+ 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)
- 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);