From: wolf Date: Thu, 19 Dec 2002 19:41:35 +0000 (+0000) Subject: Detect and possibly use __verbose_terminate_handler. The text in aclocal.m4 says: X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59aace0c401acc3edf2ad7907385233fab2b0df6;p=dealii-svn.git Detect and possibly use __verbose_terminate_handler. The text in aclocal.m4 says: // Newer versions of gcc have a very nice feature: you can set // a verbose terminate handler, that not only aborts a program // when an exception is thrown and not caught somewhere, but // before aborting it prints that an exception has been thrown, // and possibly what the std::exception::what() function has to // say. Since many people run into the trap of not having a // catch clause in main(), they wonder where that abort may be // coming from. The terminate handler then at least says what is // missing in their program. git-svn-id: https://svn.dealii.org/trunk@6859 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index af89621b5d..1b0c51ac68 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -2388,6 +2388,59 @@ AC_DEFUN(DEAL_II_HAVE_BUILTIN_EXPECT, dnl +dnl ------------------------------------------------------------- +dnl Newer versions of gcc have a very nice feature: you can set +dnl a verbose terminate handler, that not only aborts a program +dnl when an exception is thrown and not caught somewhere, but +dnl before aborting it prints that an exception has been thrown, +dnl and possibly what the std::exception::what() function has to +dnl say. Since many people run into the trap of not having a +dnl catch clause in main(), they wonder where that abort may be +dnl coming from. The terminate handler then at least says what is +dnl missing in their program. +dnl +dnl This test checks whether this feature is available. +dnl +dnl Usage: DEAL_II_HAVE_VERBOSE_TERMINATE +dnl +dnl ------------------------------------------------------------- +AC_DEFUN(DEAL_II_HAVE_VERBOSE_TERMINATE, dnl +[ + AC_MSG_CHECKING(for __verbose_terminate_handler) + AC_LANG(C++) + CXXFLAGS="$CXXFLAGSG" + AC_TRY_LINK( + [ +#include + +namespace __gnu_cxx +{ + extern void __verbose_terminate_handler (); +} + +struct preload_terminate_dummy +{ + preload_terminate_dummy() + { std::set_terminate (__gnu_cxx::__verbose_terminate_handler); } +}; + +static preload_terminate_dummy dummy; + ], + [ + throw 1; + ], + [ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_VERBOSE_TERMINATE, 1, + [Define if the compiler provides __verbose_terminate_handler]) + ], + [ + AC_MSG_RESULT(no) + ]) +]) + + + dnl ------------------------------------------------------------- dnl When compiling with ACE thread support, there are many constructs dnl that are not allowed in C++, or that yield warnings when compiling with diff --git a/deal.II/base/include/base/config.h.in b/deal.II/base/include/base/config.h.in index 36c6ce3f61..42bdc72147 100644 --- a/deal.II/base/include/base/config.h.in +++ b/deal.II/base/include/base/config.h.in @@ -171,6 +171,9 @@ classes (early gcc versions did not) */ #undef HAVE_STD_STRINGSTREAM +/* Define if the compiler provides __verbose_terminate_handler */ +#undef HAVE_VERBOSE_TERMINATE + /* On SunOS 4.x, the getrusage() function exists, but is not declared in the respective header file , as one would think when reading the man pages. Then we have to declare this function ourselves in those files @@ -211,9 +214,9 @@ * here to make them unconditionally available to all other parts of the * library. * - * The constants defined here are a subset of the constants sometimes - * declared in the system include file , but without the - * prefix . + * The constants defined here are a subset of the @p{M_XXX} constants sometimes + * declared in the system include file @p{math.h}, but without the + * prefix @p{M_}. */ namespace deal_II_numbers { /** diff --git a/deal.II/base/source/exceptions.cc b/deal.II/base/source/exceptions.cc index 80e1914a7b..6862557be8 100644 --- a/deal.II/base/source/exceptions.cc +++ b/deal.II/base/source/exceptions.cc @@ -257,3 +257,33 @@ namespace deal_II_exceptions } }; + + +// from the aclocal file: +// Newer versions of gcc have a very nice feature: you can set +// a verbose terminate handler, that not only aborts a program +// when an exception is thrown and not caught somewhere, but +// before aborting it prints that an exception has been thrown, +// and possibly what the std::exception::what() function has to +// say. Since many people run into the trap of not having a +// catch clause in main(), they wonder where that abort may be +// coming from. The terminate handler then at least says what is +// missing in their program. +#ifdef HAVE_VERBOSE_TERMINATE +namespace __gnu_cxx +{ + extern void __verbose_terminate_handler (); +} + +namespace +{ + struct preload_terminate_dummy + { + preload_terminate_dummy() + { std::set_terminate (__gnu_cxx::__verbose_terminate_handler); } + }; + + static preload_terminate_dummy dummy; +} + +#endif diff --git a/deal.II/configure b/deal.II/configure index c1b8fd6f33..ff2d69364d 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.127 . +# From configure.in Revision: 1.128 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.57. # @@ -5325,6 +5325,81 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext + echo "$as_me:$LINENO: checking for __verbose_terminate_handler" >&5 +echo $ECHO_N "checking for __verbose_terminate_handler... $ECHO_C" >&6 + ac_ext=cc +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + CXXFLAGS="$CXXFLAGSG" + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include + +namespace __gnu_cxx +{ + extern void __verbose_terminate_handler (); +} + +struct preload_terminate_dummy +{ + preload_terminate_dummy() + { std::set_terminate (__gnu_cxx::__verbose_terminate_handler); } +}; + +static preload_terminate_dummy dummy; + +int +main () +{ + + throw 1; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +cat >>confdefs.h <<\_ACEOF +#define HAVE_VERBOSE_TERMINATE 1 +_ACEOF + + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext + + echo "$as_me:$LINENO: checking whether getrusage is properly declared" >&5 echo $ECHO_N "checking whether getrusage is properly declared... $ECHO_C" >&6 ac_ext=cc diff --git a/deal.II/configure.in b/deal.II/configure.in index 070fc40408..64339e3c8c 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -183,6 +183,7 @@ DEAL_II_HAVE_STD_NUMERIC_LIMITS DEAL_II_HAVE_STD_OSTREAM_HEADER DEAL_II_HAVE_STD_IOSFWD_HEADER DEAL_II_HAVE_BUILTIN_EXPECT +DEAL_II_HAVE_VERBOSE_TERMINATE DEAL_II_CHECK_GETRUSAGE DEAL_II_CHECK_ISNAN DEAL_II_CHECK_RAND_R diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index 9c55e038e4..0ac94a590a 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -222,6 +222,20 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

base

    +
  1. + New: Newer versions of gcc have a very nice feature: you can set + a verbose terminate handler, that not only aborts a program + when an exception is thrown and not caught somewhere, but + before aborting it prints that an exception has been thrown, + and possibly what the std::exception::what() function has to + say. Since many people run into the trap of not having a + catch clause in main(), they wonder where that abort may be + coming from. The terminate handler then at least says what is + missing in their program. +
    + (WB 2002/12/19) +

    +
  2. New: There is now a Patterns::List pattern that matches a list of elements each of which has to satisfy a pattern