X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/46f34f3267630e5f6b0e01509626ff06c18d2015..372f92e67e3eb3ca800b6d9bcf214594cf3b6798:/src/mc/explo/Exploration.cpp diff --git a/src/mc/explo/Exploration.cpp b/src/mc/explo/Exploration.cpp index 02a0016b87..58bc34d610 100644 --- a/src/mc/explo/Exploration.cpp +++ b/src/mc/explo/Exploration.cpp @@ -5,9 +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 "src/mc/sosp/RemoteProcessMemory.hpp" +#include "xbt/string.hpp" #include @@ -38,6 +39,7 @@ Exploration::~Exploration() { if (dot_output_ != nullptr) fclose(dot_output_); + instance_ = nullptr; } void Exploration::dot_output(const char* fmt, ...) @@ -57,20 +59,49 @@ 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)); + } +} -void Exploration::report_crash(int status) +std::vector Exploration::get_textual_trace(int max_elements) +{ + std::vector trace; + for (auto const& transition : get_record_trace()) { + auto const& 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())); + max_elements--; + if (max_elements == 0) + break; + } + return trace; +} + +XBT_ATTRIB_NORETURN void Exploration::report_crash(int status) { XBT_INFO("**************************"); XBT_INFO("** CRASH IN THE PROGRAM **"); XBT_INFO("**************************"); if (WIFSIGNALED(status)) - XBT_INFO("From signal: %s", strsignal(WTERMSIG(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) @@ -83,17 +114,10 @@ void Exploration::report_crash(int status) "--cfg=model-check/replay:'%s'", get_record_trace().to_string().c_str()); log_state(); - if (xbt_log_no_loc) { - XBT_INFO("Stack trace not displayed because you passed --log=no_loc"); - } else { - XBT_INFO("Stack trace:"); - get_remote_app().get_remote_process_memory().dump_stack(); - } - get_remote_app().get_remote_process_memory().terminate(); - system_exit(SIMGRID_MC_EXIT_PROGRAM_CRASH); + throw McError(ExitStatus::PROGRAM_CRASH); } -void Exploration::report_assertion_failure() +XBT_ATTRIB_NORETURN void Exploration::report_assertion_failure() { XBT_INFO("**************************"); XBT_INFO("*** PROPERTY NOT VALID ***"); @@ -105,13 +129,7 @@ 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) -{ - get_remote_app().shutdown(); - ::exit(status); + throw McError(ExitStatus::SAFETY); } }; // namespace simgrid::mc