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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 227 jeremybenn
# Copyright 1998, 1999, 2001, 2003, 2004, 2007, 2008, 2009, 2010
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
# This file was written by Elena Zannoni. (ezannoni@cygnus.com)
18
 
19
if $tracelevel then {
20
        strace $tracelevel
21
        }
22
 
23
global usestubs
24
 
25
 
26
#
27
# test running programs
28
#
29
set prms_id 0
30
set bug_id 0
31
 
32
set testfile "break"
33
set srcfile ${testfile}.c
34
set srcfile1 ${testfile}1.c
35
set binfile ${objdir}/${subdir}/${testfile}
36
 
37
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
38
     untested define.exp
39
     return -1
40
}
41
 
42
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
43
     untested define.exp
44
     return -1
45
}
46
 
47
if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
48
     untested define.exp
49
     return -1
50
}
51
 
52
gdb_exit
53
gdb_start
54
gdb_reinitialize_dir $srcdir/$subdir
55
gdb_load ${binfile}
56
 
57
set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
58
set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
59
 
60
if ![runto_main] then { fail "define tests suppressed" }
61
 
62
# Verify that GDB allows a user to define their very own commands.
63
#
64
send_gdb "define nextwhere\n"
65
gdb_expect {
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"
68
           gdb_expect {
69
             -re "$gdb_prompt $"\
70
                     {pass "define user command: nextwhere"}
71
             timeout {fail "(timeout) define user command: nextwhere"}
72
           }
73
          }
74
  -re "$gdb_prompt $"\
75
          {fail "define user command: nextwhere"}
76
  timeout {fail "(timeout) define user command: nextwhere"}
77
}
78
 
79
# Verify that those commands work as gdb_expected.
80
#
81
send_gdb "nextwhere\n"
82
gdb_expect {
83
  -re ".*$bp_location1\[ \t\]*printf.*#0\[ \t\]*main.*:$bp_location1.*$gdb_prompt $"\
84
          {pass "use user command: nextwhere"}
85
  -re "$gdb_prompt $"\
86
          {fail "use user command: nextwhere"}
87
  timeout {fail "(timeout) use user command: nextwhere"}
88
}
89
 
90
# Verify that a user can define a command whose spelling is a
91
# proper substring of another user-defined command.
92
#
93
send_gdb "define nextwh\n"
94
gdb_expect {
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"
97
           gdb_expect {
98
             -re "$gdb_prompt $"\
99
                     {pass "define user command: nextwh"}
100
             timeout {fail "(timeout) define user command: nextwh"}
101
           }
102
          }
103
  -re "$gdb_prompt $"\
104
          {fail "define user command: nextwh"}
105
  timeout {fail "(timeout) define user command: nextwh"}
106
}
107
 
108
# Verify that a user can redefine their commands.  (Test both the
109
# confirmed and unconfirmed cases.)
110
#
111
send_gdb "define nextwhere\n"
112
gdb_expect {
113
  -re "Redefine command \"nextwhere\".*y or n. $"\
114
          {send_gdb "n\n"
115
           gdb_expect {
116
             -re "Command \"nextwhere\" not redefined.*$gdb_prompt $"\
117
                     {pass "redefine user command aborted: nextwhere"}
118
             -re "$gdb_prompt $"\
119
                     {fail "redefine user command aborted: nextwhere"}
120
             timeout {fail "(timeout) redefine user command aborted: nextwhere"}
121
           }
122
          }
123
  -re "$gdb_prompt $"\
124
          {fail "redefine user command aborted: nextwhere"}
125
  timeout {fail "(timeout) redefine user command aborted: nextwhere"}
126
}
127
 
128
send_gdb "define nextwhere\n"
129
gdb_expect {
130
  -re "Redefine command \"nextwhere\".*y or n. $"\
131
          {send_gdb "y\n"
132
           gdb_expect {
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"
135
                      gdb_expect {
136
                        -re "$gdb_prompt $"\
137
                                {pass "redefine user command: nextwhere"}
138
                        timeout {fail "(timeout) redefine user command: nextwhere"}
139
                      }
140
                     }
141
             timeout {fail "(timeout) redefine user command: nextwhere"}
142
           }
143
          }
144
  -re "$gdb_prompt $"\
145
          {fail "redefine user command: nextwhere"}
146
  timeout {fail "(timeout) redefine user command: nextwhere"}
147
}
148
 
149
# Verify that GDB gracefully handles an attempt to redefine the
150
# help text for a builtin command.
151
#
152
send_gdb "document step\n"
153
gdb_expect {
154
  -re "Command \"step\" is built-in..*$gdb_prompt $"\
155
          {pass "redocumenting builtin command disallowed"}
156
  -re "$gdb_prompt $"\
157
          {fail "redocumenting builtin command disallowed"}
158
  timeout {fail "(timeout) redocumenting builtin command disallowed"}
159
}
160
 
