Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : take snapshot of stacks (local variables values and stack pointer)
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Sat, 29 Sep 2012 20:23:53 +0000 (22:23 +0200)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Fri, 5 Oct 2012 17:19:15 +0000 (19:19 +0200)
src/mc/mc_checkpoint.c
src/mc/mc_private.h

index 6d9dc31..9360df8 100644 (file)
@@ -7,6 +7,10 @@
 #include "mc_private.h"
 #include "xbt/module.h"
 
 #include "mc_private.h"
 #include "xbt/module.h"
 
+#include "../simix/smx_private.h"
+
+#include <libunwind.h>
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
                                 "Logging specific to mc_checkpoint");
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
                                 "Logging specific to mc_checkpoint");
 
@@ -20,8 +24,10 @@ static void MC_region_destroy(mc_mem_region_t reg);
 
 static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size);
 
 
 static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start_addr, size_t size);
 
-static int data_program_region_compare(void *d1, void *d2, size_t size);
-static int data_libsimgrid_region_compare(void *d1, void *d2, size_t size);
+static void add_value(xbt_dynar_t *list, const char *type, unsigned long int val);
+static xbt_dynar_t take_snapshot_stacks(void *heap);
+static void get_local_variables_values(xbt_dynar_t *all_variables, stack_region_t stack, void *heap);
+static void print_local_variables_values(xbt_dynar_t all_variables);
 
 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
 {
 
 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
 {
@@ -94,6 +100,7 @@ void MC_take_snapshot_liveness(mc_snapshot_t snapshot)
   s_map_region_t reg;
   memory_map_t maps = get_memory_map();
   int nb_reg = 0;
   s_map_region_t reg;
   memory_map_t maps = get_memory_map();
   int nb_reg = 0;
+  void *heap = NULL;
 
   /* Save the std heap and the writable mapped pages of libsimgrid */
   while (i < maps->mapsize && nb_reg < 3) {
 
   /* Save the std heap and the writable mapped pages of libsimgrid */
   while (i < maps->mapsize && nb_reg < 3) {
@@ -102,6 +109,7 @@ void MC_take_snapshot_liveness(mc_snapshot_t snapshot)
       if (maps->regions[i].pathname == NULL){
         if (reg.start_addr == std_heap){ // only save the std heap (and not the raw one)
           MC_snapshot_add_region(snapshot, 0, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
       if (maps->regions[i].pathname == NULL){
         if (reg.start_addr == std_heap){ // only save the std heap (and not the raw one)
           MC_snapshot_add_region(snapshot, 0, reg.start_addr, (char*)reg.end_addr - (char*)reg.start_addr);
+          heap = snapshot->regions[nb_reg]->data;
           nb_reg++;
         }
       } else {
           nb_reg++;
         }
       } else {
@@ -125,6 +133,8 @@ void MC_take_snapshot_liveness(mc_snapshot_t snapshot)
     }
     i++;
   }
     }
     i++;
   }
+
+  snapshot->stacks = take_snapshot_stacks(heap);
   
   free_memory_map(maps);
 
   
   free_memory_map(maps);
 
index 5c64d95..17f89ce 100644 (file)
@@ -20,6 +20,7 @@
 #include "xbt/hash.h"
 #include "msg/msg.h"
 #include "msg/datatypes.h"
 #include "xbt/hash.h"
 #include "msg/msg.h"
 #include "msg/datatypes.h"
+#include "xbt/strbuff.h"
 
 /****************************** Snapshots ***********************************/
 
 
 /****************************** Snapshots ***********************************/
 
@@ -33,8 +34,14 @@ typedef struct s_mc_mem_region{
 typedef struct s_mc_snapshot{
   unsigned int num_reg;
   mc_mem_region_t *regions;
 typedef struct s_mc_snapshot{
   unsigned int num_reg;
   mc_mem_region_t *regions;
+  xbt_dynar_t stacks;
 } s_mc_snapshot_t, *mc_snapshot_t;
 
 } s_mc_snapshot_t, *mc_snapshot_t;
 
+typedef struct s_mc_snapshot_stack{
+  xbt_strbuff_t local_variables;
+  void *stack_pointer;
+}s_mc_snapshot_stack_t, *mc_snapshot_stack_t;
+
 void MC_take_snapshot(mc_snapshot_t);
 void MC_take_snapshot_liveness(mc_snapshot_t s);
 void MC_restore_snapshot(mc_snapshot_t);
 void MC_take_snapshot(mc_snapshot_t);
 void MC_take_snapshot_liveness(mc_snapshot_t s);
 void MC_restore_snapshot(mc_snapshot_t);