Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add parameter simix/breakpoint. Fixes #143.
[simgrid.git] / src / simix / smx_global.cpp
index 386d94c..683ed17 100644 (file)
@@ -158,6 +158,8 @@ namespace simix {
 
 simgrid::xbt::signal<void()> onDeadlock;
 
+simgrid::config::Flag<double> breakpoint{"simix/breakpoint",
+                                         "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
 }
 }
 
@@ -217,7 +219,7 @@ void SIMIX_global_init(int *argc, char **argv)
     });
   }
 
-  if (xbt_cfg_get_boolean("clean-atexit"))
+  if (simgrid::config::get_value<bool>("clean-atexit"))
     atexit(SIMIX_clean);
 
   if (_sg_cfg_exit_asap)
@@ -395,6 +397,12 @@ void SIMIX_run()
   do {
     XBT_DEBUG("New Schedule Round; size(queue)=%zu", simix_global->process_to_run.size());
 
+    if (simgrid::simix::breakpoint >= 0.0 && time >= simgrid::simix::breakpoint) {
+      XBT_DEBUG("Breakpoint reached (%g)", simgrid::simix::breakpoint.get());
+      simgrid::simix::breakpoint = -1.0;
+      raise(SIGTRAP);
+    }
+
     SIMIX_execute_tasks();
 
     while (not simix_global->process_to_run.empty()) {