X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3d742161495c7fa3ad6c345226d709575c5720e3..244ffce80a9e2390e24b9788114de037e4ccc0ae:/src/mc/explo/Exploration.cpp diff --git a/src/mc/explo/Exploration.cpp b/src/mc/explo/Exploration.cpp index ceac33e163..58bc34d610 100644 --- a/src/mc/explo/Exploration.cpp +++ b/src/mc/explo/Exploration.cpp @@ -5,12 +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" - -#if SIMGRID_HAVE_STATEFUL_MC -#include "src/mc/sosp/RemoteProcessMemory.hpp" -#endif +#include "xbt/string.hpp" #include @@ -23,8 +21,7 @@ static simgrid::config::Flag cfg_dot_output_file{ Exploration* Exploration::instance_ = nullptr; // singleton instance -Exploration::Exploration(const std::vector& args, bool need_memory_introspection) - : remote_app_(std::make_unique(args, need_memory_introspection)) +Exploration::Exploration(const std::vector& args) : remote_app_(std::make_unique(args)) { xbt_assert(instance_ == nullptr, "Cannot have more than one exploration instance"); instance_ = this; @@ -62,7 +59,7 @@ 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); @@ -80,6 +77,24 @@ static const char* signal_name(int status) return strsignal(WTERMSIG(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("**************************"); @@ -99,20 +114,8 @@ XBT_ATTRIB_NORETURN 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 { -#if SIMGRID_HAVE_STATEFUL_MC - const auto* memory = get_remote_app().get_remote_process_memory(); - if (memory) { - XBT_INFO("Stack trace:"); - memory->dump_stack(); - } else -#endif - 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() { @@ -126,12 +129,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