OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [define.exp] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
# Copyright 1998, 1999, 2001, 2003, 2004, 2007, 2008
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
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 srcfile1 ${testfile}1.c
38
set binfile ${objdir}/${subdir}/${testfile}
39
 
40
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
41
     untested define.exp
42
     return -1
43
}
44
 
45
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
46
     untested define.exp
47
     return -1
48
}
49
 
50
if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
51
     untested define.exp
52
     return -1
53
}
54
 
55
gdb_exit
56
gdb_start
57
gdb_reinitialize_dir $srcdir/$subdir
58
gdb_load ${binfile}
59
 
60
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
61
set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
62
 
63
if ![runto_main] then { fail "define tests suppressed" }
64
 
65
# Verify that GDB allows a user to define their very own commands.
66
#
67
send_gdb "define nextwhere\n"
68
gdb_expect {
69
  -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
70
          {send_gdb "next\nbt\nend\n"
71
           gdb_expect {
72
             -re "$gdb_prompt $"\
73
                     {pass "define user command: nextwhere"}
74
             timeout {fail "(timeout) define user command: nextwhere"}
75
           }
76
          }
77
  -re "$gdb_prompt $"\
78
          {fail "define user command: nextwhere"}
79
  timeout {fail "(timeout) define user command: nextwhere"}
80
}
81
 
82
# Verify that those commands work as gdb_expected.
83
#
84
send_gdb "nextwhere\n"
85
gdb_expect {
86
  -re ".*$bp_location1\[ \t\]*printf.*#0\[ \t\]*main.*:$bp_location1.*$gdb_prompt $"\
87
          {pass "use user command: nextwhere"}
88
  -re "$gdb_prompt $"\
89
          {fail "use user command: nextwhere"}
90
  timeout {fail "(timeout) use user command: nextwhere"}
91
}
92
 
93
# Verify that a user can define a command whose spelling is a
94
# proper substring of another user-defined command.
95
#
96
send_gdb "define nextwh\n"
97
gdb_expect {
98
  -re "Type commands for definition of \"nextwh\".\r\nEnd with a line saying just \"end\".\r\n>$"\
99
          {send_gdb "next 2\nbt\nend\n"
100
           gdb_expect {
101
             -re "$gdb_prompt $"\
102
                     {pass "define user command: nextwh"}
103
             timeout {fail "(timeout) define user command: nextwh"}
104
           }
105
          }
106
  -re "$gdb_prompt $"\
107
          {fail "define user command: nextwh"}
108
  timeout {fail "(timeout) define user command: nextwh"}
109
}
110
 
111
# Verify that a user can redefine their commands.  (Test both the
112
# confirmed and unconfirmed cases.)
113
#
114
send_gdb "define nextwhere\n"
115
gdb_expect {
116
  -re "Redefine command \"nextwhere\".*y or n. $"\
117
          {send_gdb "n\n"
118
           gdb_expect {
119
             -re "Command \"nextwhere\" not redefined.*$gdb_prompt $"\
120
                     {pass "redefine user command aborted: nextwhere"}
121
             -re "$gdb_prompt $"\
122
                     {fail "redefine user command aborted: nextwhere"}
123
             timeout {fail "(timeout) redefine user command aborted: nextwhere"}
124
           }
125
          }
126
  -re "$gdb_prompt $"\
127
          {fail "redefine user command aborted: nextwhere"}
128
  timeout {fail "(timeout) redefine user command aborted: nextwhere"}
129
}
130
 
131
send_gdb "define nextwhere\n"
132
gdb_expect {
133
  -re "Redefine command \"nextwhere\".*y or n. $"\
134
          {send_gdb "y\n"
135
           gdb_expect {
136
             -re "Type commands for definition of \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
137
                     {send_gdb "bt\nnext\nend\n"
138
                      gdb_expect {
139
                        -re "$gdb_prompt $"\
140
                                {pass "redefine user command: nextwhere"}
141
                        timeout {fail "(timeout) redefine user command: nextwhere"}
142
                      }
143
                     }
144
             timeout {fail "(timeout) redefine user command: nextwhere"}
145
           }
146
          }
147
  -re "$gdb_prompt $"\
148
          {fail "redefine user command: nextwhere"}
149
  timeout {fail "(timeout) redefine user command: nextwhere"}
150
}
151
 
