Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : get global variables with objdump and compare only the bytes in data...
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Sun, 2 Dec 2012 21:13:37 +0000 (22:13 +0100)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Sun, 2 Dec 2012 21:15:49 +0000 (22:15 +0100)
src/mc/mc_compare.c
src/mc/mc_global.c
src/mc/mc_liveness.c
src/mc/mc_private.h

index 627d2f8..d3b3f0a 100644 (file)
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, mc,
                                 "Logging specific to mc_compare");
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, mc,
                                 "Logging specific to mc_compare");
 
-static int data_bss_program_region_compare(void *d1, void *d2, size_t size);
-static int data_bss_libsimgrid_region_compare(void *d1, void *d2, size_t size);
 static int heap_region_compare(void *d1, void *d2, size_t size);
 
 static int compare_stack(stack_region_t s1, stack_region_t s2, void *sp1, void *sp2, void *heap1, void *heap2, xbt_dynar_t equals);
 static int is_heap_equality(xbt_dynar_t equals, void *a1, void *a2);
 static size_t heap_ignore_size(void *address);
 static int heap_region_compare(void *d1, void *d2, size_t size);
 
 static int compare_stack(stack_region_t s1, stack_region_t s2, void *sp1, void *sp2, void *heap1, void *heap2, xbt_dynar_t equals);
 static int is_heap_equality(xbt_dynar_t equals, void *a1, void *a2);
 static size_t heap_ignore_size(void *address);
-static size_t data_bss_ignore_size(void *address);
 
 static void stack_region_free(stack_region_t s);
 static void heap_equality_free(heap_equality_t e);
 
 static void stack_region_free(stack_region_t s);
 static void heap_equality_free(heap_equality_t e);
@@ -45,95 +42,66 @@ static size_t heap_ignore_size(void *address){
   return 0;
 }
 
   return 0;
 }
 
