Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / xbt / backtrace.cpp
index 4e26ce0..693ef55 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2005-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2005-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 #include <xbt/sysdep.h>
 #include <xbt/virtu.h>
 
-#include <cstddef>
+#include <cstdio>
 #include <cstdlib>
-#include <cstring>
-#include <fstream>
 #include <sstream>
-#include <sys/stat.h>
-#include <vector>
-
-#include <boost/algorithm/string.hpp>
 
 // Try to detect and use the C++ itanium ABI for name demangling:
 #ifdef __GXX_ABI_VERSION
@@ -59,9 +53,6 @@ std::unique_ptr<char, std::function<void(char*)>> demangle(const char* name)
 class BacktraceImpl {
 #if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
   const boost::stacktrace::stacktrace st = boost::stacktrace::stacktrace();
-#else
-  const char st[1] = ""; // fallback value
-#endif
 public:
   std::string resolve() const
   {
@@ -69,6 +60,10 @@ public:
     ss << st;
     return ss.str();
   }
+#else
+public:
+  std::string resolve() const { return ""; } // fallback value
+#endif
 };
 
 Backtrace::Backtrace() : impl_(std::make_shared<BacktraceImpl>()) {}
@@ -81,8 +76,8 @@ std::string Backtrace::resolve() const
 void Backtrace::display() const
 {
   std::string backtrace = resolve();
-  fprintf(stderr, "Backtrace (displayed in actor %s):\n%s\n", xbt_procname(),
-          backtrace.empty() ? "(backtrace not set -- did you install Boost.Stacktrace?)" : backtrace.c_str());
+  std::fprintf(stderr, "Backtrace (displayed in actor %s):\n%s\n", xbt_procname(),
+               backtrace.empty() ? "(backtrace not set -- did you install Boost.Stacktrace?)" : backtrace.c_str());
 }
 
 } // namespace xbt