]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
perf record: Fix filemap pathname parsing in /proc/pid/maps
authorJohannes Weiner <hannes@cmpxchg.org>
Wed, 24 Jun 2009 19:08:36 +0000 (21:08 +0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 25 Jun 2009 09:35:58 +0000 (11:35 +0200)
Looking backward for the first space from the end of a line in
/proc/pid/maps does not find the start of the pathname of the mapped
file if it contains a space.

Since the only slashes we have in this file occur in the (absolute!)
pathname column of file mappings, looking for the first slash in a
line is a safe method to find the name.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Stefani Seibold <stefani@seibold.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20090624190835.GA25548@cmpxchg.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
tools/perf/builtin-record.c

index d7ebbd7575432f12c53109dc8c51054dd4a25f76..9b899ba1b410816dbf216e73345012e67e0bee09 100644 (file)
@@ -306,12 +306,11 @@ static void pid_synthesize_mmap_samples(pid_t pid)
                        continue;
                pbf += n + 3;
                if (*pbf == 'x') { /* vm_exec */
-                       char *execname = strrchr(bf, ' ');
+                       char *execname = strchr(bf, '/');
 
-                       if (execname == NULL || execname[1] != '/')
+                       if (execname == NULL)
                                continue;
 
-                       execname += 1;
                        size = strlen(execname);
                        execname[size - 1] = '\0'; /* Remove \n */
                        memcpy(mmap_ev.filename, execname, size);