From: Philippe Proulx Date: Sat, 29 Aug 2015 20:57:56 +0000 (-0400) Subject: Transfer UST exclusion names from sessiond to client X-Git-Tag: v2.8.0-rc1~138 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=795d57ce3012980e16a9493f5ba8c6ac91a9d07e;p=lttng-tools.git Transfer UST exclusion names from sessiond to client The variable-length extended info has this layout as of this patch: [extended info header][filter string][excl name 1][excl name 2]... The extended info header contains the length of the subsequent filter string, including its terminal null character, as well as the number of exclusion names, each one having a fixed length of LTTNG_SYMBOL_NAME_LEN bytes, including their terminal null character. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index dee7bedf1..ee80023fa 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -199,30 +199,55 @@ static void list_lttng_channels(enum lttng_domain_type domain, } static void increment_extended_len(const char *filter_expression, - size_t *extended_len) + struct lttng_event_exclusion *exclusion, size_t *extended_len) { *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; + } } static void append_extended_info(const char *filter_expression, - void **extended_at) + struct lttng_event_exclusion *exclusion, void **extended_at) { struct lttcomm_event_extended_header extended_header; size_t filter_len = 0; + size_t nb_exclusions = 0; if (filter_expression) { filter_len = strlen(filter_expression) + 1; } + if (exclusion) { + nb_exclusions = exclusion->count; + } + + /* Set header fields */ extended_header.filter_len = filter_len; + extended_header.nb_exclusions = nb_exclusions; + + /* Copy header */ memcpy(*extended_at, &extended_header, sizeof(extended_header)); *extended_at += sizeof(extended_header); - memcpy(*extended_at, filter_expression, filter_len); - *extended_at += filter_len; + + /* 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; + } } /* @@ -264,7 +289,8 @@ static int list_lttng_agent_events(struct agent *agt, */ rcu_read_lock(); cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) { - increment_extended_len(event->filter_expression, &extended_len); + increment_extended_len(event->filter_expression, NULL, + &extended_len); } rcu_read_unlock(); @@ -289,7 +315,8 @@ static int list_lttng_agent_events(struct agent *agt, i++; /* Append extended info */ - append_extended_info(event->filter_expression, &extended_at); + append_extended_info(event->filter_expression, NULL, + &extended_at); } rcu_read_unlock(); @@ -348,7 +375,7 @@ static int list_lttng_ust_global_events(char *channel_name, } increment_extended_len(uevent->filter_expression, - &extended_len); + uevent->exclusion, &extended_len); } if (nb_event == 0) { /* All events are internal, skip. */ @@ -408,7 +435,8 @@ static int list_lttng_ust_global_events(char *channel_name, i++; /* Append extended info */ - append_extended_info(uevent->filter_expression, &extended_at); + append_extended_info(uevent->filter_expression, + uevent->exclusion, &extended_at); } ret = nb_event; @@ -450,7 +478,8 @@ static int list_lttng_kernel_events(char *channel_name, /* Compute required extended infos size */ cds_list_for_each_entry(event, &kchan->events_list.head, list) { - increment_extended_len(event->filter_expression, &extended_len); + increment_extended_len(event->filter_expression, NULL, + &extended_len); } *total_size = nb_event * sizeof(struct lttng_event) + extended_len; @@ -503,7 +532,8 @@ static int list_lttng_kernel_events(char *channel_name, i++; /* Append extended info */ - append_extended_info(event->filter_expression, &extended_at); + append_extended_info(event->filter_expression, NULL, + &extended_at); } syscall: diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index c38ed3745..575fbf019 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -359,6 +359,14 @@ struct lttcomm_event_extended_header { * This size includes the terminal null character. */ uint32_t filter_len; + + /* + * Number of exclusion names, immediately following the filter + * string. Each exclusion name has a fixed length of + * LTTNG_SYMBOL_NAME_LEN bytes, including the terminal null + * character. + */ + uint32_t nb_exclusions; } LTTNG_PACKED; /* diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 146783fd3..02b3fed4c 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -1773,6 +1773,8 @@ int lttng_list_events(struct lttng_handle *handle, (struct lttcomm_event_extended_header *) extended_at; extended_at += sizeof(*ext_header); extended_at += ext_header->filter_len; + extended_at += + ext_header->nb_exclusions * LTTNG_SYMBOL_NAME_LEN; } return ret;