From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6628 invoked by alias); 5 Jan 2009 23:03:30 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 6603 invoked by uid 9519); 5 Jan 2009 23:03:28 -0000 Date: Mon, 05 Jan 2009 23:03:00 -0000 Message-ID: <20090105230328.6587.qmail@sourceware.org> From: rmoseley@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-rmoseley-demo-merge: Left out test case for Phil's patch. X-Git-Refname: refs/heads/archer-rmoseley-demo-merge X-Git-Reftype: branch X-Git-Oldrev: b929ffe69f05ccfeb41d6c64416ddaf4e405bbe2 X-Git-Newrev: 3a6a85cc72aa3c6ef8be5e8b85d695487b26fa3d X-SW-Source: 2009-q1/txt/msg00002.txt.bz2 List-Id: The branch, archer-rmoseley-demo-merge has been updated via 3a6a85cc72aa3c6ef8be5e8b85d695487b26fa3d (commit) from b929ffe69f05ccfeb41d6c64416ddaf4e405bbe2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 3a6a85cc72aa3c6ef8be5e8b85d695487b26fa3d Author: Rick Moseley Date: Mon Jan 5 17:01:39 2009 -0600 Left out test case for Phil's patch. ----------------------------------------------------------------------- Summary of changes: gdb/testsuite/gdb.cp/gdb2495.cc | 90 +++++++++++++++++++++ gdb/testsuite/gdb.cp/gdb2495.exp | 160 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 0 deletions(-) create mode 100644 gdb/testsuite/gdb.cp/gdb2495.cc create mode 100644 gdb/testsuite/gdb.cp/gdb2495.exp First 500 lines of diff: diff --git a/gdb/testsuite/gdb.cp/gdb2495.cc b/gdb/testsuite/gdb.cp/gdb2495.cc new file mode 100644 index 0000000..4df265f --- /dev/null +++ b/gdb/testsuite/gdb.cp/gdb2495.cc @@ -0,0 +1,90 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + */ + +#include +#include + +using namespace std; + +class SimpleException +{ + +public: + + void raise_signal (int dummy) + { + if (dummy > 0) + raise(SIGABRT); + } + + int no_throw_function () + { + return 1; + } + + void throw_function () + { + throw 1; + } + + int throw_function_with_handler () + { + try + { + throw 1; + } + catch (...) + { + cout << "Handled" << endl; + } + + return 2; + } + + void call_throw_function_no_handler () + { + throw_function (); + } + + void call_throw_function_handler () + { + throw_function_with_handler (); + } +}; +SimpleException exceptions; + +int +main() +{ + // Have to call all these functions + // so not optimized away. + exceptions.raise_signal (-1); + exceptions.no_throw_function (); + exceptions.throw_function_with_handler (); + exceptions.call_throw_function_handler (); + try + { + exceptions.throw_function (); + exceptions.call_throw_function_no_handler (); + } + catch (...) + { + } + return 0; +} + diff --git a/gdb/testsuite/gdb.cp/gdb2495.exp b/gdb/testsuite/gdb.cp/gdb2495.exp new file mode 100644 index 0000000..5afeb1b --- /dev/null +++ b/gdb/testsuite/gdb.cp/gdb2495.exp @@ -0,0 +1,160 @@ +# Copyright 2008 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +# In gdb inferior function calls, if a C++ exception is raised in the +# dummy-frame, and the exception handler is (normally, and expected to +# be) out-of-frame, the default C++ handler will (wrongly) be called +# in an inferior function call. +# This is incorrect as an exception can normally and legally be handled +# out-of-frame. The confines of the dummy frame prevent the unwinder +# from finding the correct handler (or any handler, unless it is +# in-frame). The default handler calls std::terminate. This will kill +# the inferior. Assert that terminate should never be called in an +# inferior function call. These tests test the functionality around +# unwinding that sequence and also tests the flag behaviour gating this +# functionality. + +# This test is largley based off gdb.base/callfuncs.exp. + +if $tracelevel then { + strace $tracelevel +} + +if { [skip_cplus_tests] } { continue } + +set prms_id 2495 +set bug_id 0 + +set testfile "gdb2495" +set srcfile ${testfile}.cc +set binfile $objdir/$subdir/$testfile + +# Create and source the file that provides information about the compiler +# used to compile the test case. +if [get_compiler_info ${binfile} "c++"] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } { + untested gdb2495.exp + return -1 +} + +# Some targets can't do function calls, so don't even bother with this +# test. +if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" 2416 + fail "This target can not call functions" + continue +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + perror "couldn't run to main" + continue +} + +# See http://sources.redhat.com/gdb/bugs/2495 + +# Test normal baseline behaviour. Call a function that +# does not raise an exception ... +gdb_test "p exceptions.no_throw_function()" " = 1" +# And one that does but handles it in-frame ... +gdb_test "p exceptions.throw_function_with_handler()" " = 2" +# Both should return normally. + +# Test basic unwind. Call a function that raises an exception but +# does not handle it. It should be rewound ... +gdb_test "p exceptions.throw_function()" \ + "The program being debugged entered a std::terminate call .*" \ + "Call a function that raises an exception without a handler." + +# Make sure that after rewinding we are back at the call parent. +gdb_test "bt" \ + "#0 main.*" \ + "bt after returning from a popped frame" + +# Make sure the only breakpoint is the one set via the runto_main +# call and that the std::terminate breakpoint has evaporated and +# cleaned-up. +gdb_test "info breakpoints" \ + "gdb.cp/gdb2495\.cc.*" + +# Turn off this new behaviour ... +send_gdb "set unwind-on-terminating-exception off\n" +gdb_expect { + -re "$gdb_prompt $" {pass "set unwind-on-terminating-exception"} + timeout {fail "(timeout) set unwind-on-terminating-exception"} +} + +# Check that it is turned off ... +gdb_test "show unwind-on-terminating-exception" \ + "exception is unhandled while in a call dummy is off.*" \ + "Turn off unwind on terminating exception flag" + +# Check that the old behaviour is restored. +gdb_test "p exceptions.throw_function()" \ + "The program being debugged was signaled while in a function .*" \ + "Call a function that raises an exception with unwinding off.." + + +# Restart back at main +if ![runto_main] then { + perror "couldn't run to main" + continue +} + + +# Check to see if our new behaviour alters the unwind signal +# behaviour. It should not. Test both on and off states. + +# Turn on unwind on signal behaviour ... +send_gdb "set unwindonsignal on\n" +gdb_expect { + -re "$gdb_prompt $" {pass "set unwindonsignal on"} + timeout {fail "(timeout) set unwindonsignal on"} +} + +# Check that it is turned on ... +gdb_test "show unwindonsignal" \ + "signal is received while in a call dummy is on.*" \ + "Turn on unwind on signal" + +# Check to see if new behaviour interferes with +# normal signal handling in inferior function calls. +gdb_test "p exceptions.raise_signal(1)" \ + "To change this behavior use \"set unwindonsignal off\".*" + +# And reverse. Turn off +send_gdb "set unwindonsignal off\n" +gdb_expect { + -re "$gdb_prompt $" {pass "set unwindonsignal off"} + timeout {fail "(timeout) set unwindonsignal off"} +} + +# Check that it is turned off ... +gdb_test "show unwindonsignal" \ + "signal is received while in a call dummy is off.*" \ + "Turn off unwind on signal" + +# Check to see if new behaviour interferes with +# normal signal handling in inferior function calls. +gdb_test "p exceptions.raise_signal(1)" \ + "To change this behavior use \"set unwindonsignal on\".*" hooks/post-receive -- Repository for Project Archer.