Remove error count property of lttng_condition_on_event
[lttng-tools.git] / src / common / conditions / on-event.c
index 9cc80772cb3d85357edcf6e72c7e897db07c3c0e..d86563b264441513c278df2f9b76592942fb308c 100644 (file)
@@ -610,7 +610,9 @@ struct lttng_event_expr *event_expr_from_payload(
                break;
        }
        default:
-               abort();
+               ERR("Invalid event expression type encoutered while deserializing event expression: type = %" PRIu64,
+                               type);
+               goto error;
        }
 
        goto end;
@@ -652,6 +654,8 @@ ssize_t lttng_condition_on_event_create_from_payload(
                goto error;
        }
 
+       offset += event_rule_length;
+
        /* Create condition (no capture descriptors yet) at this point */
        condition = lttng_condition_on_event_create(event_rule);
        if (!condition) {
@@ -660,7 +664,6 @@ ssize_t lttng_condition_on_event_create_from_payload(
 
        /* Capture descriptor count. */
        assert(event_rule_length >= 0);
-       offset += (size_t) event_rule_length;
        capture_descr_count = uint_from_buffer(&view->buffer, sizeof(uint32_t), &offset);
        if (capture_descr_count == UINT32_C(-1)) {
                goto error;
@@ -738,6 +741,28 @@ enum lttng_condition_status lttng_condition_on_event_get_rule(
        return status;
 }
 
+LTTNG_HIDDEN
+void lttng_condition_on_event_set_error_counter_index(
+               struct lttng_condition *condition, uint64_t error_counter_index)
+{
+       struct lttng_condition_on_event *on_event_cond =
+                       container_of(condition,
+                               struct lttng_condition_on_event, parent);
+
+       LTTNG_OPTIONAL_SET(&on_event_cond->error_counter_index, error_counter_index);
+}
+
+LTTNG_HIDDEN
+uint64_t lttng_condition_on_event_get_error_counter_index(
+               const struct lttng_condition *condition)
+{
+       const struct lttng_condition_on_event *on_event_cond =
+                       container_of(condition,
+                               const struct lttng_condition_on_event, parent);
+
+       return LTTNG_OPTIONAL_GET(on_event_cond->error_counter_index);
+}
+
 enum lttng_condition_status
 lttng_condition_on_event_append_capture_descriptor(
                struct lttng_condition *condition,
@@ -745,7 +770,7 @@ lttng_condition_on_event_append_capture_descriptor(
 {
        int ret;
        enum lttng_condition_status status = LTTNG_CONDITION_STATUS_OK;
-       struct lttng_condition_on_event *event_rule_cond =
+       struct lttng_condition_on_event *on_event_cond =
                        container_of(condition,
                                struct lttng_condition_on_event, parent);
        struct lttng_capture_descriptor *descriptor = NULL;
@@ -791,7 +816,7 @@ lttng_condition_on_event_append_capture_descriptor(
        descriptor->bytecode = NULL;
 
        ret = lttng_dynamic_pointer_array_add_pointer(
-                       &event_rule_cond->capture_descriptors, descriptor);
+                       &on_event_cond->capture_descriptors, descriptor);
        if (ret) {
                status = LTTNG_CONDITION_STATUS_ERROR;
                goto end;
@@ -851,12 +876,7 @@ ssize_t lttng_evaluation_on_event_create_from_payload(
                struct lttng_evaluation **_evaluation)
 {
        ssize_t ret, offset = 0;
-       const char *trigger_name;
        struct lttng_evaluation *evaluation = NULL;
-       const struct lttng_evaluation_on_event_comm *header;
-       const struct lttng_payload_view header_view =
-                       lttng_payload_view_from_view(
-                                       view, 0, sizeof(*header));
        uint32_t capture_payload_size;
        const char *capture_payload = NULL;
 
@@ -865,37 +885,6 @@ ssize_t lttng_evaluation_on_event_create_from_payload(
                goto error;
        }
 
-       if (!lttng_payload_view_is_valid(&header_view)) {
-               ERR("Failed to initialize from malformed event rule evaluation: buffer too short to contain header");
-               ret = -1;
-               goto error;
-       }
-
-       header = (typeof(header)) header_view.buffer.data;
-
-       /* Map the originating trigger's name. */
-       offset += sizeof(*header);
-       {
-               const struct lttng_payload_view current_view =
-                               lttng_payload_view_from_view(view, offset,
-                                               header->trigger_name_length);
-
-               if (!lttng_payload_view_is_valid(&current_view)) {
-                       ERR("Failed to initialize from malformed event rule evaluation: buffer too short to contain trigger name");
-                       ret = -1;
-                       goto error;
-               }
-
-               trigger_name = current_view.buffer.data;
-               if (!lttng_buffer_view_contains_string(&current_view.buffer,
-                                   trigger_name, header->trigger_name_length)) {
-                       ERR("Failed to initialize from malformed event rule evaluation: invalid trigger name");
-                       ret = -1;
-                       goto error;
-               }
-       }
-
-       offset += header->trigger_name_length;
        {
                const struct lttng_payload_view current_view =
                                lttng_payload_view_from_view(view, offset, -1);
@@ -922,7 +911,7 @@ ssize_t lttng_evaluation_on_event_create_from_payload(
                capture_payload = current_view.buffer.data;
        }
 
-       evaluation = lttng_evaluation_on_event_create(condition, trigger_name,
+       evaluation = lttng_evaluation_on_event_create(condition,
                        capture_payload, capture_payload_size, true);
        if (!evaluation) {
                ret = -1;
@@ -945,27 +934,11 @@ static int lttng_evaluation_on_event_serialize(
 {
        int ret = 0;
        struct lttng_evaluation_on_event *hit;
-       struct lttng_evaluation_on_event_comm comm;
        uint32_t capture_payload_size;
 
        hit = container_of(
                        evaluation, struct lttng_evaluation_on_event, parent);
 
-       assert(hit->name);
-       comm.trigger_name_length = strlen(hit->name) + 1;
-
-       ret = lttng_dynamic_buffer_append(
-                       &payload->buffer, &comm, sizeof(comm));
-       if (ret) {
-               goto end;
-       }
-
-       ret = lttng_dynamic_buffer_append(
-                       &payload->buffer, hit->name, comm.trigger_name_length);
-       if (ret) {
-               goto end;
-       }
-
        capture_payload_size = (uint32_t) hit->capture_payload.size;
        ret = lttng_dynamic_buffer_append(&payload->buffer, &capture_payload_size,
                        sizeof(capture_payload_size));
@@ -1035,7 +1008,6 @@ static void lttng_evaluation_on_event_destroy(
 
        hit = container_of(
                        evaluation, struct lttng_evaluation_on_event, parent);
-       free(hit->name);
        lttng_dynamic_buffer_reset(&hit->capture_payload);
        lttng_event_field_value_destroy(hit->captured_values);
        free(hit);
@@ -1323,7 +1295,6 @@ end:
 LTTNG_HIDDEN
 struct lttng_evaluation *lttng_evaluation_on_event_create(
                const struct lttng_condition_on_event *condition,
-               const char *trigger_name,
                const char *capture_payload, size_t capture_payload_size,
                bool decode_capture_payload)
 {
@@ -1335,11 +1306,6 @@ struct lttng_evaluation *lttng_evaluation_on_event_create(
                goto error;
        }
 
-       hit->name = strdup(trigger_name);
-       if (!hit->name) {
-               goto error;
-       }
-
        lttng_dynamic_buffer_init(&hit->capture_payload);
 
        if (capture_payload) {
@@ -1408,24 +1374,6 @@ end:
        return status;
 }
 
-enum lttng_evaluation_status lttng_evaluation_on_event_get_trigger_name(
-               const struct lttng_evaluation *evaluation, const char **name)
-{
-       struct lttng_evaluation_on_event *hit;
-       enum lttng_evaluation_status status = LTTNG_EVALUATION_STATUS_OK;
-
-       if (!evaluation || !is_on_event_evaluation(evaluation) || !name) {
-               status = LTTNG_EVALUATION_STATUS_INVALID;
-               goto end;
-       }
-
-       hit = container_of(
-                       evaluation, struct lttng_evaluation_on_event, parent);
-       *name = hit->name;
-end:
-       return status;
-}
-
 LTTNG_HIDDEN
 enum lttng_error_code
 lttng_condition_on_event_generate_capture_descriptor_bytecode(
@@ -1479,7 +1427,7 @@ const struct lttng_bytecode *
 lttng_condition_on_event_get_capture_bytecode_at_index(
                const struct lttng_condition *condition, unsigned int index)
 {
-       const struct lttng_condition_on_event *event_rule_cond =
+       const struct lttng_condition_on_event *on_event_cond =
                        container_of(condition,
                                const struct lttng_condition_on_event,
                                parent);
@@ -1503,7 +1451,7 @@ lttng_condition_on_event_get_capture_bytecode_at_index(
        }
 
        desc = lttng_dynamic_pointer_array_get_pointer(
-                       &event_rule_cond->capture_descriptors, index);
+                       &on_event_cond->capture_descriptors, index);
        if (desc == NULL) {
                goto end;
        }
This page took 0.025569 seconds and 4 git commands to generate.