1 # Copyright
1998, 1999, 2001, 2003, 2004 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
2 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
, write to the Free Software
15 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-gdb@prep.ai.mit.edu
20 # This file was written by Elena Zannoni.
(ezannoni@cygnus.com
)
30 # test running programs
36 set srcfile $
{testfile
}.c
37 set srcfile1 $
{testfile
}1.c
38 set binfile $
{objdir
}/$
{subdir
}/$
{testfile
}
40 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
41 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
44 if { [gdb_compile
"${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
45 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
48 if { [gdb_compile
"${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
49 gdb_suppress_entire_file
"Testcase compile failed, so all tests in this file will automatically fail."
54 gdb_reinitialize_dir $srcdir
/$subdir
57 set bp_location1
[gdb_get_line_number
"set breakpoint 1 here"]
58 set bp_location11
[gdb_get_line_number
"set breakpoint 11 here"]
60 if ![runto_main
] then { fail
"define tests suppressed" }
62 # Verify that GDB allows a user to
define their very own commands.
64 send_gdb
"define nextwhere\n"
66 -re
"Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
67 {send_gdb
"next\nbt\nend\n"
70 {pass
"define user command: nextwhere"}
71 timeout
{fail
"(timeout) define user command: nextwhere"}
75 {fail
"define user command: nextwhere"}
76 timeout
{fail
"(timeout) define user command: nextwhere"}
79 # Verify that those commands work as gdb_expected.
81 send_gdb
"nextwhere\n"
83 -re
".*$bp_location1\[ \t\]*printf.*#0\[ \t\]*main.*:$bp_location1.*$gdb_prompt $"\
84 {pass
"use user command: nextwhere"}
86 {fail
"use user command: nextwhere"}
87 timeout
{fail
"(timeout) use user command: nextwhere"}
90 # Verify that a user can
define a command whose spelling is a
91 # proper substring of another user
-defined command.
93 send_gdb
"define nextwh\n"
95 -re
"Type commands for definition of \"nextwh\".\r\nEnd with a line saying just \"end\".\r\n>$"\
96 {send_gdb
"next 2\nbt\nend\n"
99 {pass
"define user command: nextwh"}
100 timeout
{fail
"(timeout) define user command: nextwh"}
104 {fail
"define user command: nextwh"}
105 timeout
{fail
"(timeout) define user command: nextwh"}
108 # Verify that a user can redefine their commands.
(Test both the
109 # confirmed and unconfirmed cases.
)
111 send_gdb
"define nextwhere\n"
113 -re
"Redefine command \"nextwhere\".*y or n. $"\
116 -re
"Command \"nextwhere\" not redefined.*$gdb_prompt $"\
117 {pass
"redefine user command aborted: nextwhere"}
119 {fail
"redefine user command aborted: nextwhere"}
120 timeout
{fail
"(timeout) redefine user command aborted: nextwhere"}
124 {fail
"redefine user command aborted: nextwhere"}
125 timeout
{fail
"(timeout) redefine user command aborted: nextwhere"}
128 send_gdb
"define nextwhere\n"
130 -re
"Redefine command \"nextwhere\".*y or n. $"\
133 -re
"Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
134 {send_gdb
"bt\nnext\nend\n"
137 {pass
"redefine user command: nextwhere"}
138 timeout
{fail
"(timeout) redefine user command: nextwhere"}
141 timeout
{fail
"(timeout) redefine user command: nextwhere"}
145 {fail
"redefine user command: nextwhere"}
146 timeout
{fail
"(timeout) redefine user command: nextwhere"}
149 # Verify that GDB gracefully handles an attempt to redefine the
150 # help
text for a builtin command.
152 send_gdb
"document step\n"
154 -re
"Command \"step\" is built-in..*$gdb_prompt $"\
155 {pass
"redocumenting builtin command disallowed"}
157 {fail
"redocumenting builtin command disallowed"}
158 timeout
{fail
"(timeout) redocumenting builtin command disallowed"}
161 # Verify that a user can document their own commands.
(And redocument
164 send_gdb
"document nextwhere\n"
166 -re
"Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
167 {send_gdb
"A next command that frist shows you where you're stepping from.\nend\n"
170 {pass
"document user command: nextwhere"}
171 timeout
{fail
"(timeout) document user command: nextwhere"}
175 {fail
"document user command: nextwhere"}
176 timeout
{fail
"(timeout) document user command: nextwhere"}
179 send_gdb
"document nextwhere\n"
181 -re
"Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
182 {send_gdb
"A next command that first shows you where you're stepping from.\nend\n"
185 {pass
"re-document user command: nextwhere"}
186 timeout
{fail
"(timeout) re-document user command: nextwhere"}
190 {fail
"re-document user command: nextwhere"}
191 timeout
{fail
"(timeout) re-document user command: nextwhere"}
194 send_gdb
"help nextwhere\n"
196 -re
"A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\
197 {pass
"help user command: nextwhere"}
199 {fail
"help user command: nextwhere"}
200 timeout
{fail
"(timeout) help user command: nextwhere"}
203 # Verify that the command parser doesn
't require a space after an 'if'
204 # command in a user defined function.
206 gdb_test_multiple "define ifnospace" "define user command: ifnospace" \
208 -re "Type commands for definition of \"ifnospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \
210 gdb_test_multiple "if(3<4)\nprint \"hi there\\n\"\nend\nend" "send body of ifnospace" \
213 {pass "define user command: ifnospace"}
218 gdb_test "ifnospace" ".*hi there.*" "test ifnospace is parsed correctly"
220 # Verify that the command parser doesn't require a space after an
'while'
221 # command in a user defined function.
223 gdb_test_multiple
"define whilenospace" "define user command: whilenospace" \
225 -re
"Type commands for definition of \"whilenospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \
227 gdb_test_multiple
"set \$i=1\nwhile(\$i<2)\nset \$i=2\nprint \"hi there\\n\"\nend\nend" "send body of whilenospace" \
229 -re
"$gdb_prompt $" \
230 {pass
"define user command: whilenospace"}
235 gdb_test
"whilenospace" ".*hi there.*" "test whilenospace is parsed correctly"
237 # Verify that the user can
"hook" a builtin command. We choose to
238 # hook the
"stop" pseudo command, and we'll define it to use a user-
241 send_gdb
"define user-bt\n"
243 -re
"Type commands for definition of \"user-bt\".\r\nEnd with a line saying just \"end\".\r\n>$"\
244 {send_gdb
"bt\nend\n"
247 {pass
"define user command: user-bt"}
248 timeout
{fail
"(timeout) define user command: user-bt"}
252 {fail
"define user command: user-bt"}
253 timeout
{fail
"(timeout) define user command: user-bt"}
256 send_gdb
"define hook-stop\n"
258 -re
"Type commands for definition of \"hook-stop\".\r\nEnd with a line saying just \"end\".\r\n>$"\
259 {send_gdb
"user-b\nend\n"
262 {pass
"define hook-stop command"}
263 timeout
{fail
"(timeout) define hook-stop command"}
267 {fail
"define hook-stop command"}
268 timeout
{fail
"(timeout) define hook-stop command"}
273 -re
"#0\[ \t\]*main.*:$bp_location11.*$gdb_prompt $"\
274 {pass
"use hook-stop command"}
276 {fail
"use hook-stop command"}
277 timeout
{fail
"(timeout) use hook-stop command"}
280 # Verify that GDB responds gracefully to an attempt to
define a
"hook
281 # command
" which doesn't exist. (Test both the confirmed and unconfirmed
284 send_gdb
"define hook-bar\n"
286 -re
"warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
289 -re
"Not confirmed.*$gdb_prompt $"\
290 {pass
"define hook undefined command aborted: bar"}
292 {fail
"define hook undefined command aborted: bar"}
293 timeout
{fail
"(timeout) define hook undefined command aborted: bar"}
297 {fail
"define hook undefined command aborted: bar"}
298 timeout
{fail
"(timeout) define hook undefined command aborted: bar"}
301 send_gdb
"define hook-bar\n"
303 -re
"warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
306 -re
"Type commands for definition of \"hook-bar\".\r\nEnd with a line saying just \"end\".\r\n>$"\
307 {send_gdb
"nextwhere\nend\n"
310 {pass
"define hook undefined command: bar"}
311 timeout
{fail
"(timeout) define hook undefined command: bar"}
315 {fail
"define hook undefined command: bar"}
316 timeout
{fail
"(timeout) define hook undefined command: bar"}
320 {fail
"define hook undefined command: bar"}
321 timeout
{fail
"(timeout) define hook undefined command: bar"}
324 # This is a quasi
-define command
: Verify that the user can redefine
327 send_gdb "set prompt \\(blah\\) \n"
330 {pass "set gdb_prompt"}
332 {fail "set gdb_prompt"}
333 timeout {fail "(timeout) set gdb_prompt"}
336 send_gdb "set prompt \\(gdb\\) \n"
339 {pass "reset gdb_prompt"}
340 timeout {fail "(timeout) reset gdb_prompt"}