]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi2-cli-display.exp
Update copyright year range in all GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi2-cli-display.exp
CommitLineData
b811d2c2 1# Copyright 2019-2020 Free Software Foundation, Inc.
4c7d57e7
TT
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16# Ensure that CLI "display"s aren't double-emitted in MI mode.
17
18load_lib mi-support.exp
19set MIFLAGS "-i=mi2"
20
21if {[mi_gdb_start]} {
22 continue
23}
24
25standard_testfile
26
27if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
28 untested "failed to compile"
29 return -1
30}
31
32mi_delete_breakpoints
33mi_gdb_reinitialize_dir $srcdir/$subdir
34mi_gdb_load ${binfile}
35
36mi_runto do_tests
37
38# A helper procedure that checks for the display and the line number,
39# and the following *stopped. X is the expected value of "x" and is
40# also used in test names.
41proc check_cli_display {x show_source} {
42 global mi_gdb_prompt
43
44 # Now check for the display and the source line. We don't check
45 # the source line too closely, since it's not really important
46 # here, but we do check that the stop happened.
47 set stop "\\*stopped,reason=.*\r\n$mi_gdb_prompt$"
48 if {$show_source} {
49 set src "~\"\[0-9\]+\[^\"\]*\\\\n\"\r\n"
50 } else {
51 set src ""
52 }
53 set display "~\"1: x = $x\\\\n\"\r\n"
54 gdb_expect {
55 -re "^${display}${src}${display}${stop}" {
56 # This case is the bug: the display is shown twice.
57 fail "check display and source line x=$x"
58 }
59 -re "^${src}${display}${stop}" {
60 verbose -log "got <<<$expect_out(buffer)>>>"
61 pass "check display and source line x=$x"
62 }
63 -re ".*\r\n$mi_gdb_prompt$" {
64 verbose -log "got <<<$expect_out(buffer)>>>"
65 fail "check display and source line x=$x (unexpected output)"
66 }
67 timeout {
68 fail "check display and source line x=$x (timeout)"
69 }
70 }
71}
72
73mi_gdb_test "display x" \
74 "&\"display x\\\\n\"\r\n~\"1: x = 23\\\\n\"\r\n\\^done" \
75 "display x"
76
77if {![mi_send_resuming_command "interpreter-exec console next" next]} {
78 pass "next"
79}
80check_cli_display 24 1
81
82# Also check that displays are shown for -exec-next.
83if {![mi_send_resuming_command exec-next exec-next]} {
84 pass "-exec-next"
85}
86check_cli_display 25 0