Re: gdb patch to suppress empty lines, re-visited

Michael Snyder
2002-12-11T23:28:15Z

Per Bothner wrote:
>
> This is a revision of a patch originally from 1999:
> http://sources.redhat.com/ml/gdb-patches/1999-q2/msg00093.html
>
> I'm not sure if the patch in top.c does anything, since I don't
> know when/if readline is called from command_line_input.
>
> OK to check in? With or without the top.c change?
> --
> --Per Bothner

For posterity, this changes the console output when you are
repeating a command a bunch of times by hitting return.
It changes, eg.
1038 <main+8>: call 0x138818 <get_run_time>
(gdb)
0xe103c <main+12>: st %i1, [ %fp + 0x48 ]
(gdb)
0xe1040 <main+16>: st %o0, [ %fp + -464 ]
(gdb)

to

(gdb) x/i $pc
0xe1038 <main+8>: call 0x138818 <get_run_time>
0xe103c <main+12>: st %i1, [ %fp + 0x48 ]
0xe1040 <main+16>: st %o0, [ %fp + -464 ]
(gdb)

Per, I think the first discussion needs to be,
do we agree that we want this change? This changes
visible behavior, quite broadly.

Michael

> per@bothner.com http://www.bothner.com/per/
>
> -------------------------------------------------------------------------------
> Index: top.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/top.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 top.c
> --- top.c 26 Sep 2002 17:46:04 -0000 1.68
> +++ top.c 7 Dec 2002 06:21:11 -0000
> @@ -1211,7 +1211,12 @@ command_line_input (char *prompt_arg, in
> }
> else if (command_editing_p && instream == stdin && ISATTY (instream))
> {
> + int can_repeat = repeat && *line != NULL;
> + if (can_repeat)
> + rl_erase_empty_line++;
> rl = gdb_readline_wrapper (local_prompt);
> + if (can_repeat)
> + rl_erase_empty_line--;
> }
> else
> {
> Index: event-top.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/event-top.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 event-top.c
> --- event-top.c 5 Nov 2002 22:38:11 -0000 1.24
> +++ event-top.c 7 Dec 2002 06:21:12 -0000
> @@ -191,6 +191,7 @@ cli_command_loop (void)
> strcpy (a_prompt, PREFIX (0));
> strcat (a_prompt, gdb_prompt);
> strcat (a_prompt, SUFFIX (0));
> + rl_erase_empty_line = *line != NULL;
> rl_callback_handler_install (a_prompt, input_handler);
> }
> else
> @@ -296,6 +297,7 @@ display_gdb_prompt (char *new_prompt)
> if (async_command_editing_p)
> {
> rl_callback_handler_remove ();
> + rl_erase_empty_line = *line != NULL;
> rl_callback_handler_install (new_prompt, input_handler);
> }
> /* new_prompt at this point can be the top of the stack or the one passed in */