Skip to contentSkip to conversation

perf: annotate: make it respect -i option.

PATCH In review Wang Nan 3 participants 4 messages Apr 2, 2015 – Apr 21, 2015 perf events

lore
Share & tools
lore

Wang Nan

author
#0 lore raw

PATCH 1/1 perf: annotate: make it respect -i option.

There is a bug in perf annotate that it doesn't respect user provided '-i'/'--input' option:

 # perf record ls
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.001 MB perf.data (8 samples) ]
 # mv ./perf.data ./perf.data.new
 # perf annotate -i ./perf.data.new  --stdio
   failed to open perf.data: No such file or directory  (try 'perf record' first)

This patch fix it by setting file path after option parsing, like what 'perf report' does.

---
 tools/perf/builtin-annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-annotate.c +1 -1
index 71bf745..929f83c 100644
@@ -283,7 +283,6 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 		},
 	};
 	struct perf_data_file file = {
-		.path  = input_name,
 		.mode  = PERF_DATA_MODE_READ,
 	};
 	const struct option options[] = {
@@ -342,6 +341,7 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
 
 	setup_browser(true);
 
+	file.path  = input_name,
 	annotate.session = perf_session__new(&file, false, &annotate.tool);
 	if (annotate.session == NULL)
 		return -1;
Signature · 1 line
1.8.3.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Wang Nan

There is a bug in perf annotate that it doesn't respect user provided '-i'/'--input' option:

 # perf record ls
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.001 MB perf.data (8 samples) ]
 # mv ./perf.data ./perf.data.new
 # perf annotate -i ./perf.data.new  --stdio
   failed to open perf.data: No such file or directory  (try 'perf record' first)
Quoted 4 lines

This patch fix it by setting file path after option parsing, like what 'perf report' does.

I guess other commands are also suffered from this bug.. anyway,

Thanks,
Namhyung

author
#2 lore raw
Quoted 14 lines · Namhyung Kim
Quoted 13 lines · Wang Nan

There is a bug in perf annotate that it doesn't respect user provided '-i'/'--input' option:

 # perf record ls
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.001 MB perf.data (8 samples) ]
 # mv ./perf.data ./perf.data.new
 # perf annotate -i ./perf.data.new  --stdio
   failed to open perf.data: No such file or directory  (try 'perf record' first)

This patch fix it by setting file path after option parsing, like what 'perf report' does.

Quoted 9 lines
Quoted 1 line

I guess other commands are also suffered from this bug.. anyway,

Thanks,
Namhyung

Hi,

Looks like the next patch 'perf kmem: Respect -i option' has already been collected by tip/master, but this patch is lost. Is there any problem?

Thank you!

#3 lore raw

PATCH 1/1 perf kmem: Respect -i option

In reply to Wang Nan
Quoted 10 lines · Wang Nan

There is a bug in perf annotate that it doesn't respect user provided '-i'/'--input' option:

 # perf record ls
   [ perf record: Woken up 1 times to write data ]
   [ perf record: Captured and wrote 0.001 MB perf.data (8 samples) ]
 # mv ./perf.data ./perf.data.new
 # perf annotate -i ./perf.data.new  --stdio
   failed to open perf.data: No such file or directory  (try 'perf record' first)
Quoted 4 lines

This patch fix it by setting file path after option parsing, like what 'perf report' does.

plus found another in kmem.. ;-)

thanks,
jirka

---
Currently the perf kmem does not respect -i option. Initializing the file.path properly after options get parsed.

---
 tools/perf/builtin-kmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/builtin-kmem.c +2 -1
index 64d3623d45a0..c81e24870e7b 100644
@@ -684,7 +684,6 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 	};
 	struct perf_session *session;
 	struct perf_data_file file = {
-		.path = input_name,
 		.mode = PERF_DATA_MODE_READ,
 	};
 	int ret = -1;
@@ -700,6 +699,8 @@ int cmd_kmem(int argc, const char **argv, const char *prefix __maybe_unused)
 		return __cmd_record(argc, argv);
 	}
 
+	file.path = input_name;
+
 	session = perf_session__new(&file, false, &perf_kmem);
 	if (session == NULL)
 		return -1;
Signature · 1 line
1.9.3