Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Actor: make the refcount observable, and improve debug messages
[simgrid.git] / src / simix / smx_global.cpp
index 8a524e1..ca3e4b9 100644 (file)
@@ -32,15 +32,21 @@ std::unique_ptr<simgrid::simix::Global> simix_global;
 
 void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr;
 
-bool _sg_do_verbose_exit = true;
-static void inthandler(int)
+namespace simgrid {
+namespace simix {
+simgrid::config::Flag<double> cfg_verbose_exit{
+    "debug/verbose-exit", {"verbose-exit"}, "Display the actor status at exit", true};
+}
+} // namespace simgrid
+XBT_ATTRIB_NORETURN static void inthandler(int)
 {
-  if ( _sg_do_verbose_exit ) {
-     XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option 'verbose-exit').");
-     SIMIX_display_process_status();
+  if (simgrid::simix::cfg_verbose_exit) {
+    XBT_INFO("CTRL-C pressed. The current status will be displayed before exit (disable that behavior with option "
+             "'debug/verbose-exit').");
+    SIMIX_display_process_status();
   }
   else {
-     XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'verbose-exit' is set to false.");
+    XBT_INFO("CTRL-C pressed, exiting. Hiding the current process status since 'debug/verbose-exit' is set to false.");
   }
   exit(1);
 }
@@ -165,7 +171,7 @@ void Global::empty_trash()
   while (not actors_to_destroy.empty()) {
     smx_actor_t actor = &actors_to_destroy.front();
     actors_to_destroy.pop_front();
-    XBT_DEBUG("Getting rid of %p", actor);
+    XBT_DEBUG("Getting rid of %s (refcount: %d)", actor->get_cname(), actor->get_refcount());
     intrusive_ptr_release(actor);
   }
 #if SIMGRID_HAVE_MC
@@ -181,14 +187,14 @@ void Global::empty_trash()
  */
 void Global::run_all_actors()
 {
-  SIMIX_context_runall();
+  simix_global->context_factory->run_all();
 
   actors_to_run.swap(actors_that_ran);
   actors_to_run.clear();
 }
 
-simgrid::config::Flag<double> breakpoint{"simix/breakpoint",
-                                         "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
+simgrid::config::Flag<double> cfg_breakpoint{
+    "debug/breakpoint", {"simix/breakpoint"}, "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
 }
 }
 
@@ -240,7 +246,7 @@ void SIMIX_global_init(int *argc, char **argv)
     });
   }
 
-  if (simgrid::config::get_value<bool>("clean-atexit"))
+  if (simgrid::config::get_value<bool>("debug/clean-atexit"))
     atexit(SIMIX_clean);
 }
 
@@ -278,7 +284,7 @@ void SIMIX_clean()
 
   /* Kill all processes (but maestro) */
   simix_global->maestro_process->kill_all();
-  SIMIX_context_runall();
+  simix_global->context_factory->run_all();
   simix_global->empty_trash();
 
   /* Exit the SIMIX network module */
@@ -358,11 +364,7 @@ static bool SIMIX_execute_timers()
     // FIXME: make the timers being real callbacks (i.e. provide dispatchers that read and expand the args)
     smx_timer_t timer = simgrid::simix::simix_timers.top().second;
     simgrid::simix::simix_timers.pop();
-    try {
-      timer->callback();
-    } catch (...) {
-      xbt_die("Exception thrown ouf of timer callback");
-    }
+    timer->callback();
     delete timer;
   }
   return result;
@@ -374,7 +376,7 @@ static bool SIMIX_execute_timers()
  */
 void SIMIX_run()
 {
-  if (not MC_record_path.empty()) {
+  if (MC_record_replay_is_active()) {
     simgrid::mc::replay(MC_record_path);
     return;
   }
@@ -384,9 +386,9 @@ void SIMIX_run()
   do {
     XBT_DEBUG("New Schedule Round; size(queue)=%zu", simix_global->actors_to_run.size());
 
-    if (simgrid::simix::breakpoint >= 0.0 && surf_get_clock() >= simgrid::simix::breakpoint) {
-      XBT_DEBUG("Breakpoint reached (%g)", simgrid::simix::breakpoint.get());
-      simgrid::simix::breakpoint = -1.0;
+    if (simgrid::simix::cfg_breakpoint >= 0.0 && surf_get_clock() >= simgrid::simix::cfg_breakpoint) {
+      XBT_DEBUG("Breakpoint reached (%g)", simgrid::simix::cfg_breakpoint.get());
+      simgrid::simix::cfg_breakpoint = -1.0;
 #ifdef SIGTRAP
       std::raise(SIGTRAP);
 #else