Re: [PATCH] perf tools: handle spaces in file names obtained from /proc/pid/maps
From: Marcin Ålusarz
Date: Thu Jan 07 2016 - 18:16:16 EST
On Mon, Jan 04, 2016 at 10:25:28AM +0900, Namhyung Kim wrote:
> Hi Marcin,
>
> On Fri, Jan 01, 2016 at 04:03:21AM +0100, Marcin Ålusarz wrote:
> > Steam frequently puts game binaries in folders with spaces.
> >
> > Note: "(deleted)" markers are now treated as part of the file name.
> >
> > It probably worked before 6064803313bad9ae4cae233a9d56678adb2b6e7c
> > ("perf tools: Use sscanf for parsing /proc/pid/maps").
> >
> > Signed-off-by: Marcin Ålusarz <marcin.slusarz@xxxxxxxxx>
> > Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> > Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> > ---
> > tools/perf/util/event.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> > index 8b10621..ff17fe6 100644
> > --- a/tools/perf/util/event.c
> > +++ b/tools/perf/util/event.c
> > @@ -274,7 +274,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
> > strcpy(execname, "");
> >
> > /* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
> > - n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %s\n",
> > + n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %[^\n]s\n",
>
> Is the last 's' necessary?
Nope. It should not be there.
---
From: Marcin Ålusarz <marcin.slusarz@xxxxxxxxx>
Subject: [PATCH v2] perf tools: handle spaces in file names obtained from /proc/pid/maps
Steam frequently puts game binaries in folders with spaces.
Note: "(deleted)" markers are now treated as part of the file name.
It probably worked before 6064803313bad9ae4cae233a9d56678adb2b6e7c
("perf tools: Use sscanf for parsing /proc/pid/maps").
Signed-off-by: Marcin Ålusarz <marcin.slusarz@xxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 8b10621..956187b 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -274,7 +274,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
strcpy(execname, "");
/* 00400000-0040c000 r-xp 00000000 fd:01 41038 /bin/cat */
- n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %s\n",
+ n = sscanf(bf, "%"PRIx64"-%"PRIx64" %s %"PRIx64" %x:%x %u %[^\n]\n",
&event->mmap2.start, &event->mmap2.len, prot,
&event->mmap2.pgoff, &event->mmap2.maj,
&event->mmap2.min,
--
2.1.4