1 |
106 |
markom |
# Copyright (C) 1998 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 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 |
|
|
# This file was written by Elena Zannoni. (ezannoni@cygnus.com)
|
21 |
|
|
|
22 |
|
|
if $tracelevel then {
|
23 |
|
|
strace $tracelevel
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
global usestubs
|
27 |
|
|
|
28 |
|
|
|
29 |
|
|
#
|
30 |
|
|
# test running programs
|
31 |
|
|
#
|
32 |
|
|
set prms_id 0
|
33 |
|
|
set bug_id 0
|
34 |
|
|
|
35 |
|
|
set testfile "break"
|
36 |
|
|
set srcfile ${testfile}.c
|
37 |
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
38 |
|
|
|
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."
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
gdb_exit
|
44 |
|
|
gdb_start
|
45 |
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
46 |
|
|
gdb_load ${binfile}
|
47 |
|
|
|
48 |
|
|
if ![runto_main] then { fail "define tests suppressed" }
|
49 |
|
|
|
50 |
|
|
# Verify that GDB allows a user to define their very own commands.
|
51 |
|
|
#
|
52 |
|
|
send_gdb "define nextwhere\n"
|
53 |
|
|
gdb_expect {
|
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"
|
56 |
|
|
gdb_expect {
|
57 |
|
|
-re "$gdb_prompt $"\
|
58 |
|
|
{pass "define user command: nextwhere"}
|
59 |
|
|
timeout {fail "(timeout) define user command: nextwhere"}
|
60 |
|
|
}
|
61 |
|
|
}
|
62 |
|
|
-re "$gdb_prompt $"\
|
63 |
|
|
{fail "define user command: nextwhere"}
|
64 |
|
|
timeout {fail "(timeout) define user command: nextwhere"}
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
# Verify that those commands work as gdb_expected.
|
68 |
|
|
#
|
69 |
|
|
send_gdb "nextwhere\n"
|
70 |
|
|
gdb_expect {
|
71 |
|
|
-re ".*79\[ \t\]*printf.*#0\[ \t\]*main.*:79.*$gdb_prompt $"\
|
72 |
|
|
{pass "use user command: nextwhere"}
|
73 |
|
|
-re "$gdb_prompt $"\
|
74 |
|
|
{fail "use user command: nextwhere"}
|
75 |
|
|
timeout {fail "(timeout) use user command: nextwhere"}
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
# Verify that a user can define a command whose spelling is a
|
79 |
|
|
# proper substring of another user-defined command.
|
80 |
|
|
#
|
81 |
|
|
send_gdb "define nextwh\n"
|
82 |
|
|
gdb_expect {
|
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"
|
85 |
|
|
gdb_expect {
|
86 |
|
|
-re "$gdb_prompt $"\
|
87 |
|
|
{pass "define user command: nextwh"}
|
88 |
|
|
timeout {fail "(timeout) define user command: nextwh"}
|
89 |
|
|
}
|
90 |
|
|
}
|
91 |
|
|
-re "$gdb_prompt $"\
|
92 |
|
|
{fail "define user command: nextwh"}
|
93 |
|
|
timeout {fail "(timeout) define user command: nextwh"}
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
# Verify that a user can redefine their commands. (Test both the
|
97 |
|
|
# confirmed and unconfirmed cases.)
|
98 |
|
|
#
|
99 |
|
|
send_gdb "define nextwhere\n"
|
100 |
|
|
gdb_expect {
|
101 |
|
|
-re "Redefine command \"nextwhere\".*y or n. $"\
|
102 |
|
|
{send_gdb "n\n"
|
103 |
|
|
gdb_expect {
|
104 |
|
|
-re "Command \"nextwhere\" not redefined.*$gdb_prompt $"\
|
105 |
|
|
{pass "redefine user command aborted: nextwhere"}
|
106 |
|
|
-re "$gdb_prompt $"\
|
107 |
|
|
{fail "redefine user command aborted: nextwhere"}
|
108 |
|
|
timeout {fail "(timeout) redefine user command aborted: nextwhere"}
|
109 |
|
|
}
|
110 |
|
|
}
|
111 |
|
|
-re "$gdb_prompt $"\
|
112 |
|
|
{fail "redefine user command aborted: nextwhere"}
|
113 |
|
|
timeout {fail "(timeout) redefine user command aborted: nextwhere"}
|
114 |
|
|
}
|
115 |
|
|
|
116 |
|
|
send_gdb "define nextwhere\n"
|
117 |
|
|
gdb_expect {
|
118 |
|
|
-re "Redefine command \"nextwhere\".*y or n. $"\
|
119 |
|
|
{send_gdb "y\n"
|
120 |
|
|
gdb_expect {
|
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"
|
123 |
|
|
gdb_expect {
|
124 |
|
|
-re "$gdb_prompt $"\
|
125 |
|
|
{pass "redefine user command: nextwhere"}
|
126 |
|
|
timeout {fail "(timeout) redefine user command: nextwhere"}
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
|
|
timeout {fail "(timeout) redefine user command: nextwhere"}
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
|
|
-re "$gdb_prompt $"\
|
133 |
|
|
{fail "redefine user command: nextwhere"}
|
134 |
|
|
timeout {fail "(timeout) redefine user command: nextwhere"}
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
# Verify that GDB gracefully handles an attempt to redefine the
|
138 |
|
|
# help text for a builtin command.
|
139 |
|
|
#
|
140 |
|
|
send_gdb "document step\n"
|
141 |
|
|
gdb_expect {
|
142 |
|
|
-re "Command \"step\" is built-in..*$gdb_prompt $"\
|
143 |
|
|
{pass "redocumenting builtin command disallowed"}
|
144 |
|
|
-re "$gdb_prompt $"\
|
145 |
|
|
{fail "redocumenting builtin command disallowed"}
|
146 |
|
|
timeout {fail "(timeout) redocumenting builtin command disallowed"}
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
# Verify that a user can document their own commands. (And redocument
|
150 |
|
|
# them.)
|
151 |
|
|
#
|
152 |
|
|
send_gdb "document nextwhere\n"
|
153 |
|
|
gdb_expect {
|
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"
|
156 |
|
|
gdb_expect {
|
157 |
|
|
-re "$gdb_prompt $"\
|
158 |
|
|
{pass "document user command: nextwhere"}
|
159 |
|
|
timeout {fail "(timeout) document user command: nextwhere"}
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
|
|
-re "$gdb_prompt $"\
|
163 |
|
|
{fail "documenting user command: nextwhere"}
|
164 |
|
|
timeout {fail "(timeout) documenting user command: nextwhere"}
|
165 |
|
|
}
|
166 |
|
|
|
167 |
|
|
send_gdb "document nextwhere\n"
|
168 |
|
|
gdb_expect {
|
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"
|
171 |
|
|
gdb_expect {
|
172 |
|
|
-re "$gdb_prompt $"\
|
173 |
|
|
{pass "document user command: nextwhere"}
|
174 |
|
|
timeout {fail "(timeout) document user command: nextwhere"}
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
|
|
-re "$gdb_prompt $"\
|
178 |
|
|
{fail "documenting user command: nextwhere"}
|
179 |
|
|
timeout {fail "(timeout) documenting user command: nextwhere"}
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
send_gdb "help nextwhere\n"
|
183 |
|
|
gdb_expect {
|
184 |
|
|
-re "A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\
|
185 |
|
|
{pass "help user command: nextwhere"}
|
186 |
|
|
-re "$gdb_prompt $"\
|
187 |
|
|
{fail "help user command: nextwhere"}
|
188 |
|
|
timeout {fail "(timeout) help user command: nextwhere"}
|
189 |
|
|
}
|
190 |
|
|
|
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-
|
193 |
|
|
# define command.
|
194 |
|
|
#
|
195 |
|
|
send_gdb "define user-bt\n"
|
196 |
|
|
gdb_expect {
|
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"
|
199 |
|
|
gdb_expect {
|
200 |
|
|
-re "$gdb_prompt $"\
|
201 |
|
|
{pass "define user command: user-bt"}
|
202 |
|
|
timeout {fail "(timeout) define user command: user-bt"}
|
203 |
|
|
}
|
204 |
|
|
}
|
205 |
|
|
-re "$gdb_prompt $"\
|
206 |
|
|
{fail "define user command: user-bt"}
|
207 |
|
|
timeout {fail "(timeout) define user command: user-bt"}
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
send_gdb "define hook-stop\n"
|
211 |
|
|
gdb_expect {
|
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"
|
214 |
|
|
gdb_expect {
|
215 |
|
|
-re "$gdb_prompt $"\
|
216 |
|
|
{pass "define hook-stop command"}
|
217 |
|
|
timeout {fail "(timeout) define hook-stop command"}
|
218 |
|
|
}
|
219 |
|
|
}
|
220 |
|
|
-re "$gdb_prompt $"\
|
221 |
|
|
{fail "define hook-stop command"}
|
222 |
|
|
timeout {fail "(timeout) define hook-stop command"}
|
223 |
|
|
}
|
224 |
|
|
|
225 |
|
|
send_gdb "next\n"
|
226 |
|
|
gdb_expect {
|
227 |
|
|
-re "#0\[ \t\]*main.*:81.*$gdb_prompt $"\
|
228 |
|
|
{pass "use hook-stop command"}
|
229 |
|
|
-re "$gdb_prompt $"\
|
230 |
|
|
{fail "use hook-stop command"}
|
231 |
|
|
timeout {fail "(timeout) use hook-stop command"}
|
232 |
|
|
}
|
233 |
|
|
|
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
|
236 |
|
|
# cases.)
|
237 |
|
|
#
|
238 |
|
|
send_gdb "define hook-bar\n"
|
239 |
|
|
gdb_expect {
|
240 |
|
|
-re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
|
241 |
|
|
{send_gdb "n\n"
|
242 |
|
|
gdb_expect {
|
243 |
|
|
-re "Not confirmed.*$gdb_prompt $"\
|
244 |
|
|
{pass "define hook undefined command aborted: bar"}
|
245 |
|
|
-re "$gdb_prompt $"\
|
246 |
|
|
{fail "define hook undefined command aborted: bar"}
|
247 |
|
|
timeout {fail "(timeout) define hook undefined command aborted: bar"}
|
248 |
|
|
}
|
249 |
|
|
}
|
250 |
|
|
-re "$gdb_prompt $"\
|
251 |
|
|
{fail "define hook undefined command aborted: bar"}
|
252 |
|
|
timeout {fail "(timeout) define hook undefined command aborted: bar"}
|
253 |
|
|
}
|
254 |
|
|
|
255 |
|
|
send_gdb "define hook-bar\n"
|
256 |
|
|
gdb_expect {
|
257 |
|
|
-re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
|
258 |
|
|
{send_gdb "y\n"
|
259 |
|
|
gdb_expect {
|
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"
|
262 |
|
|
gdb_expect {
|
263 |
|
|
-re "$gdb_prompt $"\
|
264 |
|
|
{pass "define hook undefined command: bar"}
|
265 |
|
|
timeout {fail "(timeout) define hook undefined command: bar"}
|
266 |
|
|
}
|
267 |
|
|
}
|
268 |
|
|
-re "$gdb_prompt $"\
|
269 |
|
|
{fail "define hook undefined command: bar"}
|
270 |
|
|
timeout {fail "(timeout) define hook undefined command: bar"}
|
271 |
|
|
}
|
272 |
|
|
}
|
273 |
|
|
-re "$gdb_prompt $"\
|
274 |
|
|
{fail "define hook undefined command: bar"}
|
275 |
|
|
timeout {fail "(timeout) define hook undefined command: bar"}
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
# This is a quasi-define command: Verify that the user can redefine
|
279 |
|
|
# GDB's gdb_prompt.
|
280 |
|
|
#
|
281 |
|
|
send_gdb "set prompt \\(blah\\) \n"
|
282 |
|
|
gdb_expect {
|
283 |
|
|
-re "\\(blah\\) $"\
|
284 |
|
|
{pass "set gdb_prompt"}
|
285 |
|
|
-re "$gdb_prompt $"\
|
286 |
|
|
{fail "set gdb_prompt"}
|
287 |
|
|
timeout {fail "(timeout) set gdb_prompt"}
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
send_gdb "set prompt \\(gdb\\) \n"
|
291 |
|
|
gdb_expect {
|
292 |
|
|
-re "$gdb_prompt $"\
|
293 |
|
|
{pass "reset gdb_prompt"}
|
294 |
|
|
timeout {fail "(timeout) reset gdb_prompt"}
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
gdb_exit
|
298 |
|
|
return 0
|
299 |
|
|
|
300 |
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
|
304 |
|
|
|