From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753428AbbCAUKp (ORCPT ); Sun, 1 Mar 2015 15:10:45 -0500 Received: from one.firstfloor.org ([193.170.194.197]:41652 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751143AbbCAUKn (ORCPT ); Sun, 1 Mar 2015 15:10:43 -0500 From: Andi Kleen To: acme@ghostprotocols.net Cc: jolsa@redhat.com, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH] perf, tools: Add some more error messages to event parser Date: Sun, 1 Mar 2015 12:09:29 -0800 Message-Id: <1425240569-1759-1-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 2.2.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen 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 --- 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