*
*/
-#include <assert.h>
#include <common/error.h>
#include <common/macros.h>
+#include <common/mi-lttng.h>
#include <inttypes.h>
#include <limits.h>
#include <lttng/condition/condition-internal.h>
free(desc);
}
+static enum lttng_error_code lttng_condition_event_rule_matches_mi_serialize(
+ const struct lttng_condition *condition,
+ struct mi_writer *writer)
+{
+ int ret;
+ enum lttng_error_code ret_code;
+ enum lttng_condition_status status;
+ const struct lttng_event_rule *rule = NULL;
+ unsigned int capture_descriptor_count, i;
+
+ LTTNG_ASSERT(condition);
+ LTTNG_ASSERT(writer);
+ LTTNG_ASSERT(IS_EVENT_RULE_MATCHES_CONDITION(condition));
+
+ status = lttng_condition_event_rule_matches_get_rule(condition, &rule);
+ LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
+ LTTNG_ASSERT(rule != NULL);
+
+ status = lttng_condition_event_rule_matches_get_capture_descriptor_count(
+ condition, &capture_descriptor_count);
+ LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
+
+ /* Open condition event rule matches element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_condition_event_rule_matches);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Serialize the event rule. */
+ ret_code = lttng_event_rule_mi_serialize(rule, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+
+ /* Open the capture descriptors element. */
+ ret = mi_lttng_writer_open_element(
+ writer, mi_lttng_element_capture_descriptors);
+ if (ret) {
+ goto mi_error;
+ }
+
+ for (i = 0; i < capture_descriptor_count; i++) {
+ const struct lttng_event_expr *descriptor = NULL;
+
+ descriptor = lttng_condition_event_rule_matches_get_capture_descriptor_at_index(
+ condition, i);
+ LTTNG_ASSERT(descriptor);
+
+ ret_code = lttng_event_expr_mi_serialize(descriptor, writer);
+ if (ret_code != LTTNG_OK) {
+ goto end;
+ }
+ }
+
+ /* Close capture descriptors element. */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto mi_error;
+ }
+
+ /* Close condition_event_rule_matches. */
+ ret = mi_lttng_writer_close_element(writer);
+ if (ret) {
+ goto mi_error;
+ }
+ ret_code = LTTNG_OK;
+ goto end;
+
+mi_error:
+ ret_code = LTTNG_ERR_MI_IO_FAIL;
+end:
+ return ret_code;
+}
+
struct lttng_condition *lttng_condition_event_rule_matches_create(
struct lttng_event_rule *rule)
{
lttng_condition_event_rule_matches_serialize,
condition->parent.equal = lttng_condition_event_rule_matches_is_equal,
condition->parent.destroy = lttng_condition_event_rule_matches_destroy,
+ condition->parent.mi_serialize = lttng_condition_event_rule_matches_mi_serialize,
lttng_event_rule_get(rule);
condition->rule = rule;
return expr;
}
-LTTNG_HIDDEN
ssize_t lttng_condition_event_rule_matches_create_from_payload(
struct lttng_payload_view *view,
struct lttng_condition **_condition)
}
/* Capture descriptor count. */
- assert(event_rule_length >= 0);
+ LTTNG_ASSERT(event_rule_length >= 0);
capture_descr_count = uint_from_buffer(&view->buffer, sizeof(uint32_t), &offset);
if (capture_descr_count == UINT32_C(-1)) {
goto error;
return consumed_length;
}
-LTTNG_HIDDEN
enum lttng_condition_status
lttng_condition_event_rule_matches_borrow_rule_mutable(
const struct lttng_condition *condition,
return status;
}
-LTTNG_HIDDEN
void lttng_condition_event_rule_matches_set_error_counter_index(
struct lttng_condition *condition, uint64_t error_counter_index)
{
error_counter_index);
}
-LTTNG_HIDDEN
uint64_t lttng_condition_event_rule_matches_get_error_counter_index(
const struct lttng_condition *condition)
{
return expr;
}
-LTTNG_HIDDEN
ssize_t lttng_evaluation_event_rule_matches_create_from_payload(
const struct lttng_condition_event_rule_matches *condition,
struct lttng_payload_view *view,
{
bool is_equal = true;
- assert(obj->type == MSGPACK_OBJECT_STR);
+ LTTNG_ASSERT(obj->type == MSGPACK_OBJECT_STR);
if (obj->via.str.size != strlen(str)) {
is_equal = false;
const msgpack_object *ret = NULL;
size_t i;
- assert(map_obj->type == MSGPACK_OBJECT_MAP);
+ LTTNG_ASSERT(map_obj->type == MSGPACK_OBJECT_MAP);
for (i = 0; i < map_obj->via.map.size; i++) {
const struct msgpack_object_kv *kv = &map_obj->via.map.ptr[i];
- assert(kv->key.type == MSGPACK_OBJECT_STR);
+ LTTNG_ASSERT(kv->key.type == MSGPACK_OBJECT_STR);
if (msgpack_str_is_equal(&kv->key, name)) {
ret = &kv->val;
{
int ret = 0;
- assert(obj);
- assert(field_val);
+ LTTNG_ASSERT(obj);
+ LTTNG_ASSERT(field_val);
switch (obj->type) {
case MSGPACK_OBJECT_NIL:
size_t i;
size_t count;
- assert(condition);
- assert(capture_payload);
+ LTTNG_ASSERT(condition);
+ LTTNG_ASSERT(capture_payload);
/* Initialize value. */
msgpack_unpacked_init(&unpacked);
*/
count = lttng_dynamic_pointer_array_get_count(
&condition->capture_descriptors);
- assert(count > 0);
+ LTTNG_ASSERT(count > 0);
for (i = 0; i < count; i++) {
const struct lttng_capture_descriptor *capture_descriptor =
struct lttng_event_field_value *elem_field_val;
int iret;
- assert(capture_descriptor);
+ LTTNG_ASSERT(capture_descriptor);
elem_obj = &root_array_obj->ptr[i];
iret = event_field_value_from_obj(elem_obj,
return ret;
}
-LTTNG_HIDDEN
struct lttng_evaluation *lttng_evaluation_event_rule_matches_create(
const struct lttng_condition_event_rule_matches *condition,
const char *capture_payload,
return status;
}
-LTTNG_HIDDEN
enum lttng_error_code
lttng_condition_event_rule_matches_generate_capture_descriptor_bytecode(
struct lttng_condition *condition)
return ret;
}
-LTTNG_HIDDEN
const struct lttng_bytecode *
lttng_condition_event_rule_matches_get_capture_bytecode_at_index(
const struct lttng_condition *condition, unsigned int index)