1 #ifndef _LTTNG_FILTER_H
2 #define _LTTNG_FILTER_H
7 * LTTng modules filter header.
9 * Copyright (C) 2010-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; only
14 * version 2.1 of the License.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 #include <linux/kernel.h>
28 #include <lttng-events.h>
29 #include <filter-bytecode.h>
31 /* Filter stack length, in number of entries */
32 #define FILTER_STACK_LEN 10 /* includes 2 dummy */
33 #define FILTER_STACK_EMPTY 1
36 #define dbg_printk(fmt, args...) \
37 printk(KERN_DEBUG "[debug bytecode in %s:%s@%u] " fmt, \
38 __FILE__, __func__, __LINE__, ## args)
40 #define dbg_printk(fmt, args...) \
42 /* do nothing but check printf format */ \
44 printk(KERN_DEBUG "[debug bytecode in %s:%s@%u] " fmt, \
45 __FILE__, __func__, __LINE__, ## args); \
49 /* Linked bytecode. Child of struct lttng_bytecode_runtime. */
50 struct bytecode_runtime
{
51 struct lttng_bytecode_runtime p
;
63 /* Validation stack */
69 int top
; /* top of stack */
70 struct vstack_entry e
[FILTER_STACK_LEN
];
74 void vstack_init(struct vstack
*stack
)
80 struct vstack_entry
*vstack_ax(struct vstack
*stack
)
82 if (unlikely(stack
->top
< 0))
84 return &stack
->e
[stack
->top
];
88 struct vstack_entry
*vstack_bx(struct vstack
*stack
)
90 if (unlikely(stack
->top
< 1))
92 return &stack
->e
[stack
->top
- 1];
96 int vstack_push(struct vstack
*stack
)
98 if (stack
->top
>= FILTER_STACK_LEN
- 1) {
99 printk(KERN_WARNING
"Stack full\n");
107 int vstack_pop(struct vstack
*stack
)
109 if (unlikely(stack
->top
< 0)) {
110 printk(KERN_WARNING
"Stack empty\n");
117 /* Execution stack */
118 struct estack_entry
{
124 const char __user
*user_str
;
126 int literal
; /* is string literal ? */
127 int user
; /* is string from userspace ? */
133 int top
; /* top of stack */
134 struct estack_entry e
[FILTER_STACK_LEN
];
137 #define estack_ax_v ax
138 #define estack_bx_v bx
140 #define estack_ax(stack, top) \
142 BUG_ON((top) <= FILTER_STACK_EMPTY); \
146 #define estack_bx(stack, top) \
148 BUG_ON((top) <= FILTER_STACK_EMPTY + 1); \
149 &(stack)->e[(top) - 1]; \
152 #define estack_push(stack, top, ax, bx) \
154 BUG_ON((top) >= FILTER_STACK_LEN - 1); \
155 (stack)->e[(top) - 1].u.v = (bx); \
160 #define estack_pop(stack, top, ax, bx) \
162 BUG_ON((top) <= FILTER_STACK_EMPTY); \
164 (bx) = (stack)->e[(top) - 2].u.v; \
168 const char *lttng_filter_print_op(enum filter_op op
);
170 int lttng_filter_validate_bytecode(struct bytecode_runtime
*bytecode
);
171 int lttng_filter_specialize_bytecode(struct bytecode_runtime
*bytecode
);
173 uint64_t lttng_filter_false(void *filter_data
,
174 struct lttng_probe_ctx
*lttng_probe_ctx
,
175 const char *filter_stack_data
);
176 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
177 struct lttng_probe_ctx
*lttng_probe_ctx
,
178 const char *filter_stack_data
);
180 #endif /* _LTTNG_FILTER_H */
This page took 0.035687 seconds and 4 git commands to generate.