3228289e1e
Make these functions restore the default handlers when passed a null pointer. This is consistent with std::pmr::set_default_resource(0), and also matches the current behaviour of libc++. In order to avoid duplicating the preprocessor condition from eh_term_handler.cc more that into a new eh_term_handler.h header and define a macro that can be used in both eh_term_handler.cc and eh_terminate.cc. PR libstdc++/90682 * libsupc++/eh_term_handler.cc: Include eh_term_handler.h to get definition of _GLIBCXX_DEFAULT_TERM_HANDLER. * libsupc++/eh_term_handler.h: New header defining _GLIBCXX_DEFAULT_TERM_HANDLER. * libsupc++/eh_terminate.cc: Include eh_term_handler.h. (set_terminate): Restore default handler when argument is null. (set_unexpected): Likewise. * testsuite/18_support/set_terminate.cc: New test. * testsuite/18_support/set_unexpected.cc: New test. From-SVN: r271808
40 lines
1.7 KiB
C++
40 lines
1.7 KiB
C++
// -*- C++ -*- default std::terminate handler
|
|
// Copyright (C) 2002-2019 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 <bits/c++config.h>
|
|
|
|
/* We default to the talkative, informative handler in a normal hosted
|
|
library. This pulls in the demangler, the dyn-string utilities, and
|
|
elements of the I/O library. For a low-memory environment, you can return
|
|
to the earlier "silent death" handler by configuring GCC with
|
|
--disable-libstdcxx-verbose and rebuilding the library.
|
|
In a freestanding environment, we default to this latter approach. */
|
|
|
|
#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE && __cpp_exceptions
|
|
# define _GLIBCXX_DEFAULT_TERM_HANDLER __gnu_cxx::__verbose_terminate_handler
|
|
#else
|
|
# include <cstdlib>
|
|
# define _GLIBCXX_DEFAULT_TERM_HANDLER std::abort
|
|
#endif
|