-static size_t data_bss_ignore_size(void *address){
-  unsigned int cursor = 0;
-  int start = 0;
-  int end = xbt_dynar_length(mc_data_bss_comparison_ignore) - 1;
-  mc_data_bss_ignore_variable_t var;
-
-  while(start <= end){
-    cursor = (start + end) / 2;
-    var = (mc_data_bss_ignore_variable_t)xbt_dynar_get_as(mc_data_bss_comparison_ignore, cursor, mc_data_bss_ignore_variable_t);
-    if(var->address == address)
-      return var->size;
-    if(var->address < address){
-      if((void *)((char *)var->address + var->size) > address)
-        return (char *)var->address + var->size - (char*)address;
-      else
-        start = cursor + 1;
-    }
-    if(var->address > address)
-      end = cursor - 1;   
-  }
-
-  return 0;
-}
-
-static int data_bss_program_region_compare(void *d1, void *d2, size_t size){
-
-  size_t i = 0, ignore_size = 0;
-  int pointer_align;
-  void *addr_pointed1 = NULL, *addr_pointed2 = NULL;
-  
-  for(i=0; i<size; i++){
-    if(memcmp(((char *)d1) + i, ((char *)d2) + i, 1) != 0){
-      if((ignore_size = data_bss_ignore_size((char *)start_data_binary+i)) > 0){
-        i = i + ignore_size;
-        continue;
-      }else if((ignore_size = data_bss_ignore_size((char *)start_bss_binary+i)) > 0){
-        i = i + ignore_size;
-        continue;
-      }
-      pointer_align = (i / sizeof(void*)) * sizeof(void*);
-      addr_pointed1 = *((void **)((char *)d1 + pointer_align));
-      addr_pointed2 = *((void **)((char *)d2 + pointer_align));
-      if((addr_pointed1 > start_plt_binary && addr_pointed1 < end_plt_binary) || (addr_pointed2 > start_plt_binary && addr_pointed2 < end_plt_binary)){
-        continue;
-      }else{
-        if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose)){
-          XBT_VERB("Different byte (offset=%zu) (%p - %p) in data program region", i, (char *)d1 + i, (char *)d2 + i);
-          XBT_VERB("Addresses pointed : %p - %p", addr_pointed1, addr_pointed2);
-        }
-        return 1;
-      }
-    }
-  }
-  
-  return 0;
-}
+static int compare_global_variables(int region_type, void *d1, void *d2){
 
 
-static int data_bss_libsimgrid_region_compare(void *d1, void *d2, size_t size){
-
-  size_t i = 0, ignore_size = 0;
-  int pointer_align;
+  unsigned int cursor = 0;
+  size_t offset; 
+  int i = 0;
+  global_variable_t current_var; 
+  int pointer_align; 
   void *addr_pointed1 = NULL, *addr_pointed2 = NULL;
 
   void *addr_pointed1 = NULL, *addr_pointed2 = NULL;
 
-  for(i=0; i<size; i++){
-    if(memcmp(((char *)d1) + i, ((char *)d2) + i, 1) != 0){
-      if((ignore_size = data_bss_ignore_size((char *)start_data_libsimgrid+i)) > 0){
-        i = i + ignore_size;
-        continue;
-      }else if((ignore_size = data_bss_ignore_size((char *)start_bss_libsimgrid+i)) > 0){
-        i = i + ignore_size;
+  if(region_type == 1){ /* libsimgrid */
+    xbt_dynar_foreach(mc_global_variables, cursor, current_var){
+      if(current_var->address < start_data_libsimgrid)
         continue;
         continue;
+      offset = (char *)current_var->address - (char *)start_data_libsimgrid;
+      i = 0;
+      while(i < current_var->size){
+        if(memcmp((char*)d1 + offset + i, (char*)d2 + offset + i, 1) != 0){
+          pointer_align = (i / sizeof(void*)) * sizeof(void*); 
+          addr_pointed1 = *((void **)((char *)d1 + offset + pointer_align));
+          addr_pointed2 = *((void **)((char *)d2 + offset + pointer_align));
+          if((addr_pointed1 > start_plt_libsimgrid && addr_pointed1 < end_plt_libsimgrid) || (addr_pointed2 > start_plt_libsimgrid && addr_pointed2 < end_plt_libsimgrid)){
+            i = current_var->size;
+            continue;
+          }else{
+            if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose)){
+              XBT_VERB("Different global variable in libsimgrid : %s", current_var->name);
+            }
+            return 1;
+          }
+        } 
+        i++;
       }
       }
-      pointer_align = (i / sizeof(void*)) * sizeof(void*);
-      addr_pointed1 = *((void **)((char *)d1 + pointer_align));
-      addr_pointed2 = *((void **)((char *)d2 + pointer_align));
-      if((addr_pointed1 > start_plt_libsimgrid && addr_pointed1 < end_plt_libsimgrid) || (addr_pointed2 > start_plt_libsimgrid && addr_pointed2 < end_plt_libsimgrid)){
-        continue;
-      }else if(addr_pointed1 >= raw_heap && addr_pointed1 <= end_raw_heap && addr_pointed2 >= raw_heap && addr_pointed2 <= end_raw_heap){
-        continue;
-      }else{
-        if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose)){
-          XBT_VERB("Different byte (offset=%zu) (%p - %p) in libsimgrid region", i, (char *)d1 + i, (char *)d2 + i);
-          XBT_VERB("Addresses pointed : %p - %p", addr_pointed1, addr_pointed2);
-        }
-        return 1;
+    }
+  }else{ /* binary */
+    xbt_dynar_foreach(mc_global_variables, cursor, current_var){
+      if(current_var->address > start_data_libsimgrid)
+        break;
+      offset = (char *)current_var->address - (char *)start_data_binary;
+      i = 0;
+      while(i < current_var->size){
+        if(memcmp((char*)d1 + offset + i, (char*)d2 + offset + i, 1) != 0){
+          pointer_align = (i / sizeof(void*)) * sizeof(void*); 
+          addr_pointed1 = *((void **)((char *)d1 + offset + pointer_align));
+          addr_pointed2 = *((void **)((char *)d2 + offset + pointer_align));
+          if((addr_pointed1 > start_plt_binary && addr_pointed1 < end_plt_binary) || (addr_pointed2 > start_plt_binary && addr_pointed2 < end_plt_binary)){
+            i = current_var->size;
+            continue;
+          }else{
+            if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose)){
+              XBT_VERB("Different global variable in binary : %s", current_var->name);
+            }
+            return 1;
+          }
+        } 
+        i++;
       }
       }
