]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-basics.exp
Index: gdb/ChangeLog
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-basics.exp
CommitLineData
3cb3b8df 1# Copyright 1999, 2000, 2001, 2002, 2003, 2005 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
5# the Free Software Foundation; either version 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20#
21# test basic Machine interface (MI) operations
22#
23# Verify that, using the MI, we can load a program and do
24# other basic things that are used by all test files through mi_gdb_exit,
25# mi_gdb_start, mi_delete_breakpoints, mi_gdb_reinitialize_dir and
26# mi_gdb_load, so we can safely use those.
27#
28# The goal is not to test gdb functionality, which is done by other tests,
29# but the command syntax and correct output response to MI operations.
30#
31
32load_lib mi-support.exp
b30bf9ee 33set MIFLAGS "-i=mi"
fb40c209
AC
34
35gdb_exit
36if [mi_gdb_start] {
37 continue
38}
39
40set testfile "basics"
41set srcfile ${testfile}.c
42set binfile ${objdir}/${subdir}/${testfile}
e0f353ce
EZ
43set escapedobjdir [string_to_regexp ${objdir}]
44set escapedsrcdir [string_to_regexp ${srcdir}]
45
fb40c209
AC
46if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
47 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
48}
49
50# In this file we want to test if the operations needed by the following
51# procedures work, so it makes no sense using them here.
52
53# mi_delete_breakpoints
54# mi_gdb_reinitialize_dir $srcdir/$subdir
55# mi_gdb_load ${binfile}
56
57# Test if the MI interpreter has been configured
58
59proc test_mi_interpreter_selection {} {
60 global mi_gdb_prompt
61 global gdb_prompt
62
63 # All this test expects is to get the prompt back
64 # with no syntax error message
65 send_gdb "-gdb-version\n"
66 gdb_expect {
67 -re "GNU gdb .*\r\n$mi_gdb_prompt$" \
68 { pass "acceptance of MI operations"
69 return 1}
70 -re ".*\r\n$mi_gdb_prompt$" \
71 { fail "acceptance of MI operations"
72 note "Skipping all other MI tests." }
73 -re "Undefined command.*$gdb_prompt $" \
74 { fail "acceptance of MI operations"
75 note "Skipping all other MI tests." }
76 -re ".*$gdb_prompt $" \
77 { fail "acceptance of MI operations"
78 note "Skipping all other MI tests." }
79 timeout { fail "acceptance of MI operations (timeout)"
80 note "Skipping all other MI tests." }
81 }
82 return 0
83}
84
85proc test_exec_and_symbol_mi_operatons {} {
86 global mi_gdb_prompt
87 global binfile
88
89 # Load symbols and specify executable on a single operation
90 # Tests:
91 # -file-exec-and-symbols
92
93 # Can't use mi_gdb_test as if this doesn't work,
94 # we must give up on the whole test file
95 send_gdb "-file-exec-and-symbols ${binfile}\n"
96 gdb_expect {
97 -re "\[\r\n\]*\\\^done\r\n$mi_gdb_prompt$" \
98 { pass "file-exec-and-symbols operation" }
99 timeout { fail "file-exec-and-symbols operation (timeout)"
100 note "Skipping all other MI tests."
101 return 0}
102 }
103
104 # The following is not used by mi-support.exp, but we test here so
105 # we get done with loading a program basics.
106
107 # Do it again, but now load symbols and specify executable with
108 # two separate operations
109 # Tests:
110 # -file-clear
111 # -file-exec-file
112 # -file-symbol-file
113
114 # FIXME: file-clear is not implemented yet.
2231a1e8
EZ
115# mi_gdb_test "-file-clear" \
116# "\\\^done" \
117# "file-clear operation"
fb40c209
AC
118
119 mi_gdb_test "-file-exec-file ${binfile}" \
120 "\\\^done" \
121 "file-exec-file operation"
122
123 mi_gdb_test "-file-symbol-file ${binfile}" \
124 "\\\^done" \
125 "file-symbol-file operation"
126
127 # FIXME: if we cannot load we have to skip all other tests.
128}
129
130proc test_breakpoints_deletion {} {
131 global mi_gdb_prompt
132 global srcfile
133
134 # Clear all breakpoints and list to confirm
135 # Tests:
136 # -break-delete (all)
137 # -break-list
138
139 # The all parameter is actually no parameter.
140 mi_gdb_test "200-break-delete" \
141 "\\\^done" \
142 "break-delete (all) operation"
143
144 mi_gdb_test "201-break-list" \
cff22675 145 ".*\\\^done,BreakpointTable=\\\{.*,body=\\\[\\\]\\\}" \
fb40c209
AC
146 "all breakpoints removed"
147}
148
149proc test_dir_specification {} {
150 global mi_gdb_prompt
151 global srcdir
152 global subdir
153
93ce5efb 154 # Add to the search directories, display, then reset back to default
fb40c209 155 # Tests:
fb40c209 156 # -environment-directory arg
93ce5efb
JJ
157 # -environment-directory
158 # -environment-directory -r
fb40c209 159
e0f353ce
EZ
160 set envirodir [string_to_regexp ${srcdir}/${subdir}]
161
93ce5efb 162 mi_gdb_test "202-environment-directory ${srcdir}/${subdir}" \
e0f353ce 163 "\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
93ce5efb
JJ
164 "environment-directory arg operation"
165
166 mi_gdb_test "203-environment-directory" \
e0f353ce 167 "\\\^done,source-path=\"${envirodir}.\\\$cdir.\\\$cwd\"" \
93ce5efb
JJ
168 "environment-directory empty-string operation"
169
170 mi_gdb_test "204-environment-directory -r" \
171 "\\\^done,source-path=\"\\\$cdir.\\\$cwd\"" \
fb40c209 172 "environment-directory operation"
fb40c209
AC
173}
174
93ce5efb
JJ
175proc test_cwd_specification {} {
176 global mi_gdb_prompt
177 global objdir
e0f353ce 178 global escapedobjdir
93ce5efb
JJ
179 global subdir
180
181 # Change the working directory, then print the current working directory
182 # Tests:
183 # -environment-cd ${objdir}
184 # -environment-pwd
185
186 mi_gdb_test "205-environment-cd ${objdir}" \
187 "\\\^done" \
188 "environment-cd arg operation"
189
190 mi_gdb_test "206-environment-pwd" \
e0f353ce 191 "\\\^done,cwd=\"${escapedobjdir}\"" \
93ce5efb
JJ
192 "environment-pwd operation"
193}
194
195proc test_path_specification {} {
196 global mi_gdb_prompt
197 global orig_path
198 global objdir
199 global srcdir
e0f353ce
EZ
200 global escapedobjdir
201 global escapedsrcdir
93ce5efb
JJ
202
203 # Add to the path, display, then reset
204 # Tests:
205 # -environment-path
206 # -environment-path dir1 dir2
207 # -environment-path -r dir
208 # -environment-path -r
209
93ce5efb
JJ
210 send_gdb "-environment-path\n"
211 gdb_expect 20 {
212 -re "\\\^done,path=\"\(.*\)\"\r\n$mi_gdb_prompt" {
213 set orig_path $expect_out(1,string);
214 }
215 timeout {
216 perror "-environment-path (timeout)" ;
217 return
218 }
219 }
220
221 mi_gdb_test "207-environment-path" \
222 "\\\^done,path=\"$orig_path\"" \
223 "environment-path no-args operation"
224
225 mi_gdb_test "208-environment-path $srcdir $objdir" \
e0f353ce 226 "\\\^done,path=\"$escapedsrcdir.$escapedobjdir.$orig_path\"" \
93ce5efb
JJ
227 "environment-path dir1 dir2 operation"
228
229 mi_gdb_test "209-environment-path -r $objdir" \
e0f353ce 230 "\\\^done,path=\"$escapedobjdir.$orig_path\"" \
93ce5efb
JJ
231 "environment-path -r dir operation"
232
233 mi_gdb_test "210-environment-path -r" \
234 "\\\^done,path=\"$orig_path\"" \
235 "environment-path -r operation"
236
93ce5efb
JJ
237}
238
3cb3b8df
BR
239proc test_setshow_inferior_tty {} {
240 global mi_gdb_prompt
241
242 # Test that the commands,
243 # -inferior-tty-set
244 # -inferior-tty-show
245 # are setting/getting the same data in GDB.
246
247 mi_gdb_test "301-inferior-tty-show" \
248 "301\\\^done" \
249 "initial tty is empty"
250
251 mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
252 "302\\\^done" \
253 "set tty to /dev/pts/1"
254
255 mi_gdb_test "303-inferior-tty-show" \
256 "303\\\^done,inferior_tty_terminal=\"/dev/pts/1\"" \
257 "tty was set correctly"
258
259 mi_gdb_test "304-inferior-tty-set" \
260 "304\\\^done" \
261 "set tty to the empty string"
262
263 mi_gdb_test "305-inferior-tty-show" \
264 "305\\\^done" \
265 "final tty is empty"
266}
267
fb40c209
AC
268if [test_mi_interpreter_selection] {
269 test_exec_and_symbol_mi_operatons
270 test_breakpoints_deletion
271 test_dir_specification
93ce5efb
JJ
272 test_cwd_specification
273 test_path_specification
3cb3b8df 274 test_setshow_inferior_tty
fb40c209
AC
275}
276
277mi_gdb_exit
278return 0