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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.c++/] [ovldbreak.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
# Copyright (C) 1998, 1999, 2001 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
# written by Elena Zannoni (ezannoni@cygnus.com)
21
# modified by Michael Chastain (chastain@redhat.com)
22
 
23
# This file is part of the gdb testsuite
24
#
25
# tests for overloaded member functions. Set breakpoints on
26
# overloaded member functions
27
#
28
 
29
 
30
if $tracelevel then {
31
        strace $tracelevel
32
        }
33
 
34
#
35
# test running programs
36
#
37
set prms_id 0
38
set bug_id 0
39
 
40
if { [skip_cplus_tests] } { continue }
41
 
42
set testfile "ovldbreak"
43
set srcfile ${testfile}.cc
44
set binfile ${objdir}/${subdir}/${testfile}
45
 
46
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
47
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
48
}
49
 
50
gdb_exit
51
gdb_start
52
gdb_reinitialize_dir $srcdir/$subdir
53
gdb_load ${binfile}
54
 
55
# set it up at a breakpoint so we can play with the variable values
56
#
57
if ![runto_main] then {
58
    perror "couldn't run to breakpoint"
59
    continue
60
}
61
 
62
 
63
 
64
# When I ask gdb to set a breakpoint on an overloaded function,
65
# gdb gives me a choice menu.  I might get stuck in that choice menu
66
# (for example, if C++ name mangling is not working properly).
67
#
68
# This procedure issues a command that works at either the menu
69
# prompt or the command prompt to get back to the command prompt.
70
#
71
# Note that an empty line won't do it (it means 'repeat the previous command'
72
# at top level).  A line with a single space in it works nicely.
73
 
74
proc take_gdb_out_of_choice_menu {} {
75
    global gdb_prompt
76
    send_gdb " \n"
77
    gdb_expect {
78
        -re ".*$gdb_prompt $" {
79
        }
80
        timeout {
81
            perror "could not resynchronize to command prompt (timeout)"
82
            continue
83
        }
84
    }
85
}
86
 
87
 
88
 
89
# This procedure sets an overloaded breakpoint.
90
# When I ask for such a breakpoint, gdb gives me a menu of 'cancel' 'all'
91
# and a bunch of choices.  I then choose from that menu by number.
92
 
93
proc set_bp_overloaded {name expectedmenu mychoice bpnumber linenumber} {
94
    global gdb_prompt hex srcfile
95
 
96
    # Get into the overload menu.
97
    send_gdb "break $name\n"
98
    gdb_expect {
99
        -re "$expectedmenu" {
100
            pass "bp menu for $name choice $mychoice"
101
 
102
            # Choose my choice.
103
            send_gdb "$mychoice\n"
104
            gdb_expect {
105
                -re "Breakpoint $bpnumber at $hex: file.*$srcfile, line $linenumber.\r\n$gdb_prompt $" {
106
                    pass "set bp $bpnumber on $name $mychoice line $linenumber"
107
                }
108
                -re ".*$gdb_prompt $" {
109
                    fail "set bp $bpnumber on $name $mychoice line $linenumber (bad bp)"
110
                }
111
                timeout {
112
                    fail "set bp $bpnumber on $name $mychoice line $linenumber (timeout)"
113
                    take_gdb_out_of_choice_menu
114
                }
115
            }
116
        }
117
        -re ".*\r\n> " {
118
            fail "bp menu for $name choice $mychoice (bad menu)"
119
            take_gdb_out_of_choice_menu
120
        }
121
        -re ".*$gdb_prompt $" {
122
            fail "bp menu for $name choice $mychoice (no menu)"
123
        }
124
        timeout {
125
            fail "bp menu for $name choice $mychoice (timeout)"
126
            take_gdb_out_of_choice_menu
127
        }
128
    }
129
}
130
 
131
# This is the expected menu for overload1arg.
132
# Note the arg type variations on lines 6 and 13.
133
# This accommodates different versions of g++.
134
 
