+class BacktraceImpl {
+#if HAVE_BOOST_STACKTRACE_BACKTRACE || HAVE_BOOST_STACKTRACE_ADDR2LINE
+ const boost::stacktrace::stacktrace st;
+
+public:
+ std::string resolve() const
+ {
+ std::stringstream ss;
+
+ int frame_count = 0;
+ int state = 0;
+
+ for (boost::stacktrace::frame frame : st) {
+ if (state == 1) {
+ if (boost::starts_with(frame.name(), "simgrid::xbt::MainFunction") ||
+ boost::starts_with(frame.name(), "simgrid::kernel::context::Context::operator()()"))
+ break;
+ ss << " -> " << frame_count++ << "# " << frame.name() << " at " << frame.source_file() << ":"
+ << frame.source_line() << std::endl;
+ if (frame.name() == "main")
+ break;
+ } else {
+ if (frame.name() == "simgrid::xbt::Backtrace::Backtrace()")
+ state = 1;
+ }
+ }
+
+ return ss.str();
+ }
+#else
+
+public:
+ std::string resolve() const { return ""; } // fallback value
+#endif
+};
+
+Backtrace::Backtrace() : impl_(std::make_shared<BacktraceImpl>()) {}
+
+std::string Backtrace::resolve() const