This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Never silently discard internal errors
Daniel Jacobowitz <drow@false.org> writes:
> On Mon, Sep 25, 2006 at 12:38:40PM -0700, Jim Blandy wrote:
>> What if we simply had 'query' itself print out the prompt, followed by
>> "[answering 'y', since standard input is not a terminal]" (or
>> something more tasteful)? Then you wouldn't have to go around
>> decorating all the calls to query.
>
> I assume that would be wrong for "set confirm off"?
I don't want to turn this into a bikeshed discussion, but here's what
I had in mind:
*** utils.c 12 Jul 2006 11:50:18 -0700 1.168
--- utils.c 25 Sep 2006 14:17:20 -0700
***************
*** 1142,1152 ****
int ans2;
int retval;
! /* Automatically answer "yes" if input is not from the user
! directly, or if the user did not want prompts. */
! if (!input_from_terminal_p () || !caution)
return 1;
if (deprecated_query_hook)
{
va_start (args, ctlstr);
--- 1142,1168 ----
int ans2;
int retval;
! /* If the user does not want prompts, answer "yes" automatically. */
! if (! caution)
return 1;
+ /* If input isn't coming from the user directly, just say what
+ question we're asking, and then answer "yes" automatically. This
+ way, important error messages don't get lost when talking to GDB
+ over a pipe. */
+ if (! input_from_terminal_p ())
+ {
+ wrap_here ("");
+
+ va_start (args, ctlstr);
+ vfprintf_filtered (gdb_stdout, ctlstr, args);
+ va_end (args);
+ printf_filtered (_("(y or n) [answered yes; input not from terminal]"));
+ gdb_flush (gdb_stdout);
+
+ return 1;
+ }
+
if (deprecated_query_hook)
{
va_start (args, ctlstr);