135
set menu_overload1arg "\\\[0\\\] cancel\r\n\\\[1\\\] all\r\n\\\[2\\\] foo::overload1arg\\(double\\) at.*$srcfile:121\r\n\\\[3\\\] foo::overload1arg\\(float\\) at.*$srcfile:120\r\n\\\[4\\\] foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r\n\\\[5\\\] foo::overload1arg\\(long\\) at.*$srcfile:118\r\n\\\[6\\\] foo::overload1arg\\((unsigned int|unsigned)\\) at.*$srcfile:117\r\n\\\[7\\\] foo::overload1arg\\(int\\) at.*$srcfile:116\r\n\\\[8\\\] foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r\n\\\[9\\\] foo::overload1arg\\(short\\) at.*$srcfile:114\r\n\\\[10\\\] foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r\n\\\[11\\\] foo::overload1arg\\(signed char\\) at.*$srcfile:112\r\n\\\[12\\\] foo::overload1arg\\(char\\) at.*$srcfile:111\r\n\\\[13\\\] foo::overload1arg\\((void|)\\) at.*$srcfile:110\r\n> $"
136
 
137
 
138
 
139
# Set breakpoints on foo::overload1arg, one by one.
140
 
141
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 12    2 111
142
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 11    3 112
143
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 10    4 113
144
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  9    5 114
145
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  8    6 115
146
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  7    7 116
147
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  6    8 117
148
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  5    9 118
149
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  4   10 119
150
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  3   11 120
151
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg"  2   12 121
152
set_bp_overloaded "foo::overload1arg" "$menu_overload1arg" 13   13 110
153
 
154
 
155
 
156
# Verify the breakpoints.
157
 
158
gdb_test "info break" \
159
    "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
160
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
161
\[\t \]+breakpoint already hit 1 time\r
162
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
163
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
164
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
165
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
166
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
167
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
168
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
169
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
170
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
171
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
172
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
173
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
174
    "breakpoint info (after setting one-by-one)"
175
 
176
 
177
 
178
# Test choice "cancel".
179
# This is copy-and-paste from set_bp_overloaded.
180
 
181
send_gdb "break foo::overload1arg\n"
182
gdb_expect {
183
    -re "$menu_overload1arg" {
184
        pass "bp menu for foo::overload1arg choice cancel"
185
        # Choose cancel.
186
        send_gdb "0\n"
187
        gdb_expect {
188
            -re "canceled\r\n$gdb_prompt $" {
189
                pass "set bp on overload1arg canceled"
190
            }
191
            -re "cancelled\r\n$gdb_prompt $" {
192
                pass "set bp on overload1arg canceled"
193
            }
194
            -re ".*$gdb_prompt $" {
195
                fail "set bp on overload1arg canceled (bad message)"
196
            }
197
            timeout {
198
                fail "set bp on overload1arg canceled (timeout)"
199
                take_gdb_out_of_choice_menu
200
            }
201
        }
202
    }
203
    -re ".*\r\n> " {
204
        fail "bp menu for foo::overload1arg choice cancel (bad menu)"
205
        take_gdb_out_of_choice_menu
206
    }
207
    -re ".*$gdb_prompt $" {
208
        fail "bp menu for foo::overload1arg choice cancel (no menu)"
209
    }
210
    timeout {
211
        fail "bp menu for foo::overload1arg choice cancel (timeout)"
212
        take_gdb_out_of_choice_menu
213
    }
214
}
215
 
216
gdb_test "info break" \
217
    "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
218
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in main at.*$srcfile:49\r
219
\[\t \]+breakpoint already hit 1 time\r
220
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
221
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
222
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
223
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
224
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
225
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
226
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
227
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
228
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
229
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
230
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
231
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
232
    "breakpoint info (after cancel)"
233
 
234
 
235
 
236
# Delete these breakpoints.
237
 
238
send_gdb "delete breakpoints\n"
239
gdb_expect {
240
    -re "Delete all breakpoints.* $" {
241
        send_gdb "y\n"
242
        gdb_expect {
243
            -re ".*$gdb_prompt $" {
244
                pass "delete all breakpoints"
245
            }
246
            timeout {
247
                fail "delete all breakpoints (timeout)"
248
            }
249
        }
250
    }
251
    timeout {
252
        fail "delete all breakpoints (timeout)"
253
    }
254
}
255
 
256
gdb_test "info breakpoints" "No breakpoints or watchpoints." "breakpoint info (after delete)"
257
 
258
 
259
 
260
# Test choice "all".
261
# This is copy-and-paste from set_bp_overloaded.
262
 
