1 # Copyright 2010-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # Tests for permissions and observer mode.
18 # The permissions flags are only fully functional with stubs or targets
19 # that can run asynchronously.
21 standard_testfile start.c
23 if {[build_executable $testfile.exp $testfile \
24 $srcfile {debug nowarnings}] == -1} {
25 untested "failed to compile"
31 with_test_prefix "observer mode off" {
33 gdb_test "show may-write-registers" \
34 "Permission to write into registers is on."
36 gdb_test "show may-write-memory" \
37 "Permission to write into target memory is on."
39 gdb_test "show may-insert-breakpoints" \
40 "Permission to insert breakpoints in the target is on."
42 gdb_test "show may-insert-tracepoints" \
43 "Permission to insert tracepoints in the target is on."
45 gdb_test "show may-insert-fast-tracepoints" \
46 "Permission to insert fast tracepoints in the target is on."
48 gdb_test "show may-interrupt" \
49 "Permission to interrupt or signal the target is on."
52 gdb_test "set observer on" "Observer mode is now on." "enable observer mode"
54 with_test_prefix "observer mode on" {
55 gdb_test "show may-write-memory" \
56 "Permission to write into target memory is off."
58 gdb_test "show may-write-registers" \
59 "Permission to write into registers is off."
61 gdb_test "show may-insert-breakpoints" \
62 "Permission to insert breakpoints in the target is off."
64 gdb_test "show may-insert-tracepoints" \
65 "Permission to insert tracepoints in the target is off."
67 gdb_test "show may-insert-fast-tracepoints" \
68 "Permission to insert fast tracepoints in the target is on."
70 gdb_test "show may-interrupt" \
71 "Permission to interrupt or signal the target is off."
74 gdb_test "set observer off" "Observer mode is now off." "disable observer mode"
76 # Go back to all-stop mode.
78 gdb_test_no_output "set non-stop off"
86 gdb_test "print x = 45" "$decimal = 45" "set a global"
88 gdb_test "print x" "$decimal = 45" "validate setting a global"
90 gdb_test "set may-write-memory off"
92 gdb_test "print x = 92" "Writing to memory is not allowed.*" \
93 "set a global, 2nd time"
95 gdb_test "print x" "$decimal = 45" "validate setting a global, 2nd time"
97 # FIXME Add tests for other flags when a testsuite-able target becomes