Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in the debug config items
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 9 Jun 2019 21:43:48 +0000 (23:43 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 9 Jun 2019 21:43:48 +0000 (23:43 +0200)
docs/source/Configuring_SimGrid.rst
examples/s4u/app-pingpong/simix-breakpoint.tesh
src/msg/msg_global.cpp
src/simdag/sd_global.cpp
src/simgrid/sg_config.cpp
src/simix/smx_global.cpp
src/xbt/xbt_main.cpp

index 8303e48..993f35c 100644 (file)
@@ -84,8 +84,6 @@ Existing Configuration Items
    option. For example, ``--cfg=plugin:help`` will give you the list
    of plugins available in your installation of SimGrid.
 
    option. For example, ``--cfg=plugin:help`` will give you the list
    of plugins available in your installation of SimGrid.
 
-- **clean-atexit:** :ref:`cfg=clean-atexit`
-
 - **contexts/factory:** :ref:`cfg=contexts/factory`
 - **contexts/guard-size:** :ref:`cfg=contexts/guard-size`
 - **contexts/nthreads:** :ref:`cfg=contexts/nthreads`
 - **contexts/factory:** :ref:`cfg=contexts/factory`
 - **contexts/guard-size:** :ref:`cfg=contexts/guard-size`
 - **contexts/nthreads:** :ref:`cfg=contexts/nthreads`
@@ -97,6 +95,10 @@ Existing Configuration Items
 - **cpu/model:** :ref:`options_model_select`
 - **cpu/optim:** :ref:`Cpu Optimization Level <options_model_optim>`
 
 - **cpu/model:** :ref:`options_model_select`
 - **cpu/optim:** :ref:`Cpu Optimization Level <options_model_optim>`
 
+- **debug/breakpoint:** :ref:`cfg=debug/breakpoint`
+- **debug/clean-atexit:** :ref:`cfg=debug/clean-atexit`
+- **debug/verbose-exit:** :ref:`cfg=debug/verbose-exit`
+
 - **exception/cutpath:** :ref:`cfg=exception/cutpath`
 
 - **host/model:** :ref:`options_model_select`
 - **exception/cutpath:** :ref:`cfg=exception/cutpath`
 
 - **host/model:** :ref:`options_model_select`
@@ -133,8 +135,6 @@ Existing Configuration Items
 - **path:** :ref:`cfg=path`
 - **plugin:** :ref:`cfg=plugin`
 
 - **path:** :ref:`cfg=path`
 - **plugin:** :ref:`cfg=plugin`
 
-- **simix/breakpoint:** :ref:`cfg=simix/breakpoint`
-
 - **storage/max_file_descriptors:** :ref:`cfg=storage/max_file_descriptors`
 
 - **surf/precision:** :ref:`cfg=surf/precision`
 - **storage/max_file_descriptors:** :ref:`cfg=storage/max_file_descriptors`
 
 - **surf/precision:** :ref:`cfg=surf/precision`
@@ -170,7 +170,6 @@ Existing Configuration Items
 - **Tracing configuration options** can be found in Section :ref:`tracing_tracing_options`
 
 - **storage/model:** :ref:`options_model_select`
 - **Tracing configuration options** can be found in Section :ref:`tracing_tracing_options`
 
 - **storage/model:** :ref:`options_model_select`
-- **verbose-exit:** :ref:`cfg=verbose-exit`
 
 - **vm/model:** :ref:`options_model_select`
 
 
 - **vm/model:** :ref:`options_model_select`
 
@@ -1425,12 +1424,12 @@ extra delay by setting smpi/wtime to 0.
 Other Configurations
 --------------------
 
 Other Configurations
 --------------------
 
-.. _cfg=clean-atexit:
+.. _cfg=debug/clean-atexit:
 
 Cleanup at Termination
 ......................
 
 
 Cleanup at Termination
 ......................
 
-**Option** ``clean-atexit`` **default:** on
+**Option** ``debug/clean-atexit`` **default:** on
 
 If your code is segfaulting during its finalization, it may help to
 disable this option to request SimGrid to not attempt any cleanups at
 
 If your code is segfaulting during its finalization, it may help to
 disable this option to request SimGrid to not attempt any cleanups at
@@ -1449,12 +1448,12 @@ trace files (see :ref:`pf_trace`) by using this configuration
 item. To add several directory to the path, set the configuration
 item several times, as in ``--cfg=path:toto --cfg=path:tutu``
 
 item. To add several directory to the path, set the configuration
 item several times, as in ``--cfg=path:toto --cfg=path:tutu``
 
-.. _cfg=simix/breakpoint:
+.. _cfg=debug/breakpoint:
 
 Set a Breakpoint
 ................
 
 
 Set a Breakpoint
 ................
 
-**Option** ``simix/breakpoint`` **default:** unset
+**Option** ``debug/breakpoint`` **default:** unset
 
 This configuration option sets a breakpoint: when the simulated clock
 reaches the given time, a SIGTRAP is raised.  This can be used to stop
 
 This configuration option sets a breakpoint: when the simulated clock
 reaches the given time, a SIGTRAP is raised.  This can be used to stop
@@ -1468,12 +1467,12 @@ with gdb:
 
    set variable simgrid::simix::breakpoint = 3.1416
 
 
    set variable simgrid::simix::breakpoint = 3.1416
 
-.. _cfg=verbose-exit:
+.. _cfg=debug/verbose-exit:
 
 Behavior on Ctrl-C
 ..................
 
 
 Behavior on Ctrl-C
 ..................
 
-**Option** ``verbose-exit`` **default:** on
+**Option** ``debug/verbose-exit`` **default:** on
 
 By default, when Ctrl-C is pressed, the status of all existing actors
 is displayed before exiting the simulation. This is very useful to
 
 By default, when Ctrl-C is pressed, the status of all existing actors
 is displayed before exiting the simulation. This is very useful to
index b2efa12..e77786d 100644 (file)
@@ -1,10 +1,10 @@
 #!/usr/bin/env tesh
 
 #!/usr/bin/env tesh
 
-p Testing option --cfg=simix/breakpoint
+p Testing option --cfg=debug/breakpoint
 
 ! expect signal SIGTRAP
 
 ! expect signal SIGTRAP
-$ ${bindir:=.}/s4u-app-pingpong ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=simix/breakpoint:3.1416
-> [  0.000000] (0:maestro@) Configuration change: Set 'simix/breakpoint' to '3.1416'
+$ ${bindir:=.}/s4u-app-pingpong ${platfdir}/small_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --cfg=debug/breakpoint:3.1416
+> [  0.000000] (0:maestro@) Configuration change: Set 'debug/breakpoint' to '3.1416'
 > [  0.000000] (1:pinger@Tremblay) Ping from mailbox Mailbox 1 to mailbox Mailbox 2
 > [  0.000000] (2:ponger@Jupiter) Pong from mailbox Mailbox 2 to mailbox Mailbox 1
 > [  0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
 > [  0.000000] (1:pinger@Tremblay) Ping from mailbox Mailbox 1 to mailbox Mailbox 2
 > [  0.000000] (2:ponger@Jupiter) Pong from mailbox Mailbox 2 to mailbox Mailbox 1
 > [  0.019014] (2:ponger@Jupiter) Task received : small communication (latency bound)
index 8c6365c..e061e0c 100644 (file)
@@ -51,7 +51,7 @@ void MSG_init_nocheck(int *argc, char **argv) {
     MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
   }
 
     MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
   }
 
-  if (simgrid::config::get_value<bool>("clean-atexit"))
+  if (simgrid::config::get_value<bool>("debug/clean-atexit"))
     atexit(MSG_exit);
 }
 
     atexit(MSG_exit);
 }
 
