mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] perf, tools: Add some more error messages to event parser
@ 2015-03-01 20:09 Andi Kleen
  0 siblings, 0 replies; only message in thread
From: Andi Kleen @ 2015-03-01 20:09 UTC (permalink / raw)
  To: acme; +Cc: jolsa, linux-kernel, Andi Kleen

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-03-01 20:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 20:09 [PATCH] perf, tools: Add some more error messages to event parser Andi Kleen

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®