summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2018-06-06 18:15:10 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-06-07 15:03:21 -0400
commita5cfa6217c94a1f1cfad4481fc14f5fc399abde3 (patch)
treeb86b93ebda3fc2a723ae5dc6b8a29fdf59dd4291 /tools/perf
parentc1a1f5d9da800dc715d8c1d8a9692c63c70c2955 (diff)
perf stat: Add event parsing error handling to add_default_attributes
Add missing error handling for parse_events calls in add_default_attributes functions. The error handler displays error details, like for transactions (-T): Before: $ perf stat -T Cannot set up transaction events After: $ perf stat -T Cannot set up transaction events event syntax error: '..cycles,cpu/cycles-t/,cpu/tx-start/,cpu/el-start/,cpu/cycles-ct/}' \___ unknown term Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <frederic@kernel.org> Cc: Milian Wolff <milian.wolff@kdab.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/20180606221513.11302-8-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-stat.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 3fc1f5286d50..22547a490e1f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -2442,14 +2442,13 @@ static int add_default_attributes(void)
2442 (PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) | 2442 (PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) |
2443 (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) }, 2443 (PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
2444}; 2444};
2445 struct parse_events_error errinfo;
2445 2446
2446 /* Set attrs if no event is selected and !null_run: */ 2447 /* Set attrs if no event is selected and !null_run: */
2447 if (null_run) 2448 if (null_run)
2448 return 0; 2449 return 0;
2449 2450
2450 if (transaction_run) { 2451 if (transaction_run) {
2451 struct parse_events_error errinfo;
2452
2453 if (pmu_have_event("cpu", "cycles-ct") && 2452 if (pmu_have_event("cpu", "cycles-ct") &&
2454 pmu_have_event("cpu", "el-start")) 2453 pmu_have_event("cpu", "el-start"))
2455 err = parse_events(evsel_list, transaction_attrs, 2454 err = parse_events(evsel_list, transaction_attrs,
@@ -2460,6 +2459,7 @@ static int add_default_attributes(void)
2460 &errinfo); 2459 &errinfo);
2461 if (err) { 2460 if (err) {
2462 fprintf(stderr, "Cannot set up transaction events\n"); 2461 fprintf(stderr, "Cannot set up transaction events\n");
2462 parse_events_print_error(&errinfo, transaction_attrs);
2463 return -1; 2463 return -1;
2464 } 2464 }
2465 return 0; 2465 return 0;
@@ -2485,10 +2485,11 @@ static int add_default_attributes(void)
2485 pmu_have_event("msr", "smi")) { 2485 pmu_have_event("msr", "smi")) {
2486 if (!force_metric_only) 2486 if (!force_metric_only)
2487 metric_only = true; 2487 metric_only = true;
2488 err = parse_events(evsel_list, smi_cost_attrs, NULL); 2488 err = parse_events(evsel_list, smi_cost_attrs, &errinfo);
2489 } else { 2489 } else {
2490 fprintf(stderr, "To measure SMI cost, it needs " 2490 fprintf(stderr, "To measure SMI cost, it needs "
2491 "msr/aperf/, msr/smi/ and cpu/cycles/ support\n"); 2491 "msr/aperf/, msr/smi/ and cpu/cycles/ support\n");
2492 parse_events_print_error(&errinfo, smi_cost_attrs);
2492 return -1; 2493 return -1;
2493 } 2494 }
2494 if (err) { 2495 if (err) {
@@ -2523,12 +2524,13 @@ static int add_default_attributes(void)
2523 if (topdown_attrs[0] && str) { 2524 if (topdown_attrs[0] && str) {
2524 if (warn) 2525 if (warn)
2525 arch_topdown_group_warn(); 2526 arch_topdown_group_warn();
2526 err = parse_events(evsel_list, str, NULL); 2527 err = parse_events(evsel_list, str, &errinfo);
2527 if (err) { 2528 if (err) {
2528 fprintf(stderr, 2529 fprintf(stderr,
2529 "Cannot set up top down events %s: %d\n", 2530 "Cannot set up top down events %s: %d\n",
2530 str, err); 2531 str, err);
2531 free(str); 2532 free(str);
2533 parse_events_print_error(&errinfo, str);
2532 return -1; 2534 return -1;
2533 } 2535 }
2534 } else { 2536 } else {