index e466ff0..a862ecc 100644 (file)
@@ -148,7 +148,7 @@ void SD_init_nocheck(int *argc, char **argv)
   sd_global = new simgrid::sd::Global();
 
   simgrid::config::set_default<std::string>("host/model", "ptask_L07");
   sd_global = new simgrid::sd::Global();
 
   simgrid::config::set_default<std::string>("host/model", "ptask_L07");
-  if (simgrid::config::get_value<bool>("clean-atexit"))
+  if (simgrid::config::get_value<bool>("debug/clean-atexit"))
     atexit(SD_exit);
 }
 
     atexit(SD_exit);
 }
 
index 1cbf235..7709d36 100644 (file)
@@ -299,9 +299,6 @@ void sg_config_init(int *argc, char **argv)
                                       "no");
   simgrid::config::alias("network/maxmin-selective-update", {"network/maxmin_selective_update"});
 
                                       "no");
   simgrid::config::alias("network/maxmin-selective-update", {"network/maxmin_selective_update"});
 
-  extern bool _sg_do_verbose_exit;
-  simgrid::config::bind_flag(_sg_do_verbose_exit, "verbose-exit", "Activate the \"do nothing\" mode in Ctrl-C");
-
   simgrid::config::declare_flag<int>("contexts/stack-size", "Stack size of contexts in KiB (not with threads)",
                                      8 * 1024, [](int value) { smx_context_stack_size = value * 1024; });
   simgrid::config::alias("contexts/stack-size", {"contexts/stack_size"});
   simgrid::config::declare_flag<int>("contexts/stack-size", "Stack size of contexts in KiB (not with threads)",
                                      8 * 1024, [](int value) { smx_context_stack_size = value * 1024; });
   simgrid::config::alias("contexts/stack-size", {"contexts/stack_size"});
