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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.cp/] [exception.exp] - Blame information for rev 231

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

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

powered by: WebSVN 2.1.0

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