152
# Verify that GDB gracefully handles an attempt to redefine the
153
# help text for a builtin command.
154
#
155
send_gdb "document step\n"
156
gdb_expect {
157
  -re "Command \"step\" is built-in..*$gdb_prompt $"\
158
          {pass "redocumenting builtin command disallowed"}
159
  -re "$gdb_prompt $"\
160
          {fail "redocumenting builtin command disallowed"}
161
  timeout {fail "(timeout) redocumenting builtin command disallowed"}
162
}
163
 
164
# Verify that a user can document their own commands.  (And redocument
165
# them.)
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 frist 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 "document user command: nextwhere"}
179
  timeout {fail "(timeout) document user command: nextwhere"}
180
}
181
 
182
send_gdb "document nextwhere\n"
183
gdb_expect {
184
  -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
185
          {send_gdb "A next command that first shows you where you're stepping from.\nend\n"
186
           gdb_expect {
187
             -re "$gdb_prompt $"\
188
                     {pass "re-document user command: nextwhere"}
189
             timeout {fail "(timeout) re-document user command: nextwhere"}
190
           }
191
          }
192
  -re "$gdb_prompt $"\
193
          {fail "re-document user command: nextwhere"}
194
  timeout {fail "(timeout) re-document user command: nextwhere"}
195
}
196
 
197
send_gdb "help nextwhere\n"
198
gdb_expect {
199
  -re "A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\
200
          {pass "help user command: nextwhere"}
201
  -re "$gdb_prompt $"\
202
          {fail "help user command: nextwhere"}
203
  timeout {fail "(timeout) help user command: nextwhere"}
204
}
205
 
206
# Verify that the command parser doesn't require a space after an 'if'
207
# command in a user defined function.
208
#
209
gdb_test_multiple "define ifnospace" "define user command: ifnospace" \
210
{
211
  -re "Type commands for definition of \"ifnospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \
212
    {
213
      gdb_test_multiple "if(3<4)\nprint \"hi there\\n\"\nend\nend" "send body of ifnospace"  \
214
        {
215
         -re "$gdb_prompt $"\
216
                 {pass "define user command: ifnospace"}
217
        }
218
    }
219
}
220
 
221
gdb_test "ifnospace" ".*hi there.*" "test ifnospace is parsed correctly"
222
 
223
# Verify that the command parser doesn't require a space after an 'while'
224
# command in a user defined function.
225
#
226
gdb_test_multiple "define whilenospace" "define user command: whilenospace" \
227
{
228
  -re "Type commands for definition of \"whilenospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \
229
    {
230
      gdb_test_multiple "set \$i=1\nwhile(\$i<2)\nset \$i=2\nprint \"hi there\\n\"\nend\nend" "send body of whilenospace" \
231
         {
232
           -re "$gdb_prompt $" \
233
                   {pass "define user command: whilenospace"}
234
         }
235
    }
236
}
237
 
238
gdb_test "whilenospace" ".*hi there.*" "test whilenospace is parsed correctly"
239
 
240
# Verify that the user can "hook" a builtin command.  We choose to
241
# hook the "stop" pseudo command, and we'll define it to use a user-
242
# define command.
243
#
244
send_gdb "define user-bt\n"
245
gdb_expect {
246
  -re "Type commands for definition of \"user-bt\".\r\nEnd with a line saying just \"end\".\r\n>$"\
247
          {send_gdb "bt\nend\n"
248
           gdb_expect {
249
             -re "$gdb_prompt $"\
250
                       {pass "define user command: user-bt"}
251
             timeout {fail "(timeout) define user command: user-bt"}
252
           }
253
          }
254
  -re "$gdb_prompt $"\
255
          {fail "define user command: user-bt"}
256
  timeout {fail "(timeout) define user command: user-bt"}
257
}
258
 
