From 81d566c913e31b5dbd6ec304e679a3b248abec2b Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Wed, 13 May 2020 16:24:23 -0400 Subject: [PATCH] lttng: Capture is only supported by tracepoint and syscall event-rules MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: Idfe07be4e12e0531dfdb778cdb4c011780af7a26 Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b --- include/lttng/condition/condition.h | 1 + include/lttng/condition/event-rule.h | 3 +++ src/bin/lttng/commands/add_trigger.c | 4 ++++ src/common/conditions/event-rule.c | 24 ++++++++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/include/lttng/condition/condition.h b/include/lttng/condition/condition.h index 78a206df3..6681cf76f 100644 --- a/include/lttng/condition/condition.h +++ b/include/lttng/condition/condition.h @@ -30,6 +30,7 @@ enum lttng_condition_status { LTTNG_CONDITION_STATUS_UNKNOWN = -2, LTTNG_CONDITION_STATUS_INVALID = -3, LTTNG_CONDITION_STATUS_UNSET = -4, + LTTNG_CONDITION_STATUS_UNSUPPORTED = -5, }; /* diff --git a/include/lttng/condition/event-rule.h b/include/lttng/condition/event-rule.h index 02e7a20e7..170f38160 100644 --- a/include/lttng/condition/event-rule.h +++ b/include/lttng/condition/event-rule.h @@ -123,6 +123,9 @@ lttng_evaluation_event_rule_get_captured_values( * * `LTTNG_EVENT_EXPR_TYPE_CHANNEL_CONTEXT_FIELD` * * `LTTNG_EVENT_EXPR_TYPE_APP_SPECIFIC_CONTEXT_FIELD` * * `LTTNG_EVENT_EXPR_TYPE_ARRAY_FIELD_ELEMENT` + * + * `LTTNG_CONDITION_STATUS_UNSUPPORTED`: + * * The associated event-rule does not support runtime capture. */ extern enum lttng_condition_status lttng_condition_event_rule_append_capture_descriptor( diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index b3b1dade1..feba92f6f 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -1115,6 +1115,10 @@ struct lttng_condition *handle_condition_event(int *argc, const char ***argv) status = lttng_condition_event_rule_append_capture_descriptor( c, *expr); if (status != LTTNG_CONDITION_STATUS_OK) { + if (status == LTTNG_CONDITION_STATUS_UNSUPPORTED) { + ERR("The capture feature is unsupported by the event-rule condition type"); + } + goto error; } diff --git a/src/common/conditions/event-rule.c b/src/common/conditions/event-rule.c index 3f6b96015..a8fd7c912 100644 --- a/src/common/conditions/event-rule.c +++ b/src/common/conditions/event-rule.c @@ -751,6 +751,7 @@ lttng_condition_event_rule_append_capture_descriptor( container_of(condition, struct lttng_condition_event_rule, parent); struct lttng_capture_descriptor *descriptor = NULL; + const struct lttng_event_rule *rule = NULL; /* Only accept l-values. */ if (!condition || !IS_EVENT_RULE_CONDITION(condition) || !expr || @@ -759,6 +760,29 @@ lttng_condition_event_rule_append_capture_descriptor( goto end; } + status = lttng_condition_event_rule_get_rule(condition, &rule); + if (status != LTTNG_CONDITION_STATUS_OK) { + goto end; + } + + switch(lttng_event_rule_get_type(rule)) { + case LTTNG_EVENT_RULE_TYPE_TRACEPOINT: + case LTTNG_EVENT_RULE_TYPE_SYSCALL: + /* Supported. */ + status = LTTNG_CONDITION_STATUS_OK; + break; + case LTTNG_EVENT_RULE_TYPE_UNKNOWN: + status = LTTNG_CONDITION_STATUS_INVALID; + break; + default: + status = LTTNG_CONDITION_STATUS_UNSUPPORTED; + break; + } + + if (status != LTTNG_CONDITION_STATUS_OK) { + goto end; + } + descriptor = malloc(sizeof(*descriptor)); if (descriptor == NULL) { status = LTTNG_CONDITION_STATUS_ERROR; -- 2.34.1