Rename lttng_event_rule_tracepoint_(set,get)_pattern to lttng_event_rule_tracepoint_...
[lttng-tools.git] / src / bin / lttng / commands / list_triggers.c
index b497d4f4d82bcafeeb25d68395ecbb5b8778fc82..d33ed1fc4adc140a440ddb5b36cdf761b60ffb44 100644 (file)
@@ -159,7 +159,7 @@ void print_event_rule_tracepoint(const struct lttng_event_rule *event_rule)
        unsigned int exclusions_count;
        int i;
 
-       event_rule_status = lttng_event_rule_tracepoint_get_pattern(
+       event_rule_status = lttng_event_rule_tracepoint_get_name_pattern(
                        event_rule, &pattern);
        assert(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK);
 
@@ -539,9 +539,10 @@ static void print_condition_event_rule_matches(
        }
 }
 
-static
-void print_action_errors(const struct lttng_trigger *trigger,
-               const struct lttng_action *action)
+static void print_action_errors(const struct lttng_trigger *trigger,
+               const struct lttng_action *action,
+               const uint64_t *action_path_indexes,
+               size_t action_path_length)
 {
        unsigned int i, count, printed_errors_count = 0;
        enum lttng_error_code error_query_ret;
@@ -550,12 +551,19 @@ void print_action_errors(const struct lttng_trigger *trigger,
        const char *trigger_name;
        uid_t trigger_uid;
        enum lttng_trigger_status trigger_status;
-       struct lttng_error_query *query =
-                       lttng_error_query_action_create(trigger, action);
+       struct lttng_error_query *query;
+       struct lttng_action_path *action_path = lttng_action_path_create(
+                       action_path_indexes, action_path_length);
 
+       assert(action_path);
+
+       query = lttng_error_query_action_create(trigger, action_path);
        assert(query);
 
        trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
+       /*
+        * Anonymous triggers are not listed; this would be an internal error.
+        */
        assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
 
        trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
@@ -622,11 +630,14 @@ end:
        MSG("");
        lttng_error_query_destroy(query);
        lttng_error_query_results_destroy(results);
+       lttng_action_path_destroy(action_path);
 }
 
 static
 void print_one_action(const struct lttng_trigger *trigger,
-               const struct lttng_action *action)
+               const struct lttng_action *action,
+               const uint64_t *action_path_indexes,
+               size_t action_path_length)
 {
        enum lttng_action_type action_type;
        enum lttng_action_status action_status;
@@ -634,7 +645,7 @@ void print_one_action(const struct lttng_trigger *trigger,
        const char *value;
 
        action_type = lttng_action_get_type(action);
-       assert(action_type != LTTNG_ACTION_TYPE_GROUP);
+       assert(action_type != LTTNG_ACTION_TYPE_LIST);
 
        switch (action_type) {
        case LTTNG_ACTION_TYPE_NOTIFY:
@@ -770,7 +781,7 @@ void print_one_action(const struct lttng_trigger *trigger,
                                /* The default is 1 so print only when it is a
                                 * special case.
                                 */
-                               _MSG(", rate policy: after every %" PRIu64
+                               _MSG(", rate policy: every %" PRIu64
                                     " occurrences",
                                                policy_value);
                        }
@@ -792,7 +803,8 @@ void print_one_action(const struct lttng_trigger *trigger,
        }
 
        MSG("");
-       print_action_errors(trigger, action);
+       print_action_errors(trigger, action, action_path_indexes,
+                       action_path_length);
 
 end:
        return;
@@ -812,7 +824,9 @@ void print_trigger_errors(const struct lttng_trigger *trigger)
                        lttng_error_query_trigger_create(trigger);
 
        assert(query);
-
+       /*
+        * Anonymous triggers are not listed; this would be an internal error.
+        */
        trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
        assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
 
@@ -893,7 +907,15 @@ void print_one_trigger(const struct lttng_trigger *trigger)
        const char *name;
        uid_t trigger_uid;
 
+       /*
+        * Anonymous triggers are not listed since they can't be specified nor
+        * referenced through the CLI.
+        */
        trigger_status = lttng_trigger_get_name(trigger, &name);
+       if (trigger_status == LTTNG_TRIGGER_STATUS_UNSET) {
+               goto end;
+       }
+
        assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
 
        trigger_status = lttng_trigger_get_owner_uid(trigger, &trigger_uid);
@@ -926,7 +948,7 @@ void print_one_trigger(const struct lttng_trigger *trigger)
 
        action = lttng_trigger_get_const_action(trigger);
        action_type = lttng_action_get_type(action);
-       if (action_type == LTTNG_ACTION_TYPE_GROUP) {
+       if (action_type == LTTNG_ACTION_TYPE_LIST) {
                unsigned int count, i;
                enum lttng_action_status action_status;
 
@@ -936,19 +958,23 @@ void print_one_trigger(const struct lttng_trigger *trigger)
                assert(action_status == LTTNG_ACTION_STATUS_OK);
 
                for (i = 0; i < count; i++) {
+                       const uint64_t action_path_index = i;
                        const struct lttng_action *subaction =
                                        lttng_action_list_get_at_index(
                                                        action, i);
 
                        _MSG("    ");
-                       print_one_action(trigger, subaction);
+                       print_one_action(trigger, subaction, &action_path_index,
+                                       1);
                }
        } else {
                _MSG(" action:");
-               print_one_action(trigger, action);
+               print_one_action(trigger, action, NULL, 0);
        }
 
        print_trigger_errors(trigger);
+end:
+       return;
 }
 
 static
@@ -959,6 +985,7 @@ int compare_triggers_by_name(const void *a, const void *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);
 
@@ -1032,9 +1059,24 @@ int cmd_list_triggers(int argc, const char **argv)
        }
 
        for (i = 0; i < num_triggers; i++) {
-               const int add_ret = lttng_dynamic_pointer_array_add_pointer(
-                               &sorted_triggers,
-                               (void *) lttng_triggers_get_at_index(triggers, i));
+               int add_ret;
+               const char *unused_name;
+               const struct lttng_trigger *trigger =
+                               lttng_triggers_get_at_index(triggers, i);
+
+               trigger_status = lttng_trigger_get_name(trigger, &unused_name);
+               switch (trigger_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 allocate array of struct lttng_trigger *.");
This page took 0.026746 seconds and 5 git commands to generate.