4 * LTTng UST filter code.
6 * Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; only
11 * version 2.1 of the License.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <lttng/ust-events.h>
29 int lttng_filter_interpret_bytecode(void *filter_data
,
30 const char *filter_stack_data
)
37 int _lttng_filter_event_link_bytecode(struct ltt_event
*event
,
38 struct lttng_ust_filter_bytecode
*filter_bytecode
)
43 event
->filter
= lttng_filter_interpret_bytecode
;
45 /* event->filter_data = ; */
49 void lttng_filter_event_link_bytecode(struct ltt_event
*event
,
50 struct lttng_ust_filter_bytecode
*filter_bytecode
)
54 ret
= _lttng_filter_event_link_bytecode(event
, event
->filter_bytecode
);
56 fprintf(stderr
, "[lttng filter] error linking event bytecode\n");
61 * Link bytecode to all events for a wildcard. Skips events that already
62 * have a bytecode linked.
63 * We do not set each event's filter_bytecode field, because they do not
64 * own the filter_bytecode: the wildcard owns it.
66 void lttng_filter_wildcard_link_bytecode(struct session_wildcard
*wildcard
)
68 struct ltt_event
*event
;
71 if (!wildcard
->filter_bytecode
)
74 cds_list_for_each_entry(event
, &wildcard
->events
, wildcard_list
) {
77 ret
= _lttng_filter_event_link_bytecode(event
,
78 wildcard
->filter_bytecode
);
80 fprintf(stderr
, "[lttng filter] error linking wildcard bytecode\n");
88 * Need to attach filter to an event before starting tracing for the
91 int lttng_filter_event_attach_bytecode(struct ltt_event
*event
,
92 struct lttng_ust_filter_bytecode
*filter_bytecode
)
94 struct lttng_ust_filter_bytecode
*bc
;
96 if (event
->chan
->session
->been_active
)
98 if (event
->filter_bytecode
)
101 bc
= zmalloc(sizeof(struct lttng_ust_filter_bytecode
)
102 + filter_bytecode
->len
);
105 event
->filter_bytecode
= bc
;
110 * Need to attach filter to a wildcard before starting tracing for the
113 int lttng_filter_wildcard_attach_bytecode(struct session_wildcard
*wildcard
,
114 struct lttng_ust_filter_bytecode
*filter_bytecode
)
116 struct lttng_ust_filter_bytecode
*bc
;
118 if (wildcard
->chan
->session
->been_active
)
120 if (wildcard
->filter_bytecode
)
123 bc
= zmalloc(sizeof(struct lttng_ust_filter_bytecode
)
124 + filter_bytecode
->len
);
127 wildcard
->filter_bytecode
= bc
;