#include <urcu/ref.h>
struct lttng_rate_policy;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_trigger;
typedef bool (*action_validate_cb)(struct lttng_action *action);
typedef void (*action_destroy_cb)(struct lttng_action *action);
typedef enum lttng_action_status (*action_add_error_query_results_cb)(
const struct lttng_action *action,
struct lttng_error_query_results *results);
+typedef enum lttng_error_code (*action_mi_serialize_cb)(
+ const struct lttng_action *condition, struct mi_writer *writer);
struct lttng_action {
struct urcu_ref ref;
action_destroy_cb destroy;
action_get_rate_policy_cb get_rate_policy;
action_add_error_query_results_cb add_error_query_results;
+ action_mi_serialize_cb mi_serialize;
/* Internal use only. */
action_equal_cb equal,
action_destroy_cb destroy,
action_get_rate_policy_cb get_rate_policy,
- action_add_error_query_results_cb add_error_query_results);
+ action_add_error_query_results_cb add_error_query_results,
+ action_mi_serialize_cb mi);
LTTNG_HIDDEN
bool lttng_action_validate(struct lttng_action *action);
enum lttng_action_status lttng_action_generic_add_error_query_results(
const struct lttng_action *action,
struct lttng_error_query_results *results);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes);
#endif /* LTTNG_ACTION_INTERNAL_H */
struct lttng_action;
struct lttng_payload_view;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_dynamic_array;
+struct lttng_trigger;
/*
* Create an action list from a payload view.
extern struct lttng_action *lttng_action_list_borrow_mutable_at_index(
const struct lttng_action *list, unsigned int index);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_action_list_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes);
+
#endif /* LTTNG_ACTION_LIST_INTERNAL_H */
#include <lttng/action/rate-policy.h>
#include <stdbool.h>
+struct mi_writer;
+
LTTNG_HIDDEN
int lttng_rate_policy_serialize(struct lttng_rate_policy *rate_policy,
struct lttng_payload *buf);
bool lttng_rate_policy_should_execute(
const struct lttng_rate_policy *policy, uint64_t counter);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_rate_policy_mi_serialize(
+ const struct lttng_rate_policy *policy,
+ struct mi_writer *writer);
+
#endif /* LTTNG_RATE_POLICY */
#ifndef LTTNG_CONDITION_INTERNAL_H
#define LTTNG_CONDITION_INTERNAL_H
-#include <lttng/condition/condition.h>
#include <common/macros.h>
#include <common/payload-view.h>
#include <common/payload.h>
+#include <lttng/condition/condition.h>
+#include <lttng/lttng-error.h>
#include <stdbool.h>
-#include <urcu/list.h>
-#include <urcu/ref.h>
#include <stdint.h>
#include <sys/types.h>
+#include <urcu/list.h>
+#include <urcu/ref.h>
+
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
+struct lttng_trigger;
typedef void (*condition_destroy_cb)(struct lttng_condition *condition);
typedef bool (*condition_validate_cb)(const struct lttng_condition *condition);
typedef ssize_t (*condition_create_from_payload_cb)(
struct lttng_payload_view *view,
struct lttng_condition **condition);
+typedef enum lttng_error_code (*condition_mi_serialize_cb)(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer);
struct lttng_condition {
/* Reference counting is only exposed to internal users. */
condition_serialize_cb serialize;
condition_equal_cb equal;
condition_destroy_cb destroy;
+ condition_mi_serialize_cb mi_serialize;
};
struct lttng_condition_comm {
bool lttng_condition_is_equal(const struct lttng_condition *a,
const struct lttng_condition *b);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_condition_mi_serialize(
+ const struct lttng_trigger *trigger,
+ const struct lttng_condition *condition,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks);
+
LTTNG_HIDDEN
const char *lttng_condition_type_str(enum lttng_condition_type type);
#include <common/payload.h>
#include <common/payload-view.h>
+struct mi_writer;
+
enum lttng_error_query_target_type {
LTTNG_ERROR_QUERY_TARGET_TYPE_TRIGGER,
LTTNG_ERROR_QUERY_TARGET_TYPE_CONDITION,
struct lttng_error_query_results *results,
struct lttng_error_query_result *result);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_error_query_results_mi_serialize(
+ const struct lttng_error_query_results *results,
+ struct mi_writer *writer);
+
#endif /* LTTNG_ERROR_QUERY_INTERNAL_H */
#include <lttng/event-expr.h>
struct lttng_bytecode;
+struct mi_writer;
struct lttng_event_expr {
enum lttng_event_expr_type type;
int lttng_event_expr_to_bytecode(const struct lttng_event_expr *expr,
struct lttng_bytecode **bytecode_out);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_event_expr_mi_serialize(
+ const struct lttng_event_expr *expression,
+ struct mi_writer *writer);
+
#endif /* LTTNG_EVENT_EXPR_INTERNAL_H */
struct lttng_payload;
struct lttng_payload_view;
+struct mi_writer;
enum lttng_event_rule_generate_exclusions_status {
LTTNG_EVENT_RULE_GENERATE_EXCLUSIONS_STATUS_OK,
const struct lttng_event_rule *event_rule);
typedef struct lttng_event *(*event_rule_generate_lttng_event_cb)(
const struct lttng_event_rule *event_rule);
+typedef enum lttng_error_code (*event_rule_mi_serialize_cb)(
+ const struct lttng_event_rule *event_rule,
+ struct mi_writer *writer);
struct lttng_event_rule {
struct urcu_ref ref;
event_rule_generate_exclusions_cb generate_exclusions;
event_rule_hash_cb hash;
event_rule_generate_lttng_event_cb generate_lttng_event;
+ event_rule_mi_serialize_cb mi_serialize;
};
struct lttng_event_rule_comm {
LTTNG_HIDDEN
bool lttng_event_rule_targets_agent_domain(const struct lttng_event_rule *rule);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_event_rule_mi_serialize(
+ const struct lttng_event_rule *rule, struct mi_writer *writer);
+
#endif /* LTTNG_EVENT_RULE_INTERNAL_H */
struct lttng_payload;
struct lttng_payload_view;
struct lttng_dynamic_buffer;
+struct mi_writer;
typedef bool (*kernel_probe_location_equal_cb)(
const struct lttng_kernel_probe_location *a,
struct lttng_kernel_probe_location **kernel_probe_location);
typedef unsigned long (*kernel_probe_location_hash_cb)(
const struct lttng_kernel_probe_location *location);
+typedef enum lttng_error_code (*kernel_probe_location_mi_serialize_cb)(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
struct lttng_kernel_probe_location_comm {
/* enum lttng_kernel_probe_location_type */
kernel_probe_location_equal_cb equal;
kernel_probe_location_serialize_cb serialize;
kernel_probe_location_hash_cb hash;
+ kernel_probe_location_mi_serialize_cb mi_serialize;
};
struct lttng_kernel_probe_location_symbol {
unsigned long lttng_kernel_probe_location_hash(
const struct lttng_kernel_probe_location *location);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
+
#endif /* LTTNG_KERNEL_PROBE_INTERNAL_H */
#include <lttng/event.h>
#include <lttng/log-level-rule.h>
+struct mi_writer;
+
/*
* For now only a single backing struct is used for both type of log level
* rule (exactly, as_severe) since both only have require "level" as property.
unsigned long lttng_log_level_rule_hash(
const struct lttng_log_level_rule *log_level_rule);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_log_level_rule_mi_serialize(
+ const struct lttng_log_level_rule *rule,
+ struct mi_writer *writer);
+
#endif /* LTTNG_LOG_LEVEL_RULE_INTERNAL_H */
struct lttng_payload;
struct lttng_payload_view;
+struct mi_writer;
+struct mi_lttng_error_query_callbacks;
struct lttng_trigger {
/* Reference counting is only exposed to internal users. */
LTTNG_HIDDEN
void lttng_trigger_put(struct lttng_trigger *trigger);
+/*
+ * Serialize a trigger to a mi_writer.
+ * Return LTTNG_OK in success, other enum lttng_error_code on error.
+ */
+LTTNG_HIDDEN
+enum lttng_error_code lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks);
+
/*
* Allocate a new set of triggers.
* The returned object must be freed via lttng_triggers_destroy.
ssize_t lttng_triggers_create_from_payload(struct lttng_payload_view *view,
struct lttng_triggers **triggers);
+/*
+ * Serialize a trigger set to a mi_writer.
+ * Return LTTNG_OK in success, other enum lttng_error_code on error.
+ */
+LTTNG_HIDDEN
+enum lttng_error_code lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks);
+
LTTNG_HIDDEN
const struct lttng_credentials *lttng_trigger_get_credentials(
const struct lttng_trigger *trigger);
struct lttng_payload;
struct lttng_payload_view;
struct lttng_dynamic_buffer;
+struct mi_writer;
typedef bool (*userspace_probe_location_equal_cb)(
const struct lttng_userspace_probe_location *a,
const struct lttng_userspace_probe_location *b);
typedef unsigned long (*userspace_probe_location_hash_cb)(
const struct lttng_userspace_probe_location *location);
+typedef enum lttng_error_code (*userspace_probe_location_mi)(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer);
/*
* No elf-specific comm structure is defined since no elf-specific payload is
struct lttng_userspace_probe_location_lookup_method *lookup_method;
userspace_probe_location_equal_cb equal;
userspace_probe_location_hash_cb hash;
+ userspace_probe_location_hash_cb mi;
};
struct lttng_userspace_probe_location_function {
unsigned long lttng_userspace_probe_location_hash(
const struct lttng_userspace_probe_location *location);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer);
+
#endif /* LTTNG_USERSPACE_PROBE_INTERNAL_H */
#include <assert.h>
#include <common/error.h>
+#include <common/mi-lttng.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/list-internal.h>
#include <lttng/action/notify-internal.h>
action_equal_cb equal,
action_destroy_cb destroy,
action_get_rate_policy_cb get_rate_policy,
- action_add_error_query_results_cb add_error_query_results)
+ action_add_error_query_results_cb add_error_query_results,
+ action_mi_serialize_cb mi)
{
urcu_ref_init(&action->ref);
action->type = type;
action->destroy = destroy;
action->get_rate_policy = get_rate_policy;
action->add_error_query_results = add_error_query_results;
+ action->mi_serialize = mi;
action->execution_request_counter = 0;
action->execution_counter = 0;
lttng_error_query_result_destroy(error_counter);
return action_status;
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ struct lttng_action_path *action_path = NULL;
+ struct lttng_error_query_results *error_query_results = NULL;
+
+ assert(action);
+ assert(writer);
+
+ /* Open action. */
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action);
+ if (ret) {
+ goto mi_error;
+ }
+
+ if (action->type == LTTNG_ACTION_TYPE_LIST) {
+ /*
+ * Recursion is safe since action lists can't be nested for
+ * the moment.
+ */
+ ret_code = lttng_action_list_mi_serialize(trigger, action, writer,
+ error_query_callbacks, action_path_indexes);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Nothing else to do. */
+ goto close_action_element;
+ }
+
+ assert(action->mi_serialize);
+ ret_code = action->mi_serialize(action, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Error query for the action. */
+ if (error_query_callbacks && error_query_callbacks->action_cb) {
+ const uint64_t *action_path_indexes_raw_pointer = NULL;
+ const size_t action_path_indexes_size =
+ lttng_dynamic_array_get_count(
+ action_path_indexes);
+
+ if (action_path_indexes_size != 0) {
+ action_path_indexes_raw_pointer =
+ (const uint64_t *) action_path_indexes
+ ->buffer.data;
+ }
+
+ action_path = lttng_action_path_create(
+ action_path_indexes_raw_pointer,
+ action_path_indexes_size);
+ assert(action_path);
+
+ ret_code = error_query_callbacks->action_cb(
+ trigger, action_path, &error_query_results);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Serialize the error query results. */
+ ret_code = lttng_error_query_results_mi_serialize(
+ error_query_results, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+close_action_element:
+ /* Close action. */
+ 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:
+ lttng_action_path_destroy(action_path);
+ lttng_error_query_results_destroy(error_query_results);
+ return ret_code;
+}
#include <assert.h>
#include <common/dynamic-array.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/list-internal.h>
#include <lttng/action/list.h>
return action_status;
}
+LTTNG_HIDDEN
+enum lttng_error_code lttng_action_list_mi_serialize(
+ const struct lttng_trigger *trigger,
+ const struct lttng_action *action,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks,
+ struct lttng_dynamic_array *action_path_indexes)
+{
+ int ret;
+ struct lttng_action_list *action_list;
+ unsigned int i, count;
+ enum lttng_error_code ret_code;
+
+ assert(action);
+ assert(IS_LIST_ACTION(action));
+ assert(writer);
+
+ /* Open action list. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_action_list);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize every action of the list. */
+ action_list = action_list_from_action(action);
+ count = lttng_dynamic_pointer_array_get_count(&action_list->actions);
+ for (i = 0; i < count; i++) {
+ const struct lttng_action *child =
+ lttng_action_list_get_at_index(action, i);
+ const uint64_t index = (uint64_t) i;
+
+ assert(child);
+
+ /*
+ * Add the index to the action path.
+ *
+ * This index is replaced on every iteration to walk the action
+ * tree in-order and to re-use the dynamic array instead of
+ * copying it at every level.
+ */
+ ret = lttng_dynamic_array_add_element(
+ action_path_indexes, &index);
+ if (ret) {
+ ret_code = LTTNG_ERR_NOMEM;
+ goto end;
+ }
+
+ ret_code = lttng_action_mi_serialize(trigger, child, writer,
+ error_query_callbacks, action_path_indexes);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ ret = lttng_dynamic_array_remove_element(action_path_indexes,
+ lttng_dynamic_array_get_count(
+ action_path_indexes) -
+ 1);
+ if (ret) {
+ ret_code = LTTNG_ERR_UNK;
+ goto end;
+ }
+ }
+
+ /* Close action_list 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;
+}
+
struct lttng_action *lttng_action_list_create(void)
{
struct lttng_action_list *action_list;
action = &action_list->parent;
+ /*
+ * The mi for the list is handled at the lttng_action_mi level to ease
+ * action path management for error query.
+ */
lttng_action_init(action, LTTNG_ACTION_TYPE_LIST,
- lttng_action_list_validate,
- lttng_action_list_serialize,
+ lttng_action_list_validate, lttng_action_list_serialize,
lttng_action_list_is_equal, lttng_action_list_destroy,
- NULL,
- lttng_action_list_add_error_query_results);
+ NULL, lttng_action_list_add_error_query_results, NULL);
lttng_dynamic_pointer_array_init(&action_list->actions,
destroy_lttng_action_list_element);
#include <assert.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/notify-internal.h>
#include <lttng/action/rate-policy-internal.h>
+#include <lttng/lttng-error.h>
#define IS_NOTIFY_ACTION(action) \
(lttng_action_get_type(action) == LTTNG_ACTION_TYPE_NOTIFY)
return _action->policy;
}
+static enum lttng_error_code lttng_action_notify_mi_serialize(
+ const struct lttng_action *action, struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_action_status status;
+ enum lttng_error_code ret_code;
+ const struct lttng_rate_policy *policy = NULL;
+
+ assert(action);
+ assert(IS_NOTIFY_ACTION(action));
+ assert(writer);
+
+ status = lttng_action_notify_get_rate_policy(action, &policy);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(policy != NULL);
+
+ /* Open action notify. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_action_notify);
+ if (ret) {
+ goto mi_error;
+ }
+
+ ret_code = lttng_rate_policy_mi_serialize(policy, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close action notify 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;
+}
+
struct lttng_action *lttng_action_notify_create(void)
{
struct lttng_rate_policy *policy = NULL;
lttng_action_notify_is_equal,
lttng_action_notify_destroy,
lttng_action_notify_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results);
+ lttng_action_generic_add_error_query_results,
+ lttng_action_notify_mi_serialize);
notify->policy = policy;
policy = NULL;
#include <common/dynamic-buffer.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/payload-view.h>
#include <common/payload.h>
#include <limits.h>
struct lttng_rate_policy **rate_policy);
typedef struct lttng_rate_policy *(*rate_policy_copy_cb)(
const struct lttng_rate_policy *source);
+typedef enum lttng_error_code (*rate_policy_mi_serialize_cb)(
+ const struct lttng_rate_policy *rate_policy,
+ struct mi_writer *writer);
struct lttng_rate_policy {
enum lttng_rate_policy_type type;
rate_policy_equal_cb equal;
rate_policy_destroy_cb destroy;
rate_policy_copy_cb copy;
+ rate_policy_mi_serialize_cb mi_serialize;
};
struct lttng_rate_policy_every_n {
rate_policy_serialize_cb serialize,
rate_policy_equal_cb equal,
rate_policy_destroy_cb destroy,
- rate_policy_copy_cb copy);
+ rate_policy_copy_cb copy,
+ rate_policy_mi_serialize_cb mi);
/* Forward declaration. Every n */
static bool lttng_rate_policy_every_n_should_execute(
rate_policy_serialize_cb serialize,
rate_policy_equal_cb equal,
rate_policy_destroy_cb destroy,
- rate_policy_copy_cb copy)
+ rate_policy_copy_cb copy,
+ rate_policy_mi_serialize_cb mi)
{
rate_policy->type = type;
rate_policy->serialize = serialize;
rate_policy->equal = equal;
rate_policy->destroy = destroy;
rate_policy->copy = copy;
+ rate_policy->mi_serialize = mi;
}
void lttng_rate_policy_destroy(struct lttng_rate_policy *rate_policy)
return copy;
}
+static enum lttng_error_code lttng_rate_policy_every_n_mi_serialize(
+ const struct lttng_rate_policy *rate_policy,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const struct lttng_rate_policy_every_n *every_n_policy = NULL;
+
+ assert(rate_policy);
+ assert(IS_EVERY_N_RATE_POLICY(rate_policy));
+ assert(writer);
+
+ every_n_policy = rate_policy_every_n_from_rate_policy_const(
+ rate_policy);
+
+ /* Open rate_policy_every_n element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_rate_policy_every_n);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Interval. */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_rate_policy_every_n_interval,
+ every_n_policy->interval);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close rate_policy_every_n 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;
+}
+
struct lttng_rate_policy *lttng_rate_policy_every_n_create(uint64_t interval)
{
struct lttng_rate_policy_every_n *policy = NULL;
lttng_rate_policy_every_n_serialize,
lttng_rate_policy_every_n_is_equal,
lttng_rate_policy_every_n_destroy,
- lttng_rate_policy_every_n_copy);
+ lttng_rate_policy_every_n_copy,
+ lttng_rate_policy_every_n_mi_serialize);
policy->interval = interval;
return copy;
}
+static enum lttng_error_code lttng_rate_policy_once_after_n_mi_serialize(
+ const struct lttng_rate_policy *rate_policy,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const struct lttng_rate_policy_once_after_n *once_after_n_policy = NULL;
+
+ assert(rate_policy);
+ assert(IS_ONCE_AFTER_N_RATE_POLICY(rate_policy));
+ assert(writer);
+
+ once_after_n_policy = rate_policy_once_after_n_from_rate_policy_const(
+ rate_policy);
+
+ /* Open rate_policy_once_after_n. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_rate_policy_once_after_n);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Threshold. */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_rate_policy_once_after_n_threshold,
+ once_after_n_policy->threshold);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close rate_policy_once_after_n 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;
+}
+
struct lttng_rate_policy *lttng_rate_policy_once_after_n_create(
uint64_t threshold)
{
lttng_rate_policy_once_after_n_serialize,
lttng_rate_policy_once_after_n_is_equal,
lttng_rate_policy_once_after_n_destroy,
- lttng_rate_policy_once_after_n_copy);
+ lttng_rate_policy_once_after_n_copy,
+ lttng_rate_policy_once_after_n_mi_serialize);
policy->threshold = threshold;
return counter == once_after_n_policy->threshold;
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_rate_policy_mi_serialize(
+ const struct lttng_rate_policy *rate_policy,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+
+ assert(rate_policy);
+ assert(writer);
+ assert(rate_policy->mi_serialize);
+
+ /* Open rate policy element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_rate_policy);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize underlying rate policy. */
+ ret_code = rate_policy->mi_serialize(rate_policy, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close rate policy 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;
+}
#include <assert.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/rate-policy-internal.h>
#include <lttng/action/rate-policy.h>
return consumed_len;
}
+static enum lttng_error_code lttng_action_rotate_session_mi_serialize(
+ const struct lttng_action *action, struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_action_status status;
+ const char *session_name = NULL;
+ const struct lttng_rate_policy *policy = NULL;
+
+ assert(action);
+ assert(IS_ROTATE_SESSION_ACTION(action));
+
+ status = lttng_action_rotate_session_get_session_name(
+ action, &session_name);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(session_name != NULL);
+
+ status = lttng_action_notify_get_rate_policy(action, &policy);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(policy != NULL);
+
+ /* Open action rotate session element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_action_rotate_session);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Session name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Rate policy. */
+ ret_code = lttng_rate_policy_mi_serialize(policy, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close action rotate session 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;
+}
+
struct lttng_action *lttng_action_rotate_session_create(void)
{
struct lttng_action *action = NULL;
lttng_action_rotate_session_is_equal,
lttng_action_rotate_session_destroy,
lttng_action_rotate_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results);
+ lttng_action_generic_add_error_query_results,
+ lttng_action_rotate_session_mi_serialize);
status = lttng_action_rotate_session_set_rate_policy(action, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
#include <assert.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/payload-view.h>
#include <common/payload.h>
#include <common/snapshot.h>
return consumed_len;
}
+static enum lttng_error_code lttng_action_snapshot_session_mi_serialize(
+ const struct lttng_action *action, struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_action_status status;
+ const char *session_name = NULL;
+ const struct lttng_snapshot_output *output = NULL;
+ const struct lttng_rate_policy *policy = NULL;
+
+ assert(action);
+ assert(IS_SNAPSHOT_SESSION_ACTION(action));
+
+ status = lttng_action_snapshot_session_get_session_name(
+ action, &session_name);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(session_name != NULL);
+
+ status = lttng_action_snapshot_session_get_rate_policy(action, &policy);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(policy != NULL);
+
+ /* Open action snapshot session element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_action_snapshot_session);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Session name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Output if any. */
+ status = lttng_action_snapshot_session_get_output(action, &output);
+ if (status == LTTNG_ACTION_STATUS_OK) {
+ assert(output != NULL);
+ ret_code = lttng_snapshot_output_mi_serialize(output, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ } else if (status != LTTNG_ACTION_STATUS_UNSET) {
+ /* This should not happen at this point. */
+ abort();
+ }
+
+ /* Rate policy. */
+ ret_code = lttng_rate_policy_mi_serialize(policy, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close action_snapshot_session 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;
+}
+
struct lttng_action *lttng_action_snapshot_session_create(void)
{
struct lttng_action *action = NULL;
lttng_action_snapshot_session_is_equal,
lttng_action_snapshot_session_destroy,
lttng_action_snapshot_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results);
+ lttng_action_generic_add_error_query_results,
+ lttng_action_snapshot_session_mi_serialize);
status = lttng_action_snapshot_session_set_rate_policy(action, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
#include <assert.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/rate-policy-internal.h>
#include <lttng/action/rate-policy.h>
return consumed_len;
}
+static enum lttng_error_code lttng_action_start_session_mi_serialize(
+ const struct lttng_action *action, struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_action_status status;
+ const char *session_name = NULL;
+ const struct lttng_rate_policy *policy = NULL;
+
+ assert(action);
+ assert(IS_START_SESSION_ACTION(action));
+
+ status = lttng_action_start_session_get_session_name(
+ action, &session_name);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(session_name != NULL);
+
+ status = lttng_action_start_session_get_rate_policy(action, &policy);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(policy != NULL);
+
+ /* Open action start session element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_action_start_session);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Session name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Rate policy. */
+ ret_code = lttng_rate_policy_mi_serialize(policy, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close action start session 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;
+}
+
struct lttng_action *lttng_action_start_session_create(void)
{
struct lttng_action *action = NULL;
lttng_action_start_session_is_equal,
lttng_action_start_session_destroy,
lttng_action_start_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results);
+ lttng_action_generic_add_error_query_results,
+ lttng_action_start_session_mi_serialize);
status = lttng_action_start_session_set_rate_policy(action, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
#include <assert.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/rate-policy-internal.h>
#include <lttng/action/rate-policy.h>
return consumed_len;
}
+static enum lttng_error_code lttng_action_stop_session_mi_serialize(
+ const struct lttng_action *action, struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_action_status status;
+ const char *session_name = NULL;
+ const struct lttng_rate_policy *policy = NULL;
+
+ assert(action);
+ assert(IS_STOP_SESSION_ACTION(action));
+
+ status = lttng_action_stop_session_get_session_name(
+ action, &session_name);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(session_name != NULL);
+
+ status = lttng_action_stop_session_get_rate_policy(action, &policy);
+ assert(status == LTTNG_ACTION_STATUS_OK);
+ assert(policy != NULL);
+
+ /* Open action stop session. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_action_start_session);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Session name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Rate policy. */
+ ret_code = lttng_rate_policy_mi_serialize(policy, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close action stop session 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;
+}
+
struct lttng_action *lttng_action_stop_session_create(void)
{
struct lttng_action *action = NULL;
lttng_action_stop_session_is_equal,
lttng_action_stop_session_destroy,
lttng_action_stop_session_internal_get_rate_policy,
- lttng_action_generic_add_error_query_results);
+ lttng_action_generic_add_error_query_results,
+ lttng_action_stop_session_mi_serialize);
status = lttng_action_stop_session_set_rate_policy(action, policy);
if (status != LTTNG_ACTION_STATUS_OK) {
*
*/
-#include <lttng/condition/condition-internal.h>
-#include <lttng/condition/buffer-usage-internal.h>
-#include <common/macros.h>
-#include <common/error.h>
#include <assert.h>
-#include <math.h>
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <float.h>
+#include <lttng/condition/buffer-usage-internal.h>
+#include <lttng/condition/condition-internal.h>
+#include <math.h>
#include <time.h>
#define IS_USAGE_CONDITION(condition) ( \
return is_equal;
}
+static enum lttng_error_code lttng_condition_buffer_usage_mi_serialize(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_condition_status status;
+ const char *session_name = NULL, *channel_name = NULL;
+ enum lttng_domain_type domain_type;
+ bool is_threshold_bytes = false;
+ double threshold_ratio;
+ uint64_t threshold_bytes;
+ const char *condition_type_str = NULL;
+
+ assert(condition);
+ assert(IS_USAGE_CONDITION(condition));
+
+ status = lttng_condition_buffer_usage_get_session_name(
+ condition, &session_name);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+ assert(session_name);
+
+ status = lttng_condition_buffer_usage_get_channel_name(
+ condition, &channel_name);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+ assert(session_name);
+
+ status = lttng_condition_buffer_usage_get_domain_type(
+ condition, &domain_type);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+
+ status = lttng_condition_buffer_usage_get_threshold(
+ condition, &threshold_bytes);
+ if (status == LTTNG_CONDITION_STATUS_OK) {
+ is_threshold_bytes = true;
+ } else if (status != LTTNG_CONDITION_STATUS_UNSET) {
+ /* Unexpected at this stage. */
+ ret_code = LTTNG_ERR_INVALID;
+ goto end;
+ }
+
+ if (!is_threshold_bytes) {
+ status = lttng_condition_buffer_usage_get_threshold_ratio(
+ condition, &threshold_ratio);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+ }
+
+ switch (lttng_condition_get_type(condition)) {
+ case LTTNG_CONDITION_TYPE_BUFFER_USAGE_HIGH:
+ condition_type_str =
+ mi_lttng_element_condition_buffer_usage_high;
+ break;
+ case LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW:
+ condition_type_str =
+ mi_lttng_element_condition_buffer_usage_low;
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ /* Open the sub type condition element. */
+ ret = mi_lttng_writer_open_element(writer, condition_type_str);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Session name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Channel name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_condition_channel_name, channel_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Domain. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ config_element_domain,
+ mi_lttng_domaintype_string(domain_type));
+ if (ret) {
+ goto mi_error;
+ }
+
+ if (is_threshold_bytes) {
+ /* Usage in bytes. */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_condition_threshold_bytes,
+ threshold_bytes);
+ if (ret) {
+ goto mi_error;
+ }
+ } else {
+ /* Ratio. */
+ ret = mi_lttng_writer_write_element_double(writer,
+ mi_lttng_element_condition_threshold_ratio,
+ threshold_ratio);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Closing sub type condition 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;
+}
+
static
struct lttng_condition *lttng_condition_buffer_usage_create(
enum lttng_condition_type type)
condition->parent.serialize = lttng_condition_buffer_usage_serialize;
condition->parent.equal = lttng_condition_buffer_usage_is_equal;
condition->parent.destroy = lttng_condition_buffer_usage_destroy;
+ condition->parent.mi_serialize = lttng_condition_buffer_usage_mi_serialize;
return &condition->parent;
}
*
*/
-#include <lttng/condition/condition-internal.h>
+#include <assert.h>
+#include <common/buffer-view.h>
+#include <common/dynamic-buffer.h>
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/condition/buffer-usage-internal.h>
+#include <lttng/condition/condition-internal.h>
#include <lttng/condition/event-rule-matches-internal.h>
#include <lttng/condition/session-consumed-size-internal.h>
#include <lttng/condition/session-rotation-internal.h>
-#include <common/macros.h>
-#include <common/error.h>
-#include <common/dynamic-buffer.h>
-#include <common/buffer-view.h>
+#include <lttng/error-query-internal.h>
#include <stdbool.h>
-#include <assert.h>
enum lttng_condition_type lttng_condition_get_type(
const struct lttng_condition *condition)
return "???";
}
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_condition_mi_serialize(
+ const struct lttng_trigger *trigger,
+ const struct lttng_condition *condition,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks *error_query_callbacks)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ struct lttng_error_query_results *error_query_results = NULL;
+
+ assert(condition);
+ assert(writer);
+ assert(condition->mi_serialize);
+
+ /* Open condition element. */
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_condition);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize underlying condition. */
+ ret_code = condition->mi_serialize(condition, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Serialize error query results for the action. */
+ if (error_query_callbacks && error_query_callbacks->action_cb) {
+ ret_code = error_query_callbacks->condition_cb(
+ trigger, &error_query_results);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ ret_code = lttng_error_query_results_mi_serialize(
+ error_query_results, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close condition 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:
+ lttng_error_query_results_destroy(error_query_results);
+ return ret_code;
+}
#include <assert.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <inttypes.h>
#include <limits.h>
#include <lttng/condition/condition-internal.h>
free(desc);
}
+static enum lttng_error_code lttng_condition_event_rule_matches_mi_serialize(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_condition_status status;
+ const struct lttng_event_rule *rule = NULL;
+ unsigned int capture_descriptor_count, i;
+
+ assert(condition);
+ assert(writer);
+ assert(IS_EVENT_RULE_MATCHES_CONDITION(condition));
+
+ status = lttng_condition_event_rule_matches_get_rule(condition, &rule);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+ assert(rule != NULL);
+
+ status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
+ condition, &capture_descriptor_count);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+
+ /* Open condition event rule matches element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_condition_event_rule_matches);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize the event rule. */
+ ret_code = lttng_event_rule_mi_serialize(rule, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Open the capture descriptors element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_capture_descriptors);
+ if (ret) {
+ goto mi_error;
+ }
+
+ for (i = 0; i < capture_descriptor_count; i++) {
+ const struct lttng_event_expr *descriptor = NULL;
+
+ descriptor = lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
+ condition, i);
+ assert(descriptor);
+
+ ret_code = lttng_event_expr_mi_serialize(descriptor, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close capture descriptors element. */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close condition_event_rule_matches. */
+ 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;
+}
+
struct lttng_condition *lttng_condition_event_rule_matches_create(
struct lttng_event_rule *rule)
{
lttng_condition_event_rule_matches_serialize,
condition->parent.equal = lttng_condition_event_rule_matches_is_equal,
condition->parent.destroy = lttng_condition_event_rule_matches_destroy,
+ condition->parent.mi_serialize = lttng_condition_event_rule_matches_mi_serialize,
lttng_event_rule_get(rule);
condition->rule = rule;
*
*/
+#include <assert.h>
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
+#include <float.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/condition/session-consumed-size-internal.h>
#include <lttng/constant.h>
-#include <common/macros.h>
-#include <common/error.h>
-#include <assert.h>
#include <math.h>
-#include <float.h>
#include <time.h>
#define IS_CONSUMED_SIZE_CONDITION(condition) ( \
return is_equal;
}
+static
+enum lttng_error_code lttng_condition_session_consumed_size_mi_serialize(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_condition_status status;
+ const char *session_name = NULL;
+ uint64_t threshold_bytes;
+
+ assert(condition);
+ assert(writer);
+ assert(IS_CONSUMED_SIZE_CONDITION(condition));
+
+ status = lttng_condition_session_consumed_size_get_session_name(
+ condition, &session_name);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+ assert(session_name);
+
+ status = lttng_condition_session_consumed_size_get_threshold(
+ condition, &threshold_bytes);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+
+ /* Open condition session consumed size element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_condition_session_consumed_size);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Session name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Threshold in bytes. */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_condition_threshold_bytes,
+ threshold_bytes);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close condition session consumed size 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;
+}
+
struct lttng_condition *lttng_condition_session_consumed_size_create(void)
{
struct lttng_condition_session_consumed_size *condition;
condition->parent.serialize = lttng_condition_session_consumed_size_serialize;
condition->parent.equal = lttng_condition_session_consumed_size_is_equal;
condition->parent.destroy = lttng_condition_session_consumed_size_destroy;
+ condition->parent.mi_serialize = lttng_condition_session_consumed_size_mi_serialize;
return &condition->parent;
}
*
*/
+#include <assert.h>
+#include <common/error.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/condition/condition-internal.h>
#include <lttng/condition/session-rotation-internal.h>
#include <lttng/location-internal.h>
-#include <common/macros.h>
-#include <common/error.h>
-#include <assert.h>
#include <stdbool.h>
static
void lttng_condition_session_rotation_destroy(
struct lttng_condition *condition);
+static
+enum lttng_error_code lttng_condition_session_rotation_mi_serialize(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer);
+
static const
struct lttng_condition rotation_condition_template = {
/* .type omitted; shall be set on creation. */
.serialize = lttng_condition_session_rotation_serialize,
.equal = lttng_condition_session_rotation_is_equal,
.destroy = lttng_condition_session_rotation_destroy,
+ .mi_serialize = lttng_condition_session_rotation_mi_serialize,
};
static
end:
return status;
}
+
+static
+enum lttng_error_code lttng_condition_session_rotation_mi_serialize(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_condition_status status;
+ const char *session_name = NULL;
+ const char *type_element_str = NULL;
+
+ assert(condition);
+ assert(writer);
+ assert(is_rotation_condition(condition));
+
+ switch (lttng_condition_get_type(condition)) {
+ case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
+ type_element_str =
+ mi_lttng_element_condition_session_rotation_completed;
+ break;
+ case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
+ type_element_str =
+ mi_lttng_element_condition_session_rotation_ongoing;
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ status = lttng_condition_session_rotation_get_session_name(
+ condition, &session_name);
+ assert(status == LTTNG_CONDITION_STATUS_OK);
+ assert(session_name);
+
+ /* Open condition session rotation_* element. */
+ ret = mi_lttng_writer_open_element(writer, type_element_str);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Session name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_session_name, session_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close condition session rotation 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;
+}
#include <common/dynamic-array.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/sessiond-comm/sessiond-comm.h>
#include <lttng/action/action-internal.h>
#include <lttng/action/list-internal.h>
struct lttng_dynamic_pointer_array results;
};
+static
+enum lttng_error_code lttng_error_query_result_mi_serialize(
+ const struct lttng_error_query_result *result,
+ struct mi_writer *writer);
+
+static
+enum lttng_error_code lttng_error_query_result_counter_mi_serialize(
+ const struct lttng_error_query_result *result,
+ struct mi_writer *writer);
struct lttng_error_query *lttng_error_query_trigger_create(
const struct lttng_trigger *trigger)
end:
return status;
}
+
+static
+enum lttng_error_code lttng_error_query_result_counter_mi_serialize(
+ const struct lttng_error_query_result *result,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_error_query_result_status status;
+ uint64_t value;
+
+ assert(result);
+ assert(writer);
+
+ status = lttng_error_query_result_counter_get_value(result, &value);
+ assert(status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+
+ /* Open error query result counter element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_error_query_result_counter);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Value. */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_error_query_result_counter_value,
+ value);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close error query result counter 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;
+}
+
+static
+enum lttng_error_code lttng_error_query_result_mi_serialize(
+ const struct lttng_error_query_result *result,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_error_query_result_status result_status;
+ enum lttng_error_query_result_type type;
+ const char *name = NULL;
+ const char *description = NULL;
+
+ assert(result);
+ assert(writer);
+
+ type = lttng_error_query_result_get_type(result);
+
+ result_status = lttng_error_query_result_get_name(result, &name);
+ assert(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+
+ result_status = lttng_error_query_result_get_description(
+ result, &description);
+ assert(result_status == LTTNG_ERROR_QUERY_RESULT_STATUS_OK);
+
+ /* Open error query result element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_error_query_result);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, mi_lttng_element_error_query_result_name, name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Description. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_error_query_result_description,
+ description);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize the result according to its sub type. */
+ switch (type) {
+ case LTTNG_ERROR_QUERY_RESULT_TYPE_COUNTER:
+ ret_code = lttng_error_query_result_counter_mi_serialize(
+ result, writer);
+ break;
+ default:
+ abort();
+ }
+
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close error query result 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;
+}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_error_query_results_mi_serialize(
+ const struct lttng_error_query_results *results,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ unsigned int i, count;
+ enum lttng_error_query_results_status results_status;
+
+ assert(results);
+ assert(writer);
+
+ /* Open error query results element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_error_query_results);
+ if (ret) {
+ goto mi_error;
+ }
+
+ results_status = lttng_error_query_results_get_count(results, &count);
+ assert(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
+
+ for (i = 0; i < count; i++) {
+ const struct lttng_error_query_result *result;
+
+ results_status = lttng_error_query_results_get_result(
+ results, &result, i);
+ assert(results_status == LTTNG_ERROR_QUERY_RESULTS_STATUS_OK);
+
+ /* A single error query result. */
+ ret_code = lttng_error_query_result_mi_serialize(result, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close error query results. */
+ 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;
+}
#include <common/bytecode/bytecode.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/event-expr-internal.h>
#include <lttng/event-expr.h>
#include <stdio.h>
return status;
}
+
+static
+enum lttng_error_code lttng_event_expr_event_payload_field_mi_serialize(
+ const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const char *name = NULL;
+
+ assert(expression);
+ assert(writer);
+ assert(expression->type == LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD);
+
+ name = lttng_event_expr_event_payload_field_get_name(expression);
+ assert(name);
+
+ /* Open event expr payload field element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_expr_payload_field);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close event expr payload field 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;
+}
+
+static
+enum lttng_error_code lttng_event_expr_channel_context_field_mi_serialize(
+ const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const char *name = NULL;
+
+ assert(expression);
+ assert(writer);
+ assert(expression->type == LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD);
+
+ name = lttng_event_expr_channel_context_field_get_name(expression);
+ assert(name);
+
+ /* Open event expr channel context field element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_event_expr_channel_context_field);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close event expr channel context field 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;
+}
+
+static
+enum lttng_error_code lttng_event_expr_app_specific_context_field_mi_serialize(
+ const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const char *provider_name = NULL;
+ const char *type_name = NULL;
+
+ assert(expression);
+ assert(writer);
+ assert(expression->type ==
+ LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD);
+
+ provider_name = lttng_event_expr_app_specific_context_field_get_provider_name(
+ expression);
+ assert(provider_name);
+
+ type_name = lttng_event_expr_app_specific_context_field_get_type_name(
+ expression);
+ assert(provider_name);
+
+ /* Open event expr app specific context field element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_event_expr_app_specific_context_field);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Provider name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_expr_provider_name,
+ provider_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Type name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_expr_type_name, type_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close event expr app specific context field 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;
+}
+
+static
+enum lttng_error_code lttng_event_expr_array_field_element_mi_serialize(
+ const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_event_expr_status status;
+ const struct lttng_event_expr *parent_expr = NULL;
+ unsigned int index;
+
+ assert(expression);
+ assert(writer);
+ assert(expression->type == LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT);
+
+ status = lttng_event_expr_array_field_element_get_index(
+ expression, &index);
+ assert(status == LTTNG_EVENT_EXPR_STATUS_OK);
+
+ parent_expr = lttng_event_expr_array_field_element_get_parent_expr(
+ expression);
+ assert(parent_expr != NULL);
+
+ /* Open event expr array field element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_event_expr_array_field_element);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Index. */
+ ret = mi_lttng_writer_write_element_unsigned_int(
+ writer, mi_lttng_element_event_expr_index, index);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Parent expression. */
+ ret_code = lttng_event_expr_mi_serialize(parent_expr, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close event expr array field 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;
+}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_event_expr_mi_serialize(
+ const struct lttng_event_expr *expression,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+
+ assert(expression);
+ assert(writer);
+
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_expr);
+ if (ret) {
+ goto mi_error;
+ }
+
+ switch (expression->type) {
+ case LTTNG_EVENT_EXPR_TYPE_EVENT_PAYLOAD_FIELD:
+ ret_code = lttng_event_expr_event_payload_field_mi_serialize(
+ expression, writer);
+ break;
+ case LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD:
+ ret_code = lttng_event_expr_channel_context_field_mi_serialize(
+ expression, writer);
+ break;
+ case LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD:
+ ret_code = lttng_event_expr_app_specific_context_field_mi_serialize(
+ expression, writer);
+ break;
+ case LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT:
+ ret_code = lttng_event_expr_array_field_element_mi_serialize(
+ expression, writer);
+ break;
+ default:
+ abort();
+ }
+
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ 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;
+}
#include <assert.h>
#include <common/error.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
#include <common/hashtable/hashtable.h>
#include <common/hashtable/utils.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/jul-logging-internal.h>
#include <lttng/event-rule/kernel-kprobe-internal.h>
#include <lttng/event-rule/kernel-syscall-internal.h>
-#include <lttng/event-rule/log4j-logging-internal.h>
-#include <lttng/event-rule/jul-logging-internal.h>
-#include <lttng/event-rule/python-logging-internal.h>
#include <lttng/event-rule/kernel-tracepoint-internal.h>
#include <lttng/event-rule/kernel-uprobe-internal.h>
+#include <lttng/event-rule/log4j-logging-internal.h>
+#include <lttng/event-rule/python-logging-internal.h>
#include <lttng/event-rule/user-tracepoint-internal.h>
#include <stdbool.h>
assert(rule->hash);
return rule->hash(rule);
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_event_rule_mi_serialize(
+ const struct lttng_event_rule *rule, struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+
+ assert(rule);
+ assert(writer);
+ assert(rule->mi_serialize);
+
+ /* Open event rule element. */
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_event_rule);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize underlying event rule. */
+ ret_code = rule->mi_serialize(rule, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close event rule 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;
+}
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/optional.h>
-#include <common/payload.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <common/string-utils/string-utils.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/event-rule/jul-logging-internal.h>
-#include <lttng/log-level-rule.h>
#include <lttng/event.h>
+#include <lttng/log-level-rule.h>
#define IS_JUL_LOGGING_EVENT_RULE(rule) \
(lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_JUL_LOGGING)
return event;
}
+static enum lttng_error_code lttng_event_rule_jul_logging_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 *filter = NULL;
+ const char *name_pattern = NULL;
+ const struct lttng_log_level_rule *log_level_rule = NULL;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_JUL_LOGGING_EVENT_RULE(rule));
+
+ status = lttng_event_rule_jul_logging_get_name_pattern(
+ rule, &name_pattern);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(name_pattern);
+
+ status = lttng_event_rule_jul_logging_get_filter(rule, &filter);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ status = lttng_event_rule_jul_logging_get_log_level_rule(
+ rule, &log_level_rule);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ /* Open event rule jul logging element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_jul_logging);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name pattern. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_name_pattern, name_pattern);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Filter expression. */
+ if (filter != NULL) {
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_filter_expression,
+ filter);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Log level rule. */
+ if (log_level_rule) {
+ ret_code = lttng_log_level_rule_mi_serialize(
+ log_level_rule, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close event rule jul logging 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;
+}
+
struct lttng_event_rule *lttng_event_rule_jul_logging_create(void)
{
struct lttng_event_rule *rule = NULL;
tp_rule->parent.hash = lttng_event_rule_jul_logging_hash;
tp_rule->parent.generate_lttng_event =
lttng_event_rule_jul_logging_generate_lttng_event;
+ tp_rule->parent.mi_serialize = lttng_event_rule_jul_logging_mi_serialize;
tp_rule->log_level_rule = NULL;
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
-#include <common/payload.h>
+#include <common/mi-lttng.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <ctype.h>
#include <lttng/constant.h>
-#include <lttng/event-rule/event-rule.h>
#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule.h>
#include <lttng/event-rule/kernel-kprobe-internal.h>
-#include <lttng/kernel-probe.h>
#include <lttng/kernel-probe-internal.h>
+#include <lttng/kernel-probe.h>
#include <stdio.h>
#define IS_KPROBE_EVENT_RULE(rule) \
return ret;
}
+static
+enum lttng_error_code lttng_event_rule_kernel_kprobe_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_kernel_probe_location *location = NULL;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_KPROBE_EVENT_RULE(rule));
+
+ status = lttng_event_rule_kernel_kprobe_get_event_name(
+ rule, &event_name);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(event_name);
+
+ status = lttng_event_rule_kernel_kprobe_get_location(rule, &location);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(location);
+
+ /* Open event rule kernel kprobe element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_kernel_kprobe);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* 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_kernel_probe_location_mi_serialize(location, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close event rule kernel kprobe 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;
+}
+
struct lttng_event_rule *lttng_event_rule_kernel_kprobe_create(
const struct lttng_kernel_probe_location *location)
{
krule->parent.generate_exclusions =
lttng_event_rule_kernel_kprobe_generate_exclusions;
krule->parent.hash = lttng_event_rule_kernel_kprobe_hash;
+ krule->parent.mi_serialize = lttng_event_rule_kernel_kprobe_mi_serialize;
if (kernel_probe_set_location(krule, location)) {
lttng_event_rule_destroy(rule);
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
-#include <common/payload.h>
+#include <common/mi-lttng.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <common/string-utils/string-utils.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/event-rule/kernel-syscall-internal.h>
return hash;
}
+static enum lttng_error_code lttng_event_rule_kernel_syscall_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;
+
+ enum lttng_event_rule_kernel_syscall_emission_site site_type;
+ const char *filter = NULL;
+ const char *name_pattern = NULL;
+ const char *site_type_str = NULL;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_SYSCALL_EVENT_RULE(rule));
+
+ status = lttng_event_rule_kernel_syscall_get_name_pattern(
+ rule, &name_pattern);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(name_pattern);
+
+ status = lttng_event_rule_kernel_syscall_get_filter(rule, &filter);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ site_type = lttng_event_rule_kernel_syscall_get_emission_site(rule);
+
+ switch (site_type) {
+ case LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY_EXIT:
+ site_type_str = mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
+ break;
+ case LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_ENTRY:
+ site_type_str = mi_lttng_event_rule_kernel_syscall_emission_site_entry;
+ break;
+ case LTTNG_EVENT_RULE_KERNEL_SYSCALL_EMISSION_SITE_EXIT:
+ site_type_str = mi_lttng_event_rule_kernel_syscall_emission_site_exit;
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ /* Open event rule kernel syscall element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_kernel_syscall);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Emission site. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_kernel_syscall_emission_site,
+ site_type_str);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name pattern. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_name_pattern, name_pattern);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Filter. */
+ if (filter != NULL) {
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_filter_expression,
+ filter);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Close event rule kernel syscall. */
+ 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;
+}
+
struct lttng_event_rule *lttng_event_rule_kernel_syscall_create(
enum lttng_event_rule_kernel_syscall_emission_site
emission_site)
syscall_rule->parent.generate_exclusions =
lttng_event_rule_kernel_syscall_generate_exclusions;
syscall_rule->parent.hash = lttng_event_rule_kernel_syscall_hash;
+ syscall_rule->parent.mi_serialize = lttng_event_rule_kernel_syscall_mi_serialize;
/* Default pattern is '*'. */
status = lttng_event_rule_kernel_syscall_set_name_pattern(rule, "*");
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/optional.h>
-#include <common/payload.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <common/string-utils/string-utils.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/event-rule/kernel-tracepoint-internal.h>
return hash;
}
+static enum lttng_error_code lttng_event_rule_kernel_tracepoint_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 *filter = NULL;
+ const char *name_pattern = NULL;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_KERNEL_TRACEPOINT_EVENT_RULE(rule));
+
+ status = lttng_event_rule_kernel_tracepoint_get_name_pattern(
+ rule, &name_pattern);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(name_pattern);
+
+ status = lttng_event_rule_kernel_tracepoint_get_filter(rule, &filter);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ /* Open event rule kernel tracepoint element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_kernel_tracepoint);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name pattern. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_name_pattern, name_pattern);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Filter. */
+ if (filter != NULL) {
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_filter_expression,
+ filter);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Close event rule kernel tracepoint 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;
+}
+
struct lttng_event_rule *lttng_event_rule_kernel_tracepoint_create(void)
{
struct lttng_event_rule *rule = NULL;
tp_rule->parent.generate_exclusions =
lttng_event_rule_kernel_tracepoint_generate_exclusions;
tp_rule->parent.hash = lttng_event_rule_kernel_tracepoint_hash;
+ tp_rule->parent.mi_serialize = lttng_event_rule_kernel_tracepoint_mi_serialize;
/* Not necessary for now. */
tp_rule->parent.generate_lttng_event = NULL;
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
-#include <common/payload.h>
+#include <common/mi-lttng.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/event-rule/kernel-uprobe-internal.h>
#include <lttng/userspace-probe-internal.h>
return ret;
}
+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;
+}
+
struct lttng_event_rule *lttng_event_rule_kernel_uprobe_create(
const struct lttng_userspace_probe_location *location)
{
urule->parent.generate_exclusions =
lttng_event_rule_kernel_uprobe_generate_exclusions;
urule->parent.hash = lttng_event_rule_kernel_uprobe_hash;
+ urule->parent.mi_serialize = lttng_event_rule_kernel_uprobe_mi_serialize;
if (userspace_probe_set_location(urule, location)) {
lttng_event_rule_destroy(rule);
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/optional.h>
-#include <common/payload.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <common/string-utils/string-utils.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/event-rule/log4j-logging-internal.h>
-#include <lttng/log-level-rule.h>
#include <lttng/event.h>
+#include <lttng/log-level-rule.h>
#define IS_LOG4J_LOGGING_EVENT_RULE(rule) \
(lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING)
return event;
}
+static enum lttng_error_code lttng_event_rule_log4j_logging_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 *filter = NULL;
+ const char *name_pattern = NULL;
+ const struct lttng_log_level_rule *log_level_rule = NULL;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_LOG4J_LOGGING_EVENT_RULE(rule));
+
+ status = lttng_event_rule_log4j_logging_get_name_pattern(
+ rule, &name_pattern);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(name_pattern);
+
+ status = lttng_event_rule_log4j_logging_get_filter(rule, &filter);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ status = lttng_event_rule_log4j_logging_get_log_level_rule(
+ rule, &log_level_rule);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ /* Open event rule log4j logging element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_log4j_logging);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name pattern. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_name_pattern, name_pattern);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Filter expression. */
+ if (filter != NULL) {
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_filter_expression,
+ filter);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Log level rule. */
+ if (log_level_rule) {
+ ret_code = lttng_log_level_rule_mi_serialize(
+ log_level_rule, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close event rule log4j logging 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;
+}
+
struct lttng_event_rule *lttng_event_rule_log4j_logging_create(void)
{
struct lttng_event_rule *rule = NULL;
tp_rule->parent.hash = lttng_event_rule_log4j_logging_hash;
tp_rule->parent.generate_lttng_event =
lttng_event_rule_log4j_logging_generate_lttng_event;
+ tp_rule->parent.mi_serialize = lttng_event_rule_log4j_logging_mi_serialize;
tp_rule->log_level_rule = NULL;
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/optional.h>
-#include <common/payload.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <common/string-utils/string-utils.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/event-rule/python-logging-internal.h>
-#include <lttng/log-level-rule.h>
#include <lttng/event.h>
+#include <lttng/log-level-rule.h>
#define IS_PYTHON_LOGGING_EVENT_RULE(rule) \
(lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_PYTHON_LOGGING)
return event;
}
+static enum lttng_error_code lttng_event_rule_python_logging_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 *filter = NULL;
+ const char *name_pattern = NULL;
+ const struct lttng_log_level_rule *log_level_rule = NULL;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_PYTHON_LOGGING_EVENT_RULE(rule));
+
+ status = lttng_event_rule_python_logging_get_name_pattern(
+ rule, &name_pattern);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(name_pattern);
+
+ status = lttng_event_rule_python_logging_get_filter(rule, &filter);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ status = lttng_event_rule_python_logging_get_log_level_rule(
+ rule, &log_level_rule);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ /* Open event rule python logging element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_python_logging);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name pattern. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_name_pattern, name_pattern);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Filter expression. */
+ if (filter != NULL) {
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_filter_expression,
+ filter);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Log level rule. */
+ if (log_level_rule) {
+ ret_code = lttng_log_level_rule_mi_serialize(
+ log_level_rule, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close event rule python logging 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;
+}
+
struct lttng_event_rule *lttng_event_rule_python_logging_create(void)
{
struct lttng_event_rule *rule = NULL;
tp_rule->parent.hash = lttng_event_rule_python_logging_hash;
tp_rule->parent.generate_lttng_event =
lttng_event_rule_python_logging_generate_lttng_event;
+ tp_rule->parent.mi_serialize = lttng_event_rule_python_logging_mi_serialize;
tp_rule->log_level_rule = NULL;
#include <assert.h>
#include <common/credentials.h>
#include <common/error.h>
+#include <common/hashtable/hashtable.h>
+#include <common/hashtable/utils.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <common/optional.h>
-#include <common/payload.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/runas.h>
-#include <common/hashtable/hashtable.h>
-#include <common/hashtable/utils.h>
#include <common/string-utils/string-utils.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/event-rule/user-tracepoint-internal.h>
-#include <lttng/log-level-rule.h>
#include <lttng/event.h>
+#include <lttng/log-level-rule.h>
#define IS_USER_TRACEPOINT_EVENT_RULE(rule) \
(lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_USER_TRACEPOINT)
return hash;
}
+static enum lttng_error_code lttng_event_rule_user_tracepoint_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 *filter = NULL;
+ const char *name_pattern = NULL;
+ const struct lttng_log_level_rule *log_level_rule = NULL;
+ unsigned int exclusion_count = 0;
+
+ assert(rule);
+ assert(writer);
+ assert(IS_USER_TRACEPOINT_EVENT_RULE(rule));
+
+ status = lttng_event_rule_user_tracepoint_get_name_pattern(
+ rule, &name_pattern);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+ assert(name_pattern);
+
+ status = lttng_event_rule_user_tracepoint_get_filter(rule, &filter);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ status = lttng_event_rule_user_tracepoint_get_log_level_rule(
+ rule, &log_level_rule);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK ||
+ status == LTTNG_EVENT_RULE_STATUS_UNSET);
+
+ status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_count(
+ rule, &exclusion_count);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+
+ /* Open event rule user tracepoint element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_event_rule_user_tracepoint);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name pattern. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_name_pattern, name_pattern);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Filter expression. */
+ if (filter != NULL) {
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_filter_expression,
+ filter);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Log level rule. */
+ if (log_level_rule) {
+ ret_code = lttng_log_level_rule_mi_serialize(
+ log_level_rule, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ if (exclusion_count != 0) {
+ int i;
+
+ /* Open the exclusion list. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions);
+ if (ret) {
+ goto mi_error;
+ }
+
+ for (i = 0; i < exclusion_count; i++) {
+ const char *exclusion;
+
+ status = lttng_event_rule_user_tracepoint_get_name_pattern_exclusion_at_index(
+ rule, i, &exclusion);
+ assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion,
+ exclusion);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Close the list. */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Close event rule user tracepoint 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;
+}
+
struct lttng_event_rule *lttng_event_rule_user_tracepoint_create(void)
{
struct lttng_event_rule *rule = NULL;
tp_rule->parent.generate_exclusions =
lttng_event_rule_user_tracepoint_generate_exclusions;
tp_rule->parent.hash = lttng_event_rule_user_tracepoint_hash;
+ tp_rule->parent.mi_serialize = lttng_event_rule_user_tracepoint_mi_serialize;
/* Not necessary for now. */
tp_rule->parent.generate_lttng_event = NULL;
#include "lttng/lttng-error.h"
#include <assert.h>
#include <common/error.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
#include <common/hashtable/hashtable.h>
#include <common/hashtable/utils.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
#include <fcntl.h>
#include <lttng/constant.h>
-#include <lttng/kernel-probe.h>
#include <lttng/kernel-probe-internal.h>
+#include <lttng/kernel-probe.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/unistd.h>
unsigned long lttng_kernel_probe_location_symbol_hash(
const struct lttng_kernel_probe_location *location);
+static
+enum lttng_error_code lttng_kernel_probe_location_address_mi_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
+
+static
+enum lttng_error_code lttng_kernel_probe_location_symbol_mi_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer);
+
enum lttng_kernel_probe_location_type lttng_kernel_probe_location_get_type(
const struct lttng_kernel_probe_location *location)
{
ret->equal = lttng_kernel_probe_location_address_is_equal;
ret->serialize = lttng_kernel_probe_location_address_serialize;
ret->hash = lttng_kernel_probe_location_address_hash;
+ ret->mi_serialize = lttng_kernel_probe_location_address_mi_serialize;
end:
return ret;
ret->equal = lttng_kernel_probe_location_symbol_is_equal;
ret->serialize = lttng_kernel_probe_location_symbol_serialize;
ret->hash = lttng_kernel_probe_location_symbol_hash;
+ ret->mi_serialize = lttng_kernel_probe_location_symbol_mi_serialize;
goto end;
error:
{
return location->hash(location);
}
+
+static
+enum lttng_error_code lttng_kernel_probe_location_address_mi_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_kernel_probe_location_status status;
+ uint64_t address;
+
+ assert(location);
+ assert(writer);
+ assert(location->type == LTTNG_KERNEL_PROBE_LOCATION_TYPE_ADDRESS);
+
+ status = lttng_kernel_probe_location_address_get_address(
+ location, &address);
+ assert(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK);
+
+ /* Open kernel probe location address element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_kernel_probe_location_address);
+ if (ret) {
+ goto mi_error;
+ }
+
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_kernel_probe_location_address_address,
+ address);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close kernel probe location address 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;
+}
+
+static
+enum lttng_error_code lttng_kernel_probe_location_symbol_mi_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_kernel_probe_location_status status;
+ const char *name = NULL;
+ uint64_t offset;
+
+ assert(location);
+ assert(writer);
+ assert(location->type ==
+ LTTNG_KERNEL_PROBE_LOCATION_TYPE_SYMBOL_OFFSET);
+
+ name = lttng_kernel_probe_location_symbol_get_name(location);
+ assert(name);
+
+ status = lttng_kernel_probe_location_symbol_get_offset(
+ location, &offset);
+ assert(status == LTTNG_KERNEL_PROBE_LOCATION_STATUS_OK);
+
+ /* Open kernel probe location symbol offset element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_kernel_probe_location_symbol_offset);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_kernel_probe_location_symbol_offset_name,
+ name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Offset. */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_kernel_probe_location_symbol_offset_offset,
+ offset);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close kernel probe location symbol offset 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;
+}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_kernel_probe_location_mi_serialize(
+ const struct lttng_kernel_probe_location *location,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+
+ assert(location);
+ assert(writer);
+
+ /* Open kernel probe location element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_kernel_probe_location);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize the location sub type. */
+ ret_code = location->mi_serialize(location, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close kernel probe location 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;
+}
#include <assert.h>
#include <common/dynamic-buffer.h>
#include <common/error.h>
-#include <common/macros.h>
#include <common/hashtable/hashtable.h>
#include <common/hashtable/utils.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <lttng/log-level-rule-internal.h>
#include <lttng/log-level-rule.h>
#include <stdbool.h>
return hash;
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_log_level_rule_mi_serialize(
+ const struct lttng_log_level_rule *rule,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_log_level_rule_status status;
+ const char *element_str = NULL;
+ int level;
+
+ assert(rule);
+ assert(writer);
+
+ switch (lttng_log_level_rule_get_type(rule)) {
+ case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
+ status = lttng_log_level_rule_exactly_get_level(rule, &level);
+ element_str = mi_lttng_element_log_level_rule_exactly;
+ break;
+ case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
+ element_str = mi_lttng_element_log_level_rule_at_least_as_severe_as;
+ status = lttng_log_level_rule_at_least_as_severe_as_get_level(
+ rule, &level);
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ assert(status == LTTNG_LOG_LEVEL_RULE_STATUS_OK);
+
+ /* Open log level rule element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_log_level_rule);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Log level rule type element. */
+ ret = mi_lttng_writer_open_element(writer, element_str);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Level. */
+ ret = mi_lttng_writer_write_element_signed_int(
+ writer, mi_lttng_element_log_level_rule_level, level);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close log level rule type element. */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close log level rule 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;
+}
const char * const mi_lttng_element_command = "command";
const char * const mi_lttng_element_command_action = "snapshot_action";
const char * const mi_lttng_element_command_add_context = "add-context";
+const char *const mi_lttng_element_command_add_trigger = "add-trigger";
const char * const mi_lttng_element_command_create = "create";
const char * const mi_lttng_element_command_destroy = "destroy";
const char * const mi_lttng_element_command_disable_channel = "disable-channel";
LTTNG_HIDDEN const char * const mi_lttng_element_command_regenerate_action = "regenerate_action";
const char * const mi_lttng_element_command_name = "name";
const char * const mi_lttng_element_command_output = "output";
+const char *const mi_lttng_element_command_remove_trigger = "remove-trigger";
const char * const mi_lttng_element_command_save = "save";
const char * const mi_lttng_element_command_set_session = "set-session";
const char * const mi_lttng_element_command_snapshot = "snapshot";
/* String related to enum lttng_trace_archive_location_relay_protocol_type */
LTTNG_HIDDEN const char * const mi_lttng_rotation_location_relay_protocol_str_tcp = "TCP";
+/* String related to rate_policy elements */
+LTTNG_HIDDEN const char *const mi_lttng_element_rate_policy = "rate_policy";
+LTTNG_HIDDEN const char *const mi_lttng_element_rate_policy_every_n =
+ "rate_policy_every_n";
+LTTNG_HIDDEN const char *const mi_lttng_element_rate_policy_once_after_n =
+ "rate_policy_once_after_n";
+
+LTTNG_HIDDEN const char *const mi_lttng_element_rate_policy_every_n_interval =
+ "interval";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_rate_policy_once_after_n_threshold =
+ "threshold";
+
+/* String related to action elements */
+LTTNG_HIDDEN const char *const mi_lttng_element_action = "action";
+LTTNG_HIDDEN const char *const mi_lttng_element_action_list = "action_list";
+LTTNG_HIDDEN const char *const mi_lttng_element_action_notify = "action_notify";
+LTTNG_HIDDEN const char *const mi_lttng_element_action_start_session =
+ "action_start_session";
+LTTNG_HIDDEN const char *const mi_lttng_element_action_stop_session =
+ "action_stop_session";
+LTTNG_HIDDEN const char *const mi_lttng_element_action_rotate_session =
+ "action_rotate_session";
+LTTNG_HIDDEN const char *const mi_lttng_element_action_snapshot_session =
+ "action_snapshot_session";
+LTTNG_HIDDEN const char *const mi_lttng_element_action_snapshot_session_output =
+ "output";
+
+/* String related to condition */
+LTTNG_HIDDEN const char *const mi_lttng_element_condition = "condition";
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_buffer_usage_high =
+ "condition_buffer_usage_high";
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_buffer_usage_low =
+ "condition_buffer_usage_low";
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_event_rule_matches =
+ "condition_event_rule_matches";
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_session_consumed_size =
+ "condition_session_consumed_size";
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_session_rotation =
+ "condition_session_rotation";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_condition_session_rotation_completed =
+ "condition_session_rotation_completed";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_condition_session_rotation_ongoing =
+ "condition_session_rotation_ongoing";
+
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_channel_name =
+ "channel_name";
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_threshold_bytes =
+ "threshold_bytes";
+LTTNG_HIDDEN const char *const mi_lttng_element_condition_threshold_ratio =
+ "threshold_ratio";
+
+/* String related to capture descriptor */
+LTTNG_HIDDEN const char *const mi_lttng_element_capture_descriptor =
+ "capture_descriptor";
+LTTNG_HIDDEN const char *const mi_lttng_element_capture_descriptors =
+ "capture_descriptors";
+
+/* String related to event expression */
+LTTNG_HIDDEN const char *const mi_lttng_element_event_expr = "event_expr";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_expr_payload_field =
+ "event_expr_payload_field";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_expr_channel_context_field =
+ "event_expr_channel_context_field";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_event_expr_app_specific_context_field =
+ "event_expr_app_specific_context_field";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_expr_array_field_element =
+ "event_expr_array_field_element";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_expr_provider_name =
+ "provider_name";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_expr_type_name =
+ "type_name";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_expr_index = "index";
+
+/* String related to event rule */
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule = "event_rule";
+
+/* String related to lttng_event_rule_type */
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_event_name =
+ "event_name";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_name_pattern =
+ "name_pattern";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_filter_expression =
+ "filter_expression";
+
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_jul_logging =
+ "event_rule_jul_logging";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_kernel_kprobe =
+ "event_rule_kernel_kprobe";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_kernel_syscall =
+ "event_rule_kernel_syscall";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_kernel_tracepoint =
+ "event_rule_kernel_tracepoint";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_kernel_uprobe =
+ "event_rule_kernel_uprobe";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_log4j_logging =
+ "event_rule_log4j_logging";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_python_logging =
+ "event_rule_python_logging";
+LTTNG_HIDDEN const char *const mi_lttng_element_event_rule_user_tracepoint =
+ "event_rule_user_tracepoint";
+
+/* String related to lttng_event_rule_kernel_syscall. */
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_event_rule_kernel_syscall_emission_site =
+ "emission_site";
+
+/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
+LTTNG_HIDDEN const char *const
+ mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit =
+ "entry+exit";
+LTTNG_HIDDEN const char
+ *const mi_lttng_event_rule_kernel_syscall_emission_site_entry =
+ "entry";
+LTTNG_HIDDEN const char *const
+ mi_lttng_event_rule_kernel_syscall_emission_site_exit = "exit";
+
+/* String related to lttng_event_rule_user_tracepoint */
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions =
+ "name_pattern_exclusions";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion =
+ "name_pattern_exclusion";
+
+/* String related to log level rule. */
+LTTNG_HIDDEN const char *const mi_lttng_element_log_level_rule =
+ "log_level_rule";
+LTTNG_HIDDEN const char *const mi_lttng_element_log_level_rule_exactly =
+ "log_level_rule_exactly";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_log_level_rule_at_least_as_severe_as =
+ "log_level_rule_at_least_as_severe_as";
+LTTNG_HIDDEN const char *const mi_lttng_element_log_level_rule_level = "level";
+
+/* String related to kernel probe location. */
+LTTNG_HIDDEN const char *const mi_lttng_element_kernel_probe_location =
+ "kernel_probe_location";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_kernel_probe_location_symbol_offset =
+ "kernel_probe_location_symbol_offset";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_kernel_probe_location_symbol_offset_name =
+ "name";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_kernel_probe_location_symbol_offset_offset =
+ "offset";
+
+LTTNG_HIDDEN const char *const mi_lttng_element_kernel_probe_location_address =
+ "kernel_probe_location_address";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_kernel_probe_location_address_address =
+ "address";
+
+/* String related to userspace probe location. */
+LTTNG_HIDDEN const char *const mi_lttng_element_userspace_probe_location =
+ "userspace_probe_location";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_userspace_probe_location_binary_path =
+ "binary_path";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_userspace_probe_location_function =
+ "userspace_probe_location_function";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_userspace_probe_location_function_name =
+ "name";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_userspace_probe_location_lookup_method =
+ "userspace_probe_location_lookup_method";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_function_default =
+ "userspace_probe_location_lookup_method_function_default";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_function_elf =
+ "userspace_probe_location_lookup_method_function_elf";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt =
+ "userspace_probe_location_lookup_method_tracepoint_sdt";
+LTTNG_HIDDEN const char
+ *const mi_lttng_element_userspace_probe_location_tracepoint =
+ "userspace_probe_location_tracepoint";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_userspace_probe_location_tracepoint_probe_name =
+ "probe_name";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_userspace_probe_location_tracepoint_provider_name =
+ "provider_name";
+
+/* String related to enum
+ * lttng_userspace_probe_location_function_instrumentation_type */
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_userspace_probe_location_function_instrumentation_type =
+ "instrumentation_type";
+LTTNG_HIDDEN const char *const
+ mi_lttng_userspace_probe_location_function_instrumentation_type_entry =
+ "ENTRY";
+
+/* String related to trigger */
+LTTNG_HIDDEN const char *const mi_lttng_element_triggers = "triggers";
+LTTNG_HIDDEN const char *const mi_lttng_element_trigger = "trigger";
+LTTNG_HIDDEN const char *const mi_lttng_element_trigger_owner_uid = "owner_uid";
+
+/* String related to error_query. */
+LTTNG_HIDDEN const char *const mi_lttng_element_error_query_result =
+ "error_query_result";
+LTTNG_HIDDEN const char *const mi_lttng_element_error_query_result_counter =
+ "error_query_result_counter";
+LTTNG_HIDDEN const char *const
+ mi_lttng_element_error_query_result_counter_value = "value";
+LTTNG_HIDDEN const char *const mi_lttng_element_error_query_result_description =
+ "description";
+LTTNG_HIDDEN const char *const mi_lttng_element_error_query_result_name =
+ "name";
+LTTNG_HIDDEN const char *const mi_lttng_element_error_query_result_type =
+ "type";
+LTTNG_HIDDEN const char *const mi_lttng_element_error_query_results =
+ "error_query_results";
+
/* String related to add-context command */
LTTNG_HIDDEN const char * const mi_lttng_element_context_symbol = "symbol";
case LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP:
return mi_lttng_rotation_location_relay_protocol_str_tcp;
default:
- /* Should not have an unknow relay protocol. */
+ /* Should not have an unknown relay protocol. */
assert(0);
return NULL;
}
LTTNG_HIDDEN
int mi_lttng_snapshot_list_output(struct mi_writer *writer,
- struct lttng_snapshot_output *output)
+ const struct lttng_snapshot_output *output)
{
int ret;
char package_url[LTTNG_NAME_MAX]; /* Define to the home page for this package. */
};
+/* Error query callbacks. */
+typedef enum lttng_error_code (*mi_lttng_error_query_trigger_cb)(
+ const struct lttng_trigger *trigger,
+ struct lttng_error_query_results **results);
+typedef enum lttng_error_code (*mi_lttng_error_query_condition_cb)(
+ const struct lttng_trigger *trigger,
+ struct lttng_error_query_results **results);
+typedef enum lttng_error_code (*mi_lttng_error_query_action_cb)(
+ const struct lttng_trigger *trigger,
+ const struct lttng_action_path *action_path,
+ struct lttng_error_query_results **results);
+
+struct mi_lttng_error_query_callbacks {
+ mi_lttng_error_query_trigger_cb trigger_cb;
+ mi_lttng_error_query_condition_cb condition_cb;
+ mi_lttng_error_query_action_cb action_cb;
+};
+
/* Strings related to command */
extern const char * const mi_lttng_element_command;
extern const char * const mi_lttng_element_command_action;
extern const char * const mi_lttng_element_command_add_context;
+extern const char *const mi_lttng_element_command_add_trigger;
extern const char * const mi_lttng_element_command_create;
extern const char * const mi_lttng_element_command_destroy;
extern const char * const mi_lttng_element_command_disable_channel;
extern const char * const mi_lttng_element_command_regenerate_action;
extern const char * const mi_lttng_element_command_name;
extern const char * const mi_lttng_element_command_output;
+extern const char *const mi_lttng_element_command_remove_trigger;
extern const char * const mi_lttng_element_command_save;
extern const char * const mi_lttng_element_command_set_session;
extern const char * const mi_lttng_element_command_snapshot;
/* String related to enum lttng_trace_archive_location_relay_protocol_type */
LTTNG_HIDDEN extern const char * const mi_lttng_rotation_location_relay_protocol_str_tcp;
+/* String related to rate_policy elements */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_rate_policy;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_rate_policy_every_n;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_rate_policy_once_after_n;
+
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_rate_policy_every_n_interval;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_rate_policy_once_after_n_threshold;
+
+/* String related to action elements */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_list;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_notify;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_start_session;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_stop_session;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_rotate_session;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_action_snapshot_session;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_action_snapshot_session_output;
+
+/* String related to condition */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_condition_buffer_usage_high;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_condition_buffer_usage_low;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_condition_event_rule_matches;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_condition_session_consumed_size;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_condition_session_rotation;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_condition_session_rotation_completed;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_condition_session_rotation_ongoing;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition_channel_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition_threshold_ratio;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_condition_threshold_bytes;
+
+/* String related to capture descriptor */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_capture_descriptor;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_capture_descriptors;
+
+/* String related to event expression */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_payload_field;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_event_expr_channel_context_field;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_event_expr_app_specific_context_field;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_event_expr_array_field_element;
+
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_provider_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_type_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_expr_index;
+
+/* String related to event rule */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule;
+
+/* String related to lttng_event_rule */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_event_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_name_pattern;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_event_rule_filter_expression;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_jul_logging;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_kernel_kprobe;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_kernel_syscall;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_event_rule_kernel_tracepoint;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_kernel_uprobe;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_log4j_logging;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_event_rule_python_logging;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_event_rule_user_tracepoint;
+
+/* String related to lttng_event_rule_kernel_syscall. */
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_event_rule_kernel_syscall_emission_site;
+
+/* String related to enum lttng_event_rule_kernel_syscall_emission_site. */
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_event_rule_kernel_syscall_emission_site_entry_exit;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_event_rule_kernel_syscall_emission_site_entry;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_event_rule_kernel_syscall_emission_site_exit;
+
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusions;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_event_rule_user_tracepoint_name_pattern_exclusion;
+
+/* String related to log level rule. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_log_level_rule;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_log_level_rule_exactly;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_log_level_rule_at_least_as_severe_as;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_log_level_rule_at_least_as_severe_as_thre;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_log_level_rule_level;
+
+/* String related to kernel probe location. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_kernel_probe_location;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_kernel_probe_location_symbol_offset;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_kernel_probe_location_symbol_offset_name;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_kernel_probe_location_symbol_offset_offset;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_kernel_probe_location_address;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_kernel_probe_location_address_address;
+
+/* String related to userspace probe location. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_userspace_probe_location;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_userspace_probe_location_binary_path;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_userspace_probe_location_function;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_userspace_probe_location_function_name;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_userspace_probe_location_lookup_method;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_function_default;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_userspace_probe_location_tracepoint;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_userspace_probe_location_tracepoint_probe_name;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_userspace_probe_location_tracepoint_provider_name;
+
+/* String related to enum
+ * lttng_userspace_probe_location_function_instrumentation_type */
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_element_userspace_probe_location_function_instrumentation_type;
+LTTNG_HIDDEN extern const char *const
+ mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
+
+/* String related to trigger */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_triggers;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_trigger;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_trigger_owner_uid;
+
+/* String related to error_query. */
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_result;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_error_query_result_counter;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_error_query_result_counter_value;
+LTTNG_HIDDEN extern const char
+ *const mi_lttng_element_error_query_result_description;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_result_name;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_result_type;
+LTTNG_HIDDEN extern const char *const mi_lttng_element_error_query_results;
+
/* String related to add-context command */
LTTNG_HIDDEN extern const char * const mi_lttng_element_context_symbol;
* Negative values indicate an error.
*/
int mi_lttng_snapshot_list_output(struct mi_writer *writer,
- struct lttng_snapshot_output *output);
+ const struct lttng_snapshot_output *output);
/*
* Machine interface of the output of the command snapshot del output
*
*/
-#include <common/payload.h>
+#include <common/error.h>
+#include <common/mi-lttng.h>
#include <common/payload-view.h>
+#include <common/payload.h>
#include <common/snapshot.h>
#include <lttng/snapshot-internal.h>
#include <lttng/snapshot.h>
lttng_snapshot_output_destroy(output);
return ret;
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_snapshot_output_mi_serialize(
+ const struct lttng_snapshot_output *output,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+
+ assert(output);
+ assert(writer);
+
+ /* Open output element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_action_snapshot_session_output);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Name. */
+ if (strnlen(output->name, LTTNG_NAME_MAX) != 0) {
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, output->name);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Control url (always present). */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_snapshot_ctrl_url, output->ctrl_url);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Data url (optional). */
+ if (strnlen(output->data_url, PATH_MAX) != 0) {
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_snapshot_data_url,
+ output->data_url);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /*
+ * Maximum size in bytes of the snapshot meaning the total size of all
+ * streams combined. A value of 0 means unlimited. The default value is
+ * UINT64_MAX which also means unlimited in practice.
+ *
+ * The value is not serialized when it is set to either of those values
+ * to normalize them to '0'.
+ */
+ if (output->max_size > 0 && output->max_size != UINT64_MAX) {
+ /* Total size of all stream combined. */
+ ret = mi_lttng_writer_write_element_unsigned_int(writer,
+ mi_lttng_element_snapshot_max_size,
+ output->max_size);
+ if (ret) {
+ goto mi_error;
+ }
+ }
+
+ /* Close output 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;
+}
struct lttng_payload_view;
struct lttng_payload;
struct lttng_snapshot_output;
+struct mi_writer;
LTTNG_HIDDEN
bool lttng_snapshot_output_validate(const struct lttng_snapshot_output *output);
struct lttng_payload_view *view,
struct lttng_snapshot_output **output_p);
+LTTNG_HIDDEN
+enum lttng_error_code lttng_snapshot_output_mi_serialize(
+ const struct lttng_snapshot_output *output,
+ struct mi_writer *writer);
+
#endif /* COMMON_SNAPSHOT_H */
#include <common/credentials.h>
#include <common/dynamic-array.h>
#include <common/error.h>
+#include <common/mi-lttng.h>
#include <common/optional.h>
#include <common/payload-view.h>
#include <common/payload.h>
#include <lttng/condition/event-rule-matches-internal.h>
#include <lttng/condition/event-rule-matches.h>
#include <lttng/domain.h>
+#include <lttng/error-query-internal.h>
#include <lttng/event-expr-internal.h>
#include <lttng/event-rule/event-rule-internal.h>
#include <lttng/trigger/trigger-internal.h>
{
pthread_mutex_unlock(&trigger->lock);
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_trigger_mi_serialize(const struct lttng_trigger *trigger,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_trigger_status trigger_status;
+ const struct lttng_condition *condition = NULL;
+ const struct lttng_action *action = NULL;
+ struct lttng_dynamic_array action_path_indexes;
+ uid_t owner_uid;
+
+ assert(trigger);
+ assert(writer);
+
+ lttng_dynamic_array_init(&action_path_indexes, sizeof(uint64_t), NULL);
+
+ /* Open trigger element. */
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_trigger);
+ if (ret) {
+ goto mi_error;
+ }
+
+ trigger_status = lttng_trigger_get_owner_uid(trigger, &owner_uid);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ /* Name. */
+ ret = mi_lttng_writer_write_element_string(
+ writer, config_element_name, trigger->name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Owner uid. */
+ ret = mi_lttng_writer_write_element_signed_int(writer,
+ mi_lttng_element_trigger_owner_uid,
+ (int64_t) owner_uid);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Condition. */
+ condition = lttng_trigger_get_const_condition(trigger);
+ assert(condition);
+ ret_code = lttng_condition_mi_serialize(
+ trigger, condition, writer, error_query_callbacks);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Action. */
+ action = lttng_trigger_get_const_action(trigger);
+ assert(action);
+ ret_code = lttng_action_mi_serialize(trigger, action, writer,
+ error_query_callbacks, &action_path_indexes);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ if (error_query_callbacks && error_query_callbacks->trigger_cb) {
+ struct lttng_error_query_results *results = NULL;
+
+ ret_code = error_query_callbacks->trigger_cb(trigger, &results);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ ret_code = lttng_error_query_results_mi_serialize(
+ results, writer);
+ lttng_error_query_results_destroy(results);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close trigger 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:
+ lttng_dynamic_array_reset(&action_path_indexes);
+ return ret_code;
+}
+
+/* Used by qsort, which expects the semantics of strcmp(). */
+static int compare_triggers_by_name(const void *a, const void *b)
+{
+ const struct lttng_trigger *trigger_a =
+ *((const struct lttng_trigger **) a);
+ const struct lttng_trigger *trigger_b =
+ *((const struct lttng_trigger **) b);
+ const char *name_a, *name_b;
+ enum lttng_trigger_status trigger_status;
+
+ /* Anonymous triggers are not reachable here. */
+ trigger_status = lttng_trigger_get_name(trigger_a, &name_a);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ trigger_status = lttng_trigger_get_name(trigger_b, &name_b);
+ assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+ return strcmp(name_a, name_b);
+}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_triggers_mi_serialize(const struct lttng_triggers *triggers,
+ struct mi_writer *writer,
+ const struct mi_lttng_error_query_callbacks
+ *error_query_callbacks)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_trigger_status status;
+ unsigned int count, i;
+ struct lttng_dynamic_pointer_array sorted_triggers;
+
+ assert(triggers);
+ assert(writer);
+
+ /*
+ * Sort trigger by name to ensure an order at the MI level and ignore
+ * any anonymous trigger present.
+ */
+ lttng_dynamic_pointer_array_init(&sorted_triggers, NULL);
+
+ status = lttng_triggers_get_count(triggers, &count);
+ assert(status == LTTNG_TRIGGER_STATUS_OK);
+
+ for (i = 0; i < count; i++) {
+ int add_ret;
+ const char *unused_name;
+ const struct lttng_trigger *trigger =
+ lttng_triggers_get_at_index(triggers, i);
+
+ status = lttng_trigger_get_name(trigger, &unused_name);
+ switch (status) {
+ case LTTNG_TRIGGER_STATUS_OK:
+ break;
+ case LTTNG_TRIGGER_STATUS_UNSET:
+ /* Don't list anonymous triggers. */
+ continue;
+ default:
+ abort();
+ }
+
+ add_ret = lttng_dynamic_pointer_array_add_pointer(
+ &sorted_triggers, (void *) trigger);
+
+ if (add_ret) {
+ ERR("Failed to lttng_trigger to sorting array.");
+ ret_code = LTTNG_ERR_NOMEM;
+ goto error;
+ }
+ }
+
+ qsort(sorted_triggers.array.buffer.data, count,
+ sizeof(struct lttng_trigger *),
+ compare_triggers_by_name);
+
+ /* Open triggers element. */
+ ret = mi_lttng_writer_open_element(writer, mi_lttng_element_triggers);
+ if (ret) {
+ ret_code = LTTNG_ERR_MI_IO_FAIL;
+ goto error;
+ }
+
+ for (i = 0; i < lttng_dynamic_pointer_array_get_count(&sorted_triggers); i++) {
+ const struct lttng_trigger *trigger =
+ (const struct lttng_trigger *)
+ lttng_dynamic_pointer_array_get_pointer(
+ &sorted_triggers, i);
+
+ lttng_trigger_mi_serialize(trigger, writer, error_query_callbacks);
+ }
+
+ /* Close triggers element. */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ ret_code = LTTNG_ERR_MI_IO_FAIL;
+ goto error;
+ }
+
+ ret_code = LTTNG_OK;
+
+error:
+ lttng_dynamic_pointer_array_reset(&sorted_triggers);
+ return ret_code;
+}
#include <assert.h>
#include <common/compat/string.h>
#include <common/error.h>
-#include <common/macros.h>
-#include <common/payload.h>
-#include <common/payload-view.h>
#include <common/hashtable/hashtable.h>
#include <common/hashtable/utils.h>
+#include <common/macros.h>
+#include <common/mi-lttng.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
#include <fcntl.h>
#include <lttng/constant.h>
#include <lttng/userspace-probe-internal.h>
struct lttng_userspace_probe_location *location,
struct fd_handle *binary_fd_handle);
+static
+enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
+ const struct lttng_userspace_probe_location_lookup_method
+ *method,
+ struct mi_writer *writer);
+
+static
+enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer);
+
+static
+enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer);
+
enum lttng_userspace_probe_location_lookup_method_type
lttng_userspace_probe_location_lookup_method_get_type(
const struct lttng_userspace_probe_location_lookup_method *lookup_method)
{
return location->hash(location);
}
+
+LTTNG_HIDDEN
+enum lttng_error_code lttng_userspace_probe_location_mi_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer)
+{
+ typedef enum lttng_error_code (*mi_fp)(
+ const struct lttng_userspace_probe_location *,
+ struct mi_writer *);
+
+ int ret;
+ enum lttng_error_code ret_code;
+ mi_fp mi_function = NULL;
+
+ assert(location);
+ assert(writer);
+
+ switch (lttng_userspace_probe_location_get_type(location)) {
+ case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_FUNCTION:
+ mi_function = lttng_userspace_probe_location_function_mi_serialize;
+ break;
+ case LTTNG_USERSPACE_PROBE_LOCATION_TYPE_TRACEPOINT:
+ mi_function = lttng_userspace_probe_location_tracepoint_mi_serialize;
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ /* Open userspace probe location element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_userspace_probe_location);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Underlying user space probe location. */
+ ret_code = mi_function(location, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close userspace probe location 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;
+}
+
+enum lttng_error_code lttng_userspace_probe_location_lookup_method_mi_serialize(
+ const struct lttng_userspace_probe_location_lookup_method
+ *method,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const char *type_element_str;
+
+ assert(method);
+ assert(writer);
+
+ switch (lttng_userspace_probe_location_lookup_method_get_type(method)) {
+ case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_DEFAULT:
+ type_element_str =
+ mi_lttng_element_userspace_probe_location_lookup_method_function_default;
+ break;
+ case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_FUNCTION_ELF:
+ type_element_str =
+ mi_lttng_element_userspace_probe_location_lookup_method_function_elf;
+ break;
+ case LTTNG_USERSPACE_PROBE_LOCATION_LOOKUP_METHOD_TYPE_TRACEPOINT_SDT:
+ type_element_str =
+ mi_lttng_element_userspace_probe_location_lookup_method_tracepoint_sdt;
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ /* Open userspace probe location lookup method element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_userspace_probe_location_lookup_method);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* User space probe location lookup method empty element. */
+ ret = mi_lttng_writer_open_element(writer, type_element_str);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close userspace probe location lookup method element. */
+ ret = mi_lttng_close_multi_element(writer, 2);
+ if (ret) {
+ goto mi_error;
+ }
+
+ ret_code = LTTNG_OK;
+ goto end;
+
+mi_error:
+ ret_code = LTTNG_ERR_MI_IO_FAIL;
+end:
+ return ret_code;
+}
+
+static enum lttng_error_code lttng_userspace_probe_location_tracepoint_mi_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const char *probe_name = NULL;
+ const char *provider_name = NULL;
+ const char *binary_path = NULL;
+ const struct lttng_userspace_probe_location_lookup_method
+ *lookup_method = NULL;
+
+ assert(location);
+ assert(writer);
+
+ probe_name = lttng_userspace_probe_location_tracepoint_get_probe_name(
+ location);
+ provider_name = lttng_userspace_probe_location_tracepoint_get_provider_name(
+ location);
+ binary_path = lttng_userspace_probe_location_tracepoint_get_binary_path(
+ location);
+ lookup_method = lttng_userspace_probe_location_tracepoint_get_lookup_method(
+ location);
+
+ /* Open userspace probe location tracepoint element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_userspace_probe_location_tracepoint);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Probe name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_userspace_probe_location_tracepoint_probe_name,
+ probe_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Provider name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_userspace_probe_location_tracepoint_provider_name,
+ provider_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Binary path. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_userspace_probe_location_binary_path,
+ binary_path);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* The lookup method. */
+ ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(
+ lookup_method, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close userspace probe location tracepoint. */
+ 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;
+}
+
+static enum lttng_error_code lttng_userspace_probe_location_function_mi_serialize(
+ const struct lttng_userspace_probe_location *location,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ const char *function_name = NULL;
+ const char *binary_path = NULL;
+ const char *instrumentation_type_str = NULL;
+ enum lttng_userspace_probe_location_function_instrumentation_type
+ instrumentation_type;
+ const struct lttng_userspace_probe_location_lookup_method
+ *lookup_method = NULL;
+
+ assert(location);
+ assert(writer);
+
+ function_name = lttng_userspace_probe_location_function_get_function_name(
+ location);
+ binary_path = lttng_userspace_probe_location_function_get_binary_path(
+ location);
+ instrumentation_type =
+ lttng_userspace_probe_location_function_get_instrumentation_type(
+ location);
+ lookup_method = lttng_userspace_probe_location_function_get_lookup_method(
+ location);
+
+ switch (instrumentation_type) {
+ case LTTNG_USERSPACE_PROBE_LOCATION_FUNCTION_INSTRUMENTATION_TYPE_ENTRY:
+ instrumentation_type_str =
+ mi_lttng_userspace_probe_location_function_instrumentation_type_entry;
+ break;
+ default:
+ abort();
+ break;
+ }
+
+ /* Open userspace probe location function element. */
+ ret = mi_lttng_writer_open_element(writer,
+ mi_lttng_element_userspace_probe_location_function);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Function name. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_userspace_probe_location_function_name,
+ function_name);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Binary path. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_userspace_probe_location_binary_path,
+ binary_path);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Instrumentation type. */
+ ret = mi_lttng_writer_write_element_string(writer,
+ mi_lttng_element_userspace_probe_location_function_instrumentation_type,
+ instrumentation_type_str);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* The lookup method. */
+ ret_code = lttng_userspace_probe_location_lookup_method_mi_serialize(
+ lookup_method, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Close userspace probe location function 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;
+}