161
# Verify that a user can document their own commands.  (And redocument
162
# them.)
163
#
164
send_gdb "document nextwhere\n"
165
gdb_expect {
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"
168
           gdb_expect {
169
             -re "$gdb_prompt $"\
170
                     {pass "document user command: nextwhere"}
171
             timeout {fail "(timeout) document user command: nextwhere"}
172
           }
173
          }
174
  -re "$gdb_prompt $"\
175
          {fail "document user command: nextwhere"}
176
  timeout {fail "(timeout) document user command: nextwhere"}
177
}
178
 
179
send_gdb "document nextwhere\n"
180
gdb_expect {
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"
183
           gdb_expect {
184
             -re "$gdb_prompt $"\
185
                     {pass "re-document user command: nextwhere"}
186
             timeout {fail "(timeout) re-document user command: nextwhere"}
187
           }
188
          }
189
  -re "$gdb_prompt $"\
190
          {fail "re-document user command: nextwhere"}
191
  timeout {fail "(timeout) re-document user command: nextwhere"}
192
}
193
 
194
send_gdb "help nextwhere\n"
195
gdb_expect {
196
  -re "A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\
197
          {pass "help user command: nextwhere"}
198
  -re "$gdb_prompt $"\
199
          {fail "help user command: nextwhere"}
200
  timeout {fail "(timeout) help user command: nextwhere"}
201
}
202
 
203
# Verify that the document command preserves whitespace in the beginning of the line.
204
#
205
send_gdb "document nextwhere\n"
206
gdb_expect {
207
  -re "Type documentation for \"nextwhere\".\r\nEnd with a line saying just \"end\".\r\n>$"\
208
          {send_gdb "   A next command that first shows you where you're stepping from.\nend\n"
209
           gdb_expect {
210
             -re "$gdb_prompt $" {}
211
             timeout {fail "(timeout) preserve whitespace in help string"}
212
           }
213
          }
214
  -re "$gdb_prompt $"\
215
          {fail "preserve whitespace in help string"}
216
  timeout {fail "(timeout) preserve whitespace in help string"}
217
}
218
 
219
send_gdb "help nextwhere\n"
220
gdb_expect {
221
  -re "   A next command that first shows you where you're stepping from.\r\n$gdb_prompt $"\
222
          {pass "preserve whitespace in help string"}
223
  -re "$gdb_prompt $"\
224
          {fail "preserve whitespace in help string"}
225
  timeout {fail "(timeout) preserve whitespace in help string"}
226
}
227
 
228
# Verify that the command parser doesn't require a space after an 'if'
229
# command in a user defined function.
230
#
231
gdb_test_multiple "define ifnospace" "define user command: ifnospace" \
232
{
233
  -re "Type commands for definition of \"ifnospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \
234
    {
235
      gdb_test_multiple "if(3<4)\nprint \"hi there\\n\"\nend\nend" "send body of ifnospace"  \
236
        {
237
         -re "$gdb_prompt $"\
238
                 {pass "define user command: ifnospace"}
239
        }
240
    }
241
}
242
 
243
gdb_test "ifnospace" ".*hi there.*" "test ifnospace is parsed correctly"
244
 
245
# Verify that the command parser doesn't require a space after an 'while'
246
# command in a user defined function.
247
#
248
gdb_test_multiple "define whilenospace" "define user command: whilenospace" \
249
{
250
  -re "Type commands for definition of \"whilenospace\".\r\nEnd with a line saying just \"end\".\r\n>$" \
251
    {
252
      gdb_test_multiple "set \$i=1\nwhile(\$i<2)\nset \$i=2\nprint \"hi there\\n\"\nend\nend" "send body of whilenospace" \
253
         {
254
           -re "$gdb_prompt $" \
255
                   {pass "define user command: whilenospace"}
256
         }
257
    }
258
}
259
 
260
gdb_test "whilenospace" ".*hi there.*" "test whilenospace is parsed correctly"
261
 
262
# Verify that the user can "hook" a builtin command.  We choose to
263
# hook the "stop" pseudo command, and we'll define it to use a user-
264
# define command.
265
#
266
send_gdb "define user-bt\n"
267
gdb_expect {
268
  -re "Type commands for definition of \"user-bt\".\r\nEnd with a line saying just \"end\".\r\n>$"\
269
          {send_gdb "bt\nend\n"
270
           gdb_expect {
271
             -re "$gdb_prompt $"\
272
                       {pass "define user command: user-bt"}
273
             timeout {fail "(timeout) define user command: user-bt"}
274
           }
275
          }
276
  -re "$gdb_prompt $"\
277
          {fail "define user command: user-bt"}
278
  timeout {fail "(timeout) define user command: user-bt"}
279
}
280
 
281
send_gdb "define hook-stop\n"
282
gdb_expect {
283
  -re "Type commands for definition of \"hook-stop\".\r\nEnd with a line saying just \"end\".\r\n>$"\
284
          {send_gdb "user-b\nend\n"
285
           gdb_expect {
286
             -re "$gdb_prompt $"\
287
                       {pass "define hook-stop command"}
288
             timeout {fail "(timeout) define hook-stop command"}
289
           }
290
          }
291
  -re "$gdb_prompt $"\
292
          {fail "define hook-stop command"}
293
  timeout {fail "(timeout) define hook-stop command"}
294
}
295
 
