Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : factorize code for safety and liveness model-checking
[simgrid.git] / src / mc / mc_checkpoint.c
1 /* Copyright (c) 2008-2012 Da SimGrid Team. All rights reserved.            */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <libgen.h>
7 #include "mc_private.h"
8 #include "xbt/module.h"
9
10 #include "../simix/smx_private.h"
11
12 #include <libunwind.h>
13
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
15                                 "Logging specific to mc_checkpoint");
16
17 void *start_text_libsimgrid;
18 void *start_plt_libsimgrid, *end_plt_libsimgrid;
19 void *start_plt_binary, *end_plt_binary;
20 char *libsimgrid_path;
21 void *start_data_libsimgrid, *start_bss_libsimgrid;
22 void *start_data_binary, *start_bss_binary;
23 void *start_text_binary;
24 void *end_raw_heap;
25
26 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size);
27 static void MC_region_restore(mc_mem_region_t reg);
28 static void MC_region_destroy(mc_mem_region_t reg);
29
30 static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size);
31
32 static void add_value(xbt_dynar_t *list, const char *type, unsigned long int val);
33 static xbt_dynar_t take_snapshot_stacks(void *heap);
34 static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap);
35 static void print_local_variables_values(xbt_dynar_t all_variables);
36 static void *get_stack_pointer(void *stack_context, void *heap);
37
38 static void snapshot_stack_free(mc_snapshot_stack_t s);
39
40 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
41 {
42   mc_mem_region_t new_reg = xbt_new0(s_mc_mem_region_t, 1);
43   new_reg->type = type;
44   new_reg->start_addr = start_addr;
45   new_reg->size = size;
46   new_reg->data = xbt_malloc0(size);
47   memcpy(new_reg->data, start_addr, size);
48
49   XBT_DEBUG("New region : type : %d, data : %p, size : %zu", type, new_reg->data, size);
50   
51   return new_reg;
52 }
53
54 static void MC_region_restore(mc_mem_region_t reg)
55 {
56   /*FIXME: check if start_addr is still mapped, if it is not, then map it
57     before copying the data */
58  
59   memcpy(reg->start_addr, reg->data, reg->size);
60  
61   return;
62 }
63
64 static void MC_region_destroy(mc_mem_region_t reg)
65 {
66   xbt_free(reg->data);
67   xbt_free(reg);
68 }
69
70 static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size)
71 {
72   mc_mem_region_t new_reg = MC_region_new(type, start_addr, size);
73   snapshot->regions = xbt_realloc(snapshot->regions, (snapshot->num_reg + 1) * sizeof(mc_mem_region_t));
74   snapshot->regions[snapshot->num_reg] = new_reg;
75   snapshot->num_reg++;
76   return;
77
78
79 /* void MC_take_snapshot(mc_snapshot_t snapshot) */
80 /* { */
81 /*   unsigned int i = 0; */
82 /*   s_map_region_t reg; */
83 /*   memory_map_t maps = get_memory_map(); */
84
85 /*   /\* Save the std heap and the writable mapped pages of libsimgrid *\/ */
86 /*   while (i < maps->mapsize) { */
87 /*     reg = maps->regions[i]; */
88 /*     if ((reg.prot & PROT_WRITE)){ */
89 /*       if (maps->regions[i].pathname == NULL){ */
90 /*         if (reg.start_addr == std_heap){ // only save the std heap (and not the raw one) */
91 /*           MC_snapshot_add_region(snapshot, 0, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); */
92 /*         } */
93 /*         i++; */
94 /*       } else { */
95 /*         if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){ */
96 /*           MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); */
97 /*           i++; */
98 /*           reg = maps->regions[i]; */
99 /*           while(reg.pathname == NULL && (reg.prot & PROT_WRITE) && i < maps->mapsize){ */
100 /*             MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr); */
101 /*             i++; */
102 /*             reg = maps->regions[i]; */
103 /*           } */
104 /*         }else{ */
105 /*           i++; */
106 /*         }  */
107 /*       } */
108 /*     }else{ */
109 /*       i++; */
110 /*     } */
111 /*   } */
112
113 /*   free_memory_map(maps); */
114 /* } */
115
116 void MC_init_memory_map_info(){
117
118   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
119
120   MC_SET_RAW_MEM;
121   
122   unsigned int i = 0;
123   s_map_region_t reg;
124   memory_map_t maps = get_memory_map();
125
126   while (i < maps->mapsize) {
127     reg = maps->regions[i];
128     if ((reg.prot & PROT_WRITE)){
129       if (maps->regions[i].pathname == NULL){
130         if(reg.start_addr == raw_heap){
131           end_raw_heap = reg.end_addr;
132         }
133       } else {
134         if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
135           start_data_libsimgrid = reg.start_addr;
136           i++;
137           reg = maps->regions[i];
138           if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && i < maps->mapsize)
139             start_bss_libsimgrid = reg.start_addr;
140         }else if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
141           start_data_binary = reg.start_addr;
142           i++;
143           reg = maps->regions[i];
144           if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && reg.start_addr != std_heap && reg.start_addr != raw_heap && i < maps->mapsize){
145             start_bss_binary = reg.start_addr;
146             i++;
147           }
148         }
149       }
150     }else if ((reg.prot & PROT_READ)){
151       if (maps->regions[i].pathname != NULL){
152         if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
153           start_text_libsimgrid = reg.start_addr;
154           libsimgrid_path = strdup(maps->regions[i].pathname);
155         }else{
156           if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
157             start_text_binary = reg.start_addr;
158           }
159         }
160       }
161     }
162     i++;
163   }
164   
165   free_memory_map(maps);
166
167   MC_UNSET_RAW_MEM;
168
169   if(raw_mem_set)
170     MC_SET_RAW_MEM;
171
172 }
173
174 mc_snapshot_t MC_take_snapshot()
175 {
176
177   int raw_mem = (mmalloc_get_current_heap() == raw_heap);
178   
179   MC_SET_RAW_MEM;
180
181   mc_snapshot_t snapshot = xbt_new0(s_mc_snapshot_t, 1);
182
183   unsigned int i = 0;
184   s_map_region_t reg;
185   memory_map_t maps = get_memory_map();
186   int nb_reg = 0;
187   void *heap = NULL;
188
189   /* Save the std heap and the writable mapped pages of libsimgrid */
190   while (i < maps->mapsize) {
191     reg = maps->regions[i];
192     if ((reg.prot & PROT_WRITE)){
193       if (maps->regions[i].pathname == NULL){
194         if (reg.start_addr == std_heap){ // only save the std heap (and not the raw one)
195           MC_snapshot_add_region(snapshot, 0, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
196           heap = snapshot->regions[nb_reg]->data;
197           nb_reg++;
198         }else if(reg.start_addr == raw_heap){
199           end_raw_heap = reg.end_addr;
200         }
201         i++;
202       } else {
203         if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
204           MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
205           start_data_libsimgrid = reg.start_addr;
206           nb_reg++;
207           i++;
208           reg = maps->regions[i];
209           if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && i < maps->mapsize){
210             MC_snapshot_add_region(snapshot, 1, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
211             reg = maps->regions[i];
212             i++;
213             nb_reg++;
214           }
215         } else {
216           if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
217             MC_snapshot_add_region(snapshot, 2, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
218             nb_reg++;
219             i++;
220             reg = maps->regions[i];
221             if(reg.pathname == NULL && (reg.prot & PROT_WRITE) && reg.start_addr != std_heap && reg.start_addr != raw_heap && i < maps->mapsize){
222               MC_snapshot_add_region(snapshot, 2, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
223               reg = maps->regions[i];
224               nb_reg++;
225             }
226           }else{
227             i++;
228           }
229         }
230       }
231     }else if ((reg.prot & PROT_READ)){
232       if (maps->regions[i].pathname != NULL){
233         if (!memcmp(basename(maps->regions[i].pathname), "libsimgrid", 10)){
234           start_text_libsimgrid = reg.start_addr;
235           libsimgrid_path = strdup(maps->regions[i].pathname);
236         }else{
237           if (!memcmp(basename(maps->regions[i].pathname), basename(xbt_binary_name), strlen(basename(xbt_binary_name)))){
238             start_text_binary = reg.start_addr;
239           }
240         }
241       }
242       i++;
243     }else{
244       i++;
245     }
246   }
247
248   snapshot->stacks = take_snapshot_stacks(heap);
249   
250   free_memory_map(maps);
251
252   MC_UNSET_RAW_MEM;
253
254   if(raw_mem)
255     MC_SET_RAW_MEM;
256
257   return snapshot;
258
259 }
260
261 void MC_restore_snapshot(mc_snapshot_t snapshot)
262 {
263   unsigned int i;
264   for(i=0; i < snapshot->num_reg; i++){
265     MC_region_restore(snapshot->regions[i]);
266   }
267
268 }
269
270 void MC_free_snapshot(mc_snapshot_t snapshot)
271 {
272   unsigned int i;
273   for(i=0; i < snapshot->num_reg; i++)
274     MC_region_destroy(snapshot->regions[i]);
275
276   xbt_dynar_free(&(snapshot->stacks));
277   xbt_free(snapshot);
278 }
279
280
281 void get_libsimgrid_plt_section(){
282
283   FILE *fp;
284   char *line = NULL;            /* Temporal storage for each line that is readed */
285   ssize_t read;                 /* Number of bytes readed */
286   size_t n = 0;                 /* Amount of bytes to read by getline */
287
288   char *lfields[7];
289   int i, plt_not_found = 1;
290   unsigned long int size, offset;
291
292   if(libsimgrid_path == NULL)
293     libsimgrid_path = get_libsimgrid_path();
294
295   char *command = bprintf("objdump --section-headers %s", libsimgrid_path);
296
297   fp = popen(command, "r");
298
299   if(fp == NULL)
300     perror("popen failed");
301
302   while ((read = getline(&line, &n, fp)) != -1 && plt_not_found == 1) {
303
304     if(n == 0)
305       continue;
306
307     /* Wipeout the new line character */
308     line[read - 1] = '\0';
309
310     lfields[0] = strtok(line, " ");
311
312     if(lfields[0] == NULL)
313       continue;
314
315     if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], libsimgrid_path, strlen(libsimgrid_path)) == 0)
316       continue;
317
318     for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
319       lfields[i] = strtok(NULL, " ");
320     }
321
322     if(i>=6){
323       if(strcmp(lfields[1], ".plt") == 0){
324         size = strtoul(lfields[2], NULL, 16);
325         offset = strtoul(lfields[5], NULL, 16);
326         start_plt_libsimgrid = (char *)start_text_libsimgrid + offset;
327         end_plt_libsimgrid = (char *)start_plt_libsimgrid + size;
328         plt_not_found = 0;
329       }
330     }
331     
332   }
333
334   free(command);
335   free(line);
336   pclose(fp);
337
338 }
339
340 void get_binary_plt_section(){
341
342   FILE *fp;
343   char *line = NULL;            /* Temporal storage for each line that is readed */
344   ssize_t read;                 /* Number of bytes readed */
345   size_t n = 0;                 /* Amount of bytes to read by getline */
346
347   char *lfields[7];
348   int i, plt_not_found = 1;
349   unsigned long int size, offset;
350
351   char *command = bprintf( "objdump --section-headers %s", xbt_binary_name);
352
353   fp = popen(command, "r");
354
355   if(fp == NULL)
356     perror("popen failed");
357
358   while ((read = getline(&line, &n, fp)) != -1 && plt_not_found == 1) {
359
360     if(n == 0)
361       continue;
362
363     /* Wipeout the new line character */
364     line[read - 1] = '\0';
365
366     lfields[0] = strtok(line, " ");
367
368     if(lfields[0] == NULL)
369       continue;
370
371     if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], basename(xbt_binary_name), strlen(xbt_binary_name)) == 0)
372       continue;
373
374     for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
375       lfields[i] = strtok(NULL, " ");
376     }
377
378     if(i>=6){
379       if(strcmp(lfields[1], ".plt") == 0){
380         size = strtoul(lfields[2], NULL, 16);
381         offset = strtoul(lfields[5], NULL, 16);
382         start_plt_binary = (char *)start_text_binary + offset;
383         end_plt_binary = (char *)start_plt_binary + size;
384         plt_not_found = 0;
385       }
386     }
387     
388     
389   }
390
391   free(command);
392   free(line);
393   pclose(fp);
394
395 }
396
397 static void add_value(xbt_dynar_t *list, const char *type, unsigned long int val){
398   variable_value_t value = xbt_new0(s_variable_value_t, 1);
399   value->type = strdup(type);
400   if(strcmp(type, "value") == 0){
401     value->value.res = val;
402   }else{
403     value->value.address = (void *)val;
404   }
405   xbt_dynar_push(*list, &value);
406 }
407
408 static xbt_dynar_t take_snapshot_stacks(void *heap){
409
410   xbt_dynar_t res = xbt_dynar_new(sizeof(s_mc_snapshot_stack_t), NULL);
411
412   unsigned int cursor1 = 0;
413   stack_region_t current_stack;
414   
415   xbt_dynar_foreach(stacks_areas, cursor1, current_stack){
416     mc_snapshot_stack_t st = xbt_new(s_mc_snapshot_stack_t, 1);
417     st->local_variables = get_local_variables_values(current_stack->context, heap);
418     st->stack_pointer = get_stack_pointer(current_stack->context, heap);
419     xbt_dynar_push(res, &st);
420   }
421
422   return res;
423
424 }
425
426 static void *get_stack_pointer(void *stack_context, void *heap){
427
428   unw_cursor_t c;
429   int ret;
430   unw_word_t sp;
431
432   ret = unw_init_local(&c, (unw_context_t *)stack_context);
433   if(ret < 0){
434     XBT_INFO("unw_init_local failed");
435     xbt_abort();
436   }
437
438   unw_get_reg(&c, UNW_REG_SP, &sp);
439
440   return ((char *)heap + (size_t)(((char *)((long)sp) - (char*)std_heap)));
441
442 }
443
444 static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap){
445   
446   unw_cursor_t c;
447   int ret;
448   //char *stack_name;
449
450   char frame_name[256];
451   
452   ret = unw_init_local(&c, (unw_context_t *)stack_context);
453   if(ret < 0){
454     XBT_INFO("unw_init_local failed");
455     xbt_abort();
456   }
457
458   //stack_name = strdup(((smx_process_t)((smx_ctx_sysv_t)(stack->address))->super.data)->name);
459
460   unw_word_t ip, sp, off;
461   dw_frame_t frame;
462  
463   xbt_dynar_t compose = xbt_dynar_new(sizeof(variable_value_t), NULL);
464
465   xbt_strbuff_t variables = xbt_strbuff_new();
466   xbt_dict_cursor_t dict_cursor;
467   char *variable_name;
468   dw_local_variable_t current_variable;
469   unsigned int cursor = 0, cursor2 = 0;
470   dw_location_entry_t entry = NULL;
471   dw_location_t location_entry = NULL;
472   unw_word_t res;
473   int frame_found = 0;
474   void *frame_pointer_address = NULL;
475   long true_ip;
476
477   while(ret >= 0){
478
479     unw_get_reg(&c, UNW_REG_IP, &ip);
480     unw_get_reg(&c, UNW_REG_SP, &sp);
481
482     unw_get_proc_name (&c, frame_name, sizeof (frame_name), &off);
483
484     xbt_strbuff_append(variables, bprintf("ip=%s\n", frame_name));
485
486     frame = xbt_dict_get_or_null(mc_local_variables, frame_name);
487
488     if(frame == NULL){
489       ret = unw_step(&c);
490       continue;
491     }
492
493     true_ip = (long)frame->low_pc + (long)off;
494
495     /* Get frame pointer */
496     switch(frame->frame_base->type){
497     case e_dw_loclist:
498       while((cursor < xbt_dynar_length(frame->frame_base->location.loclist)) && frame_found == 0){
499         entry = xbt_dynar_get_as(frame->frame_base->location.loclist, cursor, dw_location_entry_t);
500         if((true_ip >= entry->lowpc) && (true_ip < entry->highpc)){
501           frame_found = 1;
502           switch(entry->location->type){
503           case e_dw_compose:
504             xbt_dynar_reset(compose);
505             cursor2 = 0;
506             while(cursor2 < xbt_dynar_length(entry->location->location.compose)){
507               location_entry = xbt_dynar_get_as(entry->location->location.compose, cursor2, dw_location_t);
508               switch(location_entry->type){
509               case e_dw_register:
510                 unw_get_reg(&c, location_entry->location.reg, &res);
511                 add_value(&compose, "address", (long)res);
512                 break;
513               case e_dw_bregister_op:
514                 unw_get_reg(&c, location_entry->location.breg_op.reg, &res);
515                 add_value(&compose, "address", (long)res + location_entry->location.breg_op.offset);
516                 break;
517               default:
518                 xbt_dynar_reset(compose);
519                 break;
520               }
521               cursor2++;
522             }
523
524             if(xbt_dynar_length(compose) > 0){
525               frame_pointer_address = xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address ; 
526             }
527             break;
528           default :
529             frame_pointer_address = NULL;
530             break;
531           }
532         }
533         cursor++;
534       }
535       break;
536     default :
537       frame_pointer_address = NULL;
538       break;
539     }
540
541     frame_found = 0;
542     cursor = 0;
543
544     //XBT_INFO("Frame %s", frame->name);
545
546     xbt_dict_foreach(frame->variables, dict_cursor, variable_name, current_variable){
547       if(current_variable->location != NULL){
548         switch(current_variable->location->type){
549         case e_dw_compose:
550           xbt_dynar_reset(compose);
551           cursor = 0;
552           while(cursor < xbt_dynar_length(current_variable->location->location.compose)){
553             location_entry = xbt_dynar_get_as(current_variable->location->location.compose, cursor, dw_location_t);
554             switch(location_entry->type){
555             case e_dw_register:
556               unw_get_reg(&c, location_entry->location.reg, &res);
557               add_value(&compose, "value", (long)res);
558               break;
559             case e_dw_bregister_op:
560               unw_get_reg(&c, location_entry->location.breg_op.reg, &res);
561               add_value(&compose, "address", (long)res + location_entry->location.breg_op.offset);
562               break;
563             case e_dw_fbregister_op:
564               if(frame_pointer_address != NULL)
565                 add_value(&compose, "address", (long)((char *)frame_pointer_address + location_entry->location.fbreg_op));
566               break;
567             default:
568               xbt_dynar_reset(compose);
569               break;
570             }
571             cursor++;
572           }
573           
574           if(xbt_dynar_length(compose) > 0){
575             //XBT_INFO("Variable : %s", current_variable->name);
576             if(strcmp(xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->type, "value") == 0){
577               //XBT_INFO("Variable : %s - value : %lx", current_variable->name, xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.res);
578               xbt_strbuff_append(variables, bprintf("%s=%lx\n", current_variable->name, xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.res));
579             }else{
580               if((long)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address < 0 || *((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address) == NULL){
581                 //XBT_INFO("Variable : %s - address : NULL", current_variable->name);
582                 xbt_strbuff_append(variables, bprintf("%s=NULL\n", current_variable->name));
583               }else if(((long)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address) > 0xffffffff) || ((long)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1,variable_value_t)->value.address) < (long)start_text_binary)){
584                 //XBT_INFO("Variable : %s - value : %zd", current_variable->name, (size_t)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address));
585                 xbt_strbuff_append(variables, bprintf("%s=%d\n", current_variable->name, (int)(long)*((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address)));
586               }else{
587                 //XBT_INFO("Variable : %s - address : %p", current_variable->name, *((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address));  
588                 xbt_strbuff_append(variables, bprintf("%s=%p\n", current_variable->name, *((void**)xbt_dynar_get_as(compose, xbt_dynar_length(compose) - 1, variable_value_t)->value.address)));
589               }
590             }
591           }else{
592             //XBT_INFO("Variable %s undefined", current_variable->name);
593             xbt_strbuff_append(variables, bprintf("%s=undefined\n", current_variable->name));
594           }
595           break;
596         default :
597           break;
598         }
599       }else{
600         //XBT_INFO("Variable : %s, no location", current_variable->name);
601         xbt_strbuff_append(variables, bprintf("%s=undefined\n", current_variable->name));
602       }
603     }    
604  
605     ret = unw_step(&c);
606
607     //XBT_INFO(" ");
608      
609   }
610
611   //free(stack_name);
612
613   return variables;
614
615 }
616
617 static void print_local_variables_values(xbt_dynar_t all_variables){
618
619   unsigned cursor = 0;
620   mc_snapshot_stack_t stack;
621
622   xbt_dynar_foreach(all_variables, cursor, stack){
623     XBT_INFO("%s", stack->local_variables->data);
624   }
625 }
626
627
628 static void snapshot_stack_free(mc_snapshot_stack_t s){
629   if(s){
630     xbt_free(s->local_variables->data);
631     xbt_free(s->local_variables);
632     xbt_free(s);
633   }
634 }
635
636 void snapshot_stack_free_voidp(void *s){
637   snapshot_stack_free((mc_snapshot_stack_t) * (void **) s);
638 }
639
640 void *MC_snapshot(void){
641
642   return simcall_mc_snapshot();
643   
644 }