lttng-ctl: Introduce lttng_log_level_rule
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 6e2659c1e08f385b99ee4b55fdba5e26953e11b2..6d71df5c0ce7b003b8a1e588a56eded479ae2a87 100644 (file)
@@ -26,8 +26,8 @@
 #include <lttng/event-rule/event-rule-internal.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/condition/condition.h>
-#include <lttng/condition/event-rule-internal.h>
-#include <lttng/condition/event-rule.h>
+#include <lttng/condition/on-event-internal.h>
+#include <lttng/condition/on-event.h>
 #include <lttng/trigger/trigger-internal.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 
@@ -1253,9 +1253,9 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule(
 
        condition = lttng_trigger_get_condition(trigger);
        assert(condition);
-       assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_EVENT_RULE_HIT);
+       assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT);
 
-       assert(LTTNG_CONDITION_STATUS_OK == lttng_condition_event_rule_get_rule(condition, &event_rule));
+       assert(LTTNG_CONDITION_STATUS_OK == lttng_condition_on_event_get_rule(condition, &event_rule));
        assert(event_rule);
 
        /* Acquire the event notifier's reference to the trigger. */
@@ -1585,7 +1585,7 @@ error:
 static int set_ust_capture(struct ust_app *app,
                const struct lttng_bytecode *bytecode,
                unsigned int capture_seqnum,
-               struct lttng_ust_object_data *ust_object)
+               struct lttng_ust_abi_object_data *ust_object)
 {
        int ret;
        struct lttng_ust_abi_capture_bytecode *ust_bytecode = NULL;
@@ -2000,7 +2000,6 @@ static int init_ust_event_notifier_from_event_rule(
                struct lttng_ust_abi_event_notifier *event_notifier)
 {
        enum lttng_event_rule_status status;
-       enum lttng_loglevel_type loglevel_type;
        enum lttng_ust_abi_loglevel_type ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
        int loglevel = -1, ret = 0;
        const char *pattern;
@@ -2023,39 +2022,40 @@ static int init_ust_event_notifier_from_event_rule(
                loglevel = 0;
                ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
        } else {
-               status = lttng_event_rule_tracepoint_get_pattern(
-                               rule, &pattern);
-               if (status != LTTNG_EVENT_RULE_STATUS_OK) {
-                       /* At this point, this is a fatal error. */
-                       abort();
-               }
+               const struct lttng_log_level_rule *log_level_rule;
 
-               status = lttng_event_rule_tracepoint_get_log_level_type(
-                               rule, &loglevel_type);
+               status = lttng_event_rule_tracepoint_get_pattern(rule, &pattern);
                if (status != LTTNG_EVENT_RULE_STATUS_OK) {
                        /* At this point, this is a fatal error. */
                        abort();
                }
 
-               switch (loglevel_type) {
-               case LTTNG_EVENT_LOGLEVEL_ALL:
+               status = lttng_event_rule_tracepoint_get_log_level_rule(
+                               rule, &log_level_rule);
+               if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
                        ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_ALL;
-                       break;
-               case LTTNG_EVENT_LOGLEVEL_RANGE:
-                       ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_RANGE;
-                       break;
-               case LTTNG_EVENT_LOGLEVEL_SINGLE:
-                       ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_SINGLE;
-                       break;
-               default:
-                       /* Unknown log level specification type. */
-                       abort();
-               }
+               } else if (status == LTTNG_EVENT_RULE_STATUS_OK) {
+                       enum lttng_log_level_rule_status llr_status;
+
+                       switch (lttng_log_level_rule_get_type(log_level_rule)) {
+                       case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY:
+                               ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_SINGLE;
+                               llr_status = lttng_log_level_rule_exactly_get_level(
+                                               log_level_rule, &loglevel);
+                               break;
+                       case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS:
+                               ust_loglevel_type = LTTNG_UST_ABI_LOGLEVEL_RANGE;
+                               llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level(
+                                               log_level_rule, &loglevel);
+                               break;
+                       default:
+                               abort();
+                       }
 
-               if (loglevel_type != LTTNG_EVENT_LOGLEVEL_ALL) {
-                       status = lttng_event_rule_tracepoint_get_log_level(
-                                       rule, &loglevel);
-                       assert(status == LTTNG_EVENT_RULE_STATUS_OK);
+                       assert(llr_status == LTTNG_LOG_LEVEL_RULE_STATUS_OK);
+               } else {
+                       /* At this point this is a fatal error. */
+                       abort();
                }
        }
 
@@ -2095,10 +2095,12 @@ static int create_ust_event_notifier(struct ust_app *app,
        condition = lttng_trigger_get_const_condition(
                        ua_event_notifier_rule->trigger);
        assert(condition);
-       assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_EVENT_RULE_HIT);
+       assert(lttng_condition_get_type(condition) == LTTNG_CONDITION_TYPE_ON_EVENT);
 
-       condition_status = lttng_condition_event_rule_get_rule(condition, &event_rule);
+       condition_status = lttng_condition_on_event_get_rule(
+                       condition, &event_rule);
        assert(condition_status == LTTNG_CONDITION_STATUS_OK);
+
        assert(event_rule);
        assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_TRACEPOINT);
 
@@ -2158,13 +2160,13 @@ static int create_ust_event_notifier(struct ust_app *app,
        }
 
        /* Set the capture bytecodes. */
-       cond_status = lttng_condition_event_rule_get_capture_descriptor_count(
+       cond_status = lttng_condition_on_event_get_capture_descriptor_count(
                        condition, &capture_bytecode_count);
        assert(cond_status == LTTNG_CONDITION_STATUS_OK);
 
        for (i = 0; i < capture_bytecode_count; i++) {
                const struct lttng_bytecode *capture_bytecode =
-                               lttng_condition_event_rule_get_capture_bytecode_at_index(
+                               lttng_condition_on_event_get_capture_bytecode_at_index(
                                                condition, i);
 
                ret = set_ust_capture(app, capture_bytecode, i,
@@ -5648,12 +5650,12 @@ void ust_app_synchronize_event_notifier_rules(struct ust_app *app)
                token = lttng_trigger_get_tracer_token(trigger);
                condition = lttng_trigger_get_condition(trigger);
 
-               if (lttng_condition_get_type(condition) != LTTNG_CONDITION_TYPE_EVENT_RULE_HIT) {
+               if (lttng_condition_get_type(condition) != LTTNG_CONDITION_TYPE_ON_EVENT) {
                        /* Does not apply */
                        continue;
                }
 
-               condition_status = lttng_condition_event_rule_borrow_rule_mutable(condition, &event_rule);
+               condition_status = lttng_condition_on_event_borrow_rule_mutable(condition, &event_rule);
                assert(condition_status == LTTNG_CONDITION_STATUS_OK);
 
                if (lttng_event_rule_get_domain_type(event_rule) == LTTNG_DOMAIN_KERNEL) {
This page took 0.025589 seconds and 4 git commands to generate.