Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : remove instruction pointer offset for local variables comparison
[simgrid.git] / src / mc / mc_checkpoint.c
index a9e4916d6e72c02bd9ecef4556a897b4aba0803c..47d1be923998867de76a0ff1865fdaef6c22ff8d 100644 (file)
@@ -34,6 +34,8 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap)
 static void print_local_variables_values(xbt_dynar_t all_variables);
 static void *get_stack_pointer(void *stack_context, void *heap);
 
+static void snapshot_stack_free(mc_snapshot_stack_t s);
+
 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
 {
   mc_mem_region_t new_reg = xbt_new0(s_mc_mem_region_t, 1);
@@ -191,6 +193,7 @@ void MC_free_snapshot(mc_snapshot_t snapshot)
   for(i=0; i < snapshot->num_reg; i++)
     MC_region_destroy(snapshot->regions[i]);
 
+  xbt_dynar_free(&(snapshot->stacks));
   xbt_free(snapshot);
 }
 
@@ -226,7 +229,7 @@ void get_libsimgrid_plt_section(){
     if(lfields[0] == NULL)
       continue;
 
-    if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strcmp(lfields[0], "libsimgrid.so:") == 0)
+    if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], libsimgrid_path, strlen(libsimgrid_path)) == 0)
       continue;
 
     for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
@@ -283,7 +286,7 @@ void get_binary_plt_section(){
     if(lfields[0] == NULL)
       continue;
 
-    if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strcmp(lfields[0], basename(xbt_binary_name)) == 0)
+    if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strncmp(lfields[0], basename(xbt_binary_name), strlen(xbt_binary_name)) == 0)
       continue;
 
     for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
@@ -362,7 +365,7 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap)
   int ret;
   //char *stack_name;
 
-  char buf[512], frame_name[256];
+  char frame_name[256];
   
   ret = unw_init_local(&c, (unw_context_t *)stack_context);
   if(ret < 0){
@@ -394,16 +397,9 @@ static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap)
     unw_get_reg(&c, UNW_REG_IP, &ip);
     unw_get_reg(&c, UNW_REG_SP, &sp);
 
-    buf[0] = '\0';
-    if (unw_get_proc_name (&c, frame_name, sizeof (frame_name), &off) == 0){
-      if (off)
-        snprintf (buf, sizeof (buf), "<%s+0x%lx>", frame_name, (long) off);
-      else
-        snprintf (buf, sizeof (buf), "<%s>", frame_name);
-
-    }
+    unw_get_proc_name (&c, frame_name, sizeof (frame_name), &off);
 
-    xbt_strbuff_append(variables, bprintf("ip=%-32s\n", buf));
+    xbt_strbuff_append(variables, bprintf("ip=%s\n", frame_name));
 
     frame = xbt_dict_get_or_null(mc_local_variables, frame_name);
 
@@ -545,3 +541,15 @@ static void print_local_variables_values(xbt_dynar_t all_variables){
   }
 }
 
+
+static void snapshot_stack_free(mc_snapshot_stack_t s){
+  if(s){
+    xbt_free(s->local_variables->data);
+    xbt_free(s->local_variables);
+    xbt_free(s);
+  }
+}
+
+void snapshot_stack_free_voidp(void *s){
+  snapshot_stack_free((mc_snapshot_stack_t) * (void **) s);
+}