From: Daniel Arndt Date: Mon, 19 Aug 2024 13:04:05 +0000 (-0400) Subject: Create new string when demangling stacktraces X-Git-Tag: v9.6.1~3^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be244a2bfa5415f180681ccfe0fa4576644b56dc;p=dealii.git Create new string when demangling stacktraces --- diff --git a/source/base/exceptions.cc b/source/base/exceptions.cc index f20d577be1..91900a1cd2 100644 --- a/source/base/exceptions.cc +++ b/source/base/exceptions.cc @@ -285,8 +285,9 @@ ExceptionBase::print_stack_trace(std::ostream &out) const std::string functionname = stacktrace_entry.substr(pos_start + 1, pos_end - pos_start - 1); - stacktrace_entry.resize(pos_start); - stacktrace_entry += ": "; + std::string demangled_stacktrace_entry = + stacktrace_entry.substr(0, pos_start); + demangled_stacktrace_entry += ": "; // demangle, and if successful replace old mangled string by // unmangled one (skipping address and offset). treat "main" @@ -311,20 +312,20 @@ ExceptionBase::print_stack_trace(std::ostream &out) const realname.erase(realname.find(", boost::tuples::null_type>"), std::string(", boost::tuples::null_type").size()); - stacktrace_entry += realname; + demangled_stacktrace_entry += realname; } else - stacktrace_entry += functionname; + demangled_stacktrace_entry += functionname; free(p); #else - stacktrace_entry += functionname; + demangled_stacktrace_entry += functionname; #endif // then output what we have - out << stacktrace_entry << std::endl; + out << demangled_stacktrace_entry << std::endl; // stop if we're in main() if (functionname == "main")