+      
     }
   }
     }
   }
-  
+
   return 0;
 }
 
   return 0;
 }
 
@@ -321,41 +289,34 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, mc_comparison_times_t c
       xbt_os_timer_stop(timer);
     xbt_os_timer_start(timer);
   }
       xbt_os_timer_stop(timer);
     xbt_os_timer_start(timer);
   }
-  
-  /* Compare program data segment(s) */
-  is_diff = 0;
-  i = data_program_index;
-  while(i < s1->num_reg && s1->regions[i]->type == 2){
-    if(data_bss_program_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
-      if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-        if(is_diff == 0){
-          xbt_os_timer_stop(timer);
-          if(ct1 != NULL)
-            xbt_dynar_push_as(ct1->program_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
-          if(ct2 != NULL)
-           xbt_dynar_push_as(ct2->program_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
-        }
-        XBT_DEBUG("Different memcmp for data in program");
-        errors++;
-        is_diff = 1;
-      }else{
-        if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
-          XBT_VERB("Different memcmp for data in program"); 
 
 
-        xbt_os_timer_free(timer);
-        xbt_os_timer_stop(global_timer);
-        if(ct1 != NULL)
-          xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
-        if(ct2 != NULL)
-          xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
-        xbt_os_timer_free(global_timer);
-
-        if(!raw_mem)
-          MC_UNSET_RAW_MEM;
-        return 1;
-      }
+  /* Compare binary global variables */
+  is_diff = compare_global_variables(s1->regions[data_program_index]->type, s1->regions[data_program_index]->data, s2->regions[data_program_index]->data);
+  if(is_diff != 0){
+    if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+      xbt_os_timer_stop(timer);
+      if(ct1 != NULL)
+        xbt_dynar_push_as(ct1->binary_global_variables_comparison_times, double, xbt_os_timer_elapsed(timer));
+      if(ct2 != NULL)
+        xbt_dynar_push_as(ct2->binary_global_variables_comparison_times, double, xbt_os_timer_elapsed(timer));
+      XBT_DEBUG("Different global variables in binary"); 
+      errors++; 
+    }else{
+      if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
+        XBT_VERB("Different global variables in binary"); 
+    
+      xbt_os_timer_free(timer);
+      xbt_os_timer_stop(global_timer);
+      if(ct1 != NULL)
+        xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+      if(ct2 != NULL)
+        xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+      xbt_os_timer_free(global_timer);
+    
+      if(!raw_mem)
+        MC_UNSET_RAW_MEM;
+      return 1;
     }
     }
-    i++;
   }
 
   if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
   }
 
   if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
@@ -364,41 +325,34 @@ int snapshot_compare(mc_snapshot_t s1, mc_snapshot_t s2, mc_comparison_times_t c
     xbt_os_timer_start(timer);
   }
 
     xbt_os_timer_start(timer);
   }
 
