gcc/libstdc++-v3/libsupc++/eh_type.cc

55 lines
1.8 KiB
C++
Raw Normal View History

// -*- C++ -*- Exception handling routines for catching.
// Copyright (C) 2001-2017 Free Software Foundation, Inc.
//
// This file is part of GCC.
//
// GCC 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, or (at your option)
// any later version.
//
// GCC 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.
//
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
#include <typeinfo>
#include <cxxabi.h>
#include "unwind-cxx.h"
namespace __cxxabiv1
{
// Returns the type_info for the currently handled exception [15.3/8], or
// null if there is none.
extern "C"
std::type_info *__cxa_current_exception_type () _GLIBCXX_NOTHROW
{
__cxa_eh_globals *globals = __cxa_get_globals ();
__cxa_exception *header = globals->caughtExceptions;
if (header)
[multiple changes] 2008-08-23 Paolo Carlini <paolo.carlini@oracle.com> * testsuite/lib/libstdc++.exp (check_v3_target_atomic_builtins): Add. * testsuite/lib/dg-options.exp (dg-require-atomic-builtins): Likewise. * testsuite/18_support/exception_ptr/current_exception.cc: Use it. * testsuite/18_support/exception_ptr/rethrow_exception.cc: Likewise. * testsuite/18_support/exception_ptr/lifespan.cc: Likewise. 2008-08-23 Sebastian Redl <sebastian.redl@getdesigned.at> Add (again) exception propagation support as per N2179. Feature is available only when _GLIBCXX_ATOMIC_BUILTINS_4 is defined. * libsupc++/exception_ptr.h (exception_ptr, current_exception, copy_exception, rethrow_exception): New file, implement exception propagation. * libsupc++/eh_ptr.cc (exception_ptr, current_exception, rethrow_exception, __gxx_dependent_exception_cleanup): Likewise. * libsupc++/unwind-cxx.h (__cxa_exception): Add reference count. (__cxa_dependent_exception, __cxa_allocate_dependent_exception, __cxa_free_dependent_exception, __get_dependent_exception_from_ue, __GXX_INIT_DEPENDENT_EXCEPTION_CLASS, __is_dependent_exception, __gxx_dependent_exception_class, __get_object_from_ue, __get_object_from_ambiguous_exception): Add. (__GXX_INIT_EXCEPTION_CLASS, __gxx_exception_class): Rename. (__is_gxx_exception_class): Handle dependent exceptions. * libsupc++/eh_arm.cc (__cxa_type_match): Likewise. * libsupc++/eh_call.cc (__cxa_call_unexpected): Likewise. * libsupc++/eh_personality.cc (__gxx_personality_*): Likewise. * libsupc++/eh_type.cc (__cxa_current_exception_type): Likewise. * libsupc++/eh_alloc.cc (__cxa_allocate_dependent_exception, __cxa_free_dependent_exception): Add. * libsupc++/eh_throw.cc (__gxx_exception_cleanup): Handle reference counting. * libsupc++/exception: Conditionally include exception_ptr.h. * libsupc++/Makefile.am: Register new files. * libsupc++/Makefile.in: Regenerate. * config/abi/pre/gnu.ver: Add new symbols. * testsuite/18_support/exception_ptr/current_exception.cc: Test the core functionality of current_exception(). * testsuite/18_support/exception_ptr/rethrow_exception.cc: Test the core functionality of rethrow_exception(). * testsuite/18_support/exception_ptr/lifespan.cc: Test the life span of exception objects during exception propagation. From-SVN: r139509
2008-08-23 13:28:30 +02:00
{
if (__is_dependent_exception (header->unwindHeader.exception_class))
{
__cxa_dependent_exception *de =
__get_dependent_exception_from_ue (&header->unwindHeader);
header = __get_exception_header_from_obj (de->primaryException);
}
return header->exceptionType;
}
else
return 0;
}
} // namespace __cxxabiv1