Commits

Wez Furlong  committed b265c5b

move memory map printing to be formally triggered by the glider, not
implicitly by looking up a mapping.

  • Participants
  • Parent commits 06e89ce
  • Branches onering

Comments (0)

Files changed (4)

   }
 
   gimli_load_modules(the_proc);
+  gimli_show_memory_map(the_proc);
   gimli_proc_visit_threads(the_proc, trace_thread, &args);
 
   printf("\n");
     gimli_proc_t proc, gimli_stack_frame_t frame,
     const char *varname, gimli_type_t t,
     gimli_addr_t addr, int depth);
+void gimli_show_memory_map(gimli_proc_t proc);
 
 /* ensure that the table size is a power of 2 */
 static inline uint32_t power_2(uint32_t x)
 /*
- * Copyright (c) 2008-2011 Message Systems, Inc. All rights reserved
+ * Copyright (c) 2008-2012 Message Systems, Inc. All rights reserved
  * For licensing information, see:
  * https://bitbucket.org/wez/gimli/src/tip/LICENSE
  */
   return 1;
 }
 
+void gimli_show_memory_map(gimli_proc_t proc)
+{
+  int i;
+  /* print out the maps, coalesce adjacent maps for the same object */
+  printf("\nMEMORY MAP: (executable, shared objects and named mmaps)\n");
+  i = 0;
+  while (i < proc->nmaps) {
+    int j;
+    struct gimli_object_mapping *map = proc->mappings[i];
+    uint64_t upper = map->base + map->len;
+
+    for (j = i + 1; j < proc->nmaps; j++) {
+      struct gimli_object_mapping *om = proc->mappings[j];
+
+      if (om->objfile == map->objfile && om->base == upper) {
+        upper = om->base + om->len;
+        i = j;
+        continue;
+      }
+      break;
+    }
+
+    printf(PTRFMT " - " PTRFMT " %s\n",
+        map->base, upper, map->objfile->objname);
+    i++;
+  }
+  printf("\n\n");
+}
+
 struct gimli_object_mapping *gimli_mapping_for_addr(gimli_proc_t proc, gimli_addr_t addr)
 {
   struct gimli_object_mapping **mptr, *m;
 
   if (proc->maps_changed) {
-    int i;
-
     /* (re)sort the list of maps */
     qsort(proc->mappings, proc->nmaps, sizeof(struct gimli_object_mapping*),
         sort_compare_mapping);
     proc->maps_changed = 0;
-
-    /* print out the maps, coalesce adjacent maps for the same object */
-    printf("\nMEMORY MAP: (executable, shared objects and named mmaps)\n");
-    i = 0;
-    while (i < proc->nmaps) {
-      int j;
-      struct gimli_object_mapping *map = proc->mappings[i];
-      uint64_t upper = map->base + map->len;
-
-      for (j = i + 1; j < proc->nmaps; j++) {
-        struct gimli_object_mapping *om = proc->mappings[j];
-
-        if (om->objfile == map->objfile && om->base == upper) {
-          upper = om->base + om->len;
-          i = j;
-          continue;
-        }
-        break;
-      }
-
-      printf(PTRFMT " - " PTRFMT " %s\n",
-          map->base, upper, map->objfile->objname);
-      i++;
-    }
-    printf("\n\n");
   }
 
   mptr = bsearch(&addr, proc->mappings, proc->nmaps, sizeof(struct gimli_object_mapping*),