263
send_gdb "break foo::overload1arg\n"
264
gdb_expect {
265
    -re "$menu_overload1arg" {
266
        pass "bp menu for foo::overload1arg choice all"
267
        # Choose all.
268
        send_gdb "1\n"
269
        gdb_expect {
270
            -re "Breakpoint $decimal at $hex: file.*$srcfile, line 121.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 120.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 119.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 118.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 117.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 116.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 115.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 114.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 113.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 112.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 111.\r\nBreakpoint $decimal at $hex: file.*$srcfile, line 110.\r\nwarning: Multiple breakpoints were set.\r\nwarning: Use the .delete. command to delete unwanted breakpoints.\r\n$gdb_prompt $" {
271
                pass "set bp on overload1arg all"
272
            }
273
            -re ".*$gdb_prompt $" {
274
                fail "set bp on overload1arg all (bad message)"
275
            }
276
            timeout {
277
                fail "set bp on overload1arg all (timeout)"
278
                take_gdb_out_of_choice_menu
279
            }
280
        }
281
    }
282
    -re ".*\r\n> " {
283
        fail "bp menu for foo::overload1arg choice all (bad menu)"
284
        take_gdb_out_of_choice_menu
285
    }
286
    -re ".*$gdb_prompt $" {
287
        fail "bp menu for foo::overload1arg choice all (no menu)"
288
    }
289
    timeout {
290
        fail "bp menu for foo::overload1arg choice all (timeout)"
291
        take_gdb_out_of_choice_menu
292
    }
293
}
294
 
295
gdb_test "info break" \
296
    "Num Type\[\t \]+Disp Enb Address\[\t \]+What.*
297
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(double\\) at.*$srcfile:121\r
298
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(float\\) at.*$srcfile:120\r
299
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned long\\) at.*$srcfile:119\r
300
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(long\\) at.*$srcfile:118\r
301
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((unsigned|unsigned int)\\) at.*$srcfile:117\r
302
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(int\\) at.*$srcfile:116\r
303
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned short\\) at.*$srcfile:115\r
304
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(short\\) at.*$srcfile:114\r
305
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(unsigned char\\) at.*$srcfile:113\r
306
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(signed char\\) at.*$srcfile:112\r
307
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\(char\\) at.*$srcfile:111\r
308
\[0-9\]+\[\t \]+breakpoint     keep y\[\t \]+$hex\[\t \]+in foo::overload1arg\\((void|)\\) at.*$srcfile:110" \
309
    "breakpoint info (after setting on all)"
310
 
311
 
312
 
313
# Run through each breakpoint.
314
 
315
proc continue_to_bp_overloaded {bpnumber argtype actuals} {
316
    global gdb_prompt hex decimal srcfile
317
 
318
    send_gdb "continue\n"
319
    gdb_expect {
320
        -re "Continuing.\r\n\r\nBreakpoint ${bpnumber}, (${hex} in )?foo::overload1arg(\\(${argtype}\\))? \\(this=${hex}(, )?${actuals}\\) at.*${srcfile}:${decimal}\r\n${decimal}\[\t \]+int foo::overload1arg \\(${argtype}( arg)?\\).*\r\n.*$gdb_prompt $" {
321
            pass "continue to bp overloaded : ${argtype}"
322
        }
323
        -re ".*$gdb_prompt $" {
324
            fail "continue to bp overloaded : ${argtype}"
325
        }
326
        timeout {
327
            fail "continue to bp overloaded : ${argtype} (timeout)"
328
        }
329
    }
330
}
331
 
332
continue_to_bp_overloaded 25 "(void|)" ""
333
continue_to_bp_overloaded 24 "char" "arg=2 \\'\\\\002\\'"
334
continue_to_bp_overloaded 23 "signed char" "arg=3 \\'\\\\003\\'"
335
continue_to_bp_overloaded 22 "unsigned char" "arg=4 \\'\\\\004\\'"
336
continue_to_bp_overloaded 21 "short" "arg=5"
337
continue_to_bp_overloaded 20 "unsigned short" "arg=6"
338
continue_to_bp_overloaded 19 "int" "arg=7"
339
continue_to_bp_overloaded 18 "(unsigned|unsigned int)" "arg=8"
340
continue_to_bp_overloaded 17 "long" "arg=9"
341
continue_to_bp_overloaded 16 "unsigned long" "arg=10"
342
continue_to_bp_overloaded 15 "float" "arg=100"
343
continue_to_bp_overloaded 14 "double" "arg=200"
344
 
345
 
346
 
347
# That's all, folks.
348
 
349
gdb_continue_to_end "finish program"

powered by: WebSVN 2.1.0

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