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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [exception.exp] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
# Copyright 1997, 1998, 2004, 2005, 2007, 2008 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 3 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, see .
15
 
16
# This file is part of the gdb testsuite.
17
# tests for exception-handling support
18
# Written by Satish Pai  1997-07-23
19
# Rewritten by Michael Chastain  2004-01-08
20
 
21
# This file used to have two copies of the tests with different
22
# compiler flags for hp-ux.  Instead, the user should set CXXOPTS
23
# or run runtest with --target_board unix/gdb:debug_flags="..."
24
# to choose the compiler flags.
25
#
26
# The interesting compiler flags are: "aCC +A -Wl,-a,-archive" .
27
# Static-linked executables use a different mechanism to get the
28
# address of the notification hook in the C++ support library.
29
 
30
# TODO: this file is not ready for production yet.  If you are working
31
# on C++ exception support for gdb, you can take out the "continue"
32
# statement and try your luck.  -- chastain 2004-01-09
33
 
34
# TODO: this file has many absolute line numbers.
35
# Replace them with gdb_get_line_number.
36
 
37
set ws  "\[\r\n\t \]+"
38
set nl  "\[\r\n\]+"
39
 
40
if $tracelevel then {
41
    strace $tracelevel
42
}
43
 
44
if { [skip_cplus_tests] } { continue }
45
 
46
# On SPU this test fails because the executable exceeds local storage size.
47
if { [istarget "spu*-*-*"] } {
48
        return 0
49
}
50
 
51
set testfile "exception"
52
set srcfile ${testfile}.cc
53
set binfile ${objdir}/${subdir}/${testfile}
54
 
55
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
56
     untested exception.exp
57
     return -1
58
}
59
 
60
# Start with a fresh gdb
61
 
62
set prms_id 0
63
set bug_id 0
64
 
65
gdb_exit
66
gdb_start
67
gdb_reinitialize_dir $srcdir/$subdir
68
gdb_load ${binfile}
69
 
70
if ![runto_main] then {
71
    perror "couldn't run to breakpoint"
72
    continue
73
}
74
 
75
# As I said before, this test script is not ready yet!
76
 
77
continue
78
 
79
# Set a catch catchpoint
80
 
81
gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
82
 
83
# Set a throw catchpoint
84
 
85
gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
86
    "catch throw (static executable)"
87
 
88
# The catchpoints should be listed in the list of breakpoints.
89
 
90
set re_head     "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
91
set re_1_main   "1${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}in main.*breakpoint already hit.*"
92
set re_2_catch  "2${ws}catch catch${ws}keep${ws}y${ws}$hex${ws}exception catch"
93
set re_3_catch  "3${ws}catch throw${ws}keep${ws}y${ws}$hex${ws}exception throw"
94
set re_2_bp     "2${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception catch"
95
set re_3_bp     "3${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception throw"
96
 
97
set name "info breakpoints"
98
gdb_test_multiple "info breakpoints" $name {
99
    -re "$re_head${ws}$re_1_main${ws}$re_2_catch${ws}$re_3_catch\r\n$gdb_prompt $" {
100
        pass $name
101
    }
102
    -re "$re_head${ws}$re_1_main${ws}$re_2_bp${ws}$re_3_bp\r\n$gdb_prompt $" {
103
        # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
104
        unresolved $name
105
    }
106
}
107
 
108
# Some targets support "info catch".
109
# Some do not.
110
 
111
set name "info catch"
112
gdb_test_multiple "info catch" $name {
113
    -re "Info catch not supported with this target/compiler combination.\r\n$gdb_prompt $" {
114
        unsupported $name
115
    }
116
    -re "No catches.\r\n$gdb_prompt $" {
117
        # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
118
        unresolved $name
119
    }
120
}
121
 
122
# Get the first exception thrown
123
 
124
set name "continue to first throw"
125
gdb_test_multiple "continue" $name {
126
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
127
        pass $name
128
    }
129
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
130
        # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
131
        unresolved $name
132
    }
133
}
134
 
135
# Backtrace from the throw point.
136
# This should get to user code.
137
 
138
set name "backtrace after first throw"
139
gdb_test_multiple "backtrace" $name {
140
    -re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:48\r\n$gdb_prompt $" {
141
        pass $name
142
    }
143
}
144
 
145
# Continue to the catch.
146
 
147
set name "continue to first catch"
148
gdb_test_multiple "continue" $name {
149
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:50\r\n$gdb_prompt $" {
150
        pass $name
151
    }
152
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
153
        # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
154
        unresolved $name
155
    }
156
}
157
 
158
# Backtrace from the catch point.
159
# This should get to user code.
160
 
161
set name "backtrace after first catch"
162
gdb_test_multiple "backtrace" $name {
163
    -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:50\r\n$gdb_prompt $" {
164
        pass $name
165
    }
166
}
167
 
168
# Continue to second throw.
169
 
170
set name "continue to second throw"
171
gdb_test_multiple "continue" $name {
172
    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
173
        pass $name
174
    }
175
    -re "Continuing.${ws}Got an except 13${ws}Catchpoint \[0-9\]+ \\(exception thrown\\)\r\n.*\r\n$gdb_prompt $" {
176
        # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
177
        unresolved $name
178
    }
179
}
180
 
181
# Backtrace from the throw point.
182
# This should get to user code.
183
 
184
set name "backtrace after second throw"
185
gdb_test_multiple "backtrace" $name {
186
    -re ".*#\[0-9\]+${ws}$hex in foo \\(i=20\\) at .*${srcfile}:30\r\n#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*${srcfile}:56\r\n$gdb_prompt $" {
187
        pass $name
188
    }
189
}
190
 
191
# Continue to second catch.
192
 
193
set name "continue to second catch"
194
gdb_test_multiple "continue" $name {
195
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\), throw location.*${srcfile}:30, catch location .*${srcfile}:58\r\n$gdb_prompt $" {
196
        pass $name
197
    }
198
    -re "Continuing.${ws}Catchpoint \[0-9\]+ \\(exception caught\\)\r\n.*\r\n$gdb_prompt $" {
199
        # TODO: gdb HEAD 2004-01-08 does this.  Is this okay?
200
        unresolved $name
201
    }
202
}
203
 
204
# Backtrace from the catch point.
205
# This should get to user code.
206
 
207
set name "backtrace after second catch"
208
gdb_test_multiple "backtrace" $name {
209
    -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:58\r\n$gdb_prompt $" {
210
        pass $name
211
    }
212
}
213
 
214
# That is all for now.
215
#
216
# The original code had:
217
#
218
#    continue to re-throw ; backtrace
219
#    continue to catch    ; backtrace
220
#    continue to throw out of main
221
#
222
# The problem is that "re-throw" does not show a throw; only a catch.
223
# I do not know if this is because of a bug, or because the generated
224
# code is optimized for a throw into the same function.
225
#
226
# -- chastain 2004-01-09

powered by: WebSVN 2.1.0

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