From: Wolfgang Bangerth Date: Tue, 14 Mar 2006 17:42:51 +0000 (+0000) Subject: Detect the ability to demangle symbols from within the program X-Git-Tag: v8.0.0~12114 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fdaf7b7c7ff3282ce5078bc07bcf34482107ad6;p=dealii.git Detect the ability to demangle symbols from within the program git-svn-id: https://svn.dealii.org/trunk@12581 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/aclocal.m4 b/deal.II/aclocal.m4 index 1abb91dbd8..34360303aa 100644 --- a/deal.II/aclocal.m4 +++ b/deal.II/aclocal.m4 @@ -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 +#include +#include + +struct empty { }; + +template + struct bar { }; + ], + [ + int status; + char *realname; + + // exception classes not in , 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 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: diff --git a/deal.II/base/include/base/config.h.in b/deal.II/base/include/base/config.h.in index 1834f624be..edb929fef6 100644 --- a/deal.II/base/include/base/config.h.in +++ b/deal.II/base/include/base/config.h.in @@ -213,9 +213,8 @@ /* 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 */ @@ -233,6 +232,10 @@ /* 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 diff --git a/deal.II/configure b/deal.II/configure index c09d4739fb..c470db4595 100755 --- a/deal.II/configure +++ b/deal.II/configure @@ -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 +#include +#include + +struct empty { }; + +template + struct bar { }; + +int +main () +{ + + int status; + char *realname; + + // exception classes not in , 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 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' diff --git a/deal.II/configure.in b/deal.II/configure.in index 84faa49e81..e7d96cd283 100644 --- a/deal.II/configure.in +++ b/deal.II/configure.in @@ -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