/*
* Apply a filter expression to an event.
*
- * If event_name is NULL, the filter is applied to all events of the channel.
+ * If event is NULL, the filter is applied to all events of the channel.
* If channel_name is NULL, a lookup of the event's channel is done.
* If both are NULL, the filter is applied to all events of all channels.
*/
extern int lttng_set_event_filter(struct lttng_handle *handle,
- const char *event_name,
- const char *channel_name,
+ struct lttng_event *event, const char *channel_name,
const char *filter_expression);
+
/*
* Create or enable a channel.
* The channel name cannot be NULL.
* Command LTTNG_SET_FILTER processed by the client thread.
*/
int cmd_set_filter(struct ltt_session *session, int domain,
- char *channel_name, char *event_name,
+ char *channel_name, struct lttng_event *event,
struct lttng_filter_bytecode *bytecode)
{
int ret;
{
struct ltt_ust_session *usess = session->ust_session;
- ret = filter_ust_set(usess, domain, bytecode, event_name, channel_name);
+ ret = filter_ust_set(usess, domain, bytecode, event, channel_name);
if (ret != LTTNG_OK) {
goto error;
}
int cmd_add_context(struct ltt_session *session, int domain,
char *channel_name, struct lttng_event_context *ctx, int kwpipe);
int cmd_set_filter(struct ltt_session *session, int domain,
- char *channel_name, char *event_name,
+ char *channel_name, struct lttng_event *event,
struct lttng_filter_bytecode *bytecode);
int cmd_enable_event(struct ltt_session *session, int domain,
char *channel_name, struct lttng_event *event, int wpipe);
* Add UST context to tracer.
*/
int filter_ust_set(struct ltt_ust_session *usess, int domain,
- struct lttng_filter_bytecode *bytecode, char *event_name,
+ struct lttng_filter_bytecode *bytecode, struct lttng_event *event,
char *channel_name)
{
int ret = LTTNG_OK, have_event = 0;
goto error;
}
- /* Do we have an event name */
- if (strlen(event_name) != 0) {
+ /* Do we have a valid event. */
+ if (event && event->name[0] != '\0') {
have_event = 1;
}
/* If UST channel specified and event name, get UST event ref */
if (uchan && have_event) {
- uevent = trace_ust_find_event_by_name(uchan->events, event_name);
+ uevent = trace_ust_find_event_by_name(uchan->events, event->name);
if (uevent == NULL) {
ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
goto error;
} else if (!uchan && have_event) { /* Add filter to event */
/* Add context to event without having the channel name */
cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) {
- uevent = trace_ust_find_event_by_name(uchan->events, event_name);
+ uevent = trace_ust_find_event_by_name(uchan->events, event->name);
if (uevent != NULL) {
ret = add_ufilter_to_event(usess, domain, uchan, uevent, bytecode);
/*
struct lttng_filter_bytecode;
int filter_ust_set(struct ltt_ust_session *usess, int domain,
- struct lttng_filter_bytecode *bytecode, char *event_name,
+ struct lttng_filter_bytecode *bytecode, struct lttng_event *event,
char *channel_name);
#endif /* _LTT_FILTER_H */
ret = cmd_set_filter(cmd_ctx->session, cmd_ctx->lsm->domain.type,
cmd_ctx->lsm->u.filter.channel_name,
- cmd_ctx->lsm->u.filter.event_name,
+ &cmd_ctx->lsm->u.filter.event,
bytecode);
break;
}
goto error;
}
if (opt_filter && event_enabled) {
- ret = lttng_set_event_filter(handle, ev.name, channel_name,
+ ret = lttng_set_event_filter(handle, &ev, channel_name,
opt_filter);
if (ret < 0) {
fprintf(stderr, "Ret filter: %d\n", ret);
event_enabled = 1;
}
if (opt_filter && event_enabled) {
- ret = lttng_set_event_filter(handle, ev.name, channel_name,
+ ret = lttng_set_event_filter(handle, &ev, channel_name,
opt_filter);
if (ret < 0) {
switch (-ret) {
} uri;
struct {
char channel_name[LTTNG_SYMBOL_NAME_LEN];
- char event_name[LTTNG_SYMBOL_NAME_LEN];
+ struct lttng_event event;
/* Length of following bytecode */
uint32_t bytecode_len;
} filter;
}
/*
- * set filter for an event
+ * Set filter for an event
+ *
* Return negative error value on error.
* Return size of returned session payload data if OK.
*/
-
int lttng_set_event_filter(struct lttng_handle *handle,
- const char *event_name, const char *channel_name,
+ struct lttng_event *event, const char *channel_name,
const char *filter_expression)
{
struct lttcomm_session_msg lsm;
copy_string(lsm.u.filter.channel_name, channel_name,
sizeof(lsm.u.filter.channel_name));
/* Copy event name */
- copy_string(lsm.u.filter.event_name, event_name,
- sizeof(lsm.u.filter.event_name));
+ if (event) {
+ memcpy(&lsm.u.enable.event, event, sizeof(lsm.u.enable.event));
+ }
+
lsm.u.filter.bytecode_len = sizeof(ctx->bytecode->b)
+ bytecode_get_len(&ctx->bytecode->b);