-  /* Compare libsimgrid data segment(s) */
-  is_diff = 0;
-  i = data_libsimgrid_index;
-  while(i < s1->num_reg && s1->regions[i]->type == 1){
-    if(data_bss_libsimgrid_region_compare(s1->regions[i]->data, s2->regions[i]->data, s1->regions[i]->size) != 0){
-      if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
-        if(is_diff == 0){
-          xbt_os_timer_stop(timer);
-          if(ct1 != NULL)
-            xbt_dynar_push_as(ct1->libsimgrid_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
-          if(ct2 != NULL)
-            xbt_dynar_push_as(ct2->libsimgrid_data_segment_comparison_times, double, xbt_os_timer_elapsed(timer));
-        }
-        XBT_DEBUG("Different memcmp for data in libsimgrid");
-        errors++;
-        is_diff = 1;
-      }else{
-        if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
-          XBT_VERB("Different memcmp for data in libsimgrid");
-         
-        xbt_os_timer_free(timer);
-        xbt_os_timer_stop(global_timer);
-        if(ct1 != NULL)
-          xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
-        if(ct2 != NULL)
-          xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
-        xbt_os_timer_free(global_timer);
-        
-        if(!raw_mem)
-          MC_UNSET_RAW_MEM;
-        return 1;
-      }
+  /* Compare libsimgrid global variables */
+  is_diff = compare_global_variables(s1->regions[data_libsimgrid_index]->type, s1->regions[data_libsimgrid_index]->data, s2->regions[data_libsimgrid_index]->data);
+  if(is_diff != 0){
+    if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
+      xbt_os_timer_stop(timer);
+      if(ct1 != NULL)
+        xbt_dynar_push_as(ct1->libsimgrid_global_variables_comparison_times, double, xbt_os_timer_elapsed(timer));
+      if(ct2 != NULL)
+        xbt_dynar_push_as(ct2->libsimgrid_global_variables_comparison_times, double, xbt_os_timer_elapsed(timer));
+      XBT_DEBUG("Different global variables in libsimgrid"); 
+      errors++; 
+    }else{
+      if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_verbose))
+        XBT_VERB("Different global variables in libsimgrid"); 
+    
+      xbt_os_timer_free(timer);
+      xbt_os_timer_stop(global_timer);
+      if(ct1 != NULL)
+        xbt_dynar_push_as(ct1->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+      if(ct2 != NULL)
+        xbt_dynar_push_as(ct2->snapshot_comparison_times, double, xbt_os_timer_elapsed(global_timer));
+      xbt_os_timer_free(global_timer);
+    
+      if(!raw_mem)
+        MC_UNSET_RAW_MEM;
+      return 1;
     }
     }
