Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix include.
[simgrid.git] / src / simix / libsmx.cpp
index 41a204bbf741817f5de5075f5eec4054db985cb8..2744ea43367e9eb9f1b1dfcbb87b8f8a36286ada 100644 (file)
 
 #include "popping_bodies.cpp"
 
+#include <boost/core/demangle.hpp>
+#include <string>
+#include <typeinfo>
+
 /**
  * @ingroup simix_host_management
  * @brief Waits for the completion of an execution synchro and destroy it.
@@ -60,9 +64,9 @@ bool simcall_execution_test(const simgrid::kernel::activity::ActivityImplPtr& ex
 unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
                                            double timeout) // XBT_ATTRIB_DEPRECATED_v331
 {
-  std::vector<simgrid::kernel::activity::ExecImpl*> execsv(execs, execs + count);
+  std::vector<simgrid::kernel::activity::ExecImpl*> execs_vec(execs, execs + count);
   simgrid::kernel::actor::ActorImpl* issuer = simgrid::kernel::actor::ActorImpl::self();
-  simgrid::kernel::actor::ExecutionWaitanySimcall observer{issuer, &execsv, timeout};
+  simgrid::kernel::actor::ExecutionWaitanySimcall observer{issuer, execs_vec, timeout};
   return simgrid::kernel::actor::simcall_blocking(
       [&observer] {
         simgrid::kernel::activity::ExecImpl::wait_any_for(observer.get_issuer(), observer.get_execs(),
@@ -369,9 +373,18 @@ int simcall_mc_random(int min, int max) // XBT_ATTRIB_DEPRECATD_v331
 /* ************************************************************************** */
 
 /** @brief returns a printable string representing a simcall */
-const char* SIMIX_simcall_name(Simcall kind)
-{
-  return simcall_names[static_cast<int>(kind)];
+const char* SIMIX_simcall_name(const s_smx_simcall& simcall)
+{
+  if (simcall.observer_ != nullptr) {
+    static std::string name;
+    name              = boost::core::demangle(typeid(*simcall.observer_).name());
+    const char* cname = name.c_str();
+    if (name.rfind("simgrid::kernel::", 0) == 0)
+      cname += 17; // strip prefix "simgrid::kernel::"
+    return cname;
+  } else {
+    return simcall_names[static_cast<int>(simcall.call_)];
+  }
 }
 
 namespace simgrid {