From: tip-bot for Jiri Olsa <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: namhyung@kernel.org, mingo@kernel.org, matt@codeblueprint.co.uk,
jolsa@kernel.org, linux-kernel@vger.kernel.org,
a.p.zijlstra@chello.nl, tglx@linutronix.de, acme@redhat.com,
dsahern@gmail.com, hpa@zytor.com, raphael.beamonte@gmail.com
Subject: [tip:perf/core] perf tools: Enhance parsing events tracepoint error output
Date: Wed, 16 Sep 2015 00:29:57 -0700 [thread overview]
Message-ID: <tip-196581717d85f59365dc9303685cd5b1cdf106a3@git.kernel.org> (raw)
In-Reply-To: <1441615087-13886-6-git-send-email-jolsa@kernel.org>
Commit-ID: 196581717d85f59365dc9303685cd5b1cdf106a3
Gitweb: http://git.kernel.org/tip/196581717d85f59365dc9303685cd5b1cdf106a3
Author: Jiri Olsa <jolsa@kernel.org>
AuthorDate: Mon, 7 Sep 2015 10:38:07 +0200
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 15 Sep 2015 09:48:33 -0300
perf tools: Enhance parsing events tracepoint error output
Enhancing parsing events tracepoint error output. Adding
more verbose output when the tracepoint is not found or
the tracing event path cannot be access.
$ sudo perf record -e sched:sched_krava ls
event syntax error: 'sched:sched_krava'
\___ unknown tracepoint
Error: File /sys/kernel/debug/tracing//tracing/events/sched/sched_krava not found.
Hint: Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
Run 'perf list' for a list of valid events
...
$ perf record -e sched:sched_krava ls
event syntax error: 'sched:sched_krava'
\___ can't access trace events
Error: No permissions to read /sys/kernel/debug/tracing//tracing/events/sched/sched_krava
Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug'
Run 'perf list' for a list of valid events
...
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1441615087-13886-6-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-events.c | 35 ++++++++++++++++++++++++++++++++---
tools/perf/util/parse-events.y | 16 +++++++++-------
2 files changed, 41 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index c47831c..d3fb90b 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -387,6 +387,33 @@ int parse_events_add_cache(struct list_head *list, int *idx,
return add_event(list, idx, &attr, name, NULL);
}
+static void tracepoint_error(struct parse_events_error *error, int err,
+ char *sys, char *name)
+{
+ char help[BUFSIZ];
+
+ /*
+ * We get error directly from syscall errno ( > 0),
+ * or from encoded pointer's error ( < 0).
+ */
+ err = abs(err);
+
+ switch (err) {
+ case EACCES:
+ error->str = strdup("can't access trace events");
+ break;
+ case ENOENT:
+ error->str = strdup("unknown tracepoint");
+ break;
+ default:
+ error->str = strdup("failed to add tracepoint");
+ break;
+ }
+
+ tracing_path__strerror_open_tp(err, help, sizeof(help), sys, name);
+ error->help = strdup(help);
+}
+
static int add_tracepoint(struct list_head *list, int *idx,
char *sys_name, char *evt_name,
struct parse_events_error *error __maybe_unused)
@@ -394,8 +421,10 @@ static int add_tracepoint(struct list_head *list, int *idx,
struct perf_evsel *evsel;
evsel = perf_evsel__newtp_idx(sys_name, evt_name, (*idx)++);
- if (IS_ERR(evsel))
+ if (IS_ERR(evsel)) {
+ tracepoint_error(error, PTR_ERR(evsel), sys_name, evt_name);
return PTR_ERR(evsel);
+ }
list_add_tail(&evsel->node, list);
return 0;
@@ -413,7 +442,7 @@ static int add_tracepoint_multi_event(struct list_head *list, int *idx,
snprintf(evt_path, MAXPATHLEN, "%s/%s", tracing_events_path, sys_name);
evt_dir = opendir(evt_path);
if (!evt_dir) {
- perror("Can't open event dir");
+ tracepoint_error(error, errno, sys_name, evt_name);
return -1;
}
@@ -453,7 +482,7 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
events_dir = opendir(tracing_events_path);
if (!events_dir) {
- perror("Can't open event dir");
+ tracepoint_error(error, errno, sys_name, evt_name);
return -1;
}
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 54a3004..8bcc458 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -371,28 +371,30 @@ event_legacy_tracepoint:
PE_NAME '-' PE_NAME ':' PE_NAME
{
struct parse_events_evlist *data = _data;
+ struct parse_events_error *error = data->error;
struct list_head *list;
char sys_name[128];
snprintf(&sys_name, 128, "%s-%s", $1, $3);
ALLOC_LIST(list);
- ABORT_ON(parse_events_add_tracepoint(list, &data->idx, &sys_name, $5, data->error));
+ if (parse_events_add_tracepoint(list, &data->idx, &sys_name, $5, error)) {
+ if (error)
+ error->idx = @1.first_column;
+ return -1;
+ }
$$ = list;
}
|
PE_NAME ':' PE_NAME
{
struct parse_events_evlist *data = _data;
+ struct parse_events_error *error = data->error;
struct list_head *list;
ALLOC_LIST(list);
- if (parse_events_add_tracepoint(list, &data->idx, $1, $3, data->error)) {
- struct parse_events_error *error = data->error;
-
- if (error) {
+ if (parse_events_add_tracepoint(list, &data->idx, $1, $3, error)) {
+ if (error)
error->idx = @1.first_column;
- error->str = strdup("unknown tracepoint");
- }
return -1;
}
$$ = list;
prev parent reply other threads:[~2015-09-16 7:30 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-07 8:38 [PATCHv2 0/5] perf tools: Enhance parsing events tracepoint error output Jiri Olsa
2015-09-07 8:38 ` [PATCH 1/5] tools: Add err.h with ERR_PTR PTR_ERR interface Jiri Olsa
2015-09-08 20:22 ` Raphaël Beamonte
2015-09-08 20:24 ` Raphaël Beamonte
2015-09-08 21:06 ` Arnaldo Carvalho de Melo
2015-09-08 21:28 ` Raphaël Beamonte
2015-09-08 21:29 ` Raphaël Beamonte
2015-09-16 7:28 ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-09-21 23:41 ` Vinson Lee
2015-09-29 6:35 ` Vinson Lee
2015-09-29 7:14 ` Jiri Olsa
2015-09-29 7:20 ` Jiri Olsa
2015-09-29 7:52 ` He Kuang
2015-09-29 7:57 ` Jiri Olsa
2015-09-29 8:15 ` He Kuang
2015-09-29 10:41 ` Jiri Olsa
2015-09-29 14:52 ` Arnaldo Carvalho de Melo
2015-09-29 15:05 ` [PATCH] perf tool: Fix shadowed declaration in parse-events.c Jiri Olsa
2015-10-01 7:10 ` [tip:perf/core] perf tools: " tip-bot for Jiri Olsa
2015-09-07 8:38 ` [PATCH 2/5] perf tools: Add tools/include into tags directories Jiri Olsa
2015-09-15 7:02 ` [tip:perf/core] perf tools: Add tools/ include " tip-bot for Jiri Olsa
2015-09-07 8:38 ` [PATCH 3/5] perf tools: Propagate error info for the tracepoint parsing Jiri Olsa
2015-09-08 21:42 ` Raphaël Beamonte
2015-09-09 7:50 ` Jiri Olsa
2015-09-12 10:54 ` Matt Fleming
2015-09-16 7:29 ` [tip:perf/core] " tip-bot for Jiri Olsa
2015-09-07 8:38 ` [PATCH 4/5] perf tools: Propagate error info from tp_format Jiri Olsa
2015-09-09 20:58 ` Arnaldo Carvalho de Melo
2015-09-10 8:24 ` Jiri Olsa
2015-09-10 14:16 ` Arnaldo Carvalho de Melo
2015-09-14 20:53 ` Arnaldo Carvalho de Melo
2015-09-14 20:59 ` Raphaël Beamonte
2015-09-14 21:36 ` Arnaldo Carvalho de Melo
2015-09-14 22:05 ` Raphaël Beamonte
2015-09-15 2:35 ` Arnaldo Carvalho de Melo
2015-09-14 21:02 ` Arnaldo Carvalho de Melo
2015-09-16 7:29 ` [tip:perf/core] perf evsel: " tip-bot for Jiri Olsa
2015-09-07 8:38 ` [PATCH 5/5] perf tools: Enhance parsing events tracepoint error output Jiri Olsa
2015-09-10 7:00 ` Namhyung Kim
2015-09-10 8:05 ` Jiri Olsa
2015-09-11 16:09 ` Namhyung Kim
2015-09-11 16:16 ` Jiri Olsa
2015-09-11 17:50 ` Raphaël Beamonte
2015-09-11 18:55 ` Arnaldo Carvalho de Melo
2015-09-11 19:56 ` Raphaël Beamonte
2015-09-11 20:22 ` Arnaldo Carvalho de Melo
2015-09-11 22:01 ` Raphaël Beamonte
2015-09-14 20:59 ` Arnaldo Carvalho de Melo
2015-09-16 7:29 ` tip-bot for Jiri Olsa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-196581717d85f59365dc9303685cd5b1cdf106a3@git.kernel.org \
--to=tipbot@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=raphael.beamonte@gmail.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).