X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/20725839bfdac54bf58497e0c34705ba37f19265..ab71da4cf3e28f55f7aef47f5299519135429872:/src/mc/mc_client_api.cpp diff --git a/src/mc/mc_client_api.cpp b/src/mc/mc_client_api.cpp index 21a1db98d3..e64019f7c1 100644 --- a/src/mc/mc_client_api.cpp +++ b/src/mc/mc_client_api.cpp @@ -1,101 +1,68 @@ -/* Copyright (c) 2008-2015. The SimGrid Team. +/* Copyright (c) 2008-2022. 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 -#include -#include -#include - -#include "src/mc/mc_record.h" -#include "src/mc/mc_private.h" -#include "src/mc/mc_ignore.h" -#include "src/mc/mc_protocol.h" -#include "src/mc/mc_client.h" #include "src/mc/ModelChecker.hpp" +#include "src/mc/mc_private.hpp" +#include "src/mc/mc_record.hpp" +#include "src/mc/mc_replay.hpp" +#include "src/mc/remote/AppSide.hpp" +#include "xbt/asserts.h" -/** \file mc_client_api.cpp +/** @file mc_client_api.cpp * * This is the implementation of the API used by the user simulated program to * communicate with the MC (declared in modelchecker.h). */ -extern "C" { - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client_api, mc, - "Public API for the model-checked application"); - -} - // MC_random() is in mc_base.cpp void MC_assert(int prop) { - if (MC_is_active() && !prop) { - MC_client_send_simple_message(MC_MESSAGE_ASSERTION_FAILED); - MC_client_handle_messages(); + xbt_assert(mc_model_checker == nullptr); + if (not prop) { + if (MC_is_active()) + simgrid::mc::AppSide::get()->report_assertion_failure(); + if (MC_record_replay_is_active()) + xbt_die("MC assertion failed"); } } -void *MC_snapshot(void) -{ - return simcall_mc_snapshot(); -} - -int simcall_HANDLER_mc_compare_snapshots(smx_simcall_t simcall, - mc_snapshot_t s1, mc_snapshot_t s2) -{ - return snapshot_compare(s1, s2); -} - -int MC_compare_snapshots(void *s1, void *s2) +void MC_automaton_new_propositional_symbol(const char* /*id*/, int (*/*fct*/)()) { - return simcall_mc_compare_snapshots(s1, s2); + xbt_assert(mc_model_checker == nullptr); + if (not MC_is_active()) + return; + xbt_die("Support for client-side function proposition is not implemented: " + "use MC_automaton_new_propositional_symbol_pointer instead."); } -void MC_cut(void) +void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value) { - user_max_depth_reached = 1; + xbt_assert(mc_model_checker == nullptr); + if (not MC_is_active()) + return; + simgrid::mc::AppSide::get()->declare_symbol(name, value); } void MC_ignore(void* addr, size_t size) { - xbt_assert(mc_mode != MC_MODE_SERVER); - if (mc_mode != MC_MODE_CLIENT) + xbt_assert(mc_model_checker == nullptr); + if (not MC_is_active()) return; - - s_mc_ignore_memory_message_t message; - message.type = MC_MESSAGE_IGNORE_MEMORY; - message.addr = (std::uintptr_t) addr; - message.size = size; - MC_client_send_message(&message, sizeof(message)); + simgrid::mc::AppSide::get()->ignore_memory(addr, size); } -void MC_automaton_new_propositional_symbol(const char *id, int(*fct)(void)) +void MC_ignore_heap(void *address, size_t size) { - xbt_assert(mc_mode != MC_MODE_SERVER); - if (mc_mode != MC_MODE_CLIENT) - return; - - xbt_die("Support for client-side function proposition is not implemented: " - "use MC_automaton_new_propositional_symbol_pointer instead." - ); + xbt_assert(mc_model_checker == nullptr); + simgrid::mc::AppSide::get()->ignore_heap(address, size); } -void MC_automaton_new_propositional_symbol_pointer(const char *name, int* value) +void MC_unignore_heap(void* address, size_t size) { - xbt_assert(mc_mode != MC_MODE_SERVER); - if (mc_mode != MC_MODE_CLIENT) - return; - - s_mc_register_symbol_message_t message; - message.type = MC_MESSAGE_REGISTER_SYMBOL; - if (strlen(name) + 1 > sizeof(message.name)) - xbt_die("Symbol is too long"); - strncpy(message.name, name, sizeof(message.name)); - message.callback = nullptr; - message.data = value; - MC_client_send_message(&message, sizeof(message)); + xbt_assert(mc_model_checker == nullptr); + simgrid::mc::AppSide::get()->unignore_heap(address, size); }