* dw2-ref-missing-frame.S, dw2-ref-missing-frame.exp: New files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / exception.exp
CommitLineData
9b254dd1 1# Copyright 1997, 1998, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
7be570e7
JM
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
7be570e7 6# (at your option) any later version.
e22f8b7c 7#
7be570e7
JM
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.
e22f8b7c 12#
7be570e7 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
7be570e7 15
041ab88c 16# This file is part of the gdb testsuite.
7be570e7
JM
17# tests for exception-handling support
18# Written by Satish Pai <pai@apollo.hp.com> 1997-07-23
041ab88c 19# Rewritten by Michael Chastain <mec.gnu@mindspring.com> 2004-01-08
7be570e7 20
041ab88c
MC
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#
6fa9022e 26# The interesting compiler flags are: "aCC +A -Wl,-a,-archive" .
041ab88c
MC
27# Static-linked executables use a different mechanism to get the
28# address of the notification hook in the C++ support library.
7be570e7 29
041ab88c
MC
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
7be570e7 33
041ab88c
MC
34# TODO: this file has many absolute line numbers.
35# Replace them with gdb_get_line_number.
7be570e7 36
041ab88c
MC
37set ws "\[\r\n\t \]+"
38set nl "\[\r\n\]+"
7be570e7 39
041ab88c
MC
40if $tracelevel then {
41 strace $tracelevel
42}
7be570e7 43
5f579bc5
NS
44if { [skip_cplus_tests] } { continue }
45
c1d88655
UW
46# On SPU this test fails because the executable exceeds local storage size.
47if { [istarget "spu*-*-*"] } {
48 return 0
49}
50
7be570e7
JM
51set testfile "exception"
52set srcfile ${testfile}.cc
53set binfile ${objdir}/${subdir}/${testfile}
54
041ab88c 55if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
b60f0898
JB
56 untested exception.exp
57 return -1
7be570e7 58}
7be570e7
JM
59
60# Start with a fresh gdb
61
62set prms_id 0
63set bug_id 0
64
65gdb_exit
66gdb_start
67gdb_reinitialize_dir $srcdir/$subdir
68gdb_load ${binfile}
69
70if ![runto_main] then {
71 perror "couldn't run to breakpoint"
72 continue
73}
74
041ab88c
MC
75# As I said before, this test script is not ready yet!
76
77continue
78
7be570e7
JM
79# Set a catch catchpoint
80
041ab88c 81gdb_test "catch catch" "Catchpoint \[0-9\]+ \\(catch\\)"
7be570e7
JM
82
83# Set a throw catchpoint
84
041ab88c
MC
85gdb_test "catch throw" "Catchpoint \[0-9\]+ \\(throw\\)" \
86 "catch throw (static executable)"
7be570e7
JM
87
88# The catchpoints should be listed in the list of breakpoints.
89
041ab88c
MC
90set re_head "Num${ws}Type${ws}Disp${ws}Enb${ws}Address${ws}What"
91set re_1_main "1${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}in main.*breakpoint already hit.*"
92set re_2_catch "2${ws}catch catch${ws}keep${ws}y${ws}$hex${ws}exception catch"
93set re_3_catch "3${ws}catch throw${ws}keep${ws}y${ws}$hex${ws}exception throw"
94set re_2_bp "2${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception catch"
95set re_3_bp "3${ws}breakpoint${ws}keep${ws}y${ws}$hex${ws}exception throw"
96
97set name "info breakpoints"
98gdb_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
111set name "info catch"
112gdb_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 }
7be570e7
JM
120}
121
122# Get the first exception thrown
123
041ab88c
MC
124set name "continue to first throw"
125gdb_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 }
7be570e7
JM
133}
134
041ab88c
MC
135# Backtrace from the throw point.
136# This should get to user code.
7be570e7 137
041ab88c
MC
138set name "backtrace after first throw"
139gdb_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 }
7be570e7
JM
143}
144
041ab88c 145# Continue to the catch.
7be570e7 146
041ab88c
MC
147set name "continue to first catch"
148gdb_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 }
7be570e7
JM
156}
157
041ab88c
MC
158# Backtrace from the catch point.
159# This should get to user code.
7be570e7 160
041ab88c
MC
161set name "backtrace after first catch"
162gdb_test_multiple "backtrace" $name {
163 -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:50\r\n$gdb_prompt $" {
164 pass $name
165 }
7be570e7
JM
166}
167
041ab88c 168# Continue to second throw.
7be570e7 169
041ab88c
MC
170set name "continue to second throw"
171gdb_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 }
7be570e7
JM
179}
180
041ab88c
MC
181# Backtrace from the throw point.
182# This should get to user code.
7be570e7 183
041ab88c
MC
184set name "backtrace after second throw"
185gdb_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 }
7be570e7
JM
189}
190
041ab88c 191# Continue to second catch.
7be570e7 192
041ab88c
MC
193set name "continue to second catch"
194gdb_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 }
7be570e7
JM
202}
203
041ab88c
MC
204# Backtrace from the catch point.
205# This should get to user code.
7be570e7 206
041ab88c
MC
207set name "backtrace after second catch"
208gdb_test_multiple "backtrace" $name {
209 -re ".*#\[0-9\]+${ws}$hex in main \\((void|)\\) at .*$srcfile:58\r\n$gdb_prompt $" {
210 pass $name
211 }
7be570e7
JM
212}
213
041ab88c
MC
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
This page took 0.730463 seconds and 4 git commands to generate.