@@ -456,10 +453,6 @@ void sg_config_init(int *argc, char **argv)
   simgrid::config::declare_flag<bool>(
       "exception/cutpath", "Whether to cut all path information from call traces, used e.g. in exceptions.", false);
 
   simgrid::config::declare_flag<bool>(
       "exception/cutpath", "Whether to cut all path information from call traces, used e.g. in exceptions.", false);
 
-  extern bool _sg_do_clean_atexit;
-  simgrid::config::bind_flag(_sg_do_clean_atexit, "clean-atexit", {"clean_atexit"},
-                             "Whether to cleanup SimGrid at exit. Disable it if your code segfaults after its end.");
-
   if (surf_path.empty())
     simgrid::config::set_default<std::string>("path", "./");
 
   if (surf_path.empty())
     simgrid::config::set_default<std::string>("path", "./");
 
index cca99ec..25be94c 100644 (file)
@@ -32,15 +32,21 @@ std::unique_ptr<simgrid::simix::Global> simix_global;
 
 void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr;
 
 
 void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr;
 
-bool _sg_do_verbose_exit = true;
+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)
 {
 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 {
   }
   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);
 }
   }
   exit(1);
 }
@@ -187,8 +193,8 @@ void Global::run_all_actors()
   actors_to_run.clear();
 }
 
   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);
 }
 
     atexit(SIMIX_clean);
 }
 
@@ -384,9 +390,9 @@ void SIMIX_run()
   do {
     XBT_DEBUG("New Schedule Round; size(queue)=%zu", simix_global->actors_to_run.size());
 
   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
 #ifdef SIGTRAP
       std::raise(SIGTRAP);
 #else
index 5a80ce6..d60ccb0 100644 (file)
@@ -37,7 +37,11 @@ char *xbt_binary_name = NULL;   /* Name of the system process containing us (man
 xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */
 
 int xbt_initialized = 0;
 xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */
 
 int xbt_initialized = 0;
-bool _sg_do_clean_atexit = true;
+simgrid::config::Flag<bool> cfg_dbg_clean_atexit{
+    "debug/clean-atexit",
+    {"clean-atexit"},
+    "Whether to cleanup SimGrid at exit. Disable it if your code segfaults after its end.",
+    true};
 
 int xbt_pagesize;
 int xbt_pagebits = 0;
 
 int xbt_pagesize;
 int xbt_pagebits = 0;
@@ -98,7 +102,7 @@ static void xbt_preinit()
 
 static void xbt_postexit()
 {
 
 static void xbt_postexit()
 {
-  if (not _sg_do_clean_atexit)
+  if (not cfg_dbg_clean_atexit)
     return;
   xbt_initialized--;
   xbt_dict_postexit();
     return;
   xbt_initialized--;
   xbt_dict_postexit();