Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751368AbbDHEyk (ORCPT ); Wed, 8 Apr 2015 00:54:40 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:58813 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751077AbbDHEyg (ORCPT ); Wed, 8 Apr 2015 00:54:36 -0400 From: He Kuang To: , , , , CC: , Subject: [PATCH 2/2] perf data: Fix ctf_writer setupenv failure Date: Wed, 8 Apr 2015 12:49:20 +0800 Message-ID: <1428468560-27401-2-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 2.3.3.220.g9ab698f In-Reply-To: <1428468560-27401-1-git-send-email-hekuang@huawei.com> References: <1428468560-27401-1-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.189] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.5524B488.00E8,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 6cda3239f63ee465a9420772e2608c06 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2844 Lines: 92 Due to babeltrace commit: 7f800dc7c2a1 ("ir: make trace environment use bt_object") The trace->frozen flag is set in bt_ctf_trace_create_stream(), this flag is checked before adding environment field to trace, and causes ctf_writer__setup_env() failed. Fix this by setting all environment fields before bt_ctf_trace_create_stream(). Before this patch: $ perf data convert --to-ctf=ctf Error during CTF convert setup. After this patch: $ perf data convert --to-ctf=ctf [ perf data convert: Converted 'perf.data' into CTF data 'ctf' ] [ perf data convert: Converted and wrote 0.023 MB (596 samples) ] Signed-off-by: He Kuang --- tools/perf/util/data-convert-bt.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index a5b89b9..718dc8a 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -604,6 +604,22 @@ static int setup_events(struct ctf_writer *cw, struct perf_session *session) return 0; } +static int ctf_writer__setup_stream(struct ctf_writer *cw) +{ + struct bt_ctf_stream *stream; + + /* CTF stream instance */ + stream = bt_ctf_writer_create_stream(cw->writer, cw->stream_class); + if (!stream) { + pr("Failed to create CTF stream.\n"); + return -1; + } + + cw->stream = stream; + + return 0; +} + static int ctf_writer__setup_env(struct ctf_writer *cw, struct perf_session *session) { @@ -725,7 +741,6 @@ static int ctf_writer__init(struct ctf_writer *cw, const char *path) { struct bt_ctf_writer *writer; struct bt_ctf_stream_class *stream_class; - struct bt_ctf_stream *stream; struct bt_ctf_clock *clock; /* CTF writer */ @@ -767,15 +782,6 @@ static int ctf_writer__init(struct ctf_writer *cw, const char *path) if (ctf_writer__init_data(cw)) goto err_cleanup; - /* CTF stream instance */ - stream = bt_ctf_writer_create_stream(writer, stream_class); - if (!stream) { - pr("Failed to create CTF stream.\n"); - goto err_cleanup; - } - - cw->stream = stream; - /* CTF clock writer setup */ if (bt_ctf_writer_add_clock(writer, clock)) { pr("Failed to assign CTF clock to writer.\n"); @@ -830,6 +836,10 @@ int bt_convert__perf2ctf(const char *input, const char *path, bool force) if (ctf_writer__setup_env(cw, session)) goto free_session; + /* CTF writer trace stream setup */ + if (ctf_writer__setup_stream(cw)) + goto free_session; + /* CTF events setup */ if (setup_events(cw, session)) goto free_session; -- 2.3.3.220.g9ab698f -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/