Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9c7b2e76199c7664ccf5618cb3941a10b06f3075
[simgrid.git] / src / mc / mc_client_api.c
1 /* Copyright (c) 2008-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include <xbt/log.h>
8 #include <xbt/fifo.h>
9 #include <xbt/sysdep.h>
10 #include <simgrid/modelchecker.h>
11
12 #include "mc_record.h"
13 #include "mc_private.h"
14 #include "mc_mmalloc.h"
15 #include "mc_model_checker.h"
16 #include "mc_ignore.h"
17 #include "mc_protocol.h"
18 #include "mc_client.h"
19
20 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client_api, mc,
21   "Public API for the model-checked application");
22
23 void MC_assert(int prop)
24 {
25   if (MC_is_active() && !prop) {
26     XBT_INFO("**************************");
27     XBT_INFO("*** PROPERTY NOT VALID ***");
28     XBT_INFO("**************************");
29     XBT_INFO("Counter-example execution trace:");
30     MC_record_dump_path(mc_stack);
31     MC_dump_stack_safety(mc_stack);
32     MC_print_statistics(mc_stats);
33     xbt_abort();
34   }
35 }
36
37 // TODO, MC_automaton_new_propositional_symbol
38
39 void *MC_snapshot(void)
40 {
41   return simcall_mc_snapshot();
42 }
43
44 int simcall_HANDLER_mc_compare_snapshots(smx_simcall_t simcall,
45                                    mc_snapshot_t s1, mc_snapshot_t s2)
46 {
47   return snapshot_compare(s1, s2);
48 }
49
50 int MC_compare_snapshots(void *s1, void *s2)
51 {
52   return simcall_mc_compare_snapshots(s1, s2);
53 }
54
55 void MC_cut(void)
56 {
57   user_max_depth_reached = 1;
58 }
59
60 void MC_ignore(void* addr, size_t size)
61 {
62   if (mc_mode == MC_MODE_CLIENT) {
63     s_mc_ignore_memory_message_t message;
64     message.type = MC_MESSAGE_IGNORE_MEMORY;
65     message.addr = addr;
66     message.size = size;
67     MC_client_send_message(&message, sizeof(message));
68   }
69
70   // TODO, remove this once the migration has been completed
71   int raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
72   MC_SET_MC_HEAP;
73   MC_process_ignore_memory(&mc_model_checker->process, addr, size);
74   if (!raw_mem_set)
75     MC_SET_STD_HEAP;
76 }