]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-basics.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-basics.exp
CommitLineData
8acc9f48 1# Copyright 1999-2013 Free Software Foundation, Inc.
fb40c209
AC
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
fb40c209 6# (at your option) any later version.
e22f8b7c 7#
fb40c209
AC
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.
e22f8b7c 12#
fb40c209 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
fb40c209 15
fb40c209
AC
16#
17# test basic Machine interface (MI) operations
18#
19# Verify that, using the MI, we can load a program and do
20# other basic things that are used by all test files through mi_gdb_exit,
21# mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and
22# mi_gdb_load, so we can safely use those.
23#
24# The goal is not to test gdb functionality, which is done by other tests,
25# but the command syntax and correct output response to MI operations.
26#
27
28load_lib mi-support.exp
b30bf9ee 29set MIFLAGS "-i=mi"
fb40c209
AC
30
31gdb_exit
ecd3fd0f 32if [mi_gdb_start separate-inferior-tty] {
fb40c209
AC
33 continue
34}
35
298a9cf0 36standard_testfile basics.c
e0f353ce 37set escapedobjdir [string_to_regexp ${objdir}]
18ef391a 38set envirodir [string_to_regexp ${objdir}/${subdir}]
e0f353ce 39
9357e021 40if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
b60f0898
JB
41 untested mi-basics.exp
42 return -1
fb40c209
AC
43}
44
45# In this file we want to test if the operations needed by the following
46# procedures work, so it makes no sense using them here.
47
48# mi_delete_breakpoints
49# mi_gdb_reinitialize_dir $srcdir/$subdir
50# mi_gdb_load ${binfile}
51
52# Test if the MI interpreter has been configured
53
54proc test_mi_interpreter_selection {} {
55 global mi_gdb_prompt
56 global gdb_prompt
57
58 # All this test expects is to get the prompt back
59 # with no syntax error message
10483e8e
MP
60 if ![mi_gdb_test "-gdb-version" "~\"GNU gdb.*" "acceptance of MI operations"] {
61 return 1
62 }
63
ec9f1212 64 note "Skipping all other MI tests."
fb40c209
AC
65 return 0
66}
67
68proc test_exec_and_symbol_mi_operatons {} {
69 global mi_gdb_prompt
70 global binfile
71
72 # Load symbols and specify executable on a single operation
73 # Tests:
74 # -file-exec-and-symbols
75
10483e8e
MP
76 if [mi_gdb_test "-file-exec-and-symbols ${binfile}" "\\\^done" \
77 "file-exec-and-symbols operation"] {
78 note "Skipping all other MI tests."
79 return 0
80 }
fb40c209
AC
81
82 # The following is not used by mi-support.exp, but we test here so
83 # we get done with loading a program basics.
84
85 # Do it again, but now load symbols and specify executable with
86 # two separate operations
87 # Tests:
88 # -file-clear
89 # -file-exec-file
90 # -file-symbol-file
91
92 # FIXME: file-clear is not implemented yet.
2231a1e8
EZ
93# mi_gdb_test "-file-clear" \
94# "\\\^done" \
95# "file-clear operation"
fb40c209
AC
96
97 mi_gdb_test "-file-exec-file ${binfile}" \
98 "\\\^done" \
99 "file-exec-file operation"
100
101 mi_gdb_test "-file-symbol-file ${binfile}" \
102 "\\\^done" \
103 "file-symbol-file operation"
104
10483e8e
MP
105 # We need to return != 0.
106 return 1
fb40c209
AC
107}
108
109proc test_breakpoints_deletion {} {
110 global mi_gdb_prompt
111 global srcfile
112
113 # Clear all breakpoints and list to confirm
114 # Tests:
115 # -break-delete (all)
116 # -break-list
117
118 # The all parameter is actually no parameter.
119 mi_gdb_test "200-break-delete" \
39fb8e9e 120 "200\\\^done" \
fb40c209
AC
121 "break-delete (all) operation"
122
123 mi_gdb_test "201-break-list" \
cff22675 124 ".*\\\^done,BreakpointTable=\\\{.*,body=\\\[\\\]\\\}" \
fb40c209
AC
125 "all breakpoints removed"
126}
127
128proc test_dir_specification {} {
129 global mi_gdb_prompt
18ef391a 130 global objdir
fb40c209 131 global subdir
18ef391a 132 global envirodir
fb40c209 133
93ce5efb 134 # Add to the search directories, display, then reset back to default
fb40c209 135 # Tests:
fb40c209 136 # -environment-directory arg
93ce5efb
JJ
137 # -environment-directory
138 # -environment-directory -r
fb40c209 139
18ef391a 140 mi_gdb_test "202-environment-directory ${objdir}/${subdir}" \
540b8a30 141 "202\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
93ce5efb
JJ
142 "environment-directory arg operation"
143
144 mi_gdb_test "203-environment-directory" \
540b8a30 145 "203\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
93ce5efb
JJ
146 "environment-directory empty-string operation"
147
148 mi_gdb_test "204-environment-directory -r" \
39fb8e9e 149 "204\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \
fb40c209 150 "environment-directory operation"
fb40c209
AC
151}
152
93ce5efb
JJ
153proc test_cwd_specification {} {
154 global mi_gdb_prompt
155 global objdir
e0f353ce 156 global escapedobjdir
93ce5efb
JJ
157 global subdir
158
159 # Change the working directory, then print the current working directory
160 # Tests:
161 # -environment-cd ${objdir}
162 # -environment-pwd
163
164 mi_gdb_test "205-environment-cd ${objdir}" \
39fb8e9e 165 "205\\\^done" \
93ce5efb
JJ
166 "environment-cd arg operation"
167
07ab73a0
JM
168 # The canonical name of the working directory may differ on a
169 # remote host from that on the build system.
170 if ![is_remote host] {
171 mi_gdb_test "206-environment-pwd" \
39fb8e9e 172 "206\\\^done,cwd=\"${escapedobjdir}\"" \
93ce5efb 173 "environment-pwd operation"
07ab73a0 174 }
93ce5efb
JJ
175}
176
177proc test_path_specification {} {
178 global mi_gdb_prompt
179 global orig_path
180 global objdir
18ef391a 181 global subdir
e0f353ce 182 global escapedobjdir
18ef391a 183 global envirodir
10483e8e 184 global expect_out
93ce5efb
JJ
185
186 # Add to the path, display, then reset
187 # Tests:
188 # -environment-path
189 # -environment-path dir1 dir2
190 # -environment-path -r dir
191 # -environment-path -r
192
10483e8e
MP
193 mi_gdb_test "-environment-path" "\\\^done,path=\"(.*)\"" "environment-path"
194 set orig_path $expect_out(3,string)
93ce5efb 195
041bf30d 196 set orig_path [string_to_regexp ${orig_path}]
18ef391a 197 set pathdir [string_to_regexp ${objdir}/${subdir}]
041bf30d 198
93ce5efb 199 mi_gdb_test "207-environment-path" \
39fb8e9e 200 "207\\\^done,path=\"$orig_path\"" \
93ce5efb
JJ
201 "environment-path no-args operation"
202
18ef391a
NR
203 mi_gdb_test "208-environment-path $objdir ${objdir}/${subdir}" \
204 "208\\\^done,path=\"$escapedobjdir.${envirodir}.$orig_path\"" \
93ce5efb
JJ
205 "environment-path dir1 dir2 operation"
206
207 mi_gdb_test "209-environment-path -r $objdir" \
39fb8e9e 208 "209\\\^done,path=\"$escapedobjdir.$orig_path\"" \
93ce5efb
JJ
209 "environment-path -r dir operation"
210
211 mi_gdb_test "210-environment-path -r" \
39fb8e9e 212 "210\\\^done,path=\"$orig_path\"" \
93ce5efb
JJ
213 "environment-path -r operation"
214
93ce5efb
JJ
215}
216
3cb3b8df
BR
217proc test_setshow_inferior_tty {} {
218 global mi_gdb_prompt
ecd3fd0f 219 global mi_inferior_tty_name
3cb3b8df
BR
220
221 # Test that the commands,
222 # -inferior-tty-set
223 # -inferior-tty-show
224 # are setting/getting the same data in GDB.
225
226 mi_gdb_test "301-inferior-tty-show" \
ecd3fd0f
BR
227 "301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
228 "initial tty is mi_inferior_tty_name"
3cb3b8df
BR
229
230 mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
231 "302\\\^done" \
232 "set tty to /dev/pts/1"
233
234 mi_gdb_test "303-inferior-tty-show" \
235 "303\\\^done,inferior_tty_terminal=\"/dev/pts/1\"" \
236 "tty was set correctly"
237
238 mi_gdb_test "304-inferior-tty-set" \
239 "304\\\^done" \
240 "set tty to the empty string"
241
242 mi_gdb_test "305-inferior-tty-show" \
243 "305\\\^done" \
ecd3fd0f
BR
244 "make sure tty is empty"
245
246 mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
247 "306\\\^done" \
248 "set tty to mi_inferior_tty_name (the way it was)"
249
250 mi_gdb_test "307-inferior-tty-show" \
251 "307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
252 "verify tty is correct"
3cb3b8df
BR
253}
254
10483e8e
MP
255if { [test_mi_interpreter_selection]
256 && [test_exec_and_symbol_mi_operatons] } {
fb40c209
AC
257 test_breakpoints_deletion
258 test_dir_specification
93ce5efb
JJ
259 test_cwd_specification
260 test_path_specification
3cb3b8df 261 test_setshow_inferior_tty
fb40c209
AC
262}
263
264mi_gdb_exit
265return 0