-    i++;
-  }
+  }  
 
   if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
     if(is_diff == 0)
 
   if(XBT_LOG_ISENABLED(mc_compare, xbt_log_priority_debug)){
     if(is_diff == 0)
index 72b9532..6050c57 100644 (file)
@@ -95,6 +95,8 @@ int compare;
 
 /* Local */
 xbt_dict_t mc_local_variables = NULL;
 
 /* Local */
 xbt_dict_t mc_local_variables = NULL;
+/* Global */
+xbt_dynar_t mc_global_variables = NULL;
 
 /* Ignore mechanism */
 xbt_dynar_t mc_stack_comparison_ignore;
 
 /* Ignore mechanism */
 xbt_dynar_t mc_stack_comparison_ignore;
@@ -109,7 +111,8 @@ xbt_automaton_t _mc_property_automaton = NULL;
 static void MC_assert_pair(int prop);
 static dw_location_t get_location(xbt_dict_t location_list, char *expr);
 static dw_frame_t get_frame_by_offset(xbt_dict_t all_variables, unsigned long int offset);
 static void MC_assert_pair(int prop);
 static dw_location_t get_location(xbt_dict_t location_list, char *expr);
 static dw_frame_t get_frame_by_offset(xbt_dict_t all_variables, unsigned long int offset);
-static void ignore_coverage_variables(char *executable, int region_type);
+static size_t data_bss_ignore_size(void *address);
+static void MC_get_global_variables(char *elf_file);
 
 void MC_do_the_modelcheck_for_real() {
   if (!_surf_mc_property_file || _surf_mc_property_file[0]=='\0') {
 
 void MC_do_the_modelcheck_for_real() {
   if (!_surf_mc_property_file || _surf_mc_property_file[0]=='\0') {
@@ -153,7 +156,7 @@ void MC_init(){
 
   MC_SET_RAW_MEM;
 
 
   MC_SET_RAW_MEM;
 
-  char *ls_path = get_libsimgrid_path(); 
+  MC_init_memory_map_info();
   
   mc_local_variables = xbt_dict_new_homogeneous(NULL);
 
   
   mc_local_variables = xbt_dict_new_homogeneous(NULL);
 
@@ -162,17 +165,16 @@ void MC_init(){
   MC_get_local_variables(xbt_binary_name, binary_location_list, &mc_local_variables);
 
   /* Get local variables in libsimgrid for state equality detection */
   MC_get_local_variables(xbt_binary_name, binary_location_list, &mc_local_variables);
 
   /* Get local variables in libsimgrid for state equality detection */
-  xbt_dict_t libsimgrid_location_list = MC_get_location_list(ls_path);
-  MC_get_local_variables(ls_path, libsimgrid_location_list, &mc_local_variables);
-
-  MC_init_memory_map_info();
+  xbt_dict_t libsimgrid_location_list = MC_get_location_list(libsimgrid_path);
+  MC_get_local_variables(libsimgrid_path, libsimgrid_location_list, &mc_local_variables);
 
   /* Get .plt section (start and end addresses) for data libsimgrid and data program comparison */
   get_libsimgrid_plt_section();
   get_binary_plt_section();
 
 
   /* Get .plt section (start and end addresses) for data libsimgrid and data program comparison */
   get_libsimgrid_plt_section();
   get_binary_plt_section();
 
-  ignore_coverage_variables(libsimgrid_path, 1);
-  ignore_coverage_variables(xbt_binary_name, 2);
+  /* Get global variables */
+  MC_get_global_variables(xbt_binary_name);
+  MC_get_global_variables(libsimgrid_path);
 
   MC_UNSET_RAW_MEM;
 
 
   MC_UNSET_RAW_MEM;
 
@@ -716,70 +718,6 @@ void MC_automaton_new_propositional_symbol(const char* id, void* fct) {
 
 /************ MC_ignore ***********/ 
 
 
 /************ MC_ignore ***********/ 
 
-static void ignore_coverage_variables(char *executable, int region_type){
-
-  FILE *fp;
-
-  char *command = bprintf("objdump --syms %s", executable);
-
-  fp = popen(command, "r");
-
-  if(fp == NULL){
-    perror("popen failed");
-    xbt_abort();
-  }
-
-  char *line = NULL;
-  ssize_t read;
-  size_t n = 0;
-
-  xbt_dynar_t line_tokens = NULL;
-  unsigned long int size, offset;
-  void *address;
-
-  while ((read = getline(&line, &n, fp)) != -1){
-
-    if(n == 0)
-      continue;
-
-     /* Wipeout the new line character */
-    line[read - 1] = '\0';
-
-    xbt_str_strip_spaces(line);
-    xbt_str_ltrim(line, NULL);
-
-    line_tokens = xbt_str_split(line, NULL);
-
-    if(xbt_dynar_length(line_tokens) < 3 || strcmp(xbt_dynar_get_as(line_tokens, 0, char *), "SYMBOL") == 0)
-      continue;
-
-    if(((strncmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char *), "gcov", 4) == 0)
-        || (strncmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char *), "__gcov", 6) == 0))
-       && (((strcmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 3, char *), ".bss") == 0) 
-            || (strcmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 3, char *), ".data") == 0)))){
-      if(region_type == 1){ /* libsimgrid */
-        offset = strtoul(xbt_dynar_get_as(line_tokens, 0, char*), NULL, 16);
-        size = strtoul(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 2, char *), NULL, 16);
-        //XBT_DEBUG("Add ignore at address %p (size %lu)", (char *)start_text_libsimgrid+offset, size);
-        MC_ignore_data_bss((char *)start_text_libsimgrid+offset, size);
-      }else{ /* binary */
-        address = (void *)strtoul(xbt_dynar_get_as(line_tokens, 0, char*), NULL, 16);
-        size = strtoul(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 2, char *), NULL, 16);
-        //XBT_DEBUG("Add ignore at address %p (size %lu)", address, size);
-        MC_ignore_data_bss(address, size);
-      }
-    }
-
-    xbt_dynar_free(&line_tokens);
-
-  }
-
-  free(command);
-  free(line);
-  pclose(fp);
-
-}
-
 void MC_ignore_heap(void *address, size_t size){
 
   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
 void MC_ignore_heap(void *address, size_t size){
 
   int raw_mem_set = (mmalloc_get_current_heap() == raw_heap);
@@ -1752,3 +1690,113 @@ void print_local_variables(xbt_dict_t list){
   }
 
 }
   }
 
 }
