diff --git a/src/core/DataTypes.h b/src/core/DataTypes.h index 5bcae7599a2ababcc017f2127f25e18d7cf54f80..f90781461bcff9431501098180f1dbf39ea68d00 100644 --- a/src/core/DataTypes.h +++ b/src/core/DataTypes.h @@ -31,19 +31,6 @@ #include <string> #include <type_traits> -#ifdef __GLIBCXX__ -#define HAVE_CXXABI_H -#include <cxxabi.h> -#else -#ifdef __has_include -#if __has_include(<cxxabi.h>) -#define HAVE_CXXABI_H -#include <cxxabi.h> -#endif -#endif -#endif - - namespace walberla { @@ -332,28 +319,6 @@ TypeToString(double) template< typename T > inline const char* typeToString( T ) { return typeToString<T>(); } -// type info demangling - -inline std::string demangle( const std::string & name ) -{ -#ifdef HAVE_CXXABI_H - int status = 0; - std::size_t size = 0; - const char * demangled = abi::__cxa_demangle( name.c_str(), NULL, &size, &status ); - if( demangled == nullptr ) - { - return name; - } - std::string demangled_str(demangled); - std::free( const_cast<char*>(demangled) ); - return demangled_str; -#else - return name; -#endif -} - - - } // namespace walberla #define WALBERLA_UNUSED(x) (void)(x) diff --git a/src/core/debug/PrintStacktrace.cpp b/src/core/debug/PrintStacktrace.cpp index f939d19d576602db75a7ade1d107abe76da0c52c..7eff6bcb948834578474ebb3649d455dd0c40ee4 100644 --- a/src/core/debug/PrintStacktrace.cpp +++ b/src/core/debug/PrintStacktrace.cpp @@ -20,6 +20,7 @@ //====================================================================================================================== #include "PrintStacktrace.h" +#include "demangle.h" #include "core/DataTypes.h" #include <iostream> diff --git a/src/core/debug/demangle.h b/src/core/debug/demangle.h new file mode 100644 index 0000000000000000000000000000000000000000..2e317436e6d9bace3045ef40a79aa4fdd0f88a85 --- /dev/null +++ b/src/core/debug/demangle.h @@ -0,0 +1,59 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla 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 of +// the License, or (at your option) any later version. +// +// waLBerla 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. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file demangle.h +//! \author Florian Schornbaum <florian.schornbaum@fau.de> +// +//====================================================================================================================== + +#pragma once + +#include <string> + +#ifdef __GLIBCXX__ +#define HAVE_CXXABI_H +#include <cxxabi.h> +#else +#ifdef __has_include +#if __has_include(<cxxabi.h>) +#define HAVE_CXXABI_H +#include <cxxabi.h> +#endif +#endif +#endif + +namespace walberla { +namespace debug { + +inline std::string demangle( const std::string & name ) +{ +#ifdef HAVE_CXXABI_H + int status = 0; + std::size_t size = 0; + const char * demangled = abi::__cxa_demangle( name.c_str(), NULL, &size, &status ); + if( demangled == nullptr ) + { + return name; + } + std::string demangled_str(demangled); + std::free( const_cast<char*>(demangled) ); + return demangled_str; +#else + return name; +#endif +} + +} // namespace debug +} // namespace walberla diff --git a/src/domain_decomposition/IBlock.h b/src/domain_decomposition/IBlock.h index 215f8a51d27d714b41192ecaec0d273e721f560d..c25c55ee9a6f5e1224941ee51c3144ebd230adcc 100644 --- a/src/domain_decomposition/IBlock.h +++ b/src/domain_decomposition/IBlock.h @@ -25,6 +25,7 @@ #include "IBlockID.h" #include "core/Abort.h" +#include "core/debug/demangle.h" #include "core/NonCopyable.h" #include "core/debug/Debug.h" #include "core/math/AABB.h" @@ -103,8 +104,8 @@ public: catch (...) {} #ifndef NDEBUG WALBERLA_ABORT( "BlockData access type violation! (The block data you added is of a different type than the block data you are trying to access!)" - "\nThe original data type was: " << demangle( typeInfo_ ) << - "\nYou try to retrieve data of type: " << demangle( typeid(U).name() ) ) + "\nThe original data type was: " << debug::demangle( typeInfo_ ) << + "\nYou try to retrieve data of type: " << debug::demangle( typeid(U).name() ) ) #else WALBERLA_ABORT( "BlockData access type violation! (The block data you added is of a different type than the block data you are trying to access!)" ) #endif diff --git a/src/pe/communication/Instantiate.h b/src/pe/communication/Instantiate.h index f10a27dddab2efb0a4a6b9ae375110fce368dd29..8c157be229421932f20220516be72f50b491012f 100644 --- a/src/pe/communication/Instantiate.h +++ b/src/pe/communication/Instantiate.h @@ -28,6 +28,7 @@ //************************************************************************************************* #include "core/Abort.h" +#include "core/debug/demangle.h" #include "core/math/AABB.h" #include "core/math/Vector3.h" @@ -57,7 +58,7 @@ void correctBodyPosition(const math::AABB& domain, const Vec3& center, Vec3& pos template < class BodyT > std::unique_ptr<BodyT> instantiate( mpi::RecvBuffer& /*buffer*/, const math::AABB& /*domain*/, const math::AABB& /*block*/, BodyT*& /*newBody*/ ) { - WALBERLA_ABORT( "Body instantiation not implemented! (" << demangle(typeid(BodyT).name()) << ")" ); + WALBERLA_ABORT( "Body instantiation not implemented! (" << debug::demangle(typeid(BodyT).name()) << ")" ); } } // namespace communication