/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+#include "src/mc/mc_replay.hpp"
#include <simgrid/Exception.hpp>
#include <simgrid/s4u/Actor.hpp>
#include <simgrid/s4u/Host.hpp>
if (not wannadie())
smpi_switch_data_segment(get_iface());
#endif
+ if (simgrid_mc_replay_show_backtraces)
+ xbt_backtrace_display_current();
}
/** This actor will be terminated automatically when the last non-daemon actor finishes */
#endif
XBT_LOG_NEW_DEFAULT_CATEGORY(mc, "All MC categories");
+bool simgrid_mc_replay_show_backtraces = false;
namespace simgrid::mc {
simgrid::mc::execute_actors();
auto* engine = kernel::EngineImpl::get_instance();
+ int frame_count = 1;
+ if (xbt_log_no_loc)
+ XBT_INFO("The backtrace of each transition will not be shown because of --log=no_loc");
+ else
+ simgrid_mc_replay_show_backtraces = 1;
+
for (const simgrid::mc::Transition* transition : transitions_) {
kernel::actor::ActorImpl* actor = engine->get_actor_by_pid(transition->aid_);
xbt_assert(actor != nullptr, "Unexpected actor (id:%ld).", transition->aid_);
xbt_assert(simgrid::mc::request_is_visible(simcall), "Simcall %s of actor %s is not visible.", simcall->get_cname(),
actor->get_cname());
- XBT_DEBUG("Executing %ld$%i: %s", transition->aid_, transition->times_considered_,
- simcall->observer_->to_string().c_str());
+ XBT_INFO("***********************************************************************************");
+ XBT_INFO("* Path chunk #%d '%ld/%i' Actor %s(pid:%ld): %s", frame_count++, transition->aid_,
+ transition->times_considered_, simcall->issuer_->get_cname(), simcall->issuer_->get_pid(),
+ simcall->observer_->to_string().c_str());
+ XBT_INFO("***********************************************************************************");
if (not mc::actor_is_enabled(actor))
simgrid::kernel::EngineImpl::get_instance()->display_all_actor_status();
return not MC_record_path().empty();
}
+/** Whether we should display extra information during this MC replay */
+extern bool simgrid_mc_replay_show_backtraces;
+
#endif
if (frame_name.rfind("simgrid::xbt::MainFunction", 0) == 0 ||
frame_name.rfind("simgrid::kernel::context::Context::operator()()", 0) == 0)
break;
- ss << " -> " << frame_count++ << "# " << frame << "\n";
+ if (xbt_log_no_loc) { // Don't display file source and line if so
+ if (frame.name().empty())
+ ss << " -> #" << frame_count++ << " (debug info not found and log:no_loc activated)\n";
+ else
+ ss << " -> #" << frame_count++ << " " << frame.name() << "\n";
+ } else
+ ss << " -> #" << frame_count++ << " " << frame << "\n";
+ // If we are displaying the user side of a simcall, remove the crude details of context switching
+ if (frame_name.find("simgrid::kernel::actor::simcall_answered") != std::string::npos ||
+ frame_name.find("simgrid::kernel::actor::simcall_blocking") != std::string::npos ||
+ frame_name.find("simcall_run_answered") != std::string::npos ||
+ frame_name.find("simcall_run_blocking") != std::string::npos) {
+ frame_count = 0;
+ ss.str(std::string()); // This is how you clear a stringstream in C++. clear() is something else :'(
+ }
if (frame_name == "main")
break;
} else {
void Backtrace::display() const
{
std::string backtrace = resolve();
- std::fprintf(stderr, "Backtrace (displayed in actor %s):\n%s\n", xbt_procname(),
+ std::fprintf(stderr, "Backtrace (displayed in actor %s%s):\n%s\n", xbt_procname(),
+ (xbt_log_no_loc ? " -- short trace because of --log=no_loc" : ""),
backtrace.empty() ? "(backtrace not set -- did you install Boost.Stacktrace?)" : backtrace.c_str());
}
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
set_property(TARGET ${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
+ target_compile_options(${x} PRIVATE ${CMAKE_C_DEBUG_FLAGS})
add_dependencies(tests-mc ${x})
endif()
#!/usr/bin/env tesh
-$ ${bindir:=.}/random-bug printf ${platfdir}/small_platform.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n" "--cfg=model-check/replay:1/3;1/4"
+$ ${bindir:=.}/random-bug printf ${platfdir}/small_platform.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n" "--cfg=model-check/replay:1/3;1/4" --log=no_loc
> [ 0.000000] (0:maestro@) Behavior: printf
> [ 0.000000] (0:maestro@) path=1/3;1/4
+> [ 0.000000] (0:maestro@) The backtrace of each transition will not be shown because of --log=no_loc
+> [ 0.000000] (0:maestro@) ***********************************************************************************
+> [ 0.000000] (0:maestro@) * Path chunk #1 '1/3' Actor app(pid:1): Random(min:0 max:5)
+> [ 0.000000] (0:maestro@) ***********************************************************************************
+> [ 0.000000] (0:maestro@) ***********************************************************************************
+> [ 0.000000] (0:maestro@) * Path chunk #2 '1/4' Actor app(pid:1): Random(min:0 max:5)
+> [ 0.000000] (0:maestro@) ***********************************************************************************
> [ 0.000000] (1:app@Fafard) Error reached
> [ 0.000000] (0:maestro@) The replay of the trace is complete. The application is terminating.
# Behavior: assert does not have the same output within and without MC, so don't test it here. That's already covered with the other ones
! expect signal SIGIOT
-$ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/random-bug abort ${platfdir}/small_platform.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n" "--cfg=model-check/replay:1/3;1/4"
+$ $VALGRIND_NO_LEAK_CHECK ${bindir:=.}/random-bug abort ${platfdir}/small_platform.xml --log=xbt_cfg.thresh:warning "--log=root.fmt:[%10.6r]%e(%i:%a@%h)%e%m%n" "--cfg=model-check/replay:1/3;1/4" --log=no_loc
> [ 0.000000] (0:maestro@) Behavior: abort
> [ 0.000000] (0:maestro@) path=1/3;1/4
+> [ 0.000000] (0:maestro@) The backtrace of each transition will not be shown because of --log=no_loc
+> [ 0.000000] (0:maestro@) ***********************************************************************************
+> [ 0.000000] (0:maestro@) * Path chunk #1 '1/3' Actor app(pid:1): Random(min:0 max:5)
+> [ 0.000000] (0:maestro@) ***********************************************************************************
+> [ 0.000000] (0:maestro@) ***********************************************************************************
+> [ 0.000000] (0:maestro@) * Path chunk #2 '1/4' Actor app(pid:1): Random(min:0 max:5)
+> [ 0.000000] (0:maestro@) ***********************************************************************************