X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist_triggers.c;h=329fd293ae5ac21978735232b086b4dc299cc6e6;hb=90aa04a116a8be510b9d256b47de6bbb4144fb8b;hp=05090381e0ca43605f1263f6751a87fdf2a132db;hpb=b203b4b06b6d895d6745f3c45b83b2a36ae6a989;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list_triggers.c b/src/bin/lttng/commands/list_triggers.c index 05090381e..329fd293a 100644 --- a/src/bin/lttng/commands/list_triggers.c +++ b/src/bin/lttng/commands/list_triggers.c @@ -14,8 +14,11 @@ #include "common/mi-lttng.h" /* For lttng_condition_type_str(). */ #include "lttng/condition/condition-internal.h" +#include "lttng/condition/on-event.h" +#include "lttng/condition/on-event-internal.h" /* For lttng_domain_type_str(). */ #include "lttng/domain-internal.h" +#include "../loglevel.h" #ifdef LTTNG_EMBED_HELP static const char help_msg[] = @@ -35,6 +38,37 @@ struct argpar_opt_descr list_trigger_options[] = { ARGPAR_OPT_DESCR_SENTINEL, }; +/* + * Returns the human-readable log level name associated with a numerical value + * if there is one. The Log4j and JUL domains have discontinuous log level + * values (a value can fall between two labels). In those cases, NULL is + * returned. + */ +static const char *get_pretty_loglevel_name( + enum lttng_domain_type domain, int loglevel) +{ + const char *name = NULL; + + switch (domain) { + case LTTNG_DOMAIN_UST: + name = loglevel_value_to_name(loglevel); + break; + case LTTNG_DOMAIN_LOG4J: + name = loglevel_log4j_value_to_name(loglevel); + break; + case LTTNG_DOMAIN_JUL: + name = loglevel_jul_value_to_name(loglevel); + break; + case LTTNG_DOMAIN_PYTHON: + name = loglevel_python_value_to_name(loglevel); + break; + default: + break; + } + + return name; +} + static void print_event_rule_tracepoint(const struct lttng_event_rule *event_rule) { @@ -43,6 +77,7 @@ void print_event_rule_tracepoint(const struct lttng_event_rule *event_rule) const char *pattern; const char *filter; int log_level; + const struct lttng_log_level_rule *log_level_rule = NULL; unsigned int exclusions_count; int i; @@ -65,23 +100,38 @@ void print_event_rule_tracepoint(const struct lttng_event_rule *event_rule) assert(event_rule_status == LTTNG_EVENT_RULE_STATUS_UNSET); } - event_rule_status = lttng_event_rule_tracepoint_get_log_level( - event_rule, &log_level); + event_rule_status = lttng_event_rule_tracepoint_get_log_level_rule( + event_rule, &log_level_rule); if (event_rule_status == LTTNG_EVENT_RULE_STATUS_OK) { - enum lttng_loglevel_type log_level_type; + enum lttng_log_level_rule_status llr_status; const char *log_level_op; + const char *pretty_loglevel_name; + + switch (lttng_log_level_rule_get_type(log_level_rule)) { + case LTTNG_LOG_LEVEL_RULE_TYPE_EXACTLY: + log_level_op = "is"; + llr_status = lttng_log_level_rule_exactly_get_level( + log_level_rule, &log_level); + break; + case LTTNG_LOG_LEVEL_RULE_TYPE_AT_LEAST_AS_SEVERE_AS: + log_level_op = "at least"; + llr_status = lttng_log_level_rule_at_least_as_severe_as_get_level( + log_level_rule, &log_level); + break; + default: + abort(); + } - event_rule_status = lttng_event_rule_tracepoint_get_log_level_type( - event_rule, &log_level_type); - assert(event_rule_status == LTTNG_EVENT_RULE_STATUS_OK); - assert(log_level_type == LTTNG_EVENT_LOGLEVEL_RANGE || - log_level_type == LTTNG_EVENT_LOGLEVEL_SINGLE); - - log_level_op = (log_level_type == LTTNG_EVENT_LOGLEVEL_RANGE ? "<=" : "=="); + assert(llr_status == LTTNG_LOG_LEVEL_RULE_STATUS_OK); - _MSG(", log level %s %s", log_level_op, - mi_lttng_loglevel_string( - log_level, domain_type)); + pretty_loglevel_name = get_pretty_loglevel_name( + domain_type, log_level); + if (pretty_loglevel_name) { + _MSG(", log level %s %s", log_level_op, + pretty_loglevel_name); + } else { + _MSG(", log level %s %d", log_level_op, log_level); + } } else { assert(event_rule_status == LTTNG_EVENT_RULE_STATUS_UNSET); } @@ -160,21 +210,21 @@ end: } static -void print_event_rule_kprobe(const struct lttng_event_rule *event_rule) +void print_event_rule_kernel_probe(const struct lttng_event_rule *event_rule) { enum lttng_event_rule_status event_rule_status; const char *name; const struct lttng_kernel_probe_location *location; - assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KPROBE); + assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE); - event_rule_status = lttng_event_rule_kprobe_get_name(event_rule, &name); + event_rule_status = lttng_event_rule_kernel_probe_get_event_name(event_rule, &name); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { ERR("Failed to get kprobe event rule's name."); goto end; } - event_rule_status = lttng_event_rule_kprobe_get_location( + event_rule_status = lttng_event_rule_kernel_probe_get_location( event_rule, &location); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { ERR("Failed to get kprobe event rule's location."); @@ -192,22 +242,23 @@ end: } static -void print_event_rule_uprobe(const struct lttng_event_rule *event_rule) +void print_event_rule_userspace_probe(const struct lttng_event_rule *event_rule) { enum lttng_event_rule_status event_rule_status; const char *name; const struct lttng_userspace_probe_location *location; enum lttng_userspace_probe_location_type userspace_probe_location_type; - assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_UPROBE); + assert(lttng_event_rule_get_type(event_rule) == LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE); - event_rule_status = lttng_event_rule_uprobe_get_name(event_rule, &name); + event_rule_status = lttng_event_rule_userspace_probe_get_event_name( + event_rule, &name); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { ERR("Failed to get uprobe event rule's name."); goto end; } - event_rule_status = lttng_event_rule_uprobe_get_location( + event_rule_status = lttng_event_rule_userspace_probe_get_location( event_rule, &location); if (event_rule_status != LTTNG_EVENT_RULE_STATUS_OK) { ERR("Failed to get uprobe event rule's location."); @@ -280,11 +331,11 @@ void print_event_rule(const struct lttng_event_rule *event_rule) case LTTNG_EVENT_RULE_TYPE_TRACEPOINT: print_event_rule_tracepoint(event_rule); break; - case LTTNG_EVENT_RULE_TYPE_KPROBE: - print_event_rule_kprobe(event_rule); + case LTTNG_EVENT_RULE_TYPE_KERNEL_PROBE: + print_event_rule_kernel_probe(event_rule); break; - case LTTNG_EVENT_RULE_TYPE_UPROBE: - print_event_rule_uprobe(event_rule); + case LTTNG_EVENT_RULE_TYPE_USERSPACE_PROBE: + print_event_rule_userspace_probe(event_rule); break; case LTTNG_EVENT_RULE_TYPE_SYSCALL: print_event_rule_syscall(event_rule); @@ -362,29 +413,33 @@ void print_one_event_expr(const struct lttng_event_expr *event_expr) } static -void print_condition_event_rule_hit(const struct lttng_condition *condition) +void print_condition_on_event(const struct lttng_condition *condition) { const struct lttng_event_rule *event_rule; enum lttng_condition_status condition_status; unsigned int cap_desc_count, i; + uint64_t error_count; condition_status = - lttng_condition_event_rule_get_rule(condition, &event_rule); + lttng_condition_on_event_get_rule(condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); print_event_rule(event_rule); condition_status = - lttng_condition_event_rule_get_capture_descriptor_count( + lttng_condition_on_event_get_capture_descriptor_count( condition, &cap_desc_count); assert(condition_status == LTTNG_CONDITION_STATUS_OK); + error_count = lttng_condition_on_event_get_error_count(condition); + MSG(" tracer notifications discarded: %ld", error_count); + if (cap_desc_count > 0) { MSG(" captures:"); for (i = 0; i < cap_desc_count; i++) { const struct lttng_event_expr *cap_desc = - lttng_condition_event_rule_get_capture_descriptor_at_index( + lttng_condition_on_event_get_capture_descriptor_at_index( condition, i); _MSG(" - "); @@ -534,8 +589,8 @@ void print_one_trigger(const struct lttng_trigger *trigger) condition_type = lttng_condition_get_type(condition); MSG(" condition: %s", lttng_condition_type_str(condition_type)); switch (condition_type) { - case LTTNG_CONDITION_TYPE_EVENT_RULE_HIT: - print_condition_event_rule_hit(condition); + case LTTNG_CONDITION_TYPE_ON_EVENT: + print_condition_on_event(condition); break; default: MSG(" (condition type not handled in %s)", __func__);