Fix: lttng: add-trigger: payload capture fields specified as contexts
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 11 Mar 2021 20:26:01 +0000 (15:26 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 11 Mar 2021 20:31:53 +0000 (15:31 -0500)
ir_op_load_expr_to_event_expr() re-uses the same `load_expr_op` variable
to traverse the IR. A check for the type of the original load expression
is performed after `load_expr_op->next` is assigned to load_expr_op
which is expected to have remained the same.

The original event_expr child type is sampled at the start of the
function and re-used as needed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I14ebcb9088c5107f3133ff5b43c65c3fc6101077

src/bin/lttng/commands/add_trigger.c

index e4342cf85d99a7dfb149f85c702bd57cf99e7bfd..b3b1dade11174d7b1481c4d599f6658267bead79 100644 (file)
@@ -301,13 +301,16 @@ end:
 
 static
 struct lttng_event_expr *ir_op_load_expr_to_event_expr(
-               const struct ir_load_expression *load_exp, const char *capture_str)
+               const struct ir_load_expression *load_expr,
+               const char *capture_str)
 {
        char *provider_name = NULL;
        struct lttng_event_expr *event_expr = NULL;
-       const struct ir_load_expression_op *load_expr_op = load_exp->child;
+       const struct ir_load_expression_op *load_expr_op = load_expr->child;
+       const enum ir_load_expression_type load_expr_child_type =
+                       load_expr_op->type;
 
-       switch (load_expr_op->type) {
+       switch (load_expr_child_type) {
        case IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT:
        case IR_LOAD_EXPRESSION_GET_CONTEXT_ROOT:
        {
@@ -319,12 +322,12 @@ struct lttng_event_expr *ir_op_load_expr_to_event_expr(
                field_name = load_expr_op->u.symbol;
                assert(field_name);
 
-               event_expr = load_expr_op->type == IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT ?
+               event_expr = load_expr_child_type == IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT ?
                                lttng_event_expr_event_payload_field_create(field_name) :
                                lttng_event_expr_channel_context_field_create(field_name);
                if (!event_expr) {
                        ERR("Failed to create %s event expression: field name = `%s`.",
-                                       load_expr_op->type == IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT ?
+                                       load_expr_child_type == IR_LOAD_EXPRESSION_GET_PAYLOAD_ROOT ?
                                                        "payload field" : "channel context",
                                                        field_name);
                        goto error;
This page took 0.035605 seconds and 4 git commands to generate.