+static enum lttng_error_code lttng_event_rule_kernel_uprobe_mi_serialize(
+ const struct lttng_event_rule *rule, struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_event_rule_status status;
+ const char *event_name = NULL;
+ const struct lttng_userspace_probe_location *location = NULL;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_UPROBE_EVENT_RULE(rule));
+
+ status = lttng_event_rule_kernel_uprobe_get_event_name(
+ rule, &event_name);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(event_name);
+
+ status = lttng_event_rule_kernel_uprobe_get_location(rule, &location);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(location);
+
+ /* Open event rule kernel uprobe element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_kernel_uprobe);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Event name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_event_name, event_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Probe location. */
+ ret_code = lttng_userspace_probe_location_mi_serialize(location, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close event rule kernel uprobe element. */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto mi_error;
+ }
+
+ ret_code = LTTNG_OK;
+ goto end;
+
+mi_error:
+ ret_code = LTTNG_ERR_MI_IO_FAIL;
+end:
+ return ret_code;
+}
+