From: Arnaud Giersch Date: Thu, 19 Apr 2018 20:43:35 +0000 (+0200) Subject: Add parameter simix/breakpoint. Fixes #143. X-Git-Tag: v3.20~360 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/10be64001fd1456d256c9a64b03fa2f57b4a0bed Add parameter simix/breakpoint. Fixes #143. --- diff --git a/ChangeLog b/ChangeLog index e85b36061a..71afbb0eaa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ TRACE - Introduced new function simgrid::s4u::Host::get_actor_count. This function returns the number of actors running on a specific host. + Simix: + - Add parameter --cfg=simix/breakpoint to raise a SIGTRAP at given time. + SMPI: - Replay: The replay file has been re-written in C++. - Replay: Tags used for messages sent via MPI_Send / MPI_Recv are now @@ -18,6 +21,7 @@ TRACE the C++ API has been slightly improved. Fixed bugs: + - #143: Setting a breakpoint at a given time - #258: daemonized actors hang after all non-daemonized actors have completed ---------------------------------------------------------------------------- diff --git a/doc/doxygen/options.doc b/doc/doxygen/options.doc index 02e1350b93..dff9c9c7ed 100644 --- a/doc/doxygen/options.doc +++ b/doc/doxygen/options.doc @@ -130,6 +130,8 @@ int main(int argc, char *argv[]) { - \c path: \ref options_generic_path - \c plugin: \ref options_generic_plugin +- \c simix/breakpoint: \ref options_generic_breakpoint + - \c storage/max_file_descriptors: \ref option_model_storage_maxfd - \c surf/precision: \ref options_model_precision @@ -1264,6 +1266,23 @@ item several times, as in \verbatim --cfg=path:toto --cfg=path:tutu \endverbatim +\subsection options_generic_breakpoint Set a breakpoint + +\verbatim +--cfg=simix/breakpoint:3.1416 +\endverbatim + +This configuration option sets a breakpoint: when the simulated clock reaches +the given time, a SIGTRAP is raised. This can be used to stop the execution and +get a backtrace with a debugger. + +It is also possible to set the breakpoint from inside the debugger, by writing +in global variable simgrid::simix::breakpoint. For example, with gdb: + +\verbatim +set variable simgrid::simix::breakpoint = 3.1416 +\endverbatim + \subsection options_generic_exit Behavior on Ctrl-C By default, when Ctrl-C is pressed, the status of all existing diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 37ebaba05e..683ed17858 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -158,6 +158,8 @@ namespace simix { simgrid::xbt::signal onDeadlock; +simgrid::config::Flag breakpoint{"simix/breakpoint", + "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0}; } } @@ -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()) {