-static int increment_extended_len(const char *filter_expression,
- struct lttng_event_exclusion *exclusion,
- const struct lttng_userspace_probe_location *probe_location,
- size_t *extended_len)
-{
- int ret = 0;
-
- *extended_len += sizeof(struct lttcomm_event_extended_header);
-
- if (filter_expression) {
- *extended_len += strlen(filter_expression) + 1;
- }
-
- if (exclusion) {
- *extended_len += exclusion->count * LTTNG_SYMBOL_NAME_LEN;
- }
-
- if (probe_location) {
- ret = lttng_userspace_probe_location_serialize(probe_location,
- NULL, NULL);
- if (ret < 0) {
- goto end;
- }
- *extended_len += ret;
- }
- ret = 0;
-end:
- return ret;
-}
-
-static int append_extended_info(const char *filter_expression,
- struct lttng_event_exclusion *exclusion,
- struct lttng_userspace_probe_location *probe_location,
- void **extended_at)
-{
- int ret = 0;
- size_t filter_len = 0;
- size_t nb_exclusions = 0;
- size_t userspace_probe_location_len = 0;
- struct lttng_dynamic_buffer location_buffer;
- struct lttcomm_event_extended_header extended_header;
-
- if (filter_expression) {
- filter_len = strlen(filter_expression) + 1;
- }
-
- if (exclusion) {
- nb_exclusions = exclusion->count;
- }
-
- if (probe_location) {
- lttng_dynamic_buffer_init(&location_buffer);
- ret = lttng_userspace_probe_location_serialize(probe_location,
- &location_buffer, NULL);
- if (ret < 0) {
- ret = -1;
- goto end;
- }
- userspace_probe_location_len = location_buffer.size;
- }
-
- /* Set header fields */
- extended_header.filter_len = filter_len;
- extended_header.nb_exclusions = nb_exclusions;
- extended_header.userspace_probe_location_len = userspace_probe_location_len;
-
- /* Copy header */
- memcpy(*extended_at, &extended_header, sizeof(extended_header));
- *extended_at += sizeof(extended_header);
-
- /* Copy filter string */
- if (filter_expression) {
- memcpy(*extended_at, filter_expression, filter_len);
- *extended_at += filter_len;
- }
-
- /* Copy exclusion names */
- if (exclusion) {
- size_t len = nb_exclusions * LTTNG_SYMBOL_NAME_LEN;
-
- memcpy(*extended_at, &exclusion->names, len);
- *extended_at += len;
- }
-
- if (probe_location) {
- memcpy(*extended_at, location_buffer.data, location_buffer.size);
- *extended_at += location_buffer.size;
- lttng_dynamic_buffer_reset(&location_buffer);
- }
- ret = 0;
-end:
- return ret;
-}
-