aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Isaacson <adi@hexapodia.org>2010-06-11 23:36:15 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-06-17 12:55:54 -0400
commit0f2c3de2ba110626515234d5d584fb1b0c0749a2 (patch)
treee03dfb35a8cade9258f72d097f48ef49ac1a14c4
parent84c104ad429c8a474b93dd374815d1c238032fa8 (diff)
perf session: fix error message on failure to open perf.data
If we cannot open our data file, print strerror(errno) for a more comprehensible error message; and only suggest 'perf record' on ENOENT. In particular, this fixes the nonsensical advice when: % sudo perf record sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.009 MB perf.data (~381 samples) ] % perf trace failed to open file: perf.data (try 'perf record' first) % Cc: Ingo Molnar <mingo@elte.hu> LPU-Reference: <20100612033615.GA24731@hexapodia.org> Signed-off-by: Andy Isaacson <adi@hexapodia.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/session.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 8f83a1835766..0564a5cfb12e 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -27,8 +27,10 @@ static int perf_session__open(struct perf_session *self, bool force)
27 27
28 self->fd = open(self->filename, O_RDONLY); 28 self->fd = open(self->filename, O_RDONLY);
29 if (self->fd < 0) { 29 if (self->fd < 0) {
30 pr_err("failed to open file: %s", self->filename); 30 int err = errno;
31 if (!strcmp(self->filename, "perf.data")) 31
32 pr_err("failed to open %s: %s", self->filename, strerror(err));
33 if (err == ENOENT && !strcmp(self->filename, "perf.data"))
32 pr_err(" (try 'perf record' first)"); 34 pr_err(" (try 'perf record' first)");
33 pr_err("\n"); 35 pr_err("\n");
34 return -errno; 36 return -errno;