Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Display the stack of each actor during a MC replay (unless --log=no_log for the tests)
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 1 Nov 2022 18:39:55 +0000 (19:39 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Tue, 1 Nov 2022 18:39:55 +0000 (19:39 +0100)
src/kernel/actor/ActorImpl.cpp
src/mc/mc_base.cpp
src/mc/mc_record.cpp
src/mc/mc_replay.hpp
src/xbt/backtrace.cpp
teshsuite/mc/CMakeLists.txt
teshsuite/mc/random-bug/random-bug-replay.tesh

index 8f3b373..e308692 100644 (file)
@@ -3,6 +3,7 @@
 /* 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>
@@ -279,6 +280,8 @@ void ActorImpl::yield()
   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 */
index 95965ec..ac3f49f 100644 (file)
@@ -19,6 +19,7 @@
 #endif
 
 XBT_LOG_NEW_DEFAULT_CATEGORY(mc, "All MC categories");
+bool simgrid_mc_replay_show_backtraces = false;
 
 namespace simgrid::mc {
 
index 3b35ead..67e8883 100644 (file)
@@ -25,6 +25,12 @@ void RecordTrace::replay() const
   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_);
@@ -32,8 +38,11 @@ void RecordTrace::replay() const
     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();
 
index ae8cd4a..7c59b5d 100644 (file)
@@ -25,4 +25,7 @@ static inline int MC_record_replay_is_active()
   return not MC_record_path().empty();
 }
 
+/** Whether we should display extra information during this MC replay */
+extern bool simgrid_mc_replay_show_backtraces;
+
 #endif
index bead658..a180720 100644 (file)
@@ -50,7 +50,21 @@ public:
         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 {
@@ -78,7 +92,8 @@ std::string Backtrace::resolve() const
 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());
 }
 
index b4b7648..7d0e351 100644 (file)
@@ -15,6 +15,7 @@ foreach(x dwarf dwarf-expression random-bug mutex-handling)
     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()
 
index c32150f..560b2d9 100644 (file)
@@ -1,13 +1,27 @@
 #!/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@) ***********************************************************************************