Skip to contentSkip to conversation

perf report: Print more expressive message in case of file open error

tip:perfcounters/core tip-bot for Ingo Molnar 1 participant 1 message Jun 7, 2009 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  a14832ff977e78d1982cdf78cdabb1f2320d9ac8
Gitweb:     http://git.kernel.org/tip/a14832ff977e78d1982cdf78cdabb1f2320d9ac8
Author:     Ingo Molnar <[email protected]>
AuthorDate: Sun, 7 Jun 2009 17:58:23 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sun, 7 Jun 2009 17:58:23 +0200

perf report: Print more expressive message in case of file open error

Before:

 $ perf report
 failed to open file: No such file or directory

After:

 $ perf report
  failed to open file: perf.data  (try 'perf record' first)

Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
LKML-Reference: <new-submission>

---
 tools/perf/builtin-report.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/builtin-report.c +4 -1
index 242e09f..f053a74 100644
@@ -1120,7 +1120,10 @@ static int __cmd_report(void)
 
 	input = open(input_name, O_RDONLY);
 	if (input < 0) {
-		perror("failed to open file");
+		fprintf(stderr, " failed to open file: %s", input_name);
+		if (!strcmp(input_name, "perf.data"))
+			fprintf(stderr, "  (try 'perf record' first)");
+		fprintf(stderr, "\n");
 		exit(-1);
 	}