#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[] =
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)
{
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;
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);
}
}
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.");
}
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.");
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);
}
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(" - ");
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__);