xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.mi/mi-cmd-param-changed.exp (revision 3587d6f89c746bbb4f886219ddacd41ace480ecf)
1# Copyright 2012-2020 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
32    with_test_prefix "cmd param" {
33	if [mi_gdb_start] {
34	    return
35	}
36	mi_run_to_main
37
38	if { $scheduler_locking_supported } {
39	    foreach opt { "on" "off" "step" } {
40		mi_gdb_test "set scheduler-locking ${opt}" \
41		    ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \
42		    "\"set scheduler-locking ${opt}\""
43	    }
44	    foreach opt { "on" "off" "step" } {
45		mi_gdb_test "interpreter-exec console \"set scheduler-locking ${opt}\"" \
46		    ".*=cmd-param-changed,param=\"scheduler-locking\",value=\"${opt}\".*\\^done" \
47		    "interpreter-exec \"set scheduler-locking ${opt}\""
48	    }
49	    # Don't emit MI notification for request from MI.
50	    mi_gdb_test "-gdb-set scheduler-locking on" \
51		{\^done} \
52		"\"set scheduler-locking on\" no event (requested by MI)"
53	    mi_gdb_test "interpreter-exec mi \"-gdb-set scheduler-locking step\"" \
54	    "\\&\"interpreter-exec mi .*\"-gdb-set scheduler-locking step.*\"\\\\n\"\r\n\\^done\r\n\\^done" \
55		"\"set scheduler-locking step\" no event (requested by MI interp)"
56	    mi_gdb_test "set scheduler-locking step" \
57		"\\&\"set scheduler-locking step\\\\n\"\r\n\\^done" \
58		"\"set scheduler-locking stepr\" no event"
59	}
60
61	mi_gdb_test "-exec-arguments foo" {\^done} \
62	    "\"-exec-arguments foo\" no event"
63
64	foreach command { "remotecache" "check type" } {
65
66	    # The default value of each command option may be different, so we first
67	    # set it to 'off', and this may or may not trigger MI notification.
68	    mi_gdb_test "set ${command} off" ".*\\^done" "\"set ${command}\" warmup"
69
70	    foreach boolean_opt { "on" "off" } {
71		mi_gdb_test "set ${command} ${boolean_opt}" \
72		    ".*=cmd-param-changed,param=\"${command}\",value=\"${boolean_opt}\".*\\^done" \
73		    "\"set ${command} ${boolean_opt}\""
74	    }
75	    mi_gdb_test "set ${command} off" \
76		"\\&\"set ${command} off\\\\n\"\r\n\\^done" \
77		"\"set ${command}\" no event"
78	}
79
80
81	foreach command { "trace-notes" "remote exec-file" } {
82	    foreach str_opt { "foo" "bar" } {
83		mi_gdb_test "set ${command} ${str_opt}" \
84		    ".*=cmd-param-changed,param=\"${command}\",value=\"${str_opt}\".*\\^done" \
85		    "\"set ${command} ${str_opt}\""
86	    }
87	    mi_gdb_test "set ${command} bar" \
88		"\\&\"set ${command} bar\\\\n\"\r\n(\\&\"warning.*|)\\^done" \
89		"\"set ${command} bar\" no event"
90	}
91
92	# No notification is emitted for 'maint set' commands.
93	foreach boolean_opt { "on" "off" } {
94	    mi_gdb_test "maint set dwarf always-disassemble ${boolean_opt}" \
95		"\\&\"maint set dwarf always-disassemble ${boolean_opt}\\\\n\"\r\n\\^done" \
96		"\"maint dwarf always-disassemble ${boolean_opt}\""
97	}
98
99	# Full command parameters are included in the notification when a
100	# abbreviated one is typed.
101	mi_gdb_test "set ch type on" \
102	    ".*=cmd-param-changed,param=\"check type\",value=\"on\".*\\^done" \
103	    "\"set ch type on\""
104
105	mi_gdb_exit
106    }
107}
108
109test_command_param_changed
110
111return 0
112