[lttng-dev] [RFC-patch] Add support of variant (raw) metadata
Geneviève Bastien
gbastien+lttng at versatic.net
Mon Apr 8 10:53:35 EDT 2013
Add macros to allow to specify some raw metadata for a tracepoint event
field.
Add macros to copy dynamic length data without the length field with it,
for instance for variant event types.
Signed-off-by: Geneviève Bastien <gbastien+lttng at versatic.net>
---
lttng-events.c | 7 +++++++
lttng-events.h | 4 ++++
probes/lttng-events-reset.h | 6 ++++++
probes/lttng-events.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 62 insertions(+)
diff --git a/lttng-events.c b/lttng-events.c
index 4f30904..8ceecf5 100644
--- a/lttng-events.c
+++ b/lttng-events.c
@@ -654,6 +654,13 @@ int _lttng_field_statedump(struct lttng_session *session,
" { encoding = ASCII; }" : "",
field->name);
break;
+ case atype_raw:
+ /* field contains raw metadata! No guarantee it is valid */
+ ret = lttng_metadata_printf(session,
+ " %s _%s;\n",
+ field->type.u.raw.raw_data,
+ field->name);
+ break;
default:
WARN_ON_ONCE(1);
return -EINVAL;
diff --git a/lttng-events.h b/lttng-events.h
index 09d5618..968e2a4 100644
--- a/lttng-events.h
+++ b/lttng-events.h
@@ -48,6 +48,7 @@ enum abstract_types {
atype_array,
atype_sequence,
atype_string,
+ atype_raw,
NR_ABSTRACT_TYPES,
};
@@ -116,6 +117,9 @@ struct lttng_type {
struct lttng_basic_type length_type;
struct lttng_basic_type elem_type;
} sequence;
+ struct {
+ char *raw_data;
+ } raw;
} u;
};
diff --git a/probes/lttng-events-reset.h b/probes/lttng-events-reset.h
index 7355e18..8c9cf4d 100644
--- a/probes/lttng-events-reset.h
+++ b/probes/lttng-events-reset.h
@@ -35,6 +35,9 @@
#undef __string
#define __string(_item, _src)
+#undef __variant_raw
+#define __variant_raw(_item, _raw_metadata, _length)
+
#undef tp_assign
#define tp_assign(dest, src)
@@ -44,6 +47,9 @@
#undef tp_memcpy_dyn
#define tp_memcpy_dyn(dest, src, len)
+#undef tp_memcpy_var
+#define tp_memcpy_var(dest, src, len)
+
#undef tp_strcpy
#define tp_strcpy(dest, src)
diff --git a/probes/lttng-events.h b/probes/lttng-events.h
index 33cabcf..ce5b647 100644
--- a/probes/lttng-events.h
+++ b/probes/lttng-events.h
@@ -205,6 +205,21 @@ void trace_##_name(void *__data);
#define __string_from_user(_item, _src) \
__string(_item, _src)
+#undef __variant_raw
+#define __variant_raw(_item, _raw_metadata, _length) \
+ { \
+ .name = #_item, \
+ .type = \
+ { \
+ .atype = atype_raw, \
+ .u.raw.raw_data = #_raw_metadata, \
+ }, \
+ },
+
+#undef __variant_raw_from_user
+#define __variant_raw_from_user(_item, _raw_metadata, _length) \
+ __variant_raw(_item, _raw_metadata, _length)
+
#undef TP_STRUCT__entry
#define TP_STRUCT__entry(args...) args /* Only one used in this phase */
@@ -353,6 +368,11 @@ static __used struct lttng_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
#define __string(_item, _src) \
__event_len += __dynamic_len[__dynamic_len_idx++] = strlen(_src) + 1;
+#undef __variant_raw
+#define __variant_raw(_item, _raw_metadata, _length) \
+ __event_len += __dynamic_len[__dynamic_len_idx++] = (_length);
+
+
/*
* strlen_user includes \0. If returns 0, it faulted, so we set size to
* 1 (\0 only).
@@ -459,6 +479,10 @@ static inline size_t __event_get_align__##_name(_proto) \
#define __string_from_user(_item, _src) \
__string(_item, _src)
+#undef __variant_raw
+#define __variant_raw(_item, _raw_metadata, _length) \
+ char *_item;
+
#undef TP_STRUCT__entry
#define TP_STRUCT__entry(args...) args
@@ -510,6 +534,11 @@ __end_field_##_item:
#define __string_from_user(_item, _src) \
__string(_item, _src)
+#undef __variant_raw
+#define __variant_raw(_item, _raw_metadata, _length) \
+ goto __assign_##_item; \
+__end_field_##_item:
+
/*
* Macros mapping tp_assign() to "=", tp_memcpy() to memcpy() and tp_strcpy() to
* strcpy().
@@ -566,6 +595,22 @@ __assign_##dest##_2: \
#define tp_memcpy_dyn_from_user(dest, src) \
tp_memcpy_dyn_gen(event_write_from_user, dest, src)
+/* variable length sequence copy, with no size in metadata */
+#undef tp_memcpy_var_gen
+#define tp_memcpy_var_gen(write_ops, dest, src) \
+__assign_##dest: \
+ lib_ring_buffer_align_ctx(&__ctx, 8); \
+ __chan->ops->write_ops(&__ctx, src, __get_dynamic_array_len(dest)); \
+ goto __end_field_##dest;
+
+#undef tp_memcpy_var
+#define tp_memcpy_var(dest, src) \
+ tp_memcpy_var_gen(event_write, dest, src)
+
+#undef tp_memcpy_var_from_user
+#define tp_memcpy_var_from_user(dest, src) \
+ tp_memcpy_var_gen(event_write_from_user, dest, src)
+
/*
* The string length including the final \0.
*/
--
1.8.2
More information about the lttng-dev
mailing list