Skip to contentSkip to conversation

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

tip:perf/urgent tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jun 7, 2018 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  b879833cbaac85b1437f574791b8855d26b0dc80
Gitweb:     https://git.kernel.org/tip/b879833cbaac85b1437f574791b8855d26b0dc80
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 4 Jun 2018 10:34:20 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 5 Jun 2018 10:09:54 -0300

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.

---
 tools/perf/builtin-script.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-script.c +1 -1
index 48e940efb3cb..b3bf35512d21 100644
@@ -606,7 +606,7 @@ static int perf_sample__fprintf_start(struct perf_sample *sample,
 	if (PRINT_FIELD(COMM)) {
 		if (latency_format)
 			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));
 		else
 			printed += fprintf(fp, "%16s ", thread__comm_str(thread));