X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/824740eb0df1dedddb86035ff3730d87e037f356..a121f8b79e4e8a7104243fdc74e80f298dca4881:/src/mc/explo/Exploration.cpp diff --git a/src/mc/explo/Exploration.cpp b/src/mc/explo/Exploration.cpp index 5d35347678..f6b4c85299 100644 --- a/src/mc/explo/Exploration.cpp +++ b/src/mc/explo/Exploration.cpp @@ -5,8 +5,10 @@ #include "src/mc/explo/Exploration.hpp" #include "src/mc/mc_config.hpp" +#include "src/mc/mc_environ.h" #include "src/mc/mc_exit.hpp" #include "src/mc/mc_private.hpp" +#include "xbt/string.hpp" #if SIMGRID_HAVE_STATEFUL_MC #include "src/mc/sosp/RemoteProcessMemory.hpp" @@ -62,20 +64,46 @@ void Exploration::log_state() dot_output("}\n"); fclose(dot_output_); } - if (getenv("SIMGRID_MC_SYSTEM_STATISTICS")) { + if (getenv(MC_ENV_SYSTEM_STATISTICS)) { int ret = system("free"); if (ret != 0) XBT_WARN("Call to system(free) did not return 0, but %d", ret); } } +// Make our tests fully reproducible despite the subtle differences of strsignal() across archs +static const char* signal_name(int status) +{ + switch (WTERMSIG(status)) { + case SIGABRT: // FreeBSD uses "Abort trap" as a strsignal for SIGABRT + return "Aborted"; + case SIGSEGV: // MacOSX uses "Segmentation fault: 11" for SIGKILL + return "Segmentation fault"; + default: + return strsignal(WTERMSIG(status)); + } +} + +std::vector Exploration::get_textual_trace() +{ + std::vector trace; + for (auto const& transition : get_record_trace()) { + auto call_location = transition->get_call_location(); + if (not call_location.empty()) + trace.push_back(xbt::string_printf("Actor %ld in %s ==> simcall: %s", transition->aid_, call_location.c_str(), + transition->to_string().c_str())); + else + trace.push_back(xbt::string_printf("Actor %ld in simcall %s", transition->aid_, transition->to_string().c_str())); + } + return trace; +} XBT_ATTRIB_NORETURN void Exploration::report_crash(int status) { XBT_INFO("**************************"); XBT_INFO("** CRASH IN THE PROGRAM **"); XBT_INFO("**************************"); - if (WIFSIGNALED(status)) // FreeBSD use "Abort trap" as a strsignal for SIGABRT that is part of our tests - XBT_INFO("From signal: %s", WTERMSIG(status) == SIGABRT ? "Aborted" : strsignal(WTERMSIG(status))); + if (WIFSIGNALED(status)) + XBT_INFO("From signal: %s", signal_name(status)); else if (WIFEXITED(status)) XBT_INFO("From exit: %i", WEXITSTATUS(status)); if (not xbt_log_no_loc) @@ -101,7 +129,7 @@ XBT_ATTRIB_NORETURN void Exploration::report_crash(int status) XBT_INFO("Stack trace not shown because there is no memory introspection."); } - system_exit(SIMGRID_MC_EXIT_PROGRAM_CRASH); + throw McError(ExitStatus::PROGRAM_CRASH); } XBT_ATTRIB_NORETURN void Exploration::report_assertion_failure() { @@ -115,12 +143,7 @@ XBT_ATTRIB_NORETURN void Exploration::report_assertion_failure() "--cfg=model-check/replay:'%s'", get_record_trace().to_string().c_str()); log_state(); - system_exit(SIMGRID_MC_EXIT_SAFETY); -} - -void Exploration::system_exit(int status) const -{ - ::exit(status); + throw McError(ExitStatus::SAFETY); } }; // namespace simgrid::mc