+
+static size_t data_bss_ignore_size(void *address){
+  unsigned int cursor = 0;
+  int start = 0;
+  int end = xbt_dynar_length(mc_data_bss_comparison_ignore) - 1;
+  mc_data_bss_ignore_variable_t var;
+
+  while(start <= end){
+    cursor = (start + end) / 2;
+    var = (mc_data_bss_ignore_variable_t)xbt_dynar_get_as(mc_data_bss_comparison_ignore, cursor, mc_data_bss_ignore_variable_t);
+    if(var->address == address)
+      return var->size;
+    if(var->address < address){
+      if((void *)((char *)var->address + var->size) > address)
+        return (char *)var->address + var->size - (char*)address;
+      else
+        start = cursor + 1;
+    }
+    if(var->address > address)
+      end = cursor - 1;   
+  }
+
+  return 0;
+}
+
+
+static void MC_get_global_variables(char *elf_file){
+
+  FILE *fp;
+
+  char *command = bprintf("objdump -t -j .data -j .bss %s", elf_file);
+
+  fp = popen(command, "r");
+
+  if(fp == NULL){
+    perror("popen failed");
+    xbt_abort();
+  }
+
+  if(mc_global_variables == NULL)
+    mc_global_variables = xbt_dynar_new(sizeof(global_variable_t), global_variable_free_voidp);
+
+  char *line = NULL;
+  ssize_t read;
+  size_t n = 0;
+
+  xbt_dynar_t line_tokens = NULL;
+  unsigned long offset;
+
+  int type = strcmp(elf_file, xbt_binary_name); /* 0 = binary, other = libsimgrid */
+
+  while ((read = getline(&line, &n, fp)) != -1){
+
+    if(n == 0)
+      continue;
+
+     /* Wipeout the new line character */
+    line[read - 1] = '\0';
+
+    xbt_str_strip_spaces(line);
+    xbt_str_ltrim(line, NULL);
+
+    line_tokens = xbt_str_split(line, NULL);
+
+    if(xbt_dynar_length(line_tokens) <= 4 || strcmp(xbt_dynar_get_as(line_tokens, 0, char *), "SYMBOL") == 0)
+      continue;
+
+    if((strncmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char*), "__gcov", 6) == 0)
+       || (strncmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char*), "gcov", 4) == 0)
+       || (strcmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char*), ".data") == 0)
+       || (strcmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char*), ".bss") == 0)
+       || (strncmp(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char*), "stderr", 6) == 0)
+       || ((size_t)strtoul(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 2, char*), NULL, 16) == 0))
+      continue;
+
+    global_variable_t var = xbt_new0(s_global_variable_t, 1);
+
+    if(type == 0){
+      var->address = (void *)strtoul(xbt_dynar_get_as(line_tokens, 0, char*), NULL, 16);
+    }else{
+      offset = strtoul(xbt_dynar_get_as(line_tokens, 0, char*), NULL, 16);
+      var->address = (char *)start_text_libsimgrid+offset;
+    }
+
+    var->size = (size_t)strtoul(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 2, char*), NULL, 16);
+    var->name = strdup(xbt_dynar_get_as(line_tokens, xbt_dynar_length(line_tokens) - 1, char*));
+
+    if(data_bss_ignore_size(var->address) > 0)
+      global_variable_free(var);
+    else
+      xbt_dynar_push(mc_global_variables, &var);
+
+    xbt_dynar_free(&line_tokens);
+
+  }
+
+  free(command);
+  free(line);
+  pclose(fp);
+
+}
+
+void global_variable_free(global_variable_t v){
+  xbt_free(v->name);
+  xbt_free(v);
+}
+
+void global_variable_free_voidp(void *v){
+  global_variable_free((global_variable_t) * (void **) v);
+}
index 81f7120..8009591 100644 (file)
@@ -90,36 +90,36 @@ void MC_print_comparison_times_statistics(mc_comparison_times_t ct){
     XBT_DEBUG("Stacks sizes comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_sizes_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_sizes_comparison_times), max, min);
   }
 
     XBT_DEBUG("Stacks sizes comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->stacks_sizes_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->stacks_sizes_comparison_times), max, min);
   }
 
-  if(xbt_dynar_length(ct->program_data_segment_comparison_times) > 0){
+  if(xbt_dynar_length(ct->binary_global_variables_comparison_times) > 0){
     cursor = 0;
     total = 0.0;
     max = 0.0;
     cursor = 0;
     total = 0.0;
     max = 0.0;
-    min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
-    while(cursor < xbt_dynar_length(ct->program_data_segment_comparison_times) - 1){
-      total += xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
-      if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) > max)
-        max = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
-      if(xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double) < min)
-        min = xbt_dynar_get_as(ct->program_data_segment_comparison_times, cursor, double);
+    min = xbt_dynar_get_as(ct->binary_global_variables_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->binary_global_variables_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->binary_global_variables_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->binary_global_variables_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->binary_global_variables_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->binary_global_variables_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->binary_global_variables_comparison_times, cursor, double);
       cursor++;
     }
       cursor++;
     }
