Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1430590

[PATCH v2 1/7] perf ctf: Add value_set_string() helper

From Wang Nan <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject [PATCH v2 1/7] perf ctf: Add value_set_string() helper
Date 2016-06-24 13:30 +0200
Message-ID <rNxt8-7os-33@gated-at.bofh.it> (permalink)
References <rNxt7-7os-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.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 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)
 {
-- 
1.8.3.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/7] perf ctf: Add value_set_string() helper Wang Nan <wangnan0@huawei.com> - 2016-06-24 13:30 +0200
  [tip:perf/core] perf data ctf: Add value_set_string() helper tip-bot for Wang Nan <tipbot@zytor.com> - 2016-06-29 11:50 +0200

csiph-web