]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Detect the ability to demangle symbols from within the program
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Mar 2006 17:42:51 +0000 (17:42 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Mar 2006 17:42:51 +0000 (17:42 +0000)
git-svn-id: https://svn.dealii.org/trunk@12581 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/aclocal.m4
deal.II/base/include/base/config.h.in
deal.II/configure
deal.II/configure.in

index 1abb91dbd842f5b0ede1bc7d28dd05d649013bf8..34360303aaffa294ce6eae458abd25445846347e 100644 (file)
@@ -4171,8 +4171,8 @@ AC_DEFUN(DEAL_II_HAVE_GLIBC_STACKTRACE, dnl
     [
       AC_MSG_RESULT(yes)
       AC_DEFINE(HAVE_GLIBC_STACKTRACE, 1, 
-                [Define if deal.II is linked against the GNU C library,
-                 which provides stacktrace debug information that can be
+                [Define if deal.II is linked against a libc that
+                 provides stacktrace debug information that can be
                  printed out in the exception class])
 
       AC_MSG_CHECKING(whether compiler accepts -rdynamic)
@@ -4195,6 +4195,68 @@ AC_DEFUN(DEAL_II_HAVE_GLIBC_STACKTRACE, dnl
 ])
 
 
+
+dnl -------------------------------------------------------------
+dnl Check whether the compiler offers a way to demangle symbols
+dnl from within the program. Used inside the exception stacktrace
+dnl mechanism.
+dnl
+dnl The example code is taken from
+dnl   http://gcc.gnu.org/onlinedocs/libstdc++/18_support/howto.html#6
+dnl
+dnl Usage: DEAL_II_HAVE_DEMANGLER
+dnl
+dnl -------------------------------------------------------------
+AC_DEFUN(DEAL_II_HAVE_DEMANGLER, dnl
+[
+  AC_MSG_CHECKING(for libstdc++ demangler)
+  AC_LANG(C++)
+  CXXFLAGS="$CXXFLAGSG"
+  AC_TRY_LINK(
+    [
+#include <exception>
+#include <iostream>
+#include <cxxabi.h>
+
+struct empty { };
+
+template <typename T, int N>
+  struct bar { };
+    ],
+    [
+  int     status;
+  char   *realname;
+
+  // exception classes not in <stdexcept>, thrown by the implementation
+  // instead of the user
+  std::bad_exception  e;
+  realname = abi::__cxa_demangle(e.what(), 0, 0, &status);
+  std::cout << e.what() << "\t=> " << realname << "\t: " << status << '\n';
+  free(realname);
+
+
+  // typeid
+  bar<empty,17>          u;
+  const std::type_info  &ti = typeid(u);
+
+  realname = abi::__cxa_demangle(ti.name(), 0, 0, &status);
+  std::cout << ti.name() << "\t=> " << realname << "\t: " << status << '\n';
+  free(realname);
+
+  return 0;
+    ],
+    [
+      AC_MSG_RESULT(yes)
+      AC_DEFINE(HAVE_LIBSTDCXX_DEMANGLER, 1, 
+                [Define if the std c++ library provides a demangler conforming
+                 to the GCC libstdc++ interface.])
+    ],
+    [
+      AC_MSG_RESULT(no)
+    ])
+])
+
+
 dnl -------------------------------------------------------------
 dnl On some Cygwin systems, a system header file includes this
 dnl preprocessor define:
index 1834f624be723f2e22c66b089489842ff8a79b25..edb929fef63f19a627b14ac34ae32e5443ffa490 100644 (file)
 /* Define to 1 if you have the `gethostname' function. */
 #undef HAVE_GETHOSTNAME
 
-/* Define if deal.II is linked against the GNU C library, which provides
-   stacktrace debug information that can be printed out in the exception class
-   */
+/* Define if deal.II is linked against a libc that provides stacktrace debug
+   information that can be printed out in the exception class */
 #undef HAVE_GLIBC_STACKTRACE
 
 /* Availability of the MA27 algorithm from HSL */
 /* Define to 1 if you have the `lapack' library (-llapack). */
 #undef HAVE_LIBLAPACK
 
+/* Define if the std c++ library provides a demangler conforming to the GCC
+   libstdc++ interface. */
+#undef HAVE_LIBSTDCXX_DEMANGLER
+
 /* Define to 1 if you have the `umfpack' library (-lumfpack). */
 #undef HAVE_LIBUMFPACK
 
index c09d4739fbec99cc8fac632d4e54cfc4450706f1..c470db4595963e624b569678b83128e30998b8e0 100755 (executable)
@@ -7530,6 +7530,104 @@ fi
 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
+  echo "$as_me:$LINENO: checking for libstdc++ demangler" >&5
+echo $ECHO_N "checking for libstdc++ demangler... $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
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+#include <exception>
+#include <iostream>
+#include <cxxabi.h>
+
+struct empty { };
+
+template <typename T, int N>
+  struct bar { };
+
+int
+main ()
+{
+
+  int     status;
+  char   *realname;
+
+  // exception classes not in <stdexcept>, thrown by the implementation
+  // instead of the user
+  std::bad_exception  e;
+  realname = abi::__cxa_demangle(e.what(), 0, 0, &status);
+  std::cout << e.what() << "\t=> " << realname << "\t: " << status << '\n';
+  free(realname);
+
+
+  // typeid
+  bar<empty,17>          u;
+  const std::type_info  &ti = typeid(u);
+
+  realname = abi::__cxa_demangle(ti.name(), 0, 0, &status);
+  std::cout << ti.name() << "\t=> " << realname << "\t: " << status << '\n';
+  free(realname);
+
+  return 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_cxx_werror_flag"
+                        || test ! -s conftest.err'
+  { (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); }; } &&
+        { 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_LIBSTDCXX_DEMANGLER 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.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+
+
   ac_ext=cc
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
index 84faa49e81bded284139aaf11b26a1f7efdc63cc..e7d96cd28324de0a6e343935c53d662c2847d71b 100644 (file)
@@ -199,6 +199,7 @@ DEAL_II_HAVE_STD_IOSFWD_HEADER
 DEAL_II_HAVE_BUILTIN_EXPECT
 DEAL_II_HAVE_VERBOSE_TERMINATE
 DEAL_II_HAVE_GLIBC_STACKTRACE
+DEAL_II_HAVE_DEMANGLER
 DEAL_II_CHECK_MIN_VECTOR_CAPACITY
 DEAL_II_CHECK_ABORT
 DEAL_II_CHECK_GETRUSAGE

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.