Skip to contentSkip to conversation

perf tools: handle spaces in file names obtained from /proc/pid/maps

PATCH Superseded Marcin Ślusarz 4 participants 8 messages Jan 1, 2016 – Feb 9, 2016 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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").

Cc Namhyung Kim <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index 8b10621..ff17fe6 100644
@@ -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",
 		       &event->mmap2.start, &event->mmap2.len, prot,
 		       &event->mmap2.pgoff, &event->mmap2.maj,
 		       &event->mmap2.min,
Signature · 1 line
2.1.4
maintainer
#1 lore raw

Hi Marcin,

Quoted 19 lines · Marcin Ślusarz

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").

Cc Namhyung Kim <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +0 -0
index 8b10621..ff17fe6 100644

tools/perf/util/event.c int perf_event__synthesize_mmap_events(struct perf_tool *tool, · line 277

Quoted 5 lines
tools/perf/util/event.c +1 -1
@@ -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?

Thanks,
Namhyung

Quoted 6 lines
tools/perf/util/event.c +0 -0
 		       &event->mmap2.start, &event->mmap2.len, prot,
 		       &event->mmap2.pgoff, &event->mmap2.maj,
 		       &event->mmap2.min,
Signature · 1 line
2.1.4
#2 lore raw
Quoted 24 lines · Namhyung Kim

Hi Marcin,

Quoted 21 lines · Marcin Ślusarz

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").

Cc Namhyung Kim <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +0 -0
index 8b10621..ff17fe6 100644
@@ -274,7 +274,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
 		strcpy(execname, "");
 
Quoted 5 lines

tools/perf/util/event.c int perf_event__synthesize_mmap_events(struct perf_tool *tool, · line 277

Quoted 3 lines
tools/perf/util/event.c +1 -1
 		/* 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 <[email protected]>
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").

Cc Namhyung Kim <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index 8b10621..956187b 100644
@@ -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,
Signature · 1 line
2.1.4
maintainer Acked-by
#3 lore raw
Quoted 5 lines

From: Marcin Ślusarz <[email protected]>
Subject: [PATCH v2] perf tools: handle spaces in file names obtained from /proc/pid/maps

Steam frequently puts game binaries in folders with spaces.

Quoted 7 lines

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").

Cc Arnaldo Carvalho de Melo <[email protected]>

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index 8b10621..956187b 100644
@@ -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,
Signature · 1 line
2.1.4
#4 lore raw

PATCH v2 1/1 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").

---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index 8b10621..956187b 100644
@@ -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,
Signature · 1 line
2.1.4
#5 lore raw
Quoted 10 lines · Marcin Ślusarz

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").

Gentle ping ;)

Quoted 20 lines
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index 8b10621..956187b 100644
@@ -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,
Signature · 1 line
2.1.4
#6 lore raw

Em Thu, Feb 04, 2016 at 11:39:25PM +0100, Marcin Ślusarz escreveu:

Quoted 5 lines · Marcin Ślusarz
Quoted 4 lines

Steam frequently puts game binaries in folders with spaces.

Note: "(deleted)" markers are now treated as part of the file name.

Quoted 8 lines
Quoted 6 lines

It probably worked before 6064803313bad9ae4cae233a9d56678adb2b6e7c ("perf tools: Use sscanf for parsing /proc/pid/maps").

Gentle ping ;)

Thanks for being gentle, appreciated ;-)

Applied to perf/core,

- Arnaldo

Quoted 20 lines
Quoted 20 lines
---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index 8b10621..956187b 100644
@@ -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,
Signature · 1 line
2.1.4
#7 lore raw
In reply to Marcin Ślusarz
perf tools: handle spaces in file names obtained from /proc/pid/maps
Commit-ID:  89fee59b504f86925894fcc9ba79d5c933842f93
Gitweb:     http://git.kernel.org/tip/89fee59b504f86925894fcc9ba79d5c933842f93
Author:     Marcin Ślusarz <[email protected]>
AuthorDate: Tue, 19 Jan 2016 20:03:03 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 5 Feb 2016 09:39:56 -0300

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.

---
 tools/perf/util/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/event.c +1 -1
index 85155e9..7bad5c3 100644
@@ -282,7 +282,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,