]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/permissions.exp
4a41f741157893e10d3e6e2f0305ae46b4371e9f
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / permissions.exp
1 # Copyright 2010-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 # Tests for permissions and observer mode.
17
18 # The permissions flags are only fully functional with stubs or targets
19 # that can run asynchronously.
20
21 standard_testfile start.c
22
23 if {[build_executable $testfile.exp $testfile \
24 $srcfile {debug nowarnings}] == -1} {
25 untested "failed to compile"
26 return -1
27 }
28
29 if [get_compiler_info] {
30 return -1
31 }
32
33 gdb_exit
34 gdb_start
35 gdb_reinitialize_dir $srcdir/$subdir
36
37 gdb_test "show may-write-registers" \
38 "Permission to write into registers is on."
39
40 gdb_test "show may-write-memory" \
41 "Permission to write into target memory is on."
42
43 gdb_test "show may-insert-breakpoints" \
44 "Permission to insert breakpoints in the target is on."
45
46 gdb_test "show may-insert-tracepoints" \
47 "Permission to insert tracepoints in the target is on."
48
49 gdb_test "show may-insert-fast-tracepoints" \
50 "Permission to insert fast tracepoints in the target is on."
51
52 gdb_test "show may-interrupt" \
53 "Permission to interrupt or signal the target is on."
54
55 gdb_test "set observer on" "Observer mode is now on." "enable observer mode"
56
57 gdb_test "show may-write-memory" \
58 "Permission to write into target memory is off."
59
60 gdb_test "show may-write-registers" \
61 "Permission to write into registers is off."
62
63 gdb_test "show may-insert-breakpoints" \
64 "Permission to insert breakpoints in the target is off."
65
66 gdb_test "show may-insert-tracepoints" \
67 "Permission to insert tracepoints in the target is off."
68
69 gdb_test "show may-insert-fast-tracepoints" \
70 "Permission to insert fast tracepoints in the target is on."
71
72 gdb_test "show may-interrupt" \
73 "Permission to interrupt or signal the target is off."
74
75 gdb_test "set observer off" "Observer mode is now off." "disable observer mode"
76
77 # Go back to all-stop mode.
78
79 gdb_test_no_output "set non-stop off"
80
81 gdb_load ${binfile}
82
83 if ![runto_main] then {
84 perror "couldn't run to breakpoint"
85 continue
86 }
87
88 gdb_test "print x = 45" "$decimal = 45" "set a global"
89
90 gdb_test "print x" "$decimal = 45"
91
92 gdb_test "set may-write-memory off"
93
94 gdb_test "print x = 92" "Writing to memory is not allowed.*" \
95 "try to set a global"
96
97 gdb_test "print x" "$decimal = 45"
98
99 # FIXME Add tests for other flags when a testsuite-able target becomes
100 # available.