From: Andi Kleen <a...@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 <a...@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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/