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