From: ylamarre@efficios.com (Yannick Lamarre)
Subject: [lttng-dev] [RFC PATCH lttng-tools 14/18] Add serdes functions for lttng_event_context
Date: Thu, 18 Apr 2019 12:18:46 -0400 [thread overview]
Message-ID: <20190418161850.1536-15-ylamarre@efficios.com> (raw)
In-Reply-To: <20190418161850.1536-1-ylamarre@efficios.com>
Since those structs are only transfered across unix sockets, endianess
is kept in host order.
Signed-off-by: Yannick Lamarre <ylamarre at efficios.com>
---
include/lttng/event-internal.h | 6 ++
src/common/sessiond-comm/sessiond-comm.c | 116 +++++++++++++++++++++++++++++++
2 files changed, 122 insertions(+)
diff --git a/include/lttng/event-internal.h b/include/lttng/event-internal.h
index a43007de..ec261af4 100644
--- a/include/lttng/event-internal.h
+++ b/include/lttng/event-internal.h
@@ -95,6 +95,12 @@ struct lttng_event_extended {
LTTNG_HIDDEN
struct lttng_event *lttng_event_copy(const struct lttng_event *event);
+int lttng_event_probe_attr_serialize(struct lttng_event_serialized *dst, const struct lttng_event *src);
+int lttng_event_function_attr_serialize(struct lttng_event_serialized *dst, const struct lttng_event *src);
+int lttng_event_no_attr_serialize(struct lttng_event_serialized *dst, const struct lttng_event *src);
+int lttng_event_probe_attr_deserialize(struct lttng_event *dst, const struct lttng_event_serialized *src);
+int lttng_event_function_attr_deserialize(struct lttng_event *dst, const struct lttng_event_serialized *src);
+int lttng_event_no_attr_deserialize(struct lttng_event *dst, const struct lttng_event_serialized *src);
int lttng_event_context_serialize(struct lttng_event_context_serialized *dst, const struct lttng_event_context *src);
int lttng_event_context_deserialize(struct lttng_event_context *dst, const struct lttng_event_context_serialized *src);
int lttng_event_perf_counter_ctx_serialize(struct lttng_event_perf_counter_ctx_serialized *dst, const struct lttng_event_perf_counter_ctx *src);
diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c
index 84beb90d..d71abe0c 100644
--- a/src/common/sessiond-comm/sessiond-comm.c
+++ b/src/common/sessiond-comm/sessiond-comm.c
@@ -77,6 +77,122 @@ static const char *lttcomm_readable_code[] = {
static unsigned long network_timeout;
LTTNG_HIDDEN
+int lttng_event_common_serialize(struct lttng_event_serialized *dst,
+ const struct lttng_event *src)
+{
+ dst->type = (uint32_t) src->type;
+
+ memcpy(dst->name, src->name, LTTNG_SYMBOL_NAME_LEN);
+
+ dst->loglevel_type = (uint32_t) src->loglevel_type;
+ dst->loglevel = src->loglevel;
+ dst->enabled = src->enabled;
+ dst->pid = src->pid;
+ dst->filter = src->filter;
+ dst->exclusion = src->exclusion;
+ dst->flags = (uint32_t) src->flags;
+
+ return 0;
+}
+
+LTTNG_HIDDEN
+int lttng_event_common_deserialize(struct lttng_event *dst,
+ const struct lttng_event_serialized *src)
+{
+ dst->type = (enum lttng_event_type) src->type;
+
+ memcpy(dst->name, src->name, LTTNG_SYMBOL_NAME_LEN);
+
+ dst->loglevel_type = (enum lttng_loglevel_type) src->loglevel_type;
+ dst->loglevel = src->loglevel;
+ dst->enabled = src->enabled;
+ dst->pid = src->pid;
+ dst->filter = src->filter;
+ dst->exclusion = src->exclusion;
+ dst->flags = (enum lttng_event_flag) src->flags;
+
+ return 0;
+}
+
+LTTNG_HIDDEN
+int lttng_event_probe_attr_serialize(struct lttng_event_serialized *dst,
+ const struct lttng_event *src)
+{
+ assert(src && dst);
+ lttng_event_common_serialize(dst, src);
+
+ dst->attr.probe.addr = src->attr.probe.addr;
+ dst->attr.probe.offset = src->attr.probe.offset;
+
+ memcpy(dst->attr.probe.symbol_name, src->attr.probe.symbol_name, LTTNG_SYMBOL_NAME_LEN);
+
+ return 0;
+}
+
+LTTNG_HIDDEN
+int lttng_event_probe_attr_deserialize(struct lttng_event *dst,
+ const struct lttng_event_serialized *src)
+{
+ assert(src && dst);
+ lttng_event_common_deserialize(dst, src);
+
+ dst->attr.probe.addr = src->attr.probe.addr;
+ dst->attr.probe.offset = src->attr.probe.offset;
+
+ memcpy(dst->attr.probe.symbol_name, src->attr.probe.symbol_name, LTTNG_SYMBOL_NAME_LEN);
+
+ return 0;
+}
+
+LTTNG_HIDDEN
+int lttng_event_function_attr_serialize(struct lttng_event_serialized *dst,
+ const struct lttng_event *src)
+{
+ assert(src && dst);
+ lttng_event_common_serialize(dst, src);
+
+ memcpy(dst->attr.ftrace.symbol_name, src->attr.ftrace.symbol_name, LTTNG_SYMBOL_NAME_LEN);
+
+ return 0;
+}
+
+LTTNG_HIDDEN
+int lttng_event_function_attr_deserialize(struct lttng_event *dst,
+ const struct lttng_event_serialized *src)
+{
+ assert(src && dst);
+ lttng_event_common_deserialize(dst, src);
+
+ memcpy(dst->attr.ftrace.symbol_name, src->attr.ftrace.symbol_name, LTTNG_SYMBOL_NAME_LEN);
+
+ return 0;
+}
+
+LTTNG_HIDDEN
+int lttng_event_no_attr_serialize(struct lttng_event_serialized *dst,
+ const struct lttng_event *src)
+{
+ assert(src && dst);
+ lttng_event_common_serialize(dst, src);
+
+ memset(&dst->attr, 0, sizeof(dst->attr));
+
+ return 0;
+}
+
+LTTNG_HIDDEN
+int lttng_event_no_attr_deserialize(struct lttng_event *dst,
+ const struct lttng_event_serialized *src)
+{
+ assert(src && dst);
+ lttng_event_common_deserialize(dst, src);
+
+ memset(&dst->attr, 0, sizeof(dst->attr));
+
+ return 0;
+}
+
+LTTNG_HIDDEN
int lttng_event_perf_counter_ctx_serialize(struct lttng_event_perf_counter_ctx_serialized *dst,
const struct lttng_event_perf_counter_ctx *src)
{
--
2.11.0
next prev parent reply other threads:[~2019-04-18 16:18 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-18 16:18 [lttng-dev] [RFC PATCH lttng-tools 00/18] Improvements in sessiond-comm Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 01/18] Fix: Use platform-independant types in sessiond to consumerd communication Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 02/18] Clean-up: Switch enum fields in lttcomm_consumer_msg Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 03/18] Clean-up: Switch enum fields in lttcomm_consumer_status_msg Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 04/18] Clean-up: Switch enum fields in lttcomm_consumer_status_channel Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 05/18] Clean-up: Remove unused structure Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 06/18] Clean-up: Removed deprecated field Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 07/18] Add serialized versions of lttng_channel structs Yannick Lamarre
2019-04-18 19:38 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 08/18] Add serdes functions for lttng_channel Yannick Lamarre
2019-04-18 19:32 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 09/18] Integrate serialized communication in lttng-ctl and sessiond Yannick Lamarre
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 10/18] Add serialized versions of lttng_event_context structs Yannick Lamarre
2019-04-18 19:41 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 11/18] Add serdes functions for lttng_event_context Yannick Lamarre
2019-04-18 19:42 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 12/18] Integrate serialized communication in lttng-ctl and sessiond Yannick Lamarre
2019-04-18 19:44 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 13/18] Add serialized versions of lttng_event structs Yannick Lamarre
2019-04-18 19:45 ` Mathieu Desnoyers
2019-04-18 16:18 ` Yannick Lamarre [this message]
2019-04-18 19:46 ` [lttng-dev] [RFC PATCH lttng-tools 14/18] Add serdes functions for lttng_event_context Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 15/18] Integrate serialized communication in lttng-ctl and sessiond Yannick Lamarre
2019-04-18 19:49 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 16/18] Add serialized versions of lttng_event structs Yannick Lamarre
2019-04-18 19:50 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 17/18] Add serdes functions for lttng_snapshot_output Yannick Lamarre
2019-04-18 19:52 ` Mathieu Desnoyers
2019-04-18 16:18 ` [lttng-dev] [RFC PATCH lttng-tools 18/18] Integrate serialized communication in lttng-ctl and sessiond Yannick Lamarre
2019-04-18 19:58 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190418161850.1536-15-ylamarre@efficios.com \
--to=ylamarre@efficios.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox