From: Martin Quinson Date: Sun, 9 Jun 2019 21:43:48 +0000 (+0200) Subject: cleanups in the debug config items X-Git-Tag: v3.23~53 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7207080bb744f50a6d8c418f25d82ad69e9b4f44 cleanups in the debug config items --- diff --git a/docs/source/Configuring_SimGrid.rst b/docs/source/Configuring_SimGrid.rst index 8303e48643..993f35cf79 100644 --- a/docs/source/Configuring_SimGrid.rst +++ b/docs/source/Configuring_SimGrid.rst @@ -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. -- **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` @@ -97,6 +95,10 @@ Existing Configuration Items - **cpu/model:** :ref:`options_model_select` - **cpu/optim:** :ref:`Cpu Optimization Level ` +- **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` @@ -133,8 +135,6 @@ Existing Configuration Items - **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` @@ -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` -- **verbose-exit:** :ref:`cfg=verbose-exit` - **vm/model:** :ref:`options_model_select` @@ -1425,12 +1424,12 @@ extra delay by setting smpi/wtime to 0. Other Configurations -------------------- -.. _cfg=clean-atexit: +.. _cfg=debug/clean-atexit: 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 @@ -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`` -.. _cfg=simix/breakpoint: +.. _cfg=debug/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 @@ -1468,12 +1467,12 @@ with gdb: set variable simgrid::simix::breakpoint = 3.1416 -.. _cfg=verbose-exit: +.. _cfg=debug/verbose-exit: 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 diff --git a/examples/s4u/app-pingpong/simix-breakpoint.tesh b/examples/s4u/app-pingpong/simix-breakpoint.tesh index b2efa12f70..e77786d247 100644 --- a/examples/s4u/app-pingpong/simix-breakpoint.tesh +++ b/examples/s4u/app-pingpong/simix-breakpoint.tesh @@ -1,10 +1,10 @@ #!/usr/bin/env tesh -p Testing option --cfg=simix/breakpoint +p Testing option --cfg=debug/breakpoint ! 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) diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index 8c6365cf08..e061e0c500 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -51,7 +51,7 @@ void MSG_init_nocheck(int *argc, char **argv) { MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg)); } - if (simgrid::config::get_value("clean-atexit")) + if (simgrid::config::get_value("debug/clean-atexit")) atexit(MSG_exit); } diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index e466ff038d..a862ecceaa 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -148,7 +148,7 @@ void SD_init_nocheck(int *argc, char **argv) sd_global = new simgrid::sd::Global(); simgrid::config::set_default("host/model", "ptask_L07"); - if (simgrid::config::get_value("clean-atexit")) + if (simgrid::config::get_value("debug/clean-atexit")) atexit(SD_exit); } diff --git a/src/simgrid/sg_config.cpp b/src/simgrid/sg_config.cpp index 1cbf235da9..7709d360b8 100644 --- a/src/simgrid/sg_config.cpp +++ b/src/simgrid/sg_config.cpp @@ -299,9 +299,6 @@ void sg_config_init(int *argc, char **argv) "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("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( "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("path", "./"); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index cca99ec5ab..25be94c5cb 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -32,15 +32,21 @@ std::unique_ptr simix_global; void (*SMPI_switch_data_segment)(simgrid::s4u::ActorPtr) = nullptr; -bool _sg_do_verbose_exit = true; +namespace simgrid { +namespace simix { +simgrid::config::Flag 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); } @@ -187,8 +193,8 @@ void Global::run_all_actors() actors_to_run.clear(); } -simgrid::config::Flag breakpoint{"simix/breakpoint", - "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0}; +simgrid::config::Flag 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("clean-atexit")) + if (simgrid::config::get_value("debug/clean-atexit")) 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()); - 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 diff --git a/src/xbt/xbt_main.cpp b/src/xbt/xbt_main.cpp index 5a80ce6412..d60ccb09de 100644 --- a/src/xbt/xbt_main.cpp +++ b/src/xbt/xbt_main.cpp @@ -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; -bool _sg_do_clean_atexit = true; +simgrid::config::Flag 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; @@ -98,7 +102,7 @@ static void xbt_preinit() static void xbt_postexit() { - if (not _sg_do_clean_atexit) + if (not cfg_dbg_clean_atexit) return; xbt_initialized--; xbt_dict_postexit();