SoW-2020-0002: Trace Hit Counters
[lttng-tools.git] / src / bin / lttng-sessiond / agent.c
index 283d5b0353e16d2832b9a37fce71b9c66ea12cd3..cbd81c57622a05cfa2a1f5a9375579a9169c9551 100644 (file)
@@ -15,8 +15,9 @@
 #include <lttng/event-rule/event-rule-internal.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/condition/condition.h>
-#include <lttng/condition/event-rule.h>
+#include <lttng/condition/on-event.h>
 #include <lttng/domain-internal.h>
+#include <lttng/log-level-rule-internal.h>
 
 #include <common/common.h>
 #include <common/sessiond-comm/agent.h>
@@ -1243,6 +1244,7 @@ struct agent_event *agent_find_event_by_trigger(
        const struct lttng_event_rule *rule;
        const char *name;
        const char *filter_expression;
+       const struct lttng_log_level_rule *log_level_rule;
        /* Unused when loglevel_type is 'ALL'. */
        int loglevel_value = 0;
        enum lttng_loglevel_type loglevel_type;
@@ -1253,9 +1255,9 @@ struct agent_event *agent_find_event_by_trigger(
        condition = lttng_trigger_get_const_condition(trigger);
 
        assert(lttng_condition_get_type(condition) ==
-                       LTTNG_CONDITION_TYPE_EVENT_RULE_HIT);
+                       LTTNG_CONDITION_TYPE_ON_EVENT);
 
-       c_status = lttng_condition_event_rule_get_rule(condition, &rule);
+       c_status = lttng_condition_on_event_get_rule(condition, &rule);
        assert(c_status == LTTNG_CONDITION_STATUS_OK);
 
        assert(lttng_event_rule_get_type(rule) ==
@@ -1272,14 +1274,19 @@ struct agent_event *agent_find_event_by_trigger(
        /* Get the internal filter expression. */
        filter_expression = lttng_event_rule_get_filter(rule);
 
-       er_status = lttng_event_rule_tracepoint_get_log_level_type(
-                       rule, &loglevel_type);
-       assert(er_status == LTTNG_EVENT_RULE_STATUS_OK);
-
-       if (loglevel_type != LTTNG_EVENT_LOGLEVEL_ALL) {
-               er_status = lttng_event_rule_tracepoint_get_log_level(
-                               rule, &loglevel_value);
-               assert(er_status == LTTNG_EVENT_RULE_STATUS_OK);
+       /* Map log_level_rule to loglevel.
+        * TODO: There is a possibility of extracting this to the log_level_rule
+        * internal api since multiple callsite do the same.
+        */
+       er_status = lttng_event_rule_tracepoint_get_log_level_rule(
+                       rule, &log_level_rule);
+       if (er_status == LTTNG_EVENT_RULE_STATUS_UNSET) {
+               loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
+               loglevel_value = 0;
+       } else if (er_status == LTTNG_EVENT_RULE_STATUS_OK) {
+               lttng_log_level_rule_to_loglevel(log_level_rule, &loglevel_type, &loglevel_value);
+       } else {
+               abort();
        }
 
        return agent_find_event(name, loglevel_type, loglevel_value,
This page took 0.026047 seconds and 5 git commands to generate.