SoW-2020-0002: Trace Hit Counters: trigger error reporting integration
[lttng-tools.git] / src / common / event-rule / tracepoint.c
index 14e4c7b01901e9b7706ab5e3b83162ba82764337..c3b9d0783b49b4febdfe4877649507174ebe7b1b 100644 (file)
@@ -13,6 +13,7 @@
 #include <common/runas.h>
 #include <lttng/event-rule/event-rule-internal.h>
 #include <lttng/event-rule/tracepoint-internal.h>
+#include <lttng/event.h>
 
 #define IS_TRACEPOINT_EVENT_RULE(rule) \
        (lttng_event_rule_get_type(rule) == LTTNG_EVENT_RULE_TYPE_TRACEPOINT)
@@ -365,7 +366,7 @@ lttng_event_rule_tracepoint_generate_filter_bytecode(
        enum lttng_domain_type domain_type;
        enum lttng_event_rule_status status;
        const char *filter;
-       struct lttng_filter_bytecode *bytecode = NULL;
+       struct lttng_bytecode *bytecode = NULL;
 
        assert(rule);
 
@@ -457,7 +458,7 @@ static const char *lttng_event_rule_tracepoint_get_internal_filter(
        return tracepoint->internal_filter.filter;
 }
 
-static const struct lttng_filter_bytecode *
+static const struct lttng_bytecode *
 lttng_event_rule_tracepoint_get_internal_filter_bytecode(
                const struct lttng_event_rule *rule)
 {
@@ -540,6 +541,35 @@ static void destroy_lttng_exclusions_element(void *ptr)
        free(ptr);
 }
 
+static struct lttng_event *lttng_event_rule_tracepoint_generate_lttng_event(
+               const struct lttng_event_rule *rule)
+{
+       const struct lttng_event_rule_tracepoint *tracepoint;
+       struct lttng_event *local_event = NULL;
+       struct lttng_event *event = NULL;
+
+       tracepoint = container_of(
+                       rule, const struct lttng_event_rule_tracepoint, parent);
+
+       local_event = zmalloc(sizeof(*local_event));
+       if (!local_event) {
+               goto error;
+       }
+
+       local_event->type = LTTNG_EVENT_TRACEPOINT;
+       (void) strncpy(local_event->name, tracepoint->pattern,
+                       sizeof(local_event->name) - 1);
+       local_event->name[sizeof(local_event->name) - 1] = '\0';
+       local_event->loglevel_type = tracepoint->loglevel.type;
+       local_event->loglevel = tracepoint->loglevel.value;
+
+       event = local_event;
+       local_event = NULL;
+error:
+       free(local_event);
+       return event;
+}
+
 struct lttng_event_rule *lttng_event_rule_tracepoint_create(
                enum lttng_domain_type domain_type)
 {
@@ -569,6 +599,8 @@ struct lttng_event_rule *lttng_event_rule_tracepoint_create(
                        lttng_event_rule_tracepoint_get_internal_filter_bytecode;
        tp_rule->parent.generate_exclusions =
                        lttng_event_rule_tracepoint_generate_exclusions;
+       tp_rule->parent.generate_lttng_event =
+                       lttng_event_rule_tracepoint_generate_lttng_event;
 
        tp_rule->domain = domain_type;
        tp_rule->loglevel.type = LTTNG_EVENT_LOGLEVEL_ALL;
This page took 0.033658 seconds and 5 git commands to generate.