perf script: No tracepoints? Don't call libtraceevent.
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 3 Aug 2015 19:27:40 +0000 (16:27 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 4 Aug 2015 15:28:10 +0000 (12:28 -0300)
The libtraceevent handler (session->tevent) is only initialized when
there are tracepoints in a perf.data event list, so do not call
pevent_set_function_resolve() in those cases, fixing a segfault.

Reported-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-xyynkucl5p4bcs13zi4i4b1f@git.kernel.org
link: http://lkml.kernel.org/r/20150803174113.GA20282@krava.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c

index bd31380122f96cdbabcba5451f2e246cef559802..7912feb9a0245c8fc3ecad51c652a6ff4a4d9387 100644 (file)
@@ -1861,7 +1861,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
        else
                symbol_conf.use_callchain = false;
 
-       if (pevent_set_function_resolver(session->tevent.pevent,
+       if (session->tevent.pevent &&
+           pevent_set_function_resolver(session->tevent.pevent,
                                         machine__resolve_kernel_addr,
                                         &session->machines.host) < 0) {
                pr_err("%s: failed to set libtraceevent function resolver\n", __func__);