*
*/
-#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>
b = container_of(_b, struct lttng_event_rule_kernel_uprobe, parent);
/* uprobe is invalid if this is not true. */
- assert(a->name);
- assert(b->name);
+ LTTNG_ASSERT(a->name);
+ LTTNG_ASSERT(b->name);
if (strcmp(a->name, b->name)) {
goto end;
}
- assert(a->location);
- assert(b->location);
+ LTTNG_ASSERT(a->location);
+ LTTNG_ASSERT(b->location);
is_equal = lttng_userspace_probe_location_is_equal(
a->location, b->location);
end:
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;
+
+ LTTNG_ASSERT(rule);
+ LTTNG_ASSERT(writer);
+ LTTNG_ASSERT(IS_UPROBE_EVENT_RULE(rule));
+
+ status = lttng_event_rule_kernel_uprobe_get_event_name(
+ rule, &event_name);
+ LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
+ LTTNG_ASSERT(event_name);
+
+ status = lttng_event_rule_kernel_uprobe_get_location(rule, &location);
+ LTTNG_ASSERT(status == LTTNG_EVENT_RULE_STATUS_OK);
+ LTTNG_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);
return rule;
}
-LTTNG_HIDDEN
ssize_t lttng_event_rule_kernel_uprobe_create_from_payload(
struct lttng_payload_view *view,
struct lttng_event_rule **_event_rule)
}
}
- assert(ret == uprobe_comm->location_len);
+ LTTNG_ASSERT(ret == uprobe_comm->location_len);
/* Skip after the location. */
offset += uprobe_comm->location_len;
return status;
}
-LTTNG_HIDDEN
struct lttng_userspace_probe_location *
lttng_event_rule_kernel_uprobe_get_location_mutable(
const struct lttng_event_rule *rule)
{
struct lttng_event_rule_kernel_uprobe *uprobe;
- assert(rule);
+ LTTNG_ASSERT(rule);
uprobe = container_of(rule, struct lttng_event_rule_kernel_uprobe, parent);
return uprobe->location;