src/mc/mc_base.cpp
src/mc/mc_base.h
src/mc/mc_record.h
+ src/mc/mc_replay.h
src/mc/mc_record.cpp
src/mc/mc_config.cpp
src/mc/mc_global.cpp
#include "xbt/asserts.h"
#include "simgrid/modelchecker.h"
#include <xbt/RngStream.h>
+#include "mc/mc_replay.h"
/** @addtogroup MSG_examples
*
! timeout 60
$ ../../../smpi_script/bin/smpirun -wrapper "${bindir:=.}/../../../bin/simgrid-mc" --log=xbt_cfg.thresh:warning -hostfile ${srcdir:=.}/hostfile_only_send_deterministic -platform ${srcdir:=.}/../../platforms/cluster.xml --cfg=model-check:1 --cfg=model-check/communications_determinism:1 --cfg=smpi/send_is_detached_thres:0 --cfg=smpi/running_power:1e9 ./smpi_only_send_deterministic
-> [0.000000] [mc_global/INFO] Check communication determinism
+> [0.000000] [mc_comm_determinism/INFO] Check communication determinism
> [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s)
> [0.000000] [mc_global/INFO] ******************************************************
> [0.000000] [mc_global/INFO] **** Only-send-deterministic communication pattern ****
SG_BEGIN_DECL()
-/** Replay path (if any) in string representation
- *
- * This is a path as generated by `MC_record_stack_to_string()`.
- */
-XBT_PUBLIC_DATA(char*) MC_record_path;
-
-/** Whether the replay mode is enabled */
-static inline bool MC_record_replay_is_active(void) {
- return MC_record_path;
-}
-
XBT_PUBLIC(int) MC_random(int min, int max);
#ifdef HAVE_MC
void _mc_cfg_cb_send_determinism(const char *name, int pos);
void _mc_cfg_cb_termination(const char *name, int pos);
-XBT_PUBLIC(void) MC_do_the_modelcheck_for_real(void);
+XBT_PUBLIC(void) MC_run(void);
XBT_PUBLIC(void) MC_init(void);
XBT_PUBLIC(void) MC_exit(void);
XBT_PUBLIC(void) MC_process_clock_add(smx_process_t, double);
#include "mc_base.h"
#include "../simix/smx_private.h"
-#include "mc_record.h"
+#include "mc/mc_record.h"
+#include "mc/mc_replay.h"
#ifdef HAVE_MC
#include "mc_process.h"
void MC_assert(int prop)
{
if (MC_is_active() && !prop) {
- if (mc_mode == MC_MODE_STANDALONE) {
- MC_report_assertion_error();
- } else {
- MC_client_send_simple_message(MC_MESSAGE_ASSERTION_FAILED);
- MC_client_handle_messages();
- }
+ MC_client_send_simple_message(MC_MESSAGE_ASSERTION_FAILED);
+ MC_client_handle_messages();
}
}
void MC_modelcheck_comm_determinism(void)
{
+ XBT_INFO("Check communication determinism");
+ mc_reduce_kind = e_mc_reduce_none;
+ MC_wait_for_requests();
+
if (mc_mode == MC_MODE_CLIENT) {
// This will move somehwere else:
MC_client_handle_messages();
#include <xbt/config.h>
#include <mc/mc.h>
+#include "mc/mc_replay.h"
#include <simgrid/sg_config.h>
}
-static void MC_init_mode(void)
-{
- if (mc_mode == MC_MODE_NONE) {
- if (getenv(MC_ENV_SOCKET_FD)) {
- mc_mode = MC_MODE_CLIENT;
- } else {
- mc_mode = MC_MODE_STANDALONE;
- }
- }
-}
-
#ifdef HAVE_MC
void MC_init()
{
/* SIMIX */
MC_ignore_global_variable("smx_total_comms");
- if (mc_mode == MC_MODE_STANDALONE || mc_mode == MC_MODE_CLIENT) {
+ if (mc_mode == MC_MODE_CLIENT) {
/* Those requests are handled on the client side and propagated by message
* to the server: */
/******************************* Core of MC *******************************/
/**************************************************************************/
-void MC_do_the_modelcheck_for_real()
+void MC_run()
{
- MC_init_mode();
-
- switch(mc_mode) {
- default:
- xbt_die("Unexpected mc mode");
- break;
- case MC_MODE_CLIENT:
- MC_init();
- MC_client_main_loop();
- return;
- case MC_MODE_SERVER:
- break;
- case MC_MODE_STANDALONE:
- MC_init();
- break;
- }
-
- if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
- XBT_INFO("Check communication determinism");
- mc_reduce_kind = e_mc_reduce_none;
- MC_wait_for_requests();
- MC_modelcheck_comm_determinism();
- }
-
- else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0') {
- if(_sg_mc_termination)
- mc_reduce_kind = e_mc_reduce_none;
- else if (mc_reduce_kind == e_mc_reduce_unset)
- mc_reduce_kind = e_mc_reduce_dpor;
- _sg_mc_safety = 1;
- if (_sg_mc_termination)
- XBT_INFO("Check non progressive cycles");
- else
- XBT_INFO("Check a safety property");
- MC_wait_for_requests();
- MC_modelcheck_safety();
- }
-
- else {
- if (mc_reduce_kind == e_mc_reduce_unset)
- mc_reduce_kind = e_mc_reduce_none;
- XBT_INFO("Check the liveness property %s", _sg_mc_property_file);
- MC_automaton_load(_sg_mc_property_file);
- MC_wait_for_requests();
- MC_modelcheck_liveness();
- }
-
+ mc_mode = MC_MODE_CLIENT;
+ MC_init();
+ MC_client_main_loop();
}
-
void MC_exit(void)
{
xbt_free(mc_time);
#include "mc_record.h"
#include "mc_smx.h"
#include "mc_client.h"
+#include "mc_replay.h"
+#include "mc_safety.h"
extern "C" {
void MC_modelcheck_liveness(void)
{
+ if (mc_reduce_kind == e_mc_reduce_unset)
+ mc_reduce_kind = e_mc_reduce_none;
+ XBT_INFO("Check the liveness property %s", _sg_mc_property_file);
+ MC_automaton_load(_sg_mc_property_file);
+ MC_wait_for_requests();
+
XBT_DEBUG("Starting the liveness algorithm");
_sg_mc_liveness = 1;
unsigned long MC_smx_get_maxpid(void)
{
- if (mc_mode == MC_MODE_STANDALONE)
- return simix_process_maxpid;
-
unsigned long maxpid;
MC_process_read_variable(&mc_model_checker->process, "simix_process_maxpid",
&maxpid, sizeof(maxpid));
switch(mode) {
case MC_MODE_NONE:
return "NONE";
- case MC_MODE_STANDALONE:
- return "STANDALONE";
case MC_MODE_CLIENT:
return "CLIENT";
case MC_MODE_SERVER:
typedef enum {
MC_MODE_NONE = 0,
- MC_MODE_STANDALONE,
MC_MODE_CLIENT,
MC_MODE_SERVER
} e_mc_mode_t;
--- /dev/null
+/* simgrid/modelchecker.h - Formal Verification made possible in SimGrid */
+
+/* Copyright (c) 2008-2014. The SimGrid Team.
+ * All rights reserved. */
+
+/* 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 <xbt/misc.h>
+
+#ifndef SIMGRID_MC_REPLAY_H
+#define SIMGRID_MC_REPLAY_H
+
+SG_BEGIN_DECL()
+
+/** Replay path (if any) in string representation
+ *
+ * This is a path as generated by `MC_record_stack_to_string()`.
+ */
+XBT_PUBLIC_DATA(char*) MC_record_path;
+
+/** Whether the replay mode is enabled */
+static inline int MC_record_replay_is_active(void) {
+ return MC_record_path != 0;
+}
+
+SG_END_DECL()
+
+#endif
void MC_modelcheck_safety(void)
{
+ if(_sg_mc_termination)
+ mc_reduce_kind = e_mc_reduce_none;
+ else if (mc_reduce_kind == e_mc_reduce_unset)
+ mc_reduce_kind = e_mc_reduce_dpor;
+ _sg_mc_safety = 1;
+ if (_sg_mc_termination)
+ XBT_INFO("Check non progressive cycles");
+ else
+ XBT_INFO("Check a safety property");
+ MC_wait_for_requests();
+
XBT_DEBUG("Starting the safety algorithm");
_sg_mc_safety = 1;
#include "mc_server.h"
#include "mc_model_checker.h"
#include "mc_safety.h"
+#include "mc_comm_pattern.h"
+#include "mc_liveness.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_main, mc, "Entry point for simgrid-mc");
mc_server = new s_mc_server(child, socket);
mc_server->start();
MC_init_pid(child, socket);
- MC_do_the_modelcheck_for_real();
+ if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
+ MC_modelcheck_comm_determinism();
+ else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0')
+ MC_modelcheck_safety();
+ else
+ MC_modelcheck_liveness();
mc_server->shutdown();
mc_server->exit();
}
fflush(stderr);
if (MC_is_active()) {
- MC_do_the_modelcheck_for_real();
+ MC_run();
} else {
SIMIX_run();
}
#include "mc/mc.h"
#include "mc/mc_record.h"
#include "simgrid/instr.h"
+#include "mc/mc_replay.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_config, surf,
"About the configuration of simgrid");
/* 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 "mc/mc_replay.h"
#include "smx_private.h"
#include "mc/mc_interface.h"
#include "xbt/ex.h"
#include "xbt/str.h"
#include "xbt/ex.h" /* ex_backtrace_display */
#include "mc/mc.h"
+#include "mc/mc_replay.h"
#include "simgrid/sg_config.h"
#ifdef HAVE_MC
MC_client_init();
MC_client_hello();
MC_client_handle_messages();
- } else {
- mc_mode = MC_MODE_STANDALONE;
}
}
#endif
#include "xbt/log.h"
#include "xbt/dict.h"
#include "mc/mc.h"
+#include "mc/mc_replay.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_host, simix,
"SIMIX hosts");
#include "smx_private.h"
#include "xbt/log.h"
#include "mc/mc.h"
+#include "mc/mc_replay.h"
#include "xbt/dict.h"
#include "smpi/private.h"
-
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_network, simix,
"SIMIX network-related synchronization");
#include "xbt/log.h"
#include "xbt/dict.h"
#include "mc/mc.h"
+#include "mc/mc_replay.h"
#include "mc/mc_client.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_process, simix,
#include "private.h"
#include "xbt/virtu.h"
#include "mc/mc.h"
+#include "mc/mc_replay.h"
#include "xbt/replay.h"
#include <errno.h>
#include "simix/smx_private.h"
#include "surf/surf.h"
#include "simgrid/sg_config.h"
#include "simgrid/modelchecker.h"
+#include "mc/mc_replay.h"
#ifndef WIN32
#include <sys/mman.h>
#include "surf/surf.h"
#include "simix/smx_private.h"
#include "simgrid/sg_config.h"
+#include "mc/mc_replay.h"
#include <float.h> /* DBL_MAX */
#include <stdint.h>
fflush(stderr);
if (MC_is_active()) {
- MC_do_the_modelcheck_for_real();
+ MC_run();
} else {
SIMIX_run();