Re: [PATCH 2/7] PR gdb/15224 fix for Unify interactivity tests to use input_from_terminal_p

Pedro Alves
2013-05-09T11:32:15Z

On 05/09/2013 12:08 PM, mbilal wrote:
> On Wednesday, May 08, 2013 9:22 PM Pedro Alves wrote:
>
>>I'd guess that input_from_terminal_p already does some of the
>>checks this is also making, so that this could be simplified.
>
> I don't think that because input_from_terminal_p
> checks the condition instream==stdin that
> is equal in both sanario , but input_from_terminal_p
> also return 1 when instream==NULL.
> So I think that there is no any condition that is overlapping with
> input_from_terminal_p.

/* If INSTREAM is unset, and we are not in a user command, we
must be in Insight. That's like having a terminal, for our
purposes. */
if (instream == NULL && !in_user_command)
return 1;

This very much looks like a case where history should work, but
won't unless we simplify to check input_from_terminal_p only.

The point of unifying interactivity tests is exactly so that
all these little details are centralized in a single place.

Doesn't

- if (instream == stdin
- && ISATTY (stdin) && *linebuffer)
+ if (*linebuffer && input_from_terminal_p ())

work? If not, why not? It'd be great to try that on
GNU/Linux, mingw32 gdb running under cmd.exe, and mingw32 gdb under
Cygwin bash, the latter with and without "set interactive-mode on".
I suspect this change would fix history for the forced
"set interactive-mode on" case too.

> Index: event-top.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/event-top.c,v
> retrieving revision 1.94
> diff -u -p -r1.94 event-top.c
> --- event-top.c 21 Mar 2013 17:37:29 -0000 1.94
> +++ event-top.c 9 May 2013 10:23:21 -0000
> @@ -604,7 +604,8 @@ command_line_handler (char *rl)
>
> /* Add line to history if appropriate. */
> if (instream == stdin
> - && ISATTY (stdin) && *linebuffer)
> + && ISATTY (stdin) && *linebuffer
> + && input_from_terminal_p ())
> add_history (linebuffer);

Please grep for add_history. There's at least one more call in
the tree.

--
Pedro Alves