From patchwork Fri Jun 24 11:22:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 70816 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp895311qgy; Fri, 24 Jun 2016 04:23:18 -0700 (PDT) X-Received: by 10.98.103.198 with SMTP id t67mr6275716pfj.158.1466767397961; Fri, 24 Jun 2016 04:23:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gl5si6392721pac.8.2016.06.24.04.23.17; Fri, 24 Jun 2016 04:23:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751138AbcFXLXP (ORCPT + 30 others); Fri, 24 Jun 2016 07:23:15 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:7294 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750951AbcFXLXO (ORCPT ); Fri, 24 Jun 2016 07:23:14 -0400 Received: from 172.24.1.137 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.137]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DJG80987; Fri, 24 Jun 2016 19:22:58 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Fri, 24 Jun 2016 19:22:51 +0800 From: Wang Nan To: , CC: , , , Wang Nan , Arnaldo Carvalho de Melo Subject: [PATCH v2 1/7] perf ctf: Add value_set_string() helper Date: Fri, 24 Jun 2016 11:22:06 +0000 Message-ID: <1466767332-114472-2-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1466767332-114472-1-git-send-email-wangnan0@huawei.com> References: <1466767332-114472-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.576D1813.003B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 52be20616a7a75ea3e30c3e8443aa5d2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are many value_set_##x helper for integer, but only for integer. This patch adds value_set_string() helper to help following commits create string fields. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa --- tools/perf/util/data-convert-bt.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 1.8.3.4 diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index 4b59879..7908278 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -140,6 +140,36 @@ FUNC_VALUE_SET(s64) FUNC_VALUE_SET(u64) __FUNC_VALUE_SET(u64_hex, u64) +static int string_set_value(struct bt_ctf_field *field, const char *string); +static __maybe_unused int +value_set_string(struct ctf_writer *cw, struct bt_ctf_event *event, + const char *name, const char *string) +{ + struct bt_ctf_field_type *type = cw->data.string; + struct bt_ctf_field *field; + int ret = 0; + + field = bt_ctf_field_create(type); + if (!field) { + pr_err("failed to create a field %s\n", name); + return -1; + } + + ret = string_set_value(field, string); + if (ret) { + pr_err("failed to set value %s\n", name); + goto err_put_field; + } + + ret = bt_ctf_event_set_payload(event, name, field); + if (ret) + pr_err("failed to set payload %s\n", name); + +err_put_field: + bt_ctf_field_put(field); + return ret; +} + static struct bt_ctf_field_type* get_tracepoint_field_type(struct ctf_writer *cw, struct format_field *field) {