296
send_gdb "next\n"
297
gdb_expect {
298
  -re "#0\[ \t\]*main.*:$bp_location11.*$gdb_prompt $"\
299
          {pass "use hook-stop command"}
300
  -re "$gdb_prompt $"\
301
          {fail "use hook-stop command"}
302
  timeout {fail "(timeout) use hook-stop command"}
303
}
304
 
305
# Verify that GDB responds gracefully to an attempt to define a "hook
306
# command" which doesn't exist.  (Test both the confirmed and unconfirmed
307
# cases.)
308
#
309
send_gdb "define hook-bar\n"
310
gdb_expect {
311
  -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
312
          {send_gdb "n\n"
313
           gdb_expect {
314
             -re "Not confirmed.*$gdb_prompt $"\
315
                     {pass "define hook undefined command aborted: bar"}
316
             -re "$gdb_prompt $"\
317
                     {fail "define hook undefined command aborted: bar"}
318
             timeout {fail "(timeout) define hook undefined command aborted: bar"}
319
           }
320
          }
321
  -re "$gdb_prompt $"\
322
          {fail "define hook undefined command aborted: bar"}
323
  timeout {fail "(timeout) define hook undefined command aborted: bar"}
324
}
325
 
326
send_gdb "define hook-bar\n"
327
gdb_expect {
328
  -re "warning: Your new `hook-bar' command does not hook any existing command.\r\nProceed.*y or n. $"\
329
          {send_gdb "y\n"
330
           gdb_expect {
331
             -re "Type commands for definition of \"hook-bar\".\r\nEnd with a line saying just \"end\".\r\n>$"\
332
                     {send_gdb "nextwhere\nend\n"
333
                      gdb_expect {
334
                        -re "$gdb_prompt $"\
335
                                {pass "define hook undefined command: bar"}
336
                        timeout {fail "(timeout) define hook undefined command: bar"}
337
                      }
338
                     }
339
             -re "$gdb_prompt $"\
340
                     {fail "define hook undefined command: bar"}
341
             timeout {fail "(timeout) define hook undefined command: bar"}
342
           }
343
          }
344
  -re "$gdb_prompt $"\
345
          {fail "define hook undefined command: bar"}
346
  timeout {fail "(timeout) define hook undefined command: bar"}
347
}
348
 
349
# Test creation of an additional target subcommand.
350
gdb_test_multiple "define target testsuite" "" {
351
    -re "Type commands for definition of \"target testsuite\".\r\nEnd with a line saying just \"end\".\r\n>$" {
352
        gdb_test "printf \"hello\\n\"\nend" "" "define target testsuite"
353
    }
354
}
355
gdb_test_multiple "document target testsuite" "" {
356
    -re "Type documentation for \"target testsuite\".\r\nEnd with a line saying just \"end\".\r\n>$" {
357
        gdb_test "A test target.\nend" "" "document target testsuite"
358
    }
359
}
360
 
361
gdb_test "help target" ".*A test target.*"
362
gdb_test "target testsuite" "hello"
363
gdb_test "show user target testsuite" "User command \"target testsuite\":\r\n  printf \"hello\\\\n\"\r\n"
364
 
365
# We should even be able to hook subcommands.
366
gdb_test_multiple "define target hook-testsuite" "" {
367
    -re "Type commands for definition of \"target hook-testsuite\".\r\nEnd with a line saying just \"end\".\r\n>$" {
368
        gdb_test "printf \"one\\n\"\nend" "" "define target hook-testsuite"
369
    }
370
}
371
 
372
gdb_test_multiple "define target hookpost-testsuite" "" {
373
    -re "Type commands for definition of \"target hookpost-testsuite\".\r\nEnd with a line saying just \"end\".\r\n>$" {
374
        gdb_test "printf \"two\\n\"\nend" "" "define target hookpost-testsuite"
375
    }
376
}
377
 
378
gdb_test "target testsuite" "one\r\nhello\r\ntwo" "target testsuite with hooks"
379
 
380
# This is a quasi-define command: Verify that the user can redefine
381
# GDB's gdb_prompt.
382
#
383
send_gdb "set prompt \\(blah\\) \n"
384
gdb_expect {
385
  -re "\\(blah\\) $"\
386
          {pass "set gdb_prompt"}
387
  -re "$gdb_prompt $"\
388
          {fail "set gdb_prompt"}
389
  timeout {fail "(timeout) set gdb_prompt"}
390
}
391
 
392
send_gdb "set prompt \\(gdb\\) \n"
393
gdb_expect {
394
  -re "$gdb_prompt $"\
395
          {pass "reset gdb_prompt"}
396
  timeout {fail "(timeout) reset gdb_prompt"}
397
}
398
 
399
gdb_exit
400
return 0

powered by: WebSVN 2.1.0

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