259
send_gdb "define hook-stop\n"
260
gdb_expect {
261
  -re "Type commands for definition of \"hook-stop\".\r\nEnd with a line saying just \"end\".\r\n>$"\
262
          {send_gdb "user-b\nend\n"
263
           gdb_expect {
264
             -re "$gdb_prompt $"\
265
                       {pass "define hook-stop command"}
266
             timeout {fail "(timeout) define hook-stop command"}
267
           }
268
          }
269
  -re "$gdb_prompt $"\
270
          {fail "define hook-stop command"}
271
  timeout {fail "(timeout) define hook-stop command"}
272
}
273
 
274
send_gdb "next\n"
275
gdb_expect {
276
  -re "#0\[ \t\]*main.*:$bp_location11.*$gdb_prompt $"\
277
          {pass "use hook-stop command"}
278
  -re "$gdb_prompt $"\
279
          {fail "use hook-stop command"}
280
  timeout {fail "(timeout) use hook-stop command"}
281
}
282
 
283
# Verify that GDB responds gracefully to an attempt to define a "hook
284
# command" which doesn't exist.  (Test both the confirmed and unconfirmed
285
# cases.)
286
#
287
send_gdb "define hook-bar\n"
288
gdb_expect {
289
  -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
290
          {send_gdb "n\n"
291
           gdb_expect {
292
             -re "Not confirmed.*$gdb_prompt $"\
293
                     {pass "define hook undefined command aborted: bar"}
294
             -re "$gdb_prompt $"\
295
                     {fail "define hook undefined command aborted: bar"}
296
             timeout {fail "(timeout) define hook undefined command aborted: bar"}
297
           }
298
          }
299
  -re "$gdb_prompt $"\
300
          {fail "define hook undefined command aborted: bar"}
301
  timeout {fail "(timeout) define hook undefined command aborted: bar"}
302
}
303
 
304
send_gdb "define hook-bar\n"
305
gdb_expect {
306
  -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
307
          {send_gdb "y\n"
308
           gdb_expect {
309
             -re "Type commands for definition of \"hook-bar\".\r\nEnd with a line saying just \"end\".\r\n>$"\
310
                     {send_gdb "nextwhere\nend\n"
311
                      gdb_expect {
312
                        -re "$gdb_prompt $"\
313
                                {pass "define hook undefined command: bar"}
314
                        timeout {fail "(timeout) define hook undefined command: bar"}
315
                      }
316
                     }
317
             -re "$gdb_prompt $"\
318
                     {fail "define hook undefined command: bar"}
319
             timeout {fail "(timeout) define hook undefined command: bar"}
320
           }
321
          }
322
  -re "$gdb_prompt $"\
323
          {fail "define hook undefined command: bar"}
324
  timeout {fail "(timeout) define hook undefined command: bar"}
325
}
326
 
327
# This is a quasi-define command: Verify that the user can redefine
328
# GDB's gdb_prompt.
329
#
330
send_gdb "set prompt \\(blah\\) \n"
331
gdb_expect {
332
  -re "\\(blah\\) $"\
333
          {pass "set gdb_prompt"}
334
  -re "$gdb_prompt $"\
335
          {fail "set gdb_prompt"}
336
  timeout {fail "(timeout) set gdb_prompt"}
337
}
338
 
339
send_gdb "set prompt \\(gdb\\) \n"
340
gdb_expect {
341
  -re "$gdb_prompt $"\
342
          {pass "reset gdb_prompt"}
343
  timeout {fail "(timeout) reset gdb_prompt"}
344
}
345
 
346
gdb_exit
347
return 0
348
 
349
 
350
 
351
 
352
 
353
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.