[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-069ee5c488d161f539bb897b1bc64b83f9773221@git.kernel.org>
Date: Wed, 29 Jun 2016 02:45:07 -0700
From: tip-bot for Wang Nan <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: lizefan@...wei.com, linux-kernel@...r.kernel.org,
wangnan0@...wei.com, tglx@...utronix.de, jolsa@...nel.org,
mingo@...nel.org, hpa@...or.com, acme@...hat.com
Subject: [tip:perf/core] perf data ctf: Add value_set_string() helper
Commit-ID: 069ee5c488d161f539bb897b1bc64b83f9773221
Gitweb: http://git.kernel.org/tip/069ee5c488d161f539bb897b1bc64b83f9773221
Author: Wang Nan <wangnan0@...wei.com>
AuthorDate: Fri, 24 Jun 2016 11:22:06 +0000
Committer: Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Tue, 28 Jun 2016 10:54:55 -0300
perf data ctf: Add value_set_string() helper
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 <wangnan0@...wei.com>
Acked-by: Jiri Olsa <jolsa@...nel.org>
Cc: Zefan Li <lizefan@...wei.com>
Cc: pi3orama@....com
Link: http://lkml.kernel.org/r/1466767332-114472-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
tools/perf/util/data-convert-bt.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c
index 7b1bc24..4b68e7b 100644
--- a/tools/perf/util/data-convert-bt.c
+++ b/tools/perf/util/data-convert-bt.c
@@ -141,6 +141,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)
{
Powered by blists - more mailing lists