Fix test names starting with uppercase output by basic functions
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / gdb2495.exp
CommitLineData
618f726f 1# Copyright 2009-2016 Free Software Foundation, Inc.
7cd1089b
PM
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 <http://www.gnu.org/licenses/>.
15
16
17# In gdb inferior function calls, if a C++ exception is raised in the
18# dummy-frame, and the exception handler is (normally, and expected to
19# be) out-of-frame, the default C++ handler will (wrongly) be called
20# in an inferior function call.
21# This is incorrect as an exception can normally and legally be handled
22# out-of-frame. The confines of the dummy frame prevent the unwinder
23# from finding the correct handler (or any handler, unless it is
24# in-frame). The default handler calls std::terminate. This will kill
25# the inferior. Assert that terminate should never be called in an
26# inferior function call. These tests test the functionality around
27# unwinding that sequence and also tests the flag behaviour gating this
28# functionality.
02e7ea18
JB
29#
30# PR c++/9600.
7cd1089b
PM
31
32# This test is largely based of gdb.base/callfuncs.exp.
33
7cd1089b
PM
34if { [skip_cplus_tests] } { continue }
35
28f24826
DJ
36if [target_info exists gdb,nosignals] {
37 verbose "Skipping gdb2495.exp because of nosignals."
38 continue
39}
40
fcb34849
UW
41# On SPU this test fails because the executable exceeds local storage size.
42if { [istarget "spu*-*-*"] } {
43 return 0
44}
45
f5f3a911 46standard_testfile .cc
7cd1089b
PM
47
48# Create and source the file that provides information about the compiler
49# used to compile the test case.
4c93b1db 50if [get_compiler_info "c++"] {
7cd1089b
PM
51 return -1
52}
53
7cd1089b
PM
54# Some targets can't do function calls, so don't even bother with this
55# test.
56if [target_info exists gdb,cannot_call_functions] {
bc6c7af4 57 unsupported "this target can not call functions"
7cd1089b
PM
58 continue
59}
60
f5f3a911
TT
61if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
62 return -1
63}
7cd1089b
PM
64
65if ![runto_main] then {
66 perror "couldn't run to main"
67 continue
68}
69
70# See http://sourceware.org/gdb/bugs/2495
71
72# Test normal baseline behaviour. Call a function that
73# does not raise an exception.
74gdb_test "p exceptions.no_throw_function()" " = 1"
75# And one that does but handles it in-frame.
76gdb_test "p exceptions.throw_function_with_handler()" " = 2"
77# Both should return normally.
78
79# Test basic unwind. Call a function that raises an exception but
80# does not handle it. It should be rewound.
81gdb_test "p exceptions.throw_function()" \
82 "The program being debugged entered a std::terminate call, .*" \
83 "Call a function that raises an exception without a handler."
84
85# Make sure that after rewinding we are back at the call parent.
86gdb_test "bt" \
87 "#0 main.*" \
88 "bt after returning from a popped frame"
89
90# Make sure the only breakpoint is the one set via the runto_main
91# call and that the std::terminate breakpoint has evaporated and
92# cleaned-up.
93gdb_test "info breakpoints" \
0344e878 94 "gdb2495\.cc.*"
7cd1089b
PM
95
96# Turn off this new behaviour.
97gdb_test_multiple "set unwind-on-terminating-exception off" \
98 "Turn unwind-on-terminating-exception off" {
99 -re "$gdb_prompt $" {pass "set unwinn-on-terminating-exception off"}
100 timeout {fail "(timeout) set unwind-on-terminating-exception off"}
101}
102
103# Check that it is turned off.
104gdb_test "show unwind-on-terminating-exception" \
105 "exception is unhandled while in a call dummy is off.*" \
106 "Turn off unwind on terminating exception flag"
107
108# Check that the old behaviour is restored.
109gdb_test "p exceptions.throw_function()" \
110 "The program being debugged was signaled while in a function called .*" \
111 "Call a function that raises an exception with unwinding off.."
112
113# Restart the inferior back at main.
114if ![runto_main] then {
115 perror "couldn't run to main"
116 continue
117}
118
119
120# Check to see if the new behaviour alters the unwind signal
121# behaviour; it should not. Test both on and off states.
122
123# Turn on unwind on signal behaviour.
124gdb_test_multiple "set unwindonsignal on" "Turn unwindonsignal on" {
125 -re "$gdb_prompt $" {pass "set unwindonsignal on"}
126 timeout {fail "(timeout) set unwindonsignal on"}
127}
128
129# Check that it is turned on.
130gdb_test "show unwindonsignal" \
131 "signal is received while in a call dummy is on.*" \
132 "Turn on unwind on signal"
133
134# Check to see if new behaviour interferes with
135# normal signal handling in inferior function calls.
136gdb_test "p exceptions.raise_signal(1)" \
137 "To change this behavior use \"set unwindonsignal off\".*"
138
139# And reverse - turn off again.
140gdb_test_multiple "set unwindonsignal off" "Turn unwindonsignal off" {
141 -re "$gdb_prompt $" {pass "set unwindonsignal off"}
142 timeout {fail "(timeout) set unwindonsignal off"}
143}
144
145# Check that it is actually turned off.
146gdb_test "show unwindonsignal" \
147 "signal is received while in a call dummy is off.*" \
148 "Turn off unwind on signal"
149
150# Check to see if new behaviour interferes with
151# normal signal handling in inferior function calls.
152gdb_test "p exceptions.raise_signal(1)" \
153 "To change this behavior use \"set unwindonsignal on\".*"
This page took 0.845567 seconds and 4 git commands to generate.