*/
int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
char *channel_name, struct lttng_event *event,
+ char *filter_expression,
struct lttng_filter_bytecode *filter,
struct lttng_event_exclusion *exclusion,
int wpipe)
}
/* At this point, the session and channel exist on the tracer */
- ret = event_ust_enable_tracepoint(usess, uchan, event, filter, exclusion);
+ ret = event_ust_enable_tracepoint(usess, uchan, event,
+ filter_expression, filter, exclusion);
if (ret != LTTNG_OK) {
goto error;
}
tmp_dom.type = LTTNG_DOMAIN_UST;
ret = cmd_enable_event(session, &tmp_dom, DEFAULT_JUL_CHANNEL_NAME,
- &uevent, NULL, NULL, wpipe);
+ &uevent, NULL, NULL, NULL, wpipe);
if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
goto error;
}
*/
int cmd_enable_event_all(struct ltt_session *session,
struct lttng_domain *domain, char *channel_name, int event_type,
+ char *filter_expression,
struct lttng_filter_bytecode *filter, int wpipe)
{
int ret;
switch (event_type) {
case LTTNG_EVENT_ALL:
case LTTNG_EVENT_TRACEPOINT:
- ret = event_ust_enable_all_tracepoints(usess, uchan, filter);
+ ret = event_ust_enable_all_tracepoints(usess, uchan,
+ filter_expression, filter);
if (ret != LTTNG_OK) {
goto error;
}
tmp_dom.type = LTTNG_DOMAIN_UST;
ret = cmd_enable_event(session, &tmp_dom, DEFAULT_JUL_CHANNEL_NAME,
- &uevent, NULL, NULL, wpipe);
+ &uevent, NULL, NULL, NULL, wpipe);
if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
goto error;
}
struct lttng_filter_bytecode *bytecode);
int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain,
char *channel_name, struct lttng_event *event,
+ char *filter_expression,
struct lttng_filter_bytecode *filter,
struct lttng_event_exclusion *exclusion,
int wpipe);
int cmd_enable_event_all(struct ltt_session *session,
struct lttng_domain *domain, char *channel_name, int event_type,
+ char *filter_expression,
struct lttng_filter_bytecode *filter, int wpipe);
/* Trace session action commands */
* Enable all UST tracepoints for a channel from a UST session.
*/
int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct lttng_filter_bytecode *filter)
+ struct ltt_ust_channel *uchan,
+ char *filter_expression,
+ struct lttng_filter_bytecode *filter)
{
int ret, i, size;
struct lttng_ht_iter iter;
}
/* Create ust event */
- uevent = trace_ust_create_event(&events[i], filter, NULL);
+ uevent = trace_ust_create_event(&events[i], filter_expression,
+ filter, NULL);
if (uevent == NULL) {
ret = LTTNG_ERR_FATAL;
goto error_destroy;
*/
int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan, struct lttng_event *event,
+ char *filter_expression,
struct lttng_filter_bytecode *filter,
struct lttng_event_exclusion *exclusion)
{
uevent = trace_ust_find_event(uchan->events, event->name, filter,
event->loglevel, exclusion);
if (uevent == NULL) {
- uevent = trace_ust_create_event(event, filter, exclusion);
+ uevent = trace_ust_create_event(event, filter_expression,
+ filter, exclusion);
if (uevent == NULL) {
ret = LTTNG_ERR_UST_ENABLE_FAIL;
goto error;
int event_ust_enable_tracepoint(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan, struct lttng_event *event,
+ char *filter_expression,
struct lttng_filter_bytecode *filter,
struct lttng_event_exclusion *exclusion);
int event_ust_disable_tracepoint(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan, char *event_name);
int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess,
- struct ltt_ust_channel *uchan, struct lttng_filter_bytecode *filter);
+ struct ltt_ust_channel *uchan,
+ char *filter_expression,
+ struct lttng_filter_bytecode *filter);
int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan);
{
struct lttng_event_exclusion *exclusion = NULL;
struct lttng_filter_bytecode *bytecode = NULL;
+ char *filter_expression = NULL;
/* Handle exclusion events and receive it from the client. */
if (cmd_ctx->lsm->u.enable.exclusion_count > 0) {
}
}
+ /* Get filter expression from client. */
+ if (cmd_ctx->lsm->u.enable.expression_len > 0) {
+ size_t expression_len =
+ cmd_ctx->lsm->u.enable.expression_len;
+
+ if (expression_len > LTTNG_FILTER_MAX_LEN) {
+ ret = LTTNG_ERR_FILTER_INVAL;
+ free(exclusion);
+ goto error;
+ }
+
+ filter_expression = zmalloc(expression_len);
+ if (!filter_expression) {
+ free(exclusion);
+ ret = LTTNG_ERR_FILTER_NOMEM;
+ goto error;
+ }
+
+ /* Receive var. len. data */
+ DBG("Receiving var len filter's expression from client ...");
+ ret = lttcomm_recv_unix_sock(sock, filter_expression,
+ expression_len);
+ if (ret <= 0) {
+ DBG("Nothing recv() from client car len data... continuing");
+ *sock_error = 1;
+ free(filter_expression);
+ free(exclusion);
+ ret = LTTNG_ERR_FILTER_INVAL;
+ goto error;
+ }
+ }
+
/* Handle filter and get bytecode from client. */
if (cmd_ctx->lsm->u.enable.bytecode_len > 0) {
size_t bytecode_len = cmd_ctx->lsm->u.enable.bytecode_len;
ret = cmd_enable_event(cmd_ctx->session, &cmd_ctx->lsm->domain,
cmd_ctx->lsm->u.enable.channel_name,
- &cmd_ctx->lsm->u.enable.event, bytecode, exclusion,
+ &cmd_ctx->lsm->u.enable.event,
+ filter_expression, bytecode, exclusion,
kernel_poll_pipe[1]);
break;
}
ret = cmd_enable_event_all(cmd_ctx->session, &cmd_ctx->lsm->domain,
cmd_ctx->lsm->u.enable.channel_name,
- cmd_ctx->lsm->u.enable.event.type, NULL, kernel_poll_pipe[1]);
+ cmd_ctx->lsm->u.enable.event.type, NULL, NULL,
+ kernel_poll_pipe[1]);
break;
}
case LTTNG_LIST_TRACEPOINTS:
* Return pointer to structure or NULL.
*/
struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
+ char *filter_expression,
struct lttng_filter_bytecode *filter,
struct lttng_event_exclusion *exclusion)
{
}
/* Same layout. */
+ lue->filter_expression = filter_expression;
lue->filter = (struct lttng_ust_filter_bytecode *) filter;
lue->exclusion = (struct lttng_event_exclusion *) exclusion;
assert(event);
DBG2("Trace destroy UST event %s", event->attr.name);
+ free(event->filter_expression);
free(event->filter);
free(event->exclusion);
free(event);
unsigned int enabled;
struct lttng_ust_event attr;
struct lttng_ht_node_str node;
+ char *filter_expression;
struct lttng_ust_filter_bytecode *filter;
struct lttng_event_exclusion *exclusion;
};
struct ltt_ust_session *trace_ust_create_session(uint64_t session_id);
struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr);
struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
+ char *filter_expression,
struct lttng_filter_bytecode *filter,
struct lttng_event_exclusion *exclusion);
struct ltt_ust_context *trace_ust_create_context(
}
static inline
struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev,
+ const char *filter_expression,
struct lttng_filter_bytecode *filter,
struct lttng_event_exclusion *exclusion)
{
struct {
char channel_name[LTTNG_SYMBOL_NAME_LEN];
struct lttng_event event;
+ /* Length of following filter expression. */
+ uint32_t expression_len;
/* Length of following bytecode for filter. */
uint32_t bytecode_len;
/* exclusion data */
* After this structure, the following variable-length
* items are transmitted:
* - char exclusion_names[LTTNG_SYMBOL_NAME_LEN][exclusion_count]
+ * - unsigned char filter_expression[expression_len]
* - unsigned char filter_bytecode[bytecode_len]
*/
} LTTNG_PACKED enable;
lsm.u.enable.bytecode_len = sizeof(ctx->bytecode->b)
+ bytecode_get_len(&ctx->bytecode->b);
- }
-
- /* Allocate variable length data */
- if (lsm.u.enable.exclusion_count != 0) {
- varlen_data = zmalloc(lsm.u.enable.bytecode_len
- + LTTNG_SYMBOL_NAME_LEN * exclusion_count);
- if (!varlen_data) {
- ret = -LTTNG_ERR_EXCLUSION_NOMEM;
- goto varlen_alloc_error;
- }
- /* Put exclusion names first in the data */
- while (exclusion_count--) {
- strncpy(varlen_data + LTTNG_SYMBOL_NAME_LEN * exclusion_count,
- *(exclusion_list + exclusion_count),
- LTTNG_SYMBOL_NAME_LEN);
- }
- /* Add filter bytecode next */
- if (lsm.u.enable.bytecode_len != 0) {
- memcpy(varlen_data + LTTNG_SYMBOL_NAME_LEN * lsm.u.enable.exclusion_count,
- &ctx->bytecode->b,
- lsm.u.enable.bytecode_len);
- }
- } else {
- /* no exclusions - use the already allocated filter bytecode */
- varlen_data = (char *)(&ctx->bytecode->b);
+ lsm.u.enable.expression_len = strlen(filter_expression) + 1;
+ }
+
+ varlen_data = zmalloc(lsm.u.enable.bytecode_len
+ + lsm.u.enable.expression_len
+ + LTTNG_SYMBOL_NAME_LEN * exclusion_count);
+ if (!varlen_data) {
+ ret = -LTTNG_ERR_EXCLUSION_NOMEM;
+ goto varlen_alloc_error;
+ }
+ /* Put exclusion names first in the data */
+ while (exclusion_count--) {
+ strncpy(varlen_data + LTTNG_SYMBOL_NAME_LEN * exclusion_count,
+ *(exclusion_list + exclusion_count),
+ LTTNG_SYMBOL_NAME_LEN);
+ }
+ /* Add filter expression next */
+ if (lsm.u.enable.expression_len != 0) {
+ memcpy(varlen_data
+ + LTTNG_SYMBOL_NAME_LEN * lsm.u.enable.exclusion_count,
+ filter_expression,
+ lsm.u.enable.expression_len);
+ }
+ /* Add filter bytecode next */
+ if (lsm.u.enable.bytecode_len != 0) {
+ memcpy(varlen_data
+ + LTTNG_SYMBOL_NAME_LEN * lsm.u.enable.exclusion_count
+ + lsm.u.enable.expression_len,
+ &ctx->bytecode->b,
+ lsm.u.enable.bytecode_len);
}
ret = lttng_ctl_ask_sessiond_varlen(&lsm, varlen_data,
(LTTNG_SYMBOL_NAME_LEN * lsm.u.enable.exclusion_count) +
- lsm.u.enable.bytecode_len, NULL);
-
- if (lsm.u.enable.exclusion_count != 0) {
- free(varlen_data);
- }
+ lsm.u.enable.bytecode_len + lsm.u.enable.expression_len,
+ NULL);
+ free(varlen_data);
varlen_alloc_error:
if (filter_expression) {
ev.type = LTTNG_EVENT_TRACEPOINT;
ev.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- event = trace_ust_create_event(&ev, NULL, NULL);
+ event = trace_ust_create_event(&ev, NULL, NULL, NULL);
ok(event != NULL, "Create UST event");
exclusion->count = 1;
strncpy((char *)(exclusion->names), get_random_string(), LTTNG_SYMBOL_NAME_LEN);
- event = trace_ust_create_event(&ev, NULL, exclusion);
+ event = trace_ust_create_event(&ev, NULL, NULL, exclusion);
ok(event != NULL, "Create UST event with exclusion");