]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.mi/mi2-cli-display.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi2-cli-display.exp
1 # Copyright 2019-2023 Free Software Foundation, Inc.
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
18 load_lib mi-support.exp
19 set MIFLAGS "-i=mi2"
20
21 if {[mi_gdb_start]} {
22 return
23 }
24
25 standard_testfile
26
27 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
28 untested "failed to compile"
29 return -1
30 }
31
32 mi_delete_breakpoints
33 mi_gdb_reinitialize_dir $srcdir/$subdir
34 mi_gdb_load ${binfile}
35
36 mi_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.
41 proc 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
73 mi_gdb_test "display x" \
74 "&\"display x\\\\n\"\r\n~\"1: x = 23\\\\n\"\r\n\\^done" \
75 "display x"
76
77 if {![mi_send_resuming_command "interpreter-exec console next" next]} {
78 pass "next"
79 }
80 check_cli_display 24 1
81
82 # Also check that displays are shown for -exec-next.
83 if {![mi_send_resuming_command exec-next exec-next]} {
84 pass "-exec-next"
85 }
86 check_cli_display 25 0