Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
356562638053c5525d0ae9ac06b1c3e2972089dc
[simgrid.git] / src / mc / mc_global.cpp
1 /* Copyright (c) 2008-2014. 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 <assert.h>
8 #include <string.h>
9 #include <stdint.h>
10
11 #include "mc_base.h"
12
13 #ifndef _XBT_WIN32
14 #include <unistd.h>
15 #include <sys/wait.h>
16 #include <sys/time.h>
17 #endif
18
19 #include "simgrid/sg_config.h"
20 #include "../surf/surf_private.h"
21 #include "../simix/smx_private.h"
22 #include "xbt/fifo.h"
23 #include "xbt/automaton.h"
24 #include "xbt/dict.h"
25 #include "mc_record.h"
26
27 #ifdef HAVE_MC
28 #include "mc_server.h"
29 #include <libunwind.h>
30 #include <xbt/mmalloc.h>
31 #include "../xbt/mmalloc/mmprivate.h"
32 #include "mc_object_info.h"
33 #include "mc_comm_pattern.h"
34 #include "mc_request.h"
35 #include "mc_safety.h"
36 #include "mc_memory_map.h"
37 #include "mc_snapshot.h"
38 #include "mc_liveness.h"
39 #include "mc_private.h"
40 #include "mc_unw.h"
41 #include "mc_smx.h"
42 #include "mcer_ignore.h"
43 #endif
44 #include "mc_record.h"
45 #include "mc_protocol.h"
46 #include "mc_client.h"
47
48 extern "C" {
49
50 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_global, mc,
51                                 "Logging specific to MC (global)");
52
53 e_mc_mode_t mc_mode;
54
55 double *mc_time = NULL;
56
57 #ifdef HAVE_MC
58 int user_max_depth_reached = 0;
59
60 /* MC global data structures */
61 mc_state_t mc_current_state = NULL;
62 char mc_replay_mode = FALSE;
63
64 __thread mc_comparison_times_t mc_comp_times = NULL;
65 __thread double mc_snapshot_comparison_time;
66 mc_stats_t mc_stats = NULL;
67 mc_global_t initial_global_state = NULL;
68 xbt_fifo_t mc_stack = NULL;
69
70 /* Liveness */
71 xbt_automaton_t _mc_property_automaton = NULL;
72
73 /* Dot output */
74 FILE *dot_output = NULL;
75 const char *colors[13];
76
77
78 /*******************************  Initialisation of MC *******************************/
79 /*********************************************************************************/
80
81 static void MC_init_dot_output()
82 {                               /* FIXME : more colors */
83
84   colors[0] = "blue";
85   colors[1] = "red";
86   colors[2] = "green3";
87   colors[3] = "goldenrod";
88   colors[4] = "brown";
89   colors[5] = "purple";
90   colors[6] = "magenta";
91   colors[7] = "turquoise4";
92   colors[8] = "gray25";
93   colors[9] = "forestgreen";
94   colors[10] = "hotpink";
95   colors[11] = "lightblue";
96   colors[12] = "tan";
97
98   dot_output = fopen(_sg_mc_dot_output_file, "w");
99
100   if (dot_output == NULL) {
101     perror("Error open dot output file");
102     xbt_abort();
103   }
104
105   fprintf(dot_output,
106           "digraph graphname{\n fixedsize=true; rankdir=TB; ranksep=.25; edge [fontsize=12]; node [fontsize=10, shape=circle,width=.5 ]; graph [resolution=20, fontsize=10];\n");
107
108 }
109
110 #ifdef HAVE_MC
111 void MC_init()
112 {
113   mc_time = xbt_new0(double, simix_process_maxpid);
114
115   if (_sg_mc_visited > 0 || _sg_mc_liveness  || _sg_mc_termination || mc_mode == MC_MODE_SERVER) {
116     /* Those requests are handled on the client side and propagated by message
117      * to the server: */
118
119     MC_ignore_heap(mc_time, simix_process_maxpid * sizeof(double));
120
121     smx_process_t process;
122     xbt_swag_foreach(process, simix_global->process_list) {
123       MC_ignore_heap(&(process->process_hookup), sizeof(process->process_hookup));
124     }
125   }
126 }
127
128 void MC_init_model_checker(pid_t pid, int socket)
129 {
130   mc_model_checker = new simgrid::mc::ModelChecker(pid, socket);
131
132   mc_comp_times = xbt_new0(s_mc_comparison_times_t, 1);
133
134   /* Initialize statistics */
135   mc_stats = xbt_new0(s_mc_stats_t, 1);
136   mc_stats->state_size = 1;
137
138   if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0'))
139     MC_init_dot_output();
140
141   /* Init parmap */
142   //parmap = xbt_parmap_mc_new(xbt_os_get_numcores(), XBT_PARMAP_DEFAULT);
143
144   /* Ignore some variables from xbt/ex.h used by exception e for stacks comparison */
145   MC_ignore_local_variable("e", "*");
146   MC_ignore_local_variable("__ex_cleanup", "*");
147   MC_ignore_local_variable("__ex_mctx_en", "*");
148   MC_ignore_local_variable("__ex_mctx_me", "*");
149   MC_ignore_local_variable("__xbt_ex_ctx_ptr", "*");
150   MC_ignore_local_variable("_log_ev", "*");
151   MC_ignore_local_variable("_throw_ctx", "*");
152   MC_ignore_local_variable("ctx", "*");
153
154   MC_ignore_local_variable("self", "simcall_BODY_mc_snapshot");
155   MC_ignore_local_variable("next_cont"
156     "ext", "smx_ctx_sysv_suspend_serial");
157   MC_ignore_local_variable("i", "smx_ctx_sysv_suspend_serial");
158
159   /* Ignore local variable about time used for tracing */
160   MC_ignore_local_variable("start_time", "*");
161
162   /* Static variable used for tracing */
163   MCer_ignore_global_variable("counter");
164
165   /* SIMIX */
166   MCer_ignore_global_variable("smx_total_comms");
167 }
168 #endif
169
170 /*******************************  Core of MC *******************************/
171 /**************************************************************************/
172
173 void MC_run()
174 {
175   mc_mode = MC_MODE_CLIENT;
176   MC_init();
177   MC_client_main_loop();
178 }
179
180 void MC_exit(void)
181 {
182   xbt_free(mc_time);
183
184   MC_memory_exit();
185   //xbt_abort();
186 }
187
188 #ifdef HAVE_MC
189 int MC_deadlock_check()
190 {
191   if (mc_mode == MC_MODE_SERVER) {
192     int res;
193     if ((res = MC_protocol_send_simple_message(mc_model_checker->process().socket,
194       MC_MESSAGE_DEADLOCK_CHECK)))
195       xbt_die("Could not check deadlock state");
196     s_mc_int_message_t message;
197     ssize_t s = MC_receive_message(mc_model_checker->process().socket, &message, sizeof(message), 0);
198     if (s == -1)
199       xbt_die("Could not receive message");
200     else if (s != sizeof(message) || message.type != MC_MESSAGE_DEADLOCK_CHECK_REPLY) {
201       xbt_die("%s received unexpected message %s (%i, size=%i) "
202         "expected MC_MESSAGE_DEADLOCK_CHECK_REPLY (%i, size=%i)",
203         MC_mode_name(mc_mode),
204         MC_message_type_name(message.type), (int) message.type, (int) s,
205         (int) MC_MESSAGE_DEADLOCK_CHECK_REPLY, (int) sizeof(message)
206         );
207     }
208     else
209       return message.value;
210   }
211
212   int deadlock = FALSE;
213   smx_process_t process;
214   if (xbt_swag_size(simix_global->process_list)) {
215     deadlock = TRUE;
216     xbt_swag_foreach(process, simix_global->process_list) {
217       if (MC_process_is_enabled(process)) {
218         deadlock = FALSE;
219         break;
220       }
221     }
222   }
223   return deadlock;
224 }
225 #endif
226
227 /**
228  * \brief Re-executes from the state at position start all the transitions indicated by
229  *        a given model-checker stack.
230  * \param stack The stack with the transitions to execute.
231  * \param start Start index to begin the re-execution.
232  */
233 void MC_replay(xbt_fifo_t stack)
234 {
235   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
236
237   int value, count = 1;
238   char *req_str;
239   smx_simcall_t req = NULL, saved_req = NULL;
240   xbt_fifo_item_t item, start_item;
241   mc_state_t state;
242   
243   XBT_DEBUG("**** Begin Replay ****");
244
245   /* Intermediate backtracking */
246   if(_sg_mc_checkpoint > 0 || _sg_mc_termination || _sg_mc_visited > 0) {
247     start_item = xbt_fifo_get_first_item(stack);
248     state = (mc_state_t)xbt_fifo_get_item_content(start_item);
249     if(state->system_state){
250       MC_restore_snapshot(state->system_state);
251       if(_sg_mc_comms_determinism || _sg_mc_send_determinism) 
252         MC_restore_communications_pattern(state);
253       mmalloc_set_current_heap(std_heap);
254       return;
255     }
256   }
257
258
259   /* Restore the initial state */
260   MC_restore_snapshot(initial_global_state->snapshot);
261   /* At the moment of taking the snapshot the raw heap was set, so restoring
262    * it will set it back again, we have to unset it to continue  */
263   mmalloc_set_current_heap(std_heap);
264
265   start_item = xbt_fifo_get_last_item(stack);
266   
267   mmalloc_set_current_heap(mc_heap);
268
269   if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
270     // int n = xbt_dynar_length(incomplete_communications_pattern);
271     unsigned n = MC_smx_get_maxpid();
272     assert(n == xbt_dynar_length(incomplete_communications_pattern));
273     assert(n == xbt_dynar_length(initial_communications_pattern));
274     for (unsigned j=0; j < n ; j++) {
275       xbt_dynar_reset((xbt_dynar_t)xbt_dynar_get_as(incomplete_communications_pattern, j, xbt_dynar_t));
276       xbt_dynar_get_as(initial_communications_pattern, j, mc_list_comm_pattern_t)->index_comm = 0;
277     }
278   }
279
280   mmalloc_set_current_heap(std_heap);
281
282   /* Traverse the stack from the state at position start and re-execute the transitions */
283   for (item = start_item;
284        item != xbt_fifo_get_first_item(stack);
285        item = xbt_fifo_get_prev_item(item)) {
286
287     state = (mc_state_t) xbt_fifo_get_item_content(item);
288     saved_req = MC_state_get_executed_request(state, &value);
289     
290     if (saved_req) {
291       /* because we got a copy of the executed request, we have to fetch the  
292          real one, pointed by the request field of the issuer process */
293
294       const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req);
295       req = &issuer->simcall;
296
297       /* Debug information */
298       if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
299         req_str = MC_request_to_string(req, value, MC_REQUEST_SIMIX);
300         XBT_DEBUG("Replay: %s (%p)", req_str, state);
301         xbt_free(req_str);
302       }
303
304       /* TODO : handle test and testany simcalls */
305       e_mc_call_type_t call = MC_CALL_TYPE_NONE;
306       if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
307         call = MC_get_call_type(req);
308
309       MC_simcall_handle(req, value);
310
311       mmalloc_set_current_heap(mc_heap);
312       if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
313         MC_handle_comm_pattern(call, req, value, NULL, 1);
314       mmalloc_set_current_heap(std_heap);
315
316       MC_wait_for_requests();
317
318       count++;
319     }
320
321     /* Update statistics */
322     mc_stats->visited_states++;
323     mc_stats->executed_transitions++;
324
325   }
326
327   XBT_DEBUG("**** End Replay ****");
328   mmalloc_set_current_heap(heap);
329 }
330
331 void MC_replay_liveness(xbt_fifo_t stack)
332 {
333
334   initial_global_state->raw_mem_set = (mmalloc_get_current_heap() == mc_heap);
335
336   xbt_fifo_item_t item;
337   mc_pair_t pair = NULL;
338   mc_state_t state = NULL;
339   smx_simcall_t req = NULL, saved_req = NULL;
340   int value, depth = 1;
341   char *req_str;
342
343   XBT_DEBUG("**** Begin Replay ****");
344
345   /* Intermediate backtracking */
346   if(_sg_mc_checkpoint > 0) {
347     item = xbt_fifo_get_first_item(stack);
348     pair = (mc_pair_t) xbt_fifo_get_item_content(item);
349     if(pair->graph_state->system_state){
350       MC_restore_snapshot(pair->graph_state->system_state);
351       mmalloc_set_current_heap(std_heap);
352       return;
353     }
354   }
355
356   /* Restore the initial state */
357   MC_restore_snapshot(initial_global_state->snapshot);
358
359   /* At the moment of taking the snapshot the raw heap was set, so restoring
360    * it will set it back again, we have to unset it to continue  */
361   if (!initial_global_state->raw_mem_set)
362     mmalloc_set_current_heap(std_heap);
363
364     /* Traverse the stack from the initial state and re-execute the transitions */
365     for (item = xbt_fifo_get_last_item(stack);
366          item != xbt_fifo_get_first_item(stack);
367          item = xbt_fifo_get_prev_item(item)) {
368
369       pair = (mc_pair_t) xbt_fifo_get_item_content(item);
370
371       state = (mc_state_t) pair->graph_state;
372
373       if (pair->exploration_started) {
374
375         saved_req = MC_state_get_executed_request(state, &value);
376
377         if (saved_req != NULL) {
378           /* because we got a copy of the executed request, we have to fetch the
379              real one, pointed by the request field of the issuer process */
380           const smx_process_t issuer = MC_smx_simcall_get_issuer(saved_req);
381           req = &issuer->simcall;
382
383           /* Debug information */
384           if (XBT_LOG_ISENABLED(mc_global, xbt_log_priority_debug)) {
385             req_str = MC_request_to_string(req, value, MC_REQUEST_SIMIX);
386             XBT_DEBUG("Replay (depth = %d) : %s (%p)", depth, req_str, state);
387             xbt_free(req_str);
388           }
389
390         }
391
392         MC_simcall_handle(req, value);
393         MC_wait_for_requests();
394       }
395
396       /* Update statistics */
397       mc_stats->visited_pairs++;
398       mc_stats->executed_transitions++;
399
400       depth++;
401       
402     }
403
404   XBT_DEBUG("**** End Replay ****");
405
406   if (initial_global_state->raw_mem_set)
407     mmalloc_set_current_heap(mc_heap);
408   else
409     mmalloc_set_current_heap(std_heap);
410
411 }
412
413 /**
414  * \brief Dumps the contents of a model-checker's stack and shows the actual
415  *        execution trace
416  * \param stack The stack to dump
417  */
418 void MC_dump_stack_safety(xbt_fifo_t stack)
419 {
420   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
421
422   MC_show_stack_safety(stack);
423   
424   mc_state_t state;
425   
426   mmalloc_set_current_heap(mc_heap);
427   while ((state = (mc_state_t) xbt_fifo_pop(stack)) != NULL)
428     MC_state_delete(state, !state->in_visited_states ? 1 : 0);
429   mmalloc_set_current_heap(heap);
430 }
431
432
433 void MC_show_stack_safety(xbt_fifo_t stack)
434 {
435   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
436
437   int value;
438   mc_state_t state;
439   xbt_fifo_item_t item;
440   smx_simcall_t req;
441   char *req_str = NULL;
442
443   for (item = xbt_fifo_get_last_item(stack);
444        (item ? (state = (mc_state_t) (xbt_fifo_get_item_content(item)))
445         : (NULL)); item = xbt_fifo_get_prev_item(item)) {
446     req = MC_state_get_executed_request(state, &value);
447     if (req) {
448       req_str = MC_request_to_string(req, value, MC_REQUEST_EXECUTED);
449       XBT_INFO("%s", req_str);
450       xbt_free(req_str);
451     }
452   }
453
454   mmalloc_set_current_heap(heap);
455 }
456
457 void MC_show_deadlock(smx_simcall_t req)
458 {
459   /*char *req_str = NULL; */
460   XBT_INFO("**************************");
461   XBT_INFO("*** DEAD-LOCK DETECTED ***");
462   XBT_INFO("**************************");
463   XBT_INFO("Locked request:");
464   /*req_str = MC_request_to_string(req);
465      XBT_INFO("%s", req_str);
466      xbt_free(req_str); */
467   XBT_INFO("Counter-example execution trace:");
468   MC_dump_stack_safety(mc_stack);
469   MC_print_statistics(mc_stats);
470 }
471
472 void MC_show_non_termination(void){
473   XBT_INFO("******************************************");
474   XBT_INFO("*** NON-PROGRESSIVE CYCLE DETECTED ***");
475   XBT_INFO("******************************************");
476   XBT_INFO("Counter-example execution trace:");
477   MC_dump_stack_safety(mc_stack);
478   MC_print_statistics(mc_stats);
479 }
480
481
482 void MC_show_stack_liveness(xbt_fifo_t stack)
483 {
484   int value;
485   mc_pair_t pair;
486   xbt_fifo_item_t item;
487   smx_simcall_t req;
488   char *req_str = NULL;
489
490   for (item = xbt_fifo_get_last_item(stack);
491        (item ? (pair = (mc_pair_t) (xbt_fifo_get_item_content(item))) : (NULL));
492        item = xbt_fifo_get_prev_item(item)) {
493     req = MC_state_get_executed_request(pair->graph_state, &value);
494     if (req && req->call != SIMCALL_NONE) {
495       req_str = MC_request_to_string(req, value, MC_REQUEST_EXECUTED);
496       XBT_INFO("%s", req_str);
497       xbt_free(req_str);
498     }
499   }
500 }
501
502
503 void MC_dump_stack_liveness(xbt_fifo_t stack)
504 {
505   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
506   mc_pair_t pair;
507   while ((pair = (mc_pair_t) xbt_fifo_pop(stack)) != NULL)
508     MC_pair_delete(pair);
509   mmalloc_set_current_heap(heap);
510 }
511
512 void MC_print_statistics(mc_stats_t stats)
513 {
514   if(_sg_mc_comms_determinism) {
515     if (!initial_global_state->recv_deterministic && initial_global_state->send_deterministic){
516       XBT_INFO("******************************************************");
517       XBT_INFO("**** Only-send-deterministic communication pattern ****");
518       XBT_INFO("******************************************************");
519       XBT_INFO("%s", initial_global_state->recv_diff);
520     }else if(!initial_global_state->send_deterministic && initial_global_state->recv_deterministic) {
521       XBT_INFO("******************************************************");
522       XBT_INFO("**** Only-recv-deterministic communication pattern ****");
523       XBT_INFO("******************************************************");
524       XBT_INFO("%s", initial_global_state->send_diff);
525     }
526   }
527
528   if (stats->expanded_pairs == 0) {
529     XBT_INFO("Expanded states = %lu", stats->expanded_states);
530     XBT_INFO("Visited states = %lu", stats->visited_states);
531   } else {
532     XBT_INFO("Expanded pairs = %lu", stats->expanded_pairs);
533     XBT_INFO("Visited pairs = %lu", stats->visited_pairs);
534   }
535   XBT_INFO("Executed transitions = %lu", stats->executed_transitions);
536   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
537   if ((_sg_mc_dot_output_file != NULL) && (_sg_mc_dot_output_file[0] != '\0')) {
538     fprintf(dot_output, "}\n");
539     fclose(dot_output);
540   }
541   if (initial_global_state != NULL && (_sg_mc_comms_determinism || _sg_mc_send_determinism)) {
542     XBT_INFO("Send-deterministic : %s", !initial_global_state->send_deterministic ? "No" : "Yes");
543     if (_sg_mc_comms_determinism)
544       XBT_INFO("Recv-deterministic : %s", !initial_global_state->recv_deterministic ? "No" : "Yes");
545   }
546   mmalloc_set_current_heap(heap);
547 }
548
549 void MC_automaton_load(const char *file)
550 {
551   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
552
553   if (_mc_property_automaton == NULL)
554     _mc_property_automaton = xbt_automaton_new();
555
556   xbt_automaton_load(_mc_property_automaton, file);
557   mmalloc_set_current_heap(heap);
558 }
559
560 static void register_symbol(xbt_automaton_propositional_symbol_t symbol)
561 {
562   if (mc_mode != MC_MODE_CLIENT)
563     return;
564   s_mc_register_symbol_message_t message;
565   message.type = MC_MESSAGE_REGISTER_SYMBOL;
566   const char* name = xbt_automaton_propositional_symbol_get_name(symbol);
567   if (strlen(name) + 1 > sizeof(message.name))
568     xbt_die("Symbol is too long");
569   strncpy(message.name, name, sizeof(message.name));
570   message.callback = xbt_automaton_propositional_symbol_get_callback(symbol);
571   message.data = xbt_automaton_propositional_symbol_get_data(symbol);
572   MC_client_send_message(&message, sizeof(message));
573 }
574
575 void MC_automaton_new_propositional_symbol(const char *id, int(*fct)(void))
576 {
577   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
578
579   if (_mc_property_automaton == NULL)
580     _mc_property_automaton = xbt_automaton_new();
581
582   xbt_automaton_propositional_symbol_t symbol = xbt_automaton_propositional_symbol_new(_mc_property_automaton, id, fct);
583   register_symbol(symbol);
584   mmalloc_set_current_heap(heap);
585 }
586
587 void MC_automaton_new_propositional_symbol_pointer(const char *id, int* value)
588 {
589   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
590   if (_mc_property_automaton == NULL)
591     _mc_property_automaton = xbt_automaton_new();
592   xbt_automaton_propositional_symbol_t symbol = xbt_automaton_propositional_symbol_new_pointer(_mc_property_automaton, id, value);
593   register_symbol(symbol);
594   mmalloc_set_current_heap(heap);
595 }
596
597 void MC_automaton_new_propositional_symbol_callback(const char* id,
598   xbt_automaton_propositional_symbol_callback_type callback,
599   void* data, xbt_automaton_propositional_symbol_free_function_type free_function)
600 {
601   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
602   if (_mc_property_automaton == NULL)
603     _mc_property_automaton = xbt_automaton_new();
604   xbt_automaton_propositional_symbol_t symbol = xbt_automaton_propositional_symbol_new_callback(
605     _mc_property_automaton, id, callback, data, free_function);
606   register_symbol(symbol);
607   mmalloc_set_current_heap(heap);
608 }
609
610 // TODO, fix cross-process access (this function is not used)
611 void MC_dump_stacks(FILE* file)
612 {
613   xbt_mheap_t heap = mmalloc_set_current_heap(mc_heap);
614
615   int nstack = 0;
616   stack_region_t current_stack;
617   unsigned cursor;
618   xbt_dynar_foreach(stacks_areas, cursor, current_stack) {
619     unw_context_t * context = (unw_context_t *)current_stack->context;
620     fprintf(file, "Stack %i:\n", nstack);
621
622     int nframe = 0;
623     char buffer[100];
624     unw_cursor_t c;
625     unw_init_local (&c, context);
626     unw_word_t off;
627     do {
628       const char * name = !unw_get_proc_name(&c, buffer, 100, &off) ? buffer : "?";
629 #if defined(__x86_64__)
630       unw_word_t rip = 0;
631       unw_word_t rsp = 0;
632       unw_get_reg(&c, UNW_X86_64_RIP, &rip);
633       unw_get_reg(&c, UNW_X86_64_RSP, &rsp);
634       fprintf(file, "  %i: %s (RIP=0x%" PRIx64 " RSP=0x%" PRIx64 ")\n",
635         nframe, name, rip, rsp);
636 #else
637       fprintf(file, "  %i: %s\n", nframe, name);
638 #endif
639       ++nframe;
640     } while(unw_step(&c));
641
642     ++nstack;
643   }
644   mmalloc_set_current_heap(heap);
645 }
646 #endif
647
648 double MC_process_clock_get(smx_process_t process)
649 {
650   if (mc_time) {
651     if (process != NULL)
652       return mc_time[process->pid];
653     else
654       return -1;
655   } else {
656     return 0;
657   }
658 }
659
660 void MC_process_clock_add(smx_process_t process, double amount)
661 {
662   mc_time[process->pid] += amount;
663 }
664
665 #ifdef HAVE_MC
666 void MC_report_assertion_error(void)
667 {
668   XBT_INFO("**************************");
669   XBT_INFO("*** PROPERTY NOT VALID ***");
670   XBT_INFO("**************************");
671   XBT_INFO("Counter-example execution trace:");
672   MC_record_dump_path(mc_stack);
673   MC_dump_stack_safety(mc_stack);
674   MC_print_statistics(mc_stats);
675 }
676
677 void MC_invalidate_cache(void)
678 {
679   if (mc_model_checker)
680     mc_model_checker->process().cache_flags = 0;
681 }
682 #endif
683
684 }