+ const struct lttng_integer_type *integer_type = NULL;
+ const struct lttng_type *nested_type;
+ uint8_t *ptr;
+ bool signedness;
+ int ret, i;
+
+ ret = lttng_msgpack_begin_array(writer, output->u.sequence.nr_elem);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+
+ ptr = (uint8_t *) output->u.sequence.ptr;
+ nested_type = output->u.sequence.nested_type;
+ switch (nested_type->atype) {
+ case atype_integer:
+ integer_type = &nested_type->u.integer;
+ break;
+ case atype_enum_nestable:
+ /* Treat enumeration as an integer. */
+ integer_type = &nested_type->u.enum_nestable.container_type->u.integer;
+ break;
+ default:
+ /* Capture of array of non-integer are not supported. */
+ WARN_ON(1);
+ }
+ signedness = integer_type->signedness;
+ for (i = 0; i < output->u.sequence.nr_elem; i++) {
+ if (signedness) {
+ ret = lttng_msgpack_write_signed_integer(writer,
+ capture_sequence_element_signed(ptr, integer_type));
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+ } else {
+ ret = lttng_msgpack_write_unsigned_integer(writer,
+ capture_sequence_element_unsigned(ptr, integer_type));
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+ }
+
+ /*
+ * We assume that alignment is smaller or equal to the size.
+ * This currently holds true but if it changes in the future,
+ * we will want to change the pointer arithmetics below to
+ * take into account that the next element might be further
+ * away.
+ */
+ WARN_ON(integer_type->alignment > integer_type->size);
+
+ /* Size is in number of bits. */
+ ptr += (integer_type->size / CHAR_BIT) ;
+ }
+
+ ret = lttng_msgpack_end_array(writer);
+ if (ret)
+ WARN_ON_ONCE(1);
+end:
+ return ret;
+}
+
+static
+int notification_append_capture(
+ struct lttng_event_notifier_notification *notif,
+ struct lttng_interpreter_output *output)
+{
+ struct lttng_msgpack_writer *writer = ¬if->writer;
+ int ret = 0;
+
+ switch (output->type) {
+ case LTTNG_INTERPRETER_TYPE_S64:
+ ret = lttng_msgpack_write_signed_integer(writer, output->u.s);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+ break;
+ case LTTNG_INTERPRETER_TYPE_U64:
+ ret = lttng_msgpack_write_unsigned_integer(writer, output->u.u);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+ break;
+ case LTTNG_INTERPRETER_TYPE_STRING:
+ ret = lttng_msgpack_write_str(writer, output->u.str.str);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+ break;
+ case LTTNG_INTERPRETER_TYPE_SEQUENCE:
+ ret = capture_sequence(writer, output);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+ break;
+ case LTTNG_INTERPRETER_TYPE_SIGNED_ENUM:
+ case LTTNG_INTERPRETER_TYPE_UNSIGNED_ENUM:
+ ret = capture_enum(writer, output);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+ break;
+ default:
+ ret = -1;
+ WARN_ON(1);
+ }
+end:
+ return ret;
+}
+
+static
+int notification_append_empty_capture(
+ struct lttng_event_notifier_notification *notif)
+{
+ int ret = lttng_msgpack_write_nil(¬if->writer);
+ if (ret)
+ WARN_ON_ONCE(1);
+
+ return ret;
+}
+
+static
+int notification_init(struct lttng_event_notifier_notification *notif,
+ struct lttng_event_notifier *event_notifier)
+{
+ struct lttng_msgpack_writer *writer = ¬if->writer;
+ int ret = 0;
+
+ notif->has_captures = false;
+
+ if (event_notifier->num_captures > 0) {
+ lttng_msgpack_writer_init(writer, notif->capture_buf,
+ CAPTURE_BUFFER_SIZE);
+
+ ret = lttng_msgpack_begin_array(writer, event_notifier->num_captures);
+ if (ret) {
+ WARN_ON_ONCE(1);
+ goto end;
+ }
+
+ notif->has_captures = true;
+ }
+
+end:
+ return ret;
+}
+
+static
+void record_error(struct lttng_event_notifier *event_notifier)
+{
+