]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Create new string when demangling stacktraces 17575/head
authorDaniel Arndt <arndtd@ornl.gov>
Mon, 19 Aug 2024 13:04:05 +0000 (09:04 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Tue, 20 Aug 2024 12:51:49 +0000 (08:51 -0400)
source/base/exceptions.cc

index f20d577be1aadba1d3959251ae5776f6032b2262..91900a1cd216342042bc19360d212e45d68de446 100644 (file)
@@ -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")

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.