Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
MC: display the 100 first transitions when we reach the depth-limit
[simgrid.git] / src / mc / explo / Exploration.cpp
index 7a77588..d219abd 100644 (file)
@@ -8,6 +8,7 @@
 #include "src/mc/mc_environ.h"
 #include "src/mc/mc_exit.hpp"
 #include "src/mc/mc_private.hpp"
+#include "xbt/string.hpp"
 
 #if SIMGRID_HAVE_STATEFUL_MC
 #include "src/mc/sosp/RemoteProcessMemory.hpp"
@@ -81,6 +82,24 @@ static const char* signal_name(int status)
       return strsignal(WTERMSIG(status));
   }
 }
+
+std::vector<std::string> Exploration::get_textual_trace(int max_elements)
+{
+  std::vector<std::string> trace;
+  for (auto const& transition : get_record_trace()) {
+    auto const& call_location = transition->get_call_location();
+    if (not call_location.empty())
+      trace.push_back(xbt::string_printf("Actor %ld in %s ==> simcall: %s", transition->aid_, call_location.c_str(),
+                                         transition->to_string().c_str()));
+    else
+      trace.push_back(xbt::string_printf("Actor %ld in simcall %s", transition->aid_, transition->to_string().c_str()));
+    max_elements--;
+    if (max_elements == 0)
+      break;
+  }
+  return trace;
+}
+
 XBT_ATTRIB_NORETURN void Exploration::report_crash(int status)
 {
   XBT_INFO("**************************");