diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-05-28 15:00:29 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-06-05 09:09:54 -0400 |
commit | 27de9b2bd996de0ca4079c42c81c85158e10145c (patch) | |
tree | 98202794dad73383f1a5e865445c3c04b91d068c /tools/perf/builtin-script.c | |
parent | 9d0199cd2a7a326510fc7f731d7974ef2fbc03d0 (diff) |
perf evsel: Add has_callchain() helper to make code more compact/clear
Its common to have the (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN),
so add an evsel__has_callchain(evsel) helper.
This will actually get more uses as we check that instead of
symbol_conf.use_callchain in places where that produces the same result
but makes this decision to be more fine grained, per evsel.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-145340oytbthatpfeaq1do18@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index cefc8813e91e..48e940efb3cb 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -517,7 +517,7 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
517 | 517 | ||
518 | evlist__for_each_entry(session->evlist, evsel) { | 518 | evlist__for_each_entry(session->evlist, evsel) { |
519 | not_pipe = true; | 519 | not_pipe = true; |
520 | if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { | 520 | if (evsel__has_callchain(evsel)) { |
521 | use_callchain = true; | 521 | use_callchain = true; |
522 | break; | 522 | break; |
523 | } | 523 | } |
@@ -532,22 +532,18 @@ static int perf_session__check_output_opt(struct perf_session *session) | |||
532 | */ | 532 | */ |
533 | if (symbol_conf.use_callchain && | 533 | if (symbol_conf.use_callchain && |
534 | !output[PERF_TYPE_TRACEPOINT].user_set) { | 534 | !output[PERF_TYPE_TRACEPOINT].user_set) { |
535 | struct perf_event_attr *attr; | ||
536 | |||
537 | j = PERF_TYPE_TRACEPOINT; | 535 | j = PERF_TYPE_TRACEPOINT; |
538 | 536 | ||
539 | evlist__for_each_entry(session->evlist, evsel) { | 537 | evlist__for_each_entry(session->evlist, evsel) { |
540 | if (evsel->attr.type != j) | 538 | if (evsel->attr.type != j) |
541 | continue; | 539 | continue; |
542 | 540 | ||
543 | attr = &evsel->attr; | 541 | if (evsel__has_callchain(evsel)) { |
544 | |||
545 | if (attr->sample_type & PERF_SAMPLE_CALLCHAIN) { | ||
546 | output[j].fields |= PERF_OUTPUT_IP; | 542 | output[j].fields |= PERF_OUTPUT_IP; |
547 | output[j].fields |= PERF_OUTPUT_SYM; | 543 | output[j].fields |= PERF_OUTPUT_SYM; |
548 | output[j].fields |= PERF_OUTPUT_SYMOFFSET; | 544 | output[j].fields |= PERF_OUTPUT_SYMOFFSET; |
549 | output[j].fields |= PERF_OUTPUT_DSO; | 545 | output[j].fields |= PERF_OUTPUT_DSO; |
550 | set_print_ip_opts(attr); | 546 | set_print_ip_opts(&evsel->attr); |
551 | goto out; | 547 | goto out; |
552 | } | 548 | } |
553 | } | 549 | } |