perf script: Check if evsel has callchains before trying to use it

We were checking just if callchain processing was asked for by the
user, not if the evsel itself has callchains, and since we can have
some evsels with callchains and others without, check that.

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-inxl7k49q9f9w1se039fbxuw@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 27de9b2b
...@@ -606,7 +606,7 @@ static int perf_sample__fprintf_start(struct perf_sample *sample, ...@@ -606,7 +606,7 @@ static int perf_sample__fprintf_start(struct perf_sample *sample,
if (PRINT_FIELD(COMM)) { if (PRINT_FIELD(COMM)) {
if (latency_format) if (latency_format)
printed += fprintf(fp, "%8.8s ", thread__comm_str(thread)); printed += fprintf(fp, "%8.8s ", thread__comm_str(thread));
else if (PRINT_FIELD(IP) && symbol_conf.use_callchain) else if (PRINT_FIELD(IP) && evsel__has_callchain(evsel) && symbol_conf.use_callchain)
printed += fprintf(fp, "%s ", thread__comm_str(thread)); printed += fprintf(fp, "%s ", thread__comm_str(thread));
else else
printed += fprintf(fp, "%16s ", thread__comm_str(thread)); printed += fprintf(fp, "%16s ", thread__comm_str(thread));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment