]> git.itanic.dy.fi Git - scan-pagemap/blobdiff - parse.c
Show full process argument list instead only executable name
[scan-pagemap] / parse.c
diff --git a/parse.c b/parse.c
index 671ec507f996d75496cb3db4f8f66aa92d371104..0c9ac14ce5a5ba2463ca1327b1bde1f774f0fd6d 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Timo Kokkonen <kaapeli@itanic.dy.fi>
+ * Copyright (C) 2010 Timo Kokkonen <timo.t.kokkonen@iki.fi>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -61,7 +61,7 @@ static struct maps *parse_maps(FILE *file, int pid, int tid)
        while (fgets(line, sizeof(line), file)) {
                struct maps *map = alloc_map();
                unsigned long start, end;
-               char name[1024];
+               int skip;
 
                if (map == NULL)
                        return 0;
@@ -69,8 +69,8 @@ static struct maps *parse_maps(FILE *file, int pid, int tid)
                if (the_map == NULL)
                        the_map = map;
 
-               ret = sscanf(line, "%lx-%lx %*s %*s %*s %*s %s",
-                            &start, &end, name);
+               ret = sscanf(line, "%lx-%lx %*s %*s %*s %*s %n",
+                            &start, &end, &skip);
 
                if (ret < 2) {
                        printf("Error reading input: %s\n", line);
@@ -83,8 +83,10 @@ static struct maps *parse_maps(FILE *file, int pid, int tid)
                map->pid = pid;
                map->tid = tid;
 
-               if (ret >= 3)
-                       strncpy(map->name, name, sizeof(map->name));
+               strncpy(map->name, line + skip, sizeof(map->name) - 1);
+
+               /* zero out the newline */
+               map->name[MAX(strlen(map->name) - 1, 0)] = '\0';
 
                list_add_tail(&map->list, &the_map->list);
        }