#include "src/kernel/activity/CommImpl.hpp"
#include "src/kernel/activity/MutexImpl.hpp"
#include "src/mc/checker/SimcallInspector.hpp"
+#include "src/mc/mc_config.hpp"
#include "src/mc/mc_replay.hpp"
#include "src/simix/smx_private.hpp"
int simcall_HANDLER_mc_random(smx_simcall_t simcall, int min, int max)
{
- if (not MC_is_active() && MC_record_path.empty()) {
+ if (not MC_is_active() && not MC_record_replay_is_active()) {
static simgrid::xbt::random::XbtRandom prng;
return prng.uniform_int(min, max);
}
/* 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_config.hpp"
#include "src/mc/mc_replay.hpp"
#include <simgrid/sg_config.hpp>
#if SIMGRID_HAVE_MC
/* Replay (this part is enabled even if MC it disabled) */
simgrid::config::Flag<std::string> _sg_mc_record_path{
- "model-check/replay", "Model-check path to replay (as reported by SimGrid when a violation is reported)", ""};
+ "model-check/replay", "Model-check path to replay (as reported by SimGrid when a violation is reported)", "",
+ [](const std::string& value) { MC_record_path() = value; }};
simgrid::config::Flag<bool> _sg_mc_timeout{
- "model-check/timeout", "Whether to enable timeouts for wait requests", false,
- [](bool) { _mc_cfg_cb_check("value to enable/disable timeout for wait requests", MC_record_path.empty()); }};
+ "model-check/timeout", "Whether to enable timeouts for wait requests", false, [](bool) {
+ _mc_cfg_cb_check("value to enable/disable timeout for wait requests", not MC_record_replay_is_active());
+ }};
#if SIMGRID_HAVE_MC
int _sg_do_model_check = 0;
/********************************** Configuration of MC **************************************/
extern "C" XBT_PUBLIC int _sg_do_model_check;
extern XBT_PUBLIC simgrid::config::Flag<std::string> _sg_mc_buffering;
-extern XBT_PUBLIC simgrid::config::Flag<std::string> _sg_mc_record_path;
extern XBT_PRIVATE simgrid::config::Flag<int> _sg_mc_checkpoint;
extern XBT_PUBLIC simgrid::config::Flag<std::string> _sg_mc_property_file;
extern XBT_PUBLIC simgrid::config::Flag<bool> _sg_mc_comms_determinism;
#ifndef SIMGRID_MC_REPLAY_H
#define SIMGRID_MC_REPLAY_H
-#include "src/mc/mc_config.hpp"
+#include <string>
/** Replay path (if any) in string representation
*
* This is using the format generated by traceToString().
+ * Use a function to avoid static initialization order fiasco.
*/
-#define MC_record_path (_sg_mc_record_path.get())
+inline std::string& MC_record_path()
+{
+ static std::string value;
+ return value;
+}
/** Whether the replay mode is enabled */
static inline int MC_record_replay_is_active()
{
- return not MC_record_path.empty();
+ return not MC_record_path().empty();
}
#endif
void SIMIX_run()
{
if (MC_record_replay_is_active()) {
- simgrid::mc::replay(MC_record_path);
+ simgrid::mc::replay(MC_record_path());
return;
}