Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove unused function.
[simgrid.git] / src / mc / mc_checkpoint.c
index 411747a..1a80fd5 100644 (file)
@@ -15,7 +15,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
                                 "Logging specific to mc_checkpoint");
 
 void *start_text_libsimgrid;
-void *start_plt, *end_plt;
+void *start_plt_libsimgrid, *end_plt_libsimgrid;
+void *start_plt_binary, *end_plt_binary;
 char *libsimgrid_path;
 void *start_data_libsimgrid;
 void *start_text_binary;
@@ -28,9 +29,9 @@ static void MC_snapshot_add_region(mc_snapshot_t snapshot, int type, void *start
 
 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 xbt_strbuff_t get_local_variables_values(stack_region_t stack, void *heap);
+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(stack_region_t stack, void *heap);
+static void *get_stack_pointer(void *stack_context, void *heap);
 
 static mc_mem_region_t MC_region_new(int type, void *start_addr, size_t size)
 {
@@ -168,7 +169,7 @@ void MC_free_snapshot(mc_snapshot_t snapshot)
 }
 
 
-void get_plt_section(){
+void get_libsimgrid_plt_section(){
 
   FILE *fp;
   char *line = NULL;            /* Temporal storage for each line that is readed */
@@ -206,12 +207,69 @@ void get_plt_section(){
       lfields[i] = strtok(NULL, " ");
     }
 
-    if(i>=5){
+    if(i>=6){
       if(strcmp(lfields[1], ".plt") == 0){
         size = strtoul(lfields[2], NULL, 16);
-        offset = strtoul(lfields[4], NULL, 16);
-        start_plt = (char *)start_text_libsimgrid + offset;
-        end_plt = (char *)start_plt + size;
+        offset = strtoul(lfields[5], NULL, 16);
+        start_plt_libsimgrid = (char *)start_text_libsimgrid + offset;
+        end_plt_libsimgrid = (char *)start_plt_libsimgrid + size;
+        plt_not_found = 0;
+      }
+    }
+    
+    
+  }
+
+  free(command);
+  free(line);
+  pclose(fp);
+
+}
+
+void get_binary_plt_section(){
+
+  FILE *fp;
+  char *line = NULL;            /* Temporal storage for each line that is readed */
+  ssize_t read;                 /* Number of bytes readed */
+  size_t n = 0;                 /* Amount of bytes to read by getline */
+
+  char *lfields[7];
+  int i, plt_not_found = 1;
+  unsigned long int size, offset;
+
+  char *command = bprintf( "objdump --section-headers %s", xbt_binary_name);
+
+  fp = popen(command, "r");
+
+  if(fp == NULL)
+    perror("popen failed");
+
+  while ((read = getline(&line, &n, fp)) != -1 && plt_not_found == 1) {
+
+    if(n == 0)
+      continue;
+
+    /* Wipeout the new line character */
+    line[read - 1] = '\0';
+
+    lfields[0] = strtok(line, " ");
+
+    if(lfields[0] == NULL)
+      continue;
+
+    if(strcmp(lfields[0], "Sections:") == 0 || strcmp(lfields[0], "Idx") == 0 || strcmp(lfields[0], basename(xbt_binary_name)) == 0)
+      continue;
+
+    for (i = 1; i < 7 && lfields[i - 1] != NULL; i++) {
+      lfields[i] = strtok(NULL, " ");
+    }
+
+    if(i>=6){
+      if(strcmp(lfields[1], ".plt") == 0){
+        size = strtoul(lfields[2], NULL, 16);
+        offset = strtoul(lfields[5], NULL, 16);
+        start_plt_binary = (char *)start_text_binary + offset;
+        end_plt_binary = (char *)start_plt_binary + size;
         plt_not_found = 0;
       }
     }
@@ -245,7 +303,7 @@ static xbt_dynar_t take_snapshot_stacks(void *heap){
   
   xbt_dynar_foreach(stacks_areas, cursor1, current_stack){
     mc_snapshot_stack_t st = xbt_new(s_mc_snapshot_stack_t, 1);
-    st->local_variables = get_local_variables_values(current_stack, heap);
+    st->local_variables = get_local_variables_values(current_stack->context, heap);
     st->stack_pointer = get_stack_pointer(current_stack, heap);
     xbt_dynar_push(res, &st);
   }
@@ -254,13 +312,13 @@ static xbt_dynar_t take_snapshot_stacks(void *heap){
 
 }
 
-static void *get_stack_pointer(stack_region_t stack, void *heap){
+static void *get_stack_pointer(void *stack_context, void *heap){
 
   unw_cursor_t c;
   int ret;
   unw_word_t sp;
 
-  ret = unw_init_local(&c, (unw_context_t *)&(((smx_ctx_sysv_t)(stack->address))->uc));
+  ret = unw_init_local(&c, (unw_context_t *)stack_context);
   if(ret < 0){
     XBT_INFO("unw_init_local failed");
     xbt_abort();
@@ -272,21 +330,21 @@ static void *get_stack_pointer(stack_region_t stack, void *heap){
 
 }
 
-static xbt_strbuff_t get_local_variables_values(stack_region_t stack, void *heap){
+static xbt_strbuff_t get_local_variables_values(void *stack_context, void *heap){
   
   unw_cursor_t c;
   int ret;
-  char *stack_name;
+  //char *stack_name;
 
   char buf[512], frame_name[256];
   
-  ret = unw_init_local(&c, (unw_context_t *)&(((smx_ctx_sysv_t)(stack->address))->uc));
+  ret = unw_init_local(&c, (unw_context_t *)stack_context);
   if(ret < 0){
     XBT_INFO("unw_init_local failed");
     xbt_abort();
   }
 
-  stack_name = strdup(((smx_process_t)((smx_ctx_sysv_t)(stack->address))->super.data)->name);
+  //stack_name = strdup(((smx_process_t)((smx_ctx_sysv_t)(stack->address))->super.data)->name);
 
   unw_word_t ip, sp, off;
   dw_frame_t frame;
@@ -445,7 +503,7 @@ static xbt_strbuff_t get_local_variables_values(stack_region_t stack, void *heap
      
   }
 
-  free(stack_name);
+  //free(stack_name);
 
   return variables;