From: Jonathan Rajotte Date: Wed, 13 May 2020 20:24:23 +0000 (-0400) Subject: lttng: Capture is only supported by tracepoint and syscall event-rules X-Git-Tag: v2.13.0-rc1~229 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=81d566c913e31b5dbd6ec304e679a3b248abec2b;p=lttng-tools.git lttng: Capture is only supported by tracepoint and syscall event-rules Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: Idfe07be4e12e0531dfdb778cdb4c011780af7a26 Depends-on: lttng-ust: I8423c510bf6af2f9bf85256e8d6f931d36f7054b --- 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;