1 # Copyright (C) 1998 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 binfile ${objdir}/${subdir}/${testfile}
39 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } {
40 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
45 gdb_reinitialize_dir $srcdir/$subdir
48 if ![runto_main] then { fail "define tests suppressed" }
50 # Verify that GDB allows a user to define their very own commands.
52 send_gdb "define nextwhere\n"
54 -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
55 {send_gdb "next\nbt\nend\n"
58 {pass "define user command: nextwhere"}
59 timeout {fail "(timeout) define user command: nextwhere"}
63 {fail "define user command: nextwhere"}
64 timeout {fail "(timeout) define user command: nextwhere"}
67 # Verify that those commands work as gdb_expected.
69 send_gdb "nextwhere\n"
71 -re ".*79\[ \t\]*printf.*#0\[ \t\]*main.*:79.*$gdb_prompt $"\
72 {pass "use user command: nextwhere"}
74 {fail "use user command: nextwhere"}
75 timeout {fail "(timeout) use user command: nextwhere"}
78 # Verify that a user can define a command whose spelling is a
79 # proper substring of another user-defined command.
81 send_gdb "define nextwh\n"
83 -re "Type commands for definition of \"nextwh\".\r\nEnd with a line saying just \"end\".\r\n>$"\
84 {send_gdb "next 2\nbt\nend\n"
87 {pass "define user command: nextwh"}
88 timeout {fail "(timeout) define user command: nextwh"}
92 {fail "define user command: nextwh"}
93 timeout {fail "(timeout) define user command: nextwh"}
96 # Verify that a user can redefine their commands. (Test both the
97 # confirmed and unconfirmed cases.)
99 send_gdb "define nextwhere\n"
101 -re "Redefine command \"nextwhere\".*y or n. $"\
104 -re "Command \"nextwhere\" not redefined.*$gdb_prompt $"\
105 {pass "redefine user command aborted: nextwhere"}
107 {fail "redefine user command aborted: nextwhere"}
108 timeout {fail "(timeout) redefine user command aborted: nextwhere"}
112 {fail "redefine user command aborted: nextwhere"}
113 timeout {fail "(timeout) redefine user command aborted: nextwhere"}
116 send_gdb "define nextwhere\n"
118 -re "Redefine command \"nextwhere\".*y or n. $"\
121 -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
122 {send_gdb "bt\nnext\nend\n"
125 {pass "redefine user command: nextwhere"}
126 timeout {fail "(timeout) redefine user command: nextwhere"}
129 timeout {fail "(timeout) redefine user command: nextwhere"}
133 {fail "redefine user command: nextwhere"}
134 timeout {fail "(timeout) redefine user command: nextwhere"}
137 # Verify that GDB gracefully handles an attempt to redefine the
138 # help text for a builtin command.
140 send_gdb "document step\n"
142 -re "Command \"step\" is built-in..*$gdb_prompt $"\
143 {pass "redocumenting builtin command disallowed"}
145 {fail "redocumenting builtin command disallowed"}
146 timeout {fail "(timeout) redocumenting builtin command disallowed"}
149 # Verify that a user can document their own commands. (And redocument
152 send_gdb "document nextwhere\n"
154 -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
155 {send_gdb "A next command that frist shows you where you're stepping from.\nend\n"
158 {pass "document user command: nextwhere"}
159 timeout {fail "(timeout) document user command: nextwhere"}
163 {fail "documenting user command: nextwhere"}
164 timeout {fail "(timeout) documenting user command: nextwhere"}
167 send_gdb "document nextwhere\n"
169 -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
170 {send_gdb "A next command that first shows you where you're stepping from.\nend\n"
173 {pass "document user command: nextwhere"}
174 timeout {fail "(timeout) document user command: nextwhere"}
178 {fail "documenting user command: nextwhere"}
179 timeout {fail "(timeout) documenting user command: nextwhere"}
182 send_gdb "help nextwhere\n"
184 -re "A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\
185 {pass "help user command: nextwhere"}
187 {fail "help user command: nextwhere"}
188 timeout {fail "(timeout) help user command: nextwhere"}
191 # Verify that the user can "hook" a builtin command. We choose to
192 # hook the "stop" pseudo command, and we'll define it to use a user-
195 send_gdb "define user-bt\n"
197 -re "Type commands for definition of \"user-bt\".\r\nEnd with a line saying just \"end\".\r\n>$"\
198 {send_gdb "bt\nend\n"
201 {pass "define user command: user-bt"}
202 timeout {fail "(timeout) define user command: user-bt"}
206 {fail "define user command: user-bt"}
207 timeout {fail "(timeout) define user command: user-bt"}
210 send_gdb "define hook-stop\n"
212 -re "Type commands for definition of \"hook-stop\".\r\nEnd with a line saying just \"end\".\r\n>$"\
213 {send_gdb "user-b\nend\n"
216 {pass "define hook-stop command"}
217 timeout {fail "(timeout) define hook-stop command"}
221 {fail "define hook-stop command"}
222 timeout {fail "(timeout) define hook-stop command"}
227 -re "#0\[ \t\]*main.*:81.*$gdb_prompt $"\
228 {pass "use hook-stop command"}
230 {fail "use hook-stop command"}
231 timeout {fail "(timeout) use hook-stop command"}
234 # Verify that GDB responds gracefully to an attempt to define a "hook
235 # command" which doesn't exist. (Test both the confirmed and unconfirmed
238 send_gdb "define hook-bar\n"
240 -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
243 -re "Not confirmed.*$gdb_prompt $"\
244 {pass "define hook undefined command aborted: bar"}
246 {fail "define hook undefined command aborted: bar"}
247 timeout {fail "(timeout) define hook undefined command aborted: bar"}
251 {fail "define hook undefined command aborted: bar"}
252 timeout {fail "(timeout) define hook undefined command aborted: bar"}
255 send_gdb "define hook-bar\n"
257 -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
260 -re "Type commands for definition of \"hook-bar\".\r\nEnd with a line saying just \"end\".\r\n>$"\
261 {send_gdb "nextwhere\nend\n"
264 {pass "define hook undefined command: bar"}
265 timeout {fail "(timeout) define hook undefined command: bar"}
269 {fail "define hook undefined command: bar"}
270 timeout {fail "(timeout) define hook undefined command: bar"}
274 {fail "define hook undefined command: bar"}
275 timeout {fail "(timeout) define hook undefined command: bar"}
278 # This is a quasi-define command: Verify that the user can redefine
281 send_gdb "set prompt \\(blah\\) \n"
284 {pass "set gdb_prompt"}
286 {fail "set gdb_prompt"}
287 timeout {fail "(timeout) set gdb_prompt"}
290 send_gdb "set prompt \\(gdb\\) \n"
293 {pass "reset gdb_prompt"}
294 timeout {fail "(timeout) reset gdb_prompt"}