-static int append_extended_info(const char *filter_expression,
- struct lttng_event_exclusion *exclusion,
- struct lttng_userspace_probe_location *probe_location,
- struct lttng_payload *payload)
-{
- int ret = 0;
- size_t filter_len = 0;
- size_t nb_exclusions = 0;
- size_t userspace_probe_location_len = 0;
- struct lttcomm_event_extended_header extended_header = {};
- struct lttcomm_event_extended_header *p_extended_header;
- const size_t original_payload_size = payload->buffer.size;
-
- ret = lttng_dynamic_buffer_append(&payload->buffer, &extended_header,
- sizeof(extended_header));
- if (ret) {
- goto end;
- }
-
- if (filter_expression) {
- filter_len = strlen(filter_expression) + 1;
- ret = lttng_dynamic_buffer_append(&payload->buffer,
- filter_expression, filter_len);
- if (ret) {
- goto end;
- }
- }
-
- if (exclusion) {
- const size_t len = exclusion->count * LTTNG_SYMBOL_NAME_LEN;
-
- nb_exclusions = exclusion->count;
-
- ret = lttng_dynamic_buffer_append(
- &payload->buffer, &exclusion->names, len);
- if (ret) {
- goto end;
- }
- }
-
- if (probe_location) {
- const size_t size_before_probe = payload->buffer.size;
-
- ret = lttng_userspace_probe_location_serialize(probe_location,
- payload);
- if (ret < 0) {
- ret = -1;
- goto end;
- }
-
- userspace_probe_location_len =
- payload->buffer.size - size_before_probe;
- }
-
- /* Set header fields */
- p_extended_header = (struct lttcomm_event_extended_header *)
- (payload->buffer.data + original_payload_size);
-
- p_extended_header->filter_len = filter_len;
- p_extended_header->nb_exclusions = nb_exclusions;
- p_extended_header->userspace_probe_location_len =
- userspace_probe_location_len;
-
- ret = 0;
-end:
- return ret;
-}
-