diff options
author | Tom Tromey <tromey@adacore.com> | 2019-03-12 12:56:01 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-03-19 12:16:48 -0600 |
commit | 4c7d57e72e0340931ab01db2247bdce3c2fcadb7 (patch) | |
tree | cb73a7ab56d890e868d983aec7338b097d453f10 /gdb/testsuite/gdb.mi/mi2-cli-display.c | |
parent | cb24623460fe3e68794b79b79b0dbd5e62598d85 (diff) | |
download | gdb-4c7d57e72e0340931ab01db2247bdce3c2fcadb7.zip gdb-4c7d57e72e0340931ab01db2247bdce3c2fcadb7.tar.gz gdb-4c7d57e72e0340931ab01db2247bdce3c2fcadb7.tar.bz2 |
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.
Diffstat (limited to 'gdb/testsuite/gdb.mi/mi2-cli-display.c')
-rw-r--r-- | gdb/testsuite/gdb.mi/mi2-cli-display.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.mi/mi2-cli-display.c b/gdb/testsuite/gdb.mi/mi2-cli-display.c new file mode 100644 index 0000000..552612d --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi2-cli-display.c @@ -0,0 +1,32 @@ +/* Copyright 2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +int +do_tests (int x) +{ + ++x; + ++x; + ++x; + ++x; + return x; +} + +int +main (void) +{ + return do_tests (23); +} |