xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp (revision 7bdf38e5b7a28439665f2fdeff81e36913eef7dd)
1# Copyright 2012-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# Do this here before we start GDB for the test.
17set scheduler_locking_supported [target_supports_scheduler_locking]
18
19load_lib mi-support.exp
20set MIFLAGS "-i=mi"
21
22standard_testfile basics.c
23
24if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
25     untested "failed to compile"
26     return -1
27}
28
29proc test_command_param_changed { } {
30    global scheduler_locking_supported
31    global binfile
32
33    with_test_prefix "cmd param" {
34	mi_clean_restart $binfile
35	mi_runto_main
36
37	if { $scheduler_locking_supported } {
38	    foreach opt { "on" "off" "step" } {
39		mi_gdb_test "set scheduler-locking ${opt}" \
40		    ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \
41		    "\"set scheduler-locking ${opt}\""
42	    }
43	    foreach opt { "on" "off" "step" } {
44		mi_gdb_test "interpreter-exec console \"set scheduler-locking ${opt}\"" \
45		    ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \
46		    "interpreter-exec \"set scheduler-locking ${opt}\""
47	    }
48	    # Don't emit MI notification for request from MI.
49	    mi_gdb_test "-gdb-set scheduler-locking on" \
50		{\^done} \
51		"\"set scheduler-locking on\" no event (requested by MI)"
52	    mi_gdb_test "interpreter-exec mi \"-gdb-set scheduler-locking step\"" \
53	    "\\&\"interpreter-exec mi .*\"-gdb-set scheduler-locking step.*\"\\\\n\"\r\n\\^done\r\n\\^done" \
54		"\"set scheduler-locking step\" no event (requested by MI interp)"
55	    mi_gdb_test "set scheduler-locking step" \
56		"\\&\"set scheduler-locking step\\\\n\"\r\n\\^done" \
57		"\"set scheduler-locking stepr\" no event"
58	}
59
60	mi_gdb_test "-exec-arguments foo" {\^done} \
61	    "\"-exec-arguments foo\" no event"
62
63	foreach command { "remotecache" "check type" } {
64
65	    # The default value of each command option may be different, so we first
66	    # set it to 'off', and this may or may not trigger MI notification.
67	    mi_gdb_test "set ${command} off" ".*\\^done" "\"set ${command}\" warmup"
68
69	    foreach boolean_opt { "on" "off" } {
70		mi_gdb_test "set ${command} ${boolean_opt}" \
71		    ".*=cmd-param-changed,param=\"${command}\",value=\"${boolean_opt}\".*\\^done" \
72		    "\"set ${command} ${boolean_opt}\""
73	    }
74	    mi_gdb_test "set ${command} off" \
75		"\\&\"set ${command} off\\\\n\"\r\n\\^done" \
76		"\"set ${command}\" no event"
77	}
78
79
80	foreach command { "trace-notes" "remote exec-file" } {
81	    foreach str_opt { "foo" "bar" } {
82		mi_gdb_test "set ${command} ${str_opt}" \
83		    ".*=cmd-param-changed,param=\"${command}\",value=\"${str_opt}\".*\\^done" \
84		    "\"set ${command} ${str_opt}\""
85	    }
86	    mi_gdb_test "set ${command} bar" \
87		"\\&\"set ${command} bar\\\\n\"\r\n(\\&\"warning.*|)\\^done" \
88		"\"set ${command} bar\" no event"
89	}
90
91	# No notification is emitted for 'maint set' commands.
92	foreach boolean_opt { "on" "off" } {
93	    mi_gdb_test "maint set dwarf always-disassemble ${boolean_opt}" \
94		"\\&\"maint set dwarf always-disassemble ${boolean_opt}\\\\n\"\r\n\\^done" \
95		"\"maint dwarf always-disassemble ${boolean_opt}\""
96	}
97
98	# Full command parameters are included in the notification when a
99	# abbreviated one is typed.
100	mi_gdb_test "set ch type on" \
101	    ".*=cmd-param-changed,param=\"check type\",value=\"on\".*\\^done" \
102	    "\"set ch type on\""
103
104	# Notification is emitted for both 'set directories' and 'directory'.
105	mi_gdb_test "set directories \$cdir:\$cwd:/tmp" \
106	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
107	    "\"set directories \$cdir:\$cwd:/tmp\""
108	mi_gdb_test "directory /usr/src/gdb" \
109	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
110	    "\"directory /usr/src/gdb\""
111	mi_gdb_test "directory" \
112	    ".*=cmd-param-changed,param=\"directories\",value=\".*\".*\\^done" \
113	    "\"directory\""
114
115	mi_gdb_exit
116    }
117}
118
119test_command_param_changed
120
121return 0
122