Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Give the real type of mc_heap/std_heap (xbt_mheap_t, not void*)
[simgrid.git] / src / mc / mc_checkpoint.c
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 #define _GNU_SOURCE
8 #define UNW_LOCAL_ONLY
9
10
11 #include <string.h>
12 #include <link.h>
13
14 #include "internal_config.h"
15 #include "mc_private.h"
16 #include "xbt/module.h"
17 #include <xbt/mmalloc.h>
18 #include "../smpi/private.h"
19 #include <alloca.h>
20
21 #include "xbt/mmalloc/mmprivate.h"
22
23 #include "../simix/smx_private.h"
24
25 #include <libunwind.h>
26 #include <libelf.h>
27
28 #include "mc_private.h"
29 #include <mc/mc.h>
30
31 #include "mc_mmu.h"
32
33 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
34                                 "Logging specific to mc_checkpoint");
35
36 char *libsimgrid_path;
37
38 /************************************  Free functions **************************************/
39 /*****************************************************************************************/
40
41 static void MC_snapshot_stack_free(mc_snapshot_stack_t s)
42 {
43   if (s) {
44     xbt_dynar_free(&(s->local_variables));
45     xbt_dynar_free(&(s->stack_frames));
46     xbt_free(s);
47   }
48 }
49
50 static void MC_snapshot_stack_free_voidp(void *s)
51 {
52   MC_snapshot_stack_free((mc_snapshot_stack_t) * (void **) s);
53 }
54
55 static void local_variable_free(local_variable_t v)
56 {
57   xbt_free(v->name);
58   xbt_free(v);
59 }
60
61 static void local_variable_free_voidp(void *v)
62 {
63   local_variable_free((local_variable_t) * (void **) v);
64 }
65
66 void MC_region_destroy(mc_mem_region_t reg)
67 {
68   if (!reg)
69     return;
70
71   //munmap(reg->data, reg->size);
72   xbt_free(reg->data);
73   if (reg->page_numbers) {
74     mc_free_page_snapshot_region(reg->page_numbers, mc_page_count(reg->size));
75   }
76   xbt_free(reg);
77 }
78
79 void MC_free_snapshot(mc_snapshot_t snapshot)
80 {
81   unsigned int i;
82   for (i = 0; i < NB_REGIONS; i++) {
83     MC_region_destroy(snapshot->regions[i]);
84   }
85
86   xbt_free(snapshot->stack_sizes);
87   xbt_dynar_free(&(snapshot->stacks));
88   xbt_dynar_free(&(snapshot->to_ignore));
89   xbt_dynar_free(&snapshot->ignored_data);
90
91   if (snapshot->privatization_regions) {
92     size_t n = xbt_dynar_length(snapshot->enabled_processes);
93     for (i = 0; i != n; ++i) {
94       MC_region_destroy(snapshot->privatization_regions[i]);
95     }
96     xbt_free(snapshot->privatization_regions);
97   }
98
99   xbt_free(snapshot);
100 }
101
102 /*******************************  Snapshot regions ********************************/
103 /*********************************************************************************/
104
105   static mc_mem_region_t mc_region_new_dense(int type, void *start_addr, void* permanent_addr, size_t size, mc_mem_region_t ref_reg)
106 {
107   mc_mem_region_t new_reg = xbt_new(s_mc_mem_region_t, 1);
108   new_reg->start_addr = start_addr;
109   new_reg->permanent_addr = permanent_addr;
110   new_reg->data = NULL;
111   new_reg->size = size;
112   new_reg->page_numbers = NULL;
113   new_reg->data = xbt_malloc(size);
114   memcpy(new_reg->data, permanent_addr, size);
115   XBT_DEBUG("New region : type : %d, data : %p (real addr %p), size : %zu",
116             type, new_reg->data, permanent_addr, size);
117   return new_reg;
118
119 }
120
121 /** @brief Take a snapshot of a given region
122  *
123  * @param type
124  * @param start_addr   Address of the region in the simulated process
125  * @param permanent_addr Permanent address of this data (for privatized variables, this is the virtual address of the privatized mapping)
126  * @param size         Size of the data*
127  * @param ref_reg      Reference corresponding region
128  */
129 static mc_mem_region_t MC_region_new(int type, void *start_addr, void* permanent_addr, size_t size, mc_mem_region_t ref_reg)
130 {
131   if (_sg_mc_sparse_checkpoint) {
132     return mc_region_new_sparse(type, start_addr, permanent_addr, size, ref_reg);
133   } else  {
134     return mc_region_new_dense(type, start_addr, permanent_addr, size, ref_reg);
135   }
136 }
137
138 /** @brief Restore a region from a snapshot
139  *
140  *  If we are using per page snapshots, it is possible to use the reference
141  *  region in order to do an incremental restoration of the region: the
142  *  softclean pages which are shared between the two snapshots do not need
143  *  to be restored.
144  *
145  *  @param reg     Target region
146  *  @param reg_reg Current region (if not NULL), used for lazy per page restoration
147  */
148 static void MC_region_restore(mc_mem_region_t reg, mc_mem_region_t ref_reg)
149 {
150   /*FIXME: check if start_addr is still mapped, if it is not, then map it
151     before copying the data */
152   if (!reg->page_numbers) {
153     memcpy(reg->permanent_addr, reg->data, reg->size);
154   } else {
155     mc_region_restore_sparse(reg, ref_reg);
156   }
157   return;
158 }
159
160 static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type,
161                                    void *start_addr, void* permanent_addr, size_t size)
162
163 {
164   mc_mem_region_t ref_reg =
165     mc_model_checker->parent_snapshot ? mc_model_checker->parent_snapshot->regions[type] : NULL;
166   mc_mem_region_t new_reg = MC_region_new(type, start_addr, permanent_addr, size, ref_reg);
167   snapshot->regions[type] = new_reg;
168   return;
169 }
170
171 static void MC_get_memory_regions(mc_snapshot_t snapshot)
172 {
173
174   void *start_heap = std_heap->base;
175   void *end_heap = std_heap->breakval;
176   MC_snapshot_add_region(snapshot, 0, start_heap, start_heap,
177                          (char *) end_heap - (char *) start_heap);
178   snapshot->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
179   snapshot->privatization_regions = NULL;
180
181   MC_snapshot_add_region(snapshot, 1,
182       mc_libsimgrid_info->start_rw, mc_libsimgrid_info->start_rw,
183       mc_libsimgrid_info->end_rw - mc_libsimgrid_info->start_rw);
184
185 #ifdef HAVE_SMPI
186   size_t i;
187   if (smpi_privatize_global_variables && smpi_process_count()) {
188     // Snapshot the global variable of the application separately for each
189     // simulated process:
190     snapshot->privatization_regions =
191       xbt_new(mc_mem_region_t, smpi_process_count());
192     for (i = 0; i < smpi_process_count(); i++) {
193       mc_mem_region_t ref_reg =
194         mc_model_checker->parent_snapshot ? mc_model_checker->parent_snapshot->privatization_regions[i] : NULL;
195       snapshot->privatization_regions[i] =
196         MC_region_new(-1, mc_binary_info->start_rw, smpi_privatisation_regions[i].address, size_data_exe, ref_reg);
197     }
198     snapshot->privatization_index = smpi_loaded_page;
199     snapshot->regions[2] = NULL;
200   } else
201 #endif
202   {
203     MC_snapshot_add_region(snapshot, 2,
204                            mc_binary_info->start_rw, mc_binary_info->start_rw,
205                            mc_binary_info->end_rw - mc_binary_info->start_rw);
206     snapshot->privatization_regions = NULL;
207     snapshot->privatization_index = -1;
208   }
209 }
210
211 /** @brief Finds the range of the different memory segments and binary paths */
212 void MC_init_memory_map_info()
213 {
214
215   unsigned int i = 0;
216   s_map_region_t reg;
217   memory_map_t maps = MC_get_memory_map();
218
219   maestro_stack_start = NULL;
220   maestro_stack_end = NULL;
221   libsimgrid_path = NULL;
222
223   while (i < maps->mapsize) {
224     reg = maps->regions[i];
225     if (maps->regions[i].pathname == NULL) {
226       // Nothing to do
227     } else if ((reg.prot & PROT_WRITE)
228                && !memcmp(maps->regions[i].pathname, "[stack]", 7)) {
229       maestro_stack_start = reg.start_addr;
230       maestro_stack_end = reg.end_addr;
231     } else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)
232                && !memcmp(basename(maps->regions[i].pathname), "libsimgrid",
233                           10)) {
234       if (libsimgrid_path == NULL)
235         libsimgrid_path = strdup(maps->regions[i].pathname);
236     }
237     i++;
238   }
239
240   xbt_assert(maestro_stack_start, "maestro_stack_start");
241   xbt_assert(maestro_stack_end, "maestro_stack_end");
242   xbt_assert(libsimgrid_path, "libsimgrid_path&");
243
244   MC_free_memory_map(maps);
245
246 }
247
248 /** \brief Fill/lookup the "subtype" field.
249  */
250 static void MC_resolve_subtype(mc_object_info_t info, dw_type_t type)
251 {
252
253   if (type->dw_type_id == NULL)
254     return;
255   type->subtype = xbt_dict_get_or_null(info->types, type->dw_type_id);
256   if (type->subtype == NULL)
257     return;
258   if (type->subtype->byte_size != 0)
259     return;
260   if (type->subtype->name == NULL)
261     return;
262   // Try to find a more complete description of the type:
263   // We need to fix in order to support C++.
264
265   dw_type_t subtype =
266       xbt_dict_get_or_null(info->full_types_by_name, type->subtype->name);
267   if (subtype != NULL) {
268     type->subtype = subtype;
269   }
270
271 }
272
273 void MC_post_process_types(mc_object_info_t info)
274 {
275   xbt_dict_cursor_t cursor = NULL;
276   char *origin;
277   dw_type_t type;
278
279   // Lookup "subtype" field:
280   xbt_dict_foreach(info->types, cursor, origin, type) {
281     MC_resolve_subtype(info, type);
282
283     dw_type_t member;
284     unsigned int i = 0;
285     if (type->members != NULL)
286       xbt_dynar_foreach(type->members, i, member) {
287       MC_resolve_subtype(info, member);
288       }
289   }
290 }
291
292 /** \brief Fills the position of the segments (executable, read-only, read/write).
293  *
294  * TODO, use dl_iterate_phdr to be more robust
295  * */
296 void MC_find_object_address(memory_map_t maps, mc_object_info_t result)
297 {
298
299   unsigned int i = 0;
300   s_map_region_t reg;
301   const char *name = basename(result->file_name);
302   while (i < maps->mapsize) {
303     reg = maps->regions[i];
304     if (maps->regions[i].pathname == NULL
305         || strcmp(basename(maps->regions[i].pathname), name)) {
306       // Nothing to do
307     } else if ((reg.prot & PROT_WRITE)) {
308       xbt_assert(!result->start_rw,
309                  "Multiple read-write segments for %s, not supported",
310                  maps->regions[i].pathname);
311       result->start_rw = reg.start_addr;
312       result->end_rw = reg.end_addr;
313       // .bss is usually after the .data:
314       s_map_region_t *next = &(maps->regions[i + 1]);
315       if (next->pathname == NULL && (next->prot & PROT_WRITE)
316           && next->start_addr == reg.end_addr) {
317         result->end_rw = maps->regions[i + 1].end_addr;
318       }
319     } else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC)) {
320       xbt_assert(!result->start_exec,
321                  "Multiple executable segments for %s, not supported",
322                  maps->regions[i].pathname);
323       result->start_exec = reg.start_addr;
324       result->end_exec = reg.end_addr;
325     } else if ((reg.prot & PROT_READ) && !(reg.prot & PROT_EXEC)) {
326       xbt_assert(!result->start_ro,
327                  "Multiple read only segments for %s, not supported",
328                  maps->regions[i].pathname);
329       result->start_ro = reg.start_addr;
330       result->end_ro = reg.end_addr;
331     }
332     i++;
333   }
334
335   xbt_assert(result->file_name);
336   xbt_assert(result->start_rw);
337   xbt_assert(result->start_exec);
338 }
339
340 /************************************* Take Snapshot ************************************/
341 /****************************************************************************************/
342
343 /** \brief Checks whether the variable is in scope for a given IP.
344  *
345  *  A variable may be defined only from a given value of IP.
346  *
347  *  \param var   Variable description
348  *  \param frame Scope description
349  *  \param ip    Instruction pointer
350  *  \return      true if the variable is valid
351  * */
352 static bool mc_valid_variable(dw_variable_t var, dw_frame_t scope,
353                               const void *ip)
354 {
355   // The variable is not yet valid:
356   if ((const void *) ((const char *) scope->low_pc + var->start_scope) > ip)
357     return false;
358   else
359     return true;
360 }
361
362 static void mc_fill_local_variables_values(mc_stack_frame_t stack_frame,
363                                            dw_frame_t scope, int process_index, xbt_dynar_t result)
364 {
365   void *ip = (void *) stack_frame->ip;
366   if (ip < scope->low_pc || ip >= scope->high_pc)
367     return;
368
369   unsigned cursor = 0;
370   dw_variable_t current_variable;
371   xbt_dynar_foreach(scope->variables, cursor, current_variable) {
372
373     if (!mc_valid_variable(current_variable, scope, (void *) stack_frame->ip))
374       continue;
375
376     int region_type;
377     if ((long) stack_frame->ip > (long) mc_libsimgrid_info->start_exec)
378       region_type = 1;
379     else
380       region_type = 2;
381
382     local_variable_t new_var = xbt_new0(s_local_variable_t, 1);
383     new_var->subprogram = stack_frame->frame;
384     new_var->ip = stack_frame->ip;
385     new_var->name = xbt_strdup(current_variable->name);
386     new_var->type = current_variable->type;
387     new_var->region = region_type;
388
389     if (current_variable->address != NULL) {
390       new_var->address = current_variable->address;
391     } else if (current_variable->locations.size != 0) {
392       new_var->address =
393           (void *) mc_dwarf_resolve_locations(&current_variable->locations,
394                                               current_variable->object_info,
395                                               &(stack_frame->unw_cursor),
396                                               (void *) stack_frame->frame_base,
397                                               NULL, process_index);
398     } else {
399       xbt_die("No address");
400     }
401
402     xbt_dynar_push(result, &new_var);
403   }
404
405   // Recursive processing of nested scopes:
406   dw_frame_t nested_scope = NULL;
407   xbt_dynar_foreach(scope->scopes, cursor, nested_scope) {
408     mc_fill_local_variables_values(stack_frame, nested_scope, process_index, result);
409   }
410 }
411
412 static xbt_dynar_t MC_get_local_variables_values(xbt_dynar_t stack_frames, int process_index)
413 {
414
415   unsigned cursor1 = 0;
416   mc_stack_frame_t stack_frame;
417   xbt_dynar_t variables =
418       xbt_dynar_new(sizeof(local_variable_t), local_variable_free_voidp);
419
420   xbt_dynar_foreach(stack_frames, cursor1, stack_frame) {
421     mc_fill_local_variables_values(stack_frame, stack_frame->frame, process_index, variables);
422   }
423
424   return variables;
425 }
426
427 static void MC_stack_frame_free_voipd(void *s)
428 {
429   mc_stack_frame_t stack_frame = *(mc_stack_frame_t *) s;
430   if (stack_frame) {
431     xbt_free(stack_frame->frame_name);
432     xbt_free(stack_frame);
433   }
434 }
435
436 static xbt_dynar_t MC_unwind_stack_frames(void *stack_context)
437 {
438   xbt_dynar_t result =
439       xbt_dynar_new(sizeof(mc_stack_frame_t), MC_stack_frame_free_voipd);
440
441   unw_cursor_t c;
442
443   // TODO, check condition check (unw_init_local==0 means end of frame)
444   if (unw_init_local(&c, (unw_context_t *) stack_context) != 0) {
445
446     xbt_die("Could not initialize stack unwinding");
447
448   } else
449     while (1) {
450
451       mc_stack_frame_t stack_frame = xbt_new(s_mc_stack_frame_t, 1);
452       xbt_dynar_push(result, &stack_frame);
453
454       stack_frame->unw_cursor = c;
455
456       unw_word_t ip, sp;
457
458       unw_get_reg(&c, UNW_REG_IP, &ip);
459       unw_get_reg(&c, UNW_REG_SP, &sp);
460
461       stack_frame->ip = ip;
462       stack_frame->sp = sp;
463
464       // TODO, use real addresses in frame_t instead of fixing it here
465
466       dw_frame_t frame = MC_find_function_by_ip((void *) ip);
467       stack_frame->frame = frame;
468
469       if (frame) {
470         stack_frame->frame_name = xbt_strdup(frame->name);
471         stack_frame->frame_base =
472             (unw_word_t) mc_find_frame_base(frame, frame->object_info, &c);
473       } else {
474         stack_frame->frame_base = 0;
475         stack_frame->frame_name = NULL;
476       }
477
478       /* Stop before context switch with maestro */
479       if (frame != NULL && frame->name != NULL
480           && !strcmp(frame->name, "smx_ctx_sysv_wrapper"))
481         break;
482
483       int ret = ret = unw_step(&c);
484       if (ret == 0) {
485         xbt_die("Unexpected end of stack.");
486       } else if (ret < 0) {
487         xbt_die("Error while unwinding stack.");
488       }
489     }
490
491   if (xbt_dynar_length(result) == 0) {
492     XBT_INFO("unw_init_local failed");
493     xbt_abort();
494   }
495
496   return result;
497 };
498
499 static xbt_dynar_t MC_take_snapshot_stacks(mc_snapshot_t * snapshot)
500 {
501
502   xbt_dynar_t res =
503       xbt_dynar_new(sizeof(s_mc_snapshot_stack_t),
504                     MC_snapshot_stack_free_voidp);
505
506   unsigned int cursor = 0;
507   stack_region_t current_stack;
508
509   xbt_dynar_foreach(stacks_areas, cursor, current_stack) {
510     mc_snapshot_stack_t st = xbt_new(s_mc_snapshot_stack_t, 1);
511     st->stack_frames = MC_unwind_stack_frames(current_stack->context);
512     st->local_variables = MC_get_local_variables_values(st->stack_frames, current_stack->process_index);
513     st->process_index = current_stack->process_index;
514
515     unw_word_t sp = xbt_dynar_get_as(st->stack_frames, 0, mc_stack_frame_t)->sp;
516
517     xbt_dynar_push(res, &st);
518     (*snapshot)->stack_sizes =
519         xbt_realloc((*snapshot)->stack_sizes, (cursor + 1) * sizeof(size_t));
520     (*snapshot)->stack_sizes[cursor] =
521       (char*) current_stack->address + current_stack->size - (char*) sp;
522   }
523
524   return res;
525
526 }
527
528 static xbt_dynar_t MC_take_snapshot_ignore()
529 {
530
531   if (mc_heap_comparison_ignore == NULL)
532     return NULL;
533
534   xbt_dynar_t cpy =
535       xbt_dynar_new(sizeof(mc_heap_ignore_region_t),
536                     heap_ignore_region_free_voidp);
537
538   unsigned int cursor = 0;
539   mc_heap_ignore_region_t current_region;
540
541   xbt_dynar_foreach(mc_heap_comparison_ignore, cursor, current_region) {
542     mc_heap_ignore_region_t new_region = NULL;
543     new_region = xbt_new0(s_mc_heap_ignore_region_t, 1);
544     new_region->address = current_region->address;
545     new_region->size = current_region->size;
546     new_region->block = current_region->block;
547     new_region->fragment = current_region->fragment;
548     xbt_dynar_push(cpy, &new_region);
549   }
550
551   return cpy;
552
553 }
554
555 static void mc_free_snapshot_ignored_data_pvoid(void* data) {
556   mc_snapshot_ignored_data_t ignored_data = (mc_snapshot_ignored_data_t) data;
557   free(ignored_data->data);
558 }
559
560 static void MC_snapshot_handle_ignore(mc_snapshot_t snapshot)
561 {
562   snapshot->ignored_data = xbt_dynar_new(sizeof(s_mc_snapshot_ignored_data_t), mc_free_snapshot_ignored_data_pvoid);
563
564   // Copy the memory:
565   unsigned int cursor = 0;
566   mc_checkpoint_ignore_region_t region;
567   xbt_dynar_foreach (mc_checkpoint_ignore, cursor, region) {
568     s_mc_snapshot_ignored_data_t ignored_data;
569     ignored_data.start = region->addr;
570     ignored_data.size = region->size;
571     ignored_data.data = malloc(region->size);
572     memcpy(ignored_data.data, region->addr, region->size);
573     xbt_dynar_push(snapshot->ignored_data, &ignored_data);
574   }
575
576   // Zero the memory:
577   xbt_dynar_foreach (mc_checkpoint_ignore, cursor, region) {
578     memset(region->addr, 0, region->size);
579   }
580
581 }
582
583 static void MC_snapshot_ignore_restore(mc_snapshot_t snapshot)
584 {
585   unsigned int cursor = 0;
586   s_mc_snapshot_ignored_data_t ignored_data;
587   xbt_dynar_foreach (snapshot->ignored_data, cursor, ignored_data) {
588     memcpy(ignored_data.start, ignored_data.data, ignored_data.size);
589   }
590 }
591
592 /** @brief Can we remove this snapshot?
593  *
594  * Some snapshots cannot be removed (yet) because we need them
595  * at this point.
596  *
597  * @param snapshot
598  */
599 int mc_important_snapshot(mc_snapshot_t snapshot)
600 {
601   // We need this snapshot in order to know which
602   // pages needs to be stored in the next snapshot:
603   if (snapshot == mc_model_checker->parent_snapshot)
604     return true;
605
606   return false;
607 }
608
609 mc_snapshot_t MC_take_snapshot(int num_state)
610 {
611
612   mc_snapshot_t snapshot = xbt_new0(s_mc_snapshot_t, 1);
613   snapshot->enabled_processes = xbt_dynar_new(sizeof(int), NULL);
614   smx_process_t process;
615   xbt_swag_foreach(process, simix_global->process_list) {
616     xbt_dynar_push_as(snapshot->enabled_processes, int, (int)process->pid);
617   }
618
619   MC_snapshot_handle_ignore(snapshot);
620
621   /* Save the std heap and the writable mapped pages of libsimgrid and binary */
622   MC_get_memory_regions(snapshot);
623   if (_sg_mc_sparse_checkpoint && _sg_mc_soft_dirty) {
624     mc_softdirty_reset();
625   }
626
627   snapshot->to_ignore = MC_take_snapshot_ignore();
628
629   if (_sg_mc_visited > 0 || strcmp(_sg_mc_property_file, "")) {
630     snapshot->stacks =
631         MC_take_snapshot_stacks(&snapshot);
632     if (_sg_mc_hash && snapshot->stacks != NULL) {
633       snapshot->hash = mc_hash_processes_state(num_state, snapshot->stacks);
634     } else {
635       snapshot->hash = 0;
636     }
637   } else {
638     snapshot->hash = 0;
639   }
640
641   MC_snapshot_ignore_restore(snapshot);
642   if (_sg_mc_sparse_checkpoint && _sg_mc_soft_dirty) {
643     mc_model_checker->parent_snapshot = snapshot;
644   }
645   return snapshot;
646 }
647
648 void MC_restore_snapshot(mc_snapshot_t snapshot)
649 {
650   mc_snapshot_t parent_snapshot = mc_model_checker->parent_snapshot;
651
652   unsigned int i;
653   for (i = 0; i < NB_REGIONS; i++) {
654     // For privatized, variables we decided it was not necessary to take the snapshot:
655     if (snapshot->regions[i])
656       MC_region_restore(snapshot->regions[i],
657         parent_snapshot ? parent_snapshot->regions[i] : NULL);
658   }
659
660 #ifdef HAVE_SMPI
661   if (snapshot->privatization_regions) {
662     // Restore the global variables of the application separately for each
663     // simulated process:
664     for (i = 0; i < smpi_process_count(); i++) {
665       if (snapshot->privatization_regions[i]) {
666         MC_region_restore(snapshot->privatization_regions[i],
667           parent_snapshot ? parent_snapshot->privatization_regions[i] : NULL);
668       }
669     }
670   }
671   if(snapshot->privatization_index >= 0) {
672     smpi_switch_data_segment(snapshot->privatization_index);
673   }
674 #endif
675
676   if (_sg_mc_sparse_checkpoint && _sg_mc_soft_dirty) {
677     mc_softdirty_reset();
678   }
679
680   MC_snapshot_ignore_restore(snapshot);
681   if (_sg_mc_sparse_checkpoint && _sg_mc_soft_dirty) {
682     mc_model_checker->parent_snapshot = snapshot;
683   }
684 }
685
686 mc_snapshot_t SIMIX_pre_mc_snapshot(smx_simcall_t simcall)
687 {
688   return MC_take_snapshot(1);
689 }
690
691 void *MC_snapshot(void)
692 {
693   return simcall_mc_snapshot();
694 }