98b97c20bcd774ab89021012291ffc0ed6c51d06
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
{
125 int literal
; /* is string literal ? */
131 int top
; /* top of stack */
132 struct estack_entry e
[FILTER_STACK_LEN
];
135 #define estack_ax_v ax
136 #define estack_bx_v bx
138 #define estack_ax(stack, top) \
140 WARN_ON_ONCE((top) <= FILTER_STACK_EMPTY); \
144 #define estack_bx(stack, top) \
146 WARN_ON_ONCE((top) <= FILTER_STACK_EMPTY + 1); \
147 &(stack)->e[(top) - 1]; \
150 #define estack_push(stack, top, ax, bx) \
152 WARN_ON_ONCE((top) >= FILTER_STACK_LEN - 1); \
153 (stack)->e[(top) - 1].u.v = (bx); \
158 #define estack_pop(stack, top, ax, bx) \
160 WARN_ON_ONCE((top) <= FILTER_STACK_EMPTY); \
162 (bx) = (stack)->e[(top) - 2].u.v; \
166 const char *lttng_filter_print_op(enum filter_op op
);
168 int lttng_filter_validate_bytecode(struct bytecode_runtime
*bytecode
);
169 int lttng_filter_specialize_bytecode(struct bytecode_runtime
*bytecode
);
171 uint64_t lttng_filter_false(void *filter_data
,
172 const char *filter_stack_data
);
173 uint64_t lttng_filter_interpret_bytecode(void *filter_data
,
174 const char *filter_stack_data
);
176 #endif /* _LTTNG_FILTER_H */
This page took 0.032822 seconds and 3 git commands to generate.