From 4c7d57e72e0340931ab01db2247bdce3c2fcadb7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 12 Mar 2019 12:56:01 -0600 Subject: 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 * 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 * gdb.mi/mi2-cli-display.c: New file. * gdb.mi/mi2-cli-display.exp: New file. --- gdb/mi/mi-interp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'gdb/mi/mi-interp.c') diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index f17e09f..3c5a0d8 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -625,10 +625,15 @@ mi_on_normal_stop_1 (struct bpstats *bs, int print_frame) reason = tp->thread_fsm->async_reply_reason (); mi_uiout->field_string ("reason", async_reason_lookup (reason)); } - print_stop_event (mi_uiout); console_interp = interp_lookup (current_ui, INTERP_CONSOLE); - if (should_print_stop_to_console (console_interp, tp)) + /* We only want to print the displays once, and we want it to + look just how it would on the console, so we use this to + decide whether the MI stop should include them. */ + bool console_print = should_print_stop_to_console (console_interp, tp); + print_stop_event (mi_uiout, !console_print); + + if (console_print) print_stop_event (mi->cli_uiout); mi_uiout->field_int ("thread-id", tp->global_num); -- cgit v1.1