binutils-gdb/gdb/mi
Tom Tromey 4c7d57e72e Don't show "display"s twice in MI
If you run "gdb -i=mi2" and set a "display", then when "next"ing the
displays will be shown twice:

    ~"1: x = 23\n"
    ~"7\t  printf(\"%d\\n\", x);\n"
    ~"1: x = 23\n"
    *stopped,reason="end-stepping-range",frame={addr="0x0000000000400565",func="main",args=[],file="q.c",fullname="/tmp/q.c",line="7"},thread-id="1",stopped-threads="all",core="1"

The immediate cause of this is this code in mi_on_normal_stop_1:

      print_stop_event (mi_uiout);

      console_interp = interp_lookup (current_ui, INTERP_CONSOLE);
      if (should_print_stop_to_console (console_interp, tp))
	print_stop_event (mi->cli_uiout);

... which obviously prints the stop twice.

However, I think the first call to print_stop_event is intended just
to emit the MI *stopped notification, which explains why the source
line does not show up two times.

This patch fixes the bug by changing print_stop_event to only call
do_displays for non-MI-like ui-outs.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-03-19  Tom Tromey  <tromey@adacore.com>

	* mi/mi-interp.c (mi_on_normal_stop_1): Only show displays once.
	* infrun.h (print_stop_event): Add "displays" parameter.
	* infrun.c (print_stop_event): Add "displays" parameter.

gdb/testsuite/ChangeLog
2019-03-19  Tom Tromey  <tromey@adacore.com>

	* gdb.mi/mi2-cli-display.c: New file.
	* gdb.mi/mi2-cli-display.exp: New file.
2019-03-19 12:16:48 -06:00
..
ChangeLog-1999-2003
mi-cmd-break.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-cmd-break.h Normalize include guards in gdb 2019-02-07 03:27:23 -07:00
mi-cmd-catch.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-cmd-disas.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-cmd-env.c Normalize includes to use common/ 2019-01-25 15:28:16 -07:00
mi-cmd-file.c Add compunits range adapter to objfile 2019-01-17 15:42:05 -07:00
mi-cmd-info.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-cmd-stack.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-cmd-target.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-cmd-var.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-cmds.c Fix MI output for multi-location breakpoints 2019-03-13 15:14:36 -04:00
mi-cmds.h Normalize include guards in gdb 2019-02-07 03:27:23 -07:00
mi-common.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-common.h Normalize include guards in gdb 2019-02-07 03:27:23 -07:00
mi-console.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-console.h Normalize include guards in gdb 2019-02-07 03:27:23 -07:00
mi-getopt.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-getopt.h Normalize include guards in gdb 2019-02-07 03:27:23 -07:00
mi-interp.c Don't show "display"s twice in MI 2019-03-19 12:16:48 -06:00
mi-interp.h Normalize include guards in gdb 2019-02-07 03:27:23 -07:00
mi-main.c Fix MI output for multi-location breakpoints 2019-03-13 15:14:36 -04:00
mi-main.h Fix MI output for multi-location breakpoints 2019-03-13 15:14:36 -04:00
mi-out.c Fix MI output for multi-location breakpoints 2019-03-13 15:14:36 -04:00
mi-out.h Factor out mi_ui_out instantiation logic 2019-03-13 13:26:37 -04:00
mi-parse.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00
mi-parse.h Normalize include guards in gdb 2019-02-07 03:27:23 -07:00
mi-symbol-cmds.c Update copyright year range in all GDB files. 2019-01-01 10:01:51 +04:00