[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180620133030.2188-3-ravi.bangoria@linux.ibm.com>
Date: Wed, 20 Jun 2018 19:00:29 +0530
From: Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
To: acme@...nel.org, jolsa@...hat.com
Cc: alexander.shishkin@...ux.intel.com, namhyung@...nel.org,
dsahern@...il.com, davidcc@...gle.com, ak@...ux.intel.com,
yao.jin@...ux.intel.com, linux-kernel@...r.kernel.org,
Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
Subject: [PATCH 2/3] perf script: Fix crash because of missing evsel->priv
perf script in pipped mode is crashing because evsel->priv is not
set properly. Fix it.
Before:
# ./perf record -o - -- ls | ./perf script
Segmentation fault (core dumped)
After:
# ./perf record -o - -- ls | ./perf script
ls 2282 1031.731974: 250000 cpu-clock:uhH: 7effe4b3d29e
ls 2282 1031.732222: 250000 cpu-clock:uhH: 7effe4b3a650
Signed-off-by: Ravi Bangoria <ravi.bangoria@...ux.ibm.com>
Fixes: a14390fde64e ("perf script: Allow creating per-event dump files")
---
tools/perf/builtin-script.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 4d1cee68cfd2..acee05562f5e 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1822,6 +1822,7 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
struct perf_evlist *evlist;
struct perf_evsel *evsel, *pos;
int err;
+ static struct perf_evsel_script *es;
err = perf_event__process_attr(tool, event, pevlist);
if (err)
@@ -1830,6 +1831,19 @@ static int process_attr(struct perf_tool *tool, union perf_event *event,
evlist = *pevlist;
evsel = perf_evlist__last(*pevlist);
+ if (!evsel->priv) {
+ if (scr->per_event_dump) {
+ evsel->priv = perf_evsel_script__new(evsel,
+ scr->session->data);
+ } else {
+ es = zalloc(sizeof(*es));
+ if (!es)
+ return -ENOMEM;
+ es->fp = stdout;
+ evsel->priv = es;
+ }
+ }
+
if (evsel->attr.type >= PERF_TYPE_MAX &&
evsel->attr.type != PERF_TYPE_SYNTH)
return 0;
--
2.14.4
Powered by blists - more mailing lists