-    XBT_DEBUG("Program data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->program_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->program_data_segment_comparison_times), max, min);
+    XBT_DEBUG("Binary global variables comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->binary_global_variables_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->binary_global_variables_comparison_times), max, min);
   }
 
   }
 
-  if(xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) > 0){
+  if(xbt_dynar_length(ct->libsimgrid_global_variables_comparison_times) > 0){
     cursor = 0;
     total = 0.0;
     max = 0.0;
     cursor = 0;
     total = 0.0;
     max = 0.0;
-    min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
-    while(cursor < xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times) - 1){
-      total += xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
-      if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) > max)
-        max = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
-      if(xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double) < min)
-        min = xbt_dynar_get_as(ct->libsimgrid_data_segment_comparison_times, cursor, double);
+    min = xbt_dynar_get_as(ct->libsimgrid_global_variables_comparison_times, cursor, double);
+    while(cursor < xbt_dynar_length(ct->libsimgrid_global_variables_comparison_times) - 1){
+      total += xbt_dynar_get_as(ct->libsimgrid_global_variables_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->libsimgrid_global_variables_comparison_times, cursor, double) > max)
+        max = xbt_dynar_get_as(ct->libsimgrid_global_variables_comparison_times, cursor, double);
+      if(xbt_dynar_get_as(ct->libsimgrid_global_variables_comparison_times, cursor, double) < min)
+        min = xbt_dynar_get_as(ct->libsimgrid_global_variables_comparison_times, cursor, double);
       cursor++;
     }
       cursor++;
     }
-    XBT_DEBUG("Libsimgrid data/bss segments comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->libsimgrid_data_segment_comparison_times), max, min);
+    XBT_DEBUG("Libsimgrid global variables comparison -- Different states : %lu/%d, time (in seconds) : average = %lf, max = %lf, min = %lf", xbt_dynar_length(ct->libsimgrid_global_variables_comparison_times), ct->nb_comparisons, total/xbt_dynar_length(ct->libsimgrid_global_variables_comparison_times), max, min);
   }
 
   if(xbt_dynar_length(ct->heap_comparison_times) > 0){
   }
 
   if(xbt_dynar_length(ct->heap_comparison_times) > 0){
@@ -179,8 +179,8 @@ mc_comparison_times_t new_comparison_times(){
   ct->snapshot_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->chunks_used_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->stacks_sizes_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->snapshot_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->chunks_used_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->stacks_sizes_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  ct->program_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
-  ct->libsimgrid_data_segment_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->binary_global_variables_comparison_times = xbt_dynar_new(sizeof(double), NULL);
+  ct->libsimgrid_global_variables_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->heap_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->stacks_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   return ct;
   ct->heap_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   ct->stacks_comparison_times = xbt_dynar_new(sizeof(double), NULL);
   return ct;
@@ -484,8 +484,8 @@ void pair_reached_free(mc_pair_reached_t pair){
       xbt_dynar_free(&(pair->comparison_times->snapshot_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->chunks_used_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->stacks_sizes_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->snapshot_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->chunks_used_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->stacks_sizes_comparison_times));
-      xbt_dynar_free(&(pair->comparison_times->program_data_segment_comparison_times));
-      xbt_dynar_free(&(pair->comparison_times->libsimgrid_data_segment_comparison_times));
+      xbt_dynar_free(&(pair->comparison_times->binary_global_variables_comparison_times));
+      xbt_dynar_free(&(pair->comparison_times->libsimgrid_global_variables_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->heap_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->stacks_comparison_times));
     }
       xbt_dynar_free(&(pair->comparison_times->heap_comparison_times));
       xbt_dynar_free(&(pair->comparison_times->stacks_comparison_times));
     }
index a518c18..fdf91f6 100644 (file)
@@ -247,8 +247,8 @@ typedef struct s_mc_comparison_times{
   xbt_dynar_t snapshot_comparison_times;
   xbt_dynar_t chunks_used_comparison_times;
   xbt_dynar_t stacks_sizes_comparison_times;
   xbt_dynar_t snapshot_comparison_times;
   xbt_dynar_t chunks_used_comparison_times;
   xbt_dynar_t stacks_sizes_comparison_times;
-  xbt_dynar_t program_data_segment_comparison_times;
-  xbt_dynar_t libsimgrid_data_segment_comparison_times;
+  xbt_dynar_t binary_global_variables_comparison_times;
+  xbt_dynar_t libsimgrid_global_variables_comparison_times;
   xbt_dynar_t heap_comparison_times;
   xbt_dynar_t stacks_comparison_times;
 }s_mc_comparison_times_t, *mc_comparison_times_t;
   xbt_dynar_t heap_comparison_times;
   xbt_dynar_t stacks_comparison_times;
 }s_mc_comparison_times_t, *mc_comparison_times_t;
@@ -414,4 +414,17 @@ void print_local_variables(xbt_dict_t list);
 char *get_libsimgrid_path(void);
 xbt_dict_t MC_get_location_list(const char *elf_file);
 
 char *get_libsimgrid_path(void);
 xbt_dict_t MC_get_location_list(const char *elf_file);
 
+/**** Global variables ****/
+
+typedef struct s_global_variable{
+  char *name;
+  size_t size;
+  void *address;
+}s_global_variable_t, *global_variable_t;
+
+void global_variable_free(global_variable_t v);
+void global_variable_free_voidp(void *v);
+
+extern xbt_dynar_t mc_global_variables;
+
 #endif
 #endif