From: Andi Kleen <andi@firstfloor.org>
To: acme@ghostprotocols.net
Cc: jolsa@redhat.com, linux-kernel@vger.kernel.org,
Andi Kleen <ak@linux.intel.com>
Subject: [PATCH] perf, tools: Add some more error messages to event parser
Date: Sun, 1 Mar 2015 12:09:29 -0800 [thread overview]
Message-ID: <1425240569-1759-1-git-send-email-andi@firstfloor.org> (raw)
From: Andi Kleen <ak@linux.intel.com>
When you have a long event list and perf doesn't like it, it can be
quite difficult to figure out which event was actually the problem.
In several cases I had to resort to binary search.
This patch adds error messages to some easy cases which already
helps somewhat. It's not complete. Best would be to make the ABORT_ON macro
in the parser print the current term, but that would need
much more changes in the lexer/scanner to be able to reconstruct
all strings.
So it's not complete, but at least it's a baby step.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
tools/perf/util/parse-events.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 7f8ec6c..0dfe3da 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -338,8 +338,10 @@ int parse_events_add_cache(struct list_head *list, int *idx,
*/
cache_type = parse_aliases(type, perf_evsel__hw_cache,
PERF_COUNT_HW_CACHE_MAX);
- if (cache_type == -1)
+ if (cache_type == -1) {
+ pr_err("Invalid cache type %s\n", type);
return -EINVAL;
+ }
n = snprintf(name, MAX_NAME_LEN, "%s", type);
@@ -513,6 +515,7 @@ do { \
CHECK_SET_TYPE(HW_BREAKPOINT_X);
break;
default:
+ pr_err("Invalid breakpoint type %s\n", type);
return -EINVAL;
}
}
@@ -649,8 +652,10 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
struct perf_evsel *evsel;
pmu = perf_pmu__find(name);
- if (!pmu)
+ if (!pmu) {
+ pr_err("Cannot find PMU %s\n", name);
return -EINVAL;
+ }
if (pmu->default_config) {
memcpy(&attr, pmu->default_config,
@@ -674,8 +679,10 @@ int parse_events_add_pmu(struct list_head *list, int *idx,
*/
config_attr(&attr, head_config, 0);
- if (perf_pmu__config(pmu, &attr, head_config))
+ if (perf_pmu__config(pmu, &attr, head_config)) {
+ pr_err("Cannot configure PMU %s\n", name);
return -EINVAL;
+ }
evsel = __add_event(list, idx, &attr, pmu_event_name(head_config),
pmu->cpus);
@@ -792,8 +799,10 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
*
* See also PERF_RECORD_MISC_EXACT_IP
*/
- if (precise > 3)
+ if (precise > 3) {
+ pr_err("Invalid precise level\n");
return -EINVAL;
+ }
mod->eu = eu;
mod->ek = ek;
@@ -817,8 +826,10 @@ static int check_modifier(char *str)
char *p = str;
/* The sizeof includes 0 byte as well. */
- if (strlen(str) > (sizeof("ukhGHpppSD") - 1))
+ if (strlen(str) > (sizeof("ukhGHpppSD") - 1)) {
+ pr_err("Too many modifiers\n");
return -1;
+ }
while (*p) {
if (*p != 'p' && strchr(p + 1, *p))
--
2.2.2
reply other threads:[~2015-03-01 20:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1425240569-1759-1-git-send-email-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=acme@ghostprotocols.net \
--cc=ak@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®