From: Arnaud Giersch Date: Sat, 20 Feb 2021 10:41:41 +0000 (+0100) Subject: Drop simgrid::xbt::demangle and use boost::core::demangle instead. X-Git-Tag: v3.27~322^2~29 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ccf671a80a47f0489c33fb1dc2a8aadfc28b5b88 Drop simgrid::xbt::demangle and use boost::core::demangle instead. --- diff --git a/ChangeLog b/ChangeLog index 55e7fd547a..782c65fe90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,9 @@ S4U: - New functions: Comm::sendto_{init,async} to initiate a communication on between two (possibly remote) hosts. +XBT: + - Drop simgrid::xbt::demangle. Please use boost::core::demangle instead. + Documentation: - New section: Configuring the logs from the command line. - New section: Programming API of logs. diff --git a/include/xbt/backtrace.hpp b/include/xbt/backtrace.hpp index 3df49ff4b8..007c0c1dcc 100644 --- a/include/xbt/backtrace.hpp +++ b/include/xbt/backtrace.hpp @@ -20,12 +20,6 @@ SG_END_DECL namespace simgrid { namespace xbt { -/** Try to demangle a C++ name - * - * Return the origin string if this fails. - */ -XBT_PUBLIC std::unique_ptr> demangle(const char* name); - class BacktraceImpl; /** A backtrace * diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index d84e20443f..e2eb1842fb 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -18,6 +18,7 @@ #include "src/surf/HostImpl.hpp" #include "src/surf/cpu_interface.hpp" +#include #include #include @@ -321,8 +322,7 @@ void ActorImpl::yield() try { std::rethrow_exception(std::move(exception)); } catch (const simgrid::Exception& e) { - std::string name = simgrid::xbt::demangle(typeid(e).name()).get(); - e.rethrow_nested(XBT_THROW_POINT, name + " raised in kernel mode."); + e.rethrow_nested(XBT_THROW_POINT, boost::core::demangle(typeid(e).name()) + " raised in kernel mode."); } } diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index 2a3209622a..bd913fb87c 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -12,6 +12,7 @@ #include "src/kernel/context/ContextSwapped.hpp" +#include #include #ifdef _WIN32 @@ -51,7 +52,7 @@ void smx_ctx_wrapper(simgrid::kernel::context::SwappedContext* context) } catch (simgrid::ForcefulKillException const&) { XBT_DEBUG("Caught a ForcefulKillException"); } catch (simgrid::Exception const& e) { - XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get()); + XBT_INFO("Actor killed by an uncaught exception %s", boost::core::demangle(typeid(e).name()).c_str()); throw; } #if HAVE_SANITIZER_ADDRESS_FIBER_SUPPORT diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index b8bc3d1c82..f329df45b0 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -11,6 +11,7 @@ #include "src/xbt_modinter.h" /* prototype of os thread module's init/exit in XBT */ #include "xbt/function_types.h" +#include #include #include @@ -103,7 +104,7 @@ void ThreadContext::wrapper(ThreadContext* context) XBT_DEBUG("Caught a ForcefulKillException in Thread::wrapper"); xbt_assert(not context->is_maestro(), "Maestro shall not receive ForcefulKillExceptions, even when detached."); } catch (simgrid::Exception const& e) { - XBT_INFO("Actor killed by an uncaught exception %s", simgrid::xbt::demangle(typeid(e).name()).get()); + XBT_INFO("Actor killed by an uncaught exception %s", boost::core::demangle(typeid(e).name()).c_str()); throw; } // Signal to the caller (normally the maestro) that we have finished: diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index a86ef6b347..bd13a0a405 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -4,7 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/lmm/maxmin.hpp" -#include "xbt/backtrace.hpp" +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_maxmin, surf, "Logging specific to SURF (maxmin)"); @@ -145,8 +145,8 @@ System::~System() Constraint* cnst; while ((var = extract_variable())) { - auto demangled = simgrid::xbt::demangle(var->id_ ? typeid(*var->id_).name() : "(unidentified)"); - XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled.get(), + std::string demangled = boost::core::demangle(var->id_ ? typeid(*var->id_).name() : "(unidentified)"); + XBT_WARN("Probable bug: a %s variable (#%d) not removed before the LMM system destruction.", demangled.c_str(), var->rank_); var_free(var); } diff --git a/src/mc/mc_global.cpp b/src/mc/mc_global.cpp index dc6228a790..53dec304b9 100644 --- a/src/mc/mc_global.cpp +++ b/src/mc/mc_global.cpp @@ -18,9 +18,9 @@ #include "src/mc/mc_smx.hpp" #include "src/mc/remote/AppSide.hpp" #include "src/mc/sosp/Snapshot.hpp" -#include "xbt/backtrace.hpp" #include +#include #include #endif @@ -115,17 +115,17 @@ void dumpStack(FILE* file, unw_cursor_t* cursor) do { const char* name = not unw_get_proc_name(cursor, buffer.data(), buffer.size(), &off) ? buffer.data() : "?"; // Unmangle C++ names: - auto realname = simgrid::xbt::demangle(name); + std::string realname = boost::core::demangle(name); #if defined(__x86_64__) unw_word_t rip = 0; unw_word_t rsp = 0; unw_get_reg(cursor, UNW_X86_64_RIP, &rip); unw_get_reg(cursor, UNW_X86_64_RSP, &rsp); - fprintf(file, " %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n", nframe, realname.get(), (std::uint64_t)rip, + fprintf(file, " %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n", nframe, realname.c_str(), (std::uint64_t)rip, (std::uint64_t)rsp); #else - fprintf(file, " %i: %s\n", nframe, realname.get()); + fprintf(file, " %i: %s\n", nframe, realname.c_str()); #endif ++nframe; diff --git a/src/xbt/backtrace.cpp b/src/xbt/backtrace.cpp index 35122fbc64..03e5ad742a 100644 --- a/src/xbt/backtrace.cpp +++ b/src/xbt/backtrace.cpp @@ -15,11 +15,6 @@ #include #include -// Try to detect and use the C++ itanium ABI for name demangling: -#ifdef __GXX_ABI_VERSION -#include -#endif - #if HAVE_BOOST_STACKTRACE_BACKTRACE #define BOOST_STACKTRACE_USE_BACKTRACE #include @@ -39,20 +34,6 @@ void xbt_backtrace_display_current() namespace simgrid { namespace xbt { -std::unique_ptr> demangle(const char* name) -{ -#ifdef __GXX_ABI_VERSION - int status; - std::unique_ptr> res(abi::__cxa_demangle(name, nullptr, nullptr, &status), - &std::free); - if (res != nullptr) - return res; - // We did not manage to resolve this. Probably because this is not a mangled symbol: -#endif - // Return the symbol: - return std::unique_ptr>(xbt_strdup(name), &xbt_free_f); -} - class BacktraceImpl { #if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE const boost::stacktrace::stacktrace st; diff --git a/src/xbt/exception.cpp b/src/xbt/exception.cpp index 54a0df5216..cf4801a178 100644 --- a/src/xbt/exception.cpp +++ b/src/xbt/exception.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -34,11 +35,11 @@ UnimplementedError::~UnimplementedError() = default; void log_exception(e_xbt_log_priority_t prio, const char* context, std::exception const& exception) { try { - auto name = simgrid::xbt::demangle(typeid(exception).name()); + std::string name = boost::core::demangle(typeid(exception).name()); auto* with_context = dynamic_cast(&exception); if (with_context != nullptr) { - XBT_LOG(prio, "%s %s by %s/%d: %s", context, name.get(), with_context->throw_point().procname_.c_str(), + XBT_LOG(prio, "%s %s by %s/%d: %s", context, name.c_str(), with_context->throw_point().procname_.c_str(), with_context->throw_point().pid_, exception.what()); // Do we have a backtrace? if (not simgrid::config::get_value("exception/cutpath")) { @@ -46,7 +47,7 @@ void log_exception(e_xbt_log_priority_t prio, const char* context, std::exceptio XBT_LOG(prio, "Backtrace:\n%s", backtrace.c_str()); } } else { - XBT_LOG(prio, "%s %s: %s", context, name.get(), exception.what()); + XBT_LOG(prio, "%s %s: %s", context, name.c_str(), exception.what()); } } catch (...) { // Don't log exceptions we got when trying to log exception