]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Detect and possibly use __verbose_terminate_handler. The text in aclocal.m4 says:
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 19 Dec 2002 19:41:35 +0000 (19:41 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 19 Dec 2002 19:41:35 +0000 (19:41 +0000)
// 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

deal.II/aclocal.m4
deal.II/base/include/base/config.h.in
deal.II/base/source/exceptions.cc
deal.II/configure
deal.II/configure.in
deal.II/doc/news/2002/c-3-4.html

index af89621b5d6903926b3631824103bc10a50b5b34..1b0c51ac68d6ee827c9a2b92a757b802722315e2 100644 (file)
@@ -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 <exception>
+
+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
index 36c6ce3f61019e0f400e6bb4f088d3bba372bfbd..42bdc72147fd54465743ed47c4556de9dd0bb015 100644 (file)
    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 <resource.h>, as one would think when reading the
    man pages. Then we have to declare this function ourselves in those files
  * 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 {
                                              /**
index 80e1914a7bdec38c13ce88e2ef4337d639ecc168..6862557be81eec9c87349c8197cc4c3bea1493fa 100644 (file)
@@ -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
index c1b8fd6f33fd9f07bb730a0a1adb4ed557bf4159..ff2d69364d46d952ae504bcea17ddbfc1b889cc0 100755 (executable)
@@ -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 <exception>
+
+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
index 070fc40408332aff7b29ebe9d2ffa77a7dced89a..64339e3c8c7ba610ce757fe9e09fada6e0eeb670 100644 (file)
@@ -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
index 9c55e038e48cd5622c0fecac304942f811b4ad7e..0ac94a590ad5b349148c707fad9ecd64bab5783d 100644 (file)
@@ -222,6 +222,20 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>base</h3>
 
 <ol>
+  <li> <p> 
+       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.
+       <br>
+       (WB 2002/12/19)
+       </p>
+
   <li> <p> 
        New: There is now a <code class="class">Patterns::List</code> pattern
        that matches a list of elements each of which has to satisfy a pattern

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.