diff --git a/examples/procmap.c b/examples/procmap.c index 2c0ff929..4277e5b0 100644 --- a/examples/procmap.c +++ b/examples/procmap.c @@ -116,24 +116,41 @@ main (int argc, char *argv []) device_minor = (device & 255); device_major = ((device >> 8) & 255); - if (filename) - fprintf (stderr, "%08lx-%08lx %08lx - " - "%02x:%02x %08lu - %4s - %s\n", + if (filename) { + char *format; + + if (sizeof (void*) == 8) + format = "%016lx-%016lx %016lx - " + "%02x:%02x %08lu - %4s - %s\n"; + else + format = "%08lx-%08lx %08lx - " + "%02x:%02x %08lu - %4s - %s\n"; + + fprintf (stderr, format, (unsigned long) maps [i].start, (unsigned long) maps [i].end, (unsigned long) maps [i].offset, device_major, device_minor, (unsigned long) maps [i].inode, perm, filename); - else - fprintf (stderr, "%08lx-%08lx %08lx - " - "%02x:%02x %08lu - %4s\n", + } else { + char * format; + + if (sizeof (void*) == 8) + format = "%016lx-%016lx %016lx - " + "%02x:%02x %08lu - %4s\n"; + else + format = "%08lx-%08lx %08lx - " + "%02x:%02x %08lu - %4s\n"; + + fprintf (stderr, format, (unsigned long) maps [i].start, (unsigned long) maps [i].end, (unsigned long) maps [i].offset, device_major, device_minor, (unsigned long) maps [i].inode, perm); + } if (filename && (filename != maps [i].filename)) glibtop_free (filename); diff --git a/sysdeps/linux/procmap.c b/sysdeps/linux/procmap.c index 7109f574..d77dd912 100644 --- a/sysdeps/linux/procmap.c +++ b/sysdeps/linux/procmap.c @@ -66,11 +66,15 @@ glibtop_get_proc_map_s (glibtop *server, glibtop_proc_map *buf, pid_t pid) do { short dev_major, dev_minor; unsigned long start, end, offset, inode, perm; - char flags [5]; + char flags [5], *format; size_t size; - rv = fscanf (maps, - "%08lx-%08lx %4c\n %08lx %02hx:%02hx %ld", + if (sizeof (void*) == 8) + format = "%16lx-%16lx %4c\n %16lx %02hx:%02hx %ld"; + else + format = "%08lx-%08lx %4c\n %08lx %02hx:%02hx %ld"; + + rv = fscanf (maps, format, &start, &end, flags, &offset, &dev_major, &dev_minor, &inode);