1 /* Copyright (c) 2008-2013. The SimGrid Team.
2 * All rights reserved. */
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. */
8 #include "mc_private.h"
9 #include "xbt/module.h"
11 #include "../simix/smx_private.h"
13 #include <libunwind.h>
15 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
16 "Logging specific to mc_checkpoint");
18 void *start_text_libsimgrid;
19 void *start_plt_libsimgrid, *end_plt_libsimgrid;
20 void *start_got_plt_libsimgrid, *end_got_plt_libsimgrid;
21 void *start_plt_binary, *end_plt_binary;
22 void *start_got_plt_binary, *end_got_plt_binary;
23 char *libsimgrid_path;
25 /************************************ Free functions **************************************/
26 /*****************************************************************************************/
28 static void MC_snapshot_stack_free(mc_snapshot_stack_t s){
30 xbt_dynar_free(&(s->local_variables));
35 static void MC_snapshot_stack_free_voidp(void *s){
36 MC_snapshot_stack_free((mc_snapshot_stack_t) * (void **) s);
39 static void local_variable_free(local_variable_t v){
46 static void local_variable_free_voidp(void *v){
47 local_variable_free((local_variable_t) * (void **) v);
50 static void MC_region_destroy(mc_mem_region_t reg)
56 void MC_free_snapshot(mc_snapshot_t snapshot){
58 for(i=0; i < NB_REGIONS; i++)
59 MC_region_destroy(snapshot->regions[i]);
61 xbt_free(snapshot->stack_sizes);
62 xbt_dynar_free(&(snapshot->stacks));
63 xbt_dynar_free(&(snapshot->to_ignore));
68 /******************************* Snapshot regions ********************************/
69 /*********************************************************************************/
71 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
73 mc_mem_region_t new_reg = xbt_new0(s_mc_mem_region_t, 1);
74 new_reg->start_addr = start_addr;
76 new_reg->data = xbt_malloc0(size);
77 memcpy(new_reg->data, start_addr, size);
79 XBT_DEBUG("New region : type : %d, data : %p (real addr %p), size : %zu", type, new_reg->data, start_addr, size);
84 static void MC_region_restore(mc_mem_region_t reg)
86 /*FIXME: check if start_addr is still mapped, if it is not, then map it
87 before copying the data */
89 memcpy(reg->start_addr, reg->data, reg->size);
93 static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size)
95 mc_mem_region_t new_reg = MC_region_new(type, start_addr, size);
96 snapshot->regions[type] = new_reg;
100 static void MC_get_memory_regions(mc_snapshot_t snapshot){
107 char *lfields[6] = {0}, *tok;
108 void *start_addr, *start_addr1, *end_addr;
112 fp = fopen("/proc/self/maps", "r");
115 "Cannot open /proc/self/maps to investigate the memory map of the process. Please report this bug.");
119 while((read = xbt_getline(&line, &n, fp)) != -1){
121 /* Wipeout the new line character */
122 line[read - 1] = '\0';
124 /* Tokenize the line using spaces as delimiters and store each token */
125 lfields[0] = strtok(line, " ");
127 for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
128 lfields[i] = strtok(NULL, " ");
131 /* First get the permissions flags, need write permission */
132 if(lfields[1][1] == 'w'){
134 /* Get the start address of the map */
135 tok = strtok(lfields[0], "-");
136 start_addr = (void *)strtoul(tok, NULL, 16);
138 if(start_addr == std_heap){ /* Std_heap ? */
139 tok = strtok(NULL, "-");
140 end_addr = (void *)strtoul(tok, NULL, 16);
141 MC_snapshot_add_region(snapshot, 0, start_addr, (char*)end_addr - (char*)start_addr);
142 snapshot->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
143 }else{ /* map name == libsimgrid || binary_name ? */
144 if(lfields[5] != NULL){
145 if(!memcmp(basename(lfields[5]), "libsimgrid", 10)){
146 tok = strtok(NULL, "-");
147 end_addr = (void *)strtoul(tok, NULL, 16);
148 size = (char*)end_addr - (char*)start_addr;
149 /* BSS and data segments may be separated according to the OS */
150 if((read = xbt_getline(&line, &n, fp)) != -1){
151 line[read - 1] = '\0';
152 lfields[0] = strtok(line, " ");
153 for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
154 lfields[i] = strtok(NULL, " ");
156 if(lfields[1][1] == 'w' && lfields[5] == NULL){
157 tok = strtok(lfields[0], "-");
158 start_addr1 = (void *)strtoul(tok, NULL, 16);
159 tok = strtok(NULL, "-");
160 size += (char *)(void *)strtoul(tok, NULL, 16) - (char*)start_addr1;
163 MC_snapshot_add_region(snapshot, 1, start_addr, size);
164 }else if(!memcmp(basename(lfields[5]), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
165 tok = strtok(NULL, "-");
166 end_addr = (void *)strtoul(tok, NULL, 16);
167 size = (char*)end_addr - (char*)start_addr;
168 /* BSS and data segments may be separated according to the OS */
169 if((read = xbt_getline(&line, &n, fp)) != -1){
170 line[read - 1] = '\0';
171 lfields[0] = strtok(line, " ");
172 for (i = 1; i < 6 && lfields[i - 1] != NULL; i++) {
173 lfields[i] = strtok(NULL, " ");
175 tok = strtok(lfields[0], "-");
176 start_addr1 = (void *)strtoul(tok, NULL, 16);
177 if(lfields[1][1] == 'w'){
178 if(start_addr1 == std_heap){ /* Std_heap ? */
179 tok = strtok(NULL, "-");
180 end_addr = (void *)strtoul(tok, NULL, 16);
181 MC_snapshot_add_region(snapshot, 0, start_addr1, (char*)end_addr - (char*)start_addr1);
182 snapshot->heap_bytes_used = mmalloc_get_bytes_used(std_heap);
183 }else if(start_addr1 != raw_heap){
184 tok = strtok(NULL, "-");
185 size += (char *)(void *)strtoul(tok, NULL, 16) - (char *)start_addr1;
189 MC_snapshot_add_region(snapshot, 2, start_addr, size);
190 }else if (!memcmp(lfields[5], "[stack]", 7)){
191 maestro_stack_start = start_addr;
192 tok = strtok(NULL, "-");
193 maestro_stack_end = (void *)strtoul(tok, NULL, 16);
206 /** @brief Find the range of the different memory segments and binary paths */
207 void MC_init_memory_map_info(){
211 memory_map_t maps = MC_get_memory_map();
213 maestro_stack_start = NULL;
214 maestro_stack_end = NULL;
215 libsimgrid_path = NULL;
217 while (i < maps->mapsize) {
218 reg = maps->regions[i];
219 if (maps->regions[i].pathname == NULL) {
222 else if ((reg.prot & PROT_WRITE) && !memcmp(maps->regions[i].pathname, "[stack]", 7)){
223 maestro_stack_start = reg.start_addr;
224 maestro_stack_end = reg.end_addr;
225 }else if ((reg.prot & PROT_READ) && (reg.prot & PROT_EXEC) && !memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
226 if(libsimgrid_path == NULL)
227 libsimgrid_path = strdup(maps->regions[i].pathname);
232 xbt_assert(maestro_stack_start, "maestro_stack_start");
233 xbt_assert(maestro_stack_end, "maestro_stack_end");
234 xbt_assert(libsimgrid_path, "libsimgrid_path&");
236 MC_free_memory_map(maps);
240 mc_object_info_t MC_find_object_address(memory_map_t maps, char* name) {
241 mc_object_info_t result = MC_new_object_info();
242 result->file_name = xbt_strdup(name);
243 result->start_data = NULL;
244 result->start_text = NULL;
248 int len = strlen(basename(name));
249 while (i < maps->mapsize) {
250 reg = maps->regions[i];
251 if (maps->regions[i].pathname == NULL || memcmp(basename(maps->regions[i].pathname), basename(name), len)){
254 else if ((reg.prot & PROT_WRITE)){
255 result->start_data = reg.start_addr;
257 reg = maps->regions[i];
258 }else if (reg.prot & PROT_READ) {
259 result->start_text = reg.start_addr;
264 xbt_assert(result->file_name);
265 xbt_assert(result->start_data);
266 xbt_assert(result->start_text);
271 void MC_get_libsimgrid_plt_section(){
274 char *line = NULL; /* Temporal storage for each line that is readed */
275 ssize_t read; /* Number of bytes readed */
276 size_t n = 0; /* Amount of bytes to read by xbt_getline */
279 int i, plt_found = 0;
280 unsigned long int size, offset;
282 char *command = bprintf("LANG=C objdump --section-headers %s", libsimgrid_path);
284 fp = popen(command, "r");
287 perror("popen failed");
291 while ((read = xbt_getline(&line, &n, fp)) != -1 && plt_found != 2) {
296 /* Wipeout the new line character */
297 line[read - 1] = '\0';
299 lfields[0] = strtok(line, " ");
301 if(lfields[0] == NULL)
304 if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], libsimgrid_path, strlen(libsimgrid_path)) == 0)
307 for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
308 lfields[i] = strtok(NULL, " ");
312 if(strcmp(lfields[1], ".plt") == 0){
313 size = strtoul(lfields[2], NULL, 16);
314 offset = strtoul(lfields[5], NULL, 16);
315 start_plt_libsimgrid = (char *)start_text_libsimgrid + offset;
316 end_plt_libsimgrid = (char *)start_plt_libsimgrid + size;
318 }else if(strcmp(lfields[1], ".got.plt") == 0){
319 size = strtoul(lfields[2], NULL, 16);
320 offset = strtoul(lfields[5], NULL, 16);
321 start_got_plt_libsimgrid = (char *)start_text_libsimgrid + offset;
322 end_got_plt_libsimgrid = (char *)start_got_plt_libsimgrid + size;
336 void MC_get_binary_plt_section(){
339 char *line = NULL; /* Temporal storage for each line that is readed */
340 ssize_t read; /* Number of bytes readed */
341 size_t n = 0; /* Amount of bytes to read by xbt_getline */
344 int i, plt_found = 0;
345 unsigned long int size;
347 char *command = bprintf("LANG=C objdump --section-headers %s", xbt_binary_name);
349 fp = popen(command, "r");
352 perror("popen failed");
356 while ((read = xbt_getline(&line, &n, fp)) != -1 && plt_found != 2) {
361 /* Wipeout the new line character */
362 line[read - 1] = '\0';
364 lfields[0] = strtok(line, " ");
366 if(lfields[0] == NULL)
369 if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], basename(xbt_binary_name), strlen(xbt_binary_name)) == 0)
372 for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
373 lfields[i] = strtok(NULL, " ");
377 if(strcmp(lfields[1], ".plt") == 0){
378 size = strtoul(lfields[2], NULL, 16);
379 start_plt_binary = (void *)strtoul(lfields[3], NULL, 16);
380 end_plt_binary = (char *)start_plt_binary + size;
382 }else if(strcmp(lfields[1], ".got.plt") == 0){
383 size = strtoul(lfields[2], NULL, 16);
384 start_got_plt_binary = (char *)strtoul(lfields[3], NULL, 16);
385 end_got_plt_binary = (char *)start_got_plt_binary + size;
399 /************************************* Take Snapshot ************************************/
400 /****************************************************************************************/
402 static void MC_get_hash_global(char *snapshot_hash, void *data1, void *data2){
404 /* unsigned int cursor = 0; */
406 /* global_variable_t current_var; */
407 /* void *addr_pointed = NULL; */
408 /* void *res = NULL; */
410 /* xbt_strbuff_t clear = xbt_strbuff_new(); */
412 /* xbt_dynar_foreach(mc_global_variables, cursor, current_var){ */
413 /* if(current_var->address < start_data_libsimgrid){ /\* binary *\/ */
414 /* offset = (char *)current_var->address - (char *)start_data_binary; */
415 /* addr_pointed = *((void **)((char *)data2 + offset)); */
416 /* if(((addr_pointed >= start_plt_binary && addr_pointed <= end_plt_binary)) || ((addr_pointed >= std_heap && (char *)addr_pointed <= (char *)std_heap + STD_HEAP_SIZE ))) */
418 /* res = xbt_malloc0(current_var->size + 1); */
419 /* memset(res, 0, current_var->size + 1); */
420 /* memcpy(res, (char*)data2 + offset, current_var->size); */
421 /* }else{ /\* libsimgrid *\/ */
422 /* offset = (char *)current_var->address - (char *)start_data_libsimgrid; */
423 /* addr_pointed = *((void **)((char *)data1 + offset)); */
424 /* if((addr_pointed >= start_plt_libsimgrid && addr_pointed <= end_plt_libsimgrid) || (addr_pointed >= std_heap && (char *)addr_pointed <= (char *)std_heap + STD_HEAP_SIZE )) */
426 /* res = xbt_malloc0(current_var->size + 1); */
427 /* memset(res, 0, current_var->size + 1); */
428 /* memcpy(res, (char*)data1 + offset, current_var->size); */
430 /* if(res != NULL){ */
431 /* xbt_strbuff_append(clear, (const char*)res); */
437 /* xbt_sha(clear->data, snapshot_hash); */
439 /* xbt_strbuff_free(clear); */
443 static void MC_get_hash_local(char *snapshot_hash, xbt_dynar_t stacks){
445 /* xbt_dynar_t tokens = NULL, s_tokens = NULL; */
446 /* unsigned int cursor1 = 0, cursor2 = 0; */
447 /* mc_snapshot_stack_t current_stack; */
448 /* char *frame_name = NULL; */
451 /* xbt_strbuff_t clear = xbt_strbuff_new(); */
453 /* while(cursor1 < xbt_dynar_length(stacks)){ */
454 /* current_stack = xbt_dynar_get_as(stacks, cursor1, mc_snapshot_stack_t); */
455 /* tokens = xbt_str_split(current_stack->local_variables->data, NULL); */
457 /* while(cursor2 < xbt_dynar_length(tokens)){ */
458 /* s_tokens = xbt_str_split(xbt_dynar_get_as(tokens, cursor2, char *), "="); */
459 /* if(xbt_dynar_length(s_tokens) > 1){ */
460 /* if(strcmp(xbt_dynar_get_as(s_tokens, 0, char *), "frame_name") == 0){ */
461 /* xbt_free(frame_name); */
462 /* frame_name = xbt_strdup(xbt_dynar_get_as(s_tokens, 1, char *)); */
463 /* xbt_strbuff_append(clear, (const char*)xbt_dynar_get_as(tokens, cursor2, char *)); */
465 /* xbt_dynar_free(&s_tokens); */
468 /* addr = (void *) strtoul(xbt_dynar_get_as(s_tokens, 1, char *), NULL, 16); */
469 /* if(addr > std_heap && (char *)addr <= (char *)std_heap + STD_HEAP_SIZE){ */
471 /* xbt_dynar_free(&s_tokens); */
474 /* if(is_stack_ignore_variable(frame_name, xbt_dynar_get_as(s_tokens, 0, char *))){ */
476 /* xbt_dynar_free(&s_tokens); */
479 /* xbt_strbuff_append(clear, (const char *)xbt_dynar_get_as(tokens, cursor2, char *)); */
481 /* xbt_dynar_free(&s_tokens); */
484 /* xbt_dynar_free(&tokens); */
488 /* xbt_free(frame_name); */
490 /* xbt_sha(clear->data, snapshot_hash); */
492 /* xbt_strbuff_free(clear); */
496 static xbt_dynar_t MC_get_local_variables_values(void *stack_context){
501 char frame_name[256];
503 ret = unw_init_local(&c, (unw_context_t *)stack_context);
505 XBT_INFO("unw_init_local failed");
509 unw_word_t ip, sp, off;
512 unsigned int cursor = 0;
513 dw_variable_t current_variable;
514 dw_location_entry_t entry = NULL;
515 dw_location_t location_entry = NULL;
517 int frame_found = 0, region_type;
518 void *frame_pointer_address = NULL;
522 xbt_dynar_t variables = xbt_dynar_new(sizeof(local_variable_t), local_variable_free_voidp);
524 while(ret >= 0 && !stop){
526 unw_get_reg(&c, UNW_REG_IP, &ip);
527 unw_get_reg(&c, UNW_REG_SP, &sp);
529 unw_get_proc_name(&c, frame_name, sizeof (frame_name), &off);
531 if(!strcmp(frame_name, "smx_ctx_sysv_wrapper")) /* Stop before context switch with maestro */
534 if((long)ip > (long) mc_libsimgrid_info->start_text)
535 frame = xbt_dict_get_or_null(mc_libsimgrid_info->local_variables, frame_name);
537 frame = xbt_dict_get_or_null(mc_binary_info->local_variables, frame_name);
544 true_ip = (long)frame->low_pc + (long)off;
545 frame_pointer_address = NULL;
547 /* Get frame pointer */
548 switch(frame->frame_base->type){
551 while(cursor < xbt_dynar_length(frame->frame_base->location.loclist) && !frame_found){
552 entry = xbt_dynar_get_as(frame->frame_base->location.loclist, cursor, dw_location_entry_t);
553 if((true_ip >= entry->lowpc) && (true_ip < entry->highpc)){
555 switch(entry->location->type){
557 if(xbt_dynar_length(entry->location->location.compose) > 1){
558 frame_pointer_address = NULL; /* TODO : location list with optimizations enabled */
560 location_entry = xbt_dynar_get_as(entry->location->location.compose, 0, dw_location_t);
561 switch(location_entry->type){
563 unw_get_reg(&c, location_entry->location.reg, &res);
564 frame_pointer_address = (void*)(long)res;
566 case e_dw_bregister_op:
567 unw_get_reg(&c, location_entry->location.breg_op.reg, &res);
568 frame_pointer_address = (void*)((long)res + location_entry->location.breg_op.offset);
571 frame_pointer_address = NULL; /* FIXME : implement other cases (with optimizations enabled) */
577 frame_pointer_address = NULL; /* FIXME : implement other cases (with optimizations enabled) */
585 frame_pointer_address = NULL; /* FIXME : implement other cases (with optimizations enabled)*/
592 xbt_dynar_foreach(frame->variables, cursor, current_variable){
594 if((long)ip > (long)mc_libsimgrid_info->start_text)
599 local_variable_t new_var = xbt_new0(s_local_variable_t, 1);
600 new_var->frame = xbt_strdup(frame_name);
601 new_var->ip = (unsigned long)ip;
602 new_var->name = xbt_strdup(current_variable->name);
603 new_var->type = strdup(current_variable->type_origin);
604 new_var->region= region_type;
606 if(current_variable->address.location != NULL){
607 switch(current_variable->address.location->type){
609 if(xbt_dynar_length(current_variable->address.location->location.compose) > 1){
610 /* TODO : location list with optimizations enabled */
612 location_entry = xbt_dynar_get_as(current_variable->address.location->location.compose, 0, dw_location_t);
614 switch(location_entry->type){
616 unw_get_reg(&c, location_entry->location.reg, &res);
619 case e_dw_bregister_op:
620 unw_get_reg(&c, location_entry->location.breg_op.reg, &res);
621 value = (long)res + location_entry->location.breg_op.offset;
623 case e_dw_fbregister_op:
624 if(frame_pointer_address != NULL)
625 value = (long)((char *)frame_pointer_address + location_entry->location.fbreg_op);
630 value = 0; /* FIXME : implement other cases (with optimizations enabled)*/
635 new_var->address = (void *)value;
637 new_var->address = NULL;
645 xbt_dynar_push(variables, &new_var);
658 static void *MC_get_stack_pointer(void *stack_context, void *heap){
664 ret = unw_init_local(&c, (unw_context_t *)stack_context);
666 XBT_INFO("unw_init_local failed");
670 unw_get_reg(&c, UNW_REG_SP, &sp);
672 return ((char *)heap + (size_t)(((char *)((long)sp) - (char*)std_heap)));
676 static xbt_dynar_t MC_take_snapshot_stacks(mc_snapshot_t *snapshot, void *heap){
678 xbt_dynar_t res = xbt_dynar_new(sizeof(s_mc_snapshot_stack_t), MC_snapshot_stack_free_voidp);
680 unsigned int cursor = 0;
681 stack_region_t current_stack;
683 xbt_dynar_foreach(stacks_areas, cursor, current_stack){
684 mc_snapshot_stack_t st = xbt_new(s_mc_snapshot_stack_t, 1);
685 st->local_variables = MC_get_local_variables_values(current_stack->context);
686 st->stack_pointer = MC_get_stack_pointer(current_stack->context, heap);
687 st->real_address = current_stack->address;
688 xbt_dynar_push(res, &st);
689 (*snapshot)->stack_sizes = xbt_realloc((*snapshot)->stack_sizes, (cursor + 1) * sizeof(size_t));
690 (*snapshot)->stack_sizes[cursor] = current_stack->size - ((char *)st->stack_pointer - (char *)((char *)heap + ((char *)current_stack->address - (char *)std_heap)));
697 static xbt_dynar_t MC_take_snapshot_ignore(){
699 if(mc_heap_comparison_ignore == NULL)
702 xbt_dynar_t cpy = xbt_dynar_new(sizeof(mc_heap_ignore_region_t), heap_ignore_region_free_voidp);
704 unsigned int cursor = 0;
705 mc_heap_ignore_region_t current_region;
707 xbt_dynar_foreach(mc_heap_comparison_ignore, cursor, current_region){
708 mc_heap_ignore_region_t new_region = NULL;
709 new_region = xbt_new0(s_mc_heap_ignore_region_t, 1);
710 new_region->address = current_region->address;
711 new_region->size = current_region->size;
712 new_region->block = current_region->block;
713 new_region->fragment = current_region->fragment;
714 xbt_dynar_push(cpy, &new_region);
721 static void MC_dump_checkpoint_ignore(mc_snapshot_t snapshot){
723 unsigned int cursor = 0;
724 mc_checkpoint_ignore_region_t region;
727 xbt_dynar_foreach(mc_checkpoint_ignore, cursor, region){
728 if(region->addr > snapshot->regions[0]->start_addr && (char *)(region->addr) < (char *)snapshot->regions[0]->start_addr + STD_HEAP_SIZE){
729 offset = (char *)region->addr - (char *)snapshot->regions[0]->start_addr;
730 memset((char *)snapshot->regions[0]->data + offset, 0, region->size);
731 }else if(region->addr > snapshot->regions[2]->start_addr && (char *)(region->addr) < (char*)snapshot->regions[2]->start_addr + snapshot->regions[2]->size){
732 offset = (char *)region->addr - (char *)snapshot->regions[2]->start_addr;
733 memset((char *)snapshot->regions[2]->data + offset, 0, region->size);
734 }else if(region->addr > snapshot->regions[1]->start_addr && (char *)(region->addr) < (char*)snapshot->regions[1]->start_addr + snapshot->regions[1]->size){
735 offset = (char *)region->addr - (char *)snapshot->regions[1]->start_addr;
736 memset((char *)snapshot->regions[1]->data + offset, 0, region->size);
743 mc_snapshot_t MC_take_snapshot(int num_state){
745 mc_snapshot_t snapshot = xbt_new0(s_mc_snapshot_t, 1);
746 snapshot->nb_processes = xbt_swag_size(simix_global->process_list);
748 /* Save the std heap and the writable mapped pages of libsimgrid and binary */
749 MC_get_memory_regions(snapshot);
751 snapshot->to_ignore = MC_take_snapshot_ignore();
753 if(_sg_mc_visited > 0 || strcmp(_sg_mc_property_file,"")){
754 snapshot->stacks = MC_take_snapshot_stacks(&snapshot, snapshot->regions[0]->data);
755 //MC_get_hash_global(snapshot->hash_global, snapshot->regions[1]->data, snapshot->regions[2]->data);
756 //MC_get_hash_local(snapshot->hash_local, snapshot->stacks);
760 MC_dump_checkpoint_ignore(snapshot);
766 void MC_restore_snapshot(mc_snapshot_t snapshot){
768 for(i=0; i < NB_REGIONS; i++){
769 MC_region_restore(snapshot->regions[i]);
774 mc_snapshot_t SIMIX_pre_mc_snapshot(smx_simcall_t simcall){
775 return MC_take_snapshot(1);
778 void *MC_snapshot(void){
779 return simcall_mc_snapshot();