1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Michel Dagenais
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 #include <lttv/traceset.h>
24 /* A filter expression consists in nested AND, OR and NOT expressions
25 involving boolean relation (>, >=, =, !=, <, <=) between event fields and
26 specific values. It is compiled into an efficient data structure which
27 is used in functions to check if a given event or tracefile satisfies the
30 The grammar for filters is:
34 expression = "(" expression ")" | "!" expression |
35 expression "&&" expression | expression "||" expression |
38 simpleExpression = fieldPath op value
40 fieldPath = fieldComponent [ "." fieldPath ]
42 fieldComponent = name [ "[" integer "]" ]
44 value = integer | double | string
49 * @enum lttv_expression_op
51 typedef enum _lttv_expression_op
53 LTTV_FIELD_EQ
, /** equal */
54 LTTV_FIELD_NE
, /** not equal */
55 LTTV_FIELD_LT
, /** lower than */
56 LTTV_FIELD_LE
, /** lower or equal */
57 LTTV_FIELD_GT
, /** greater than */
58 LTTV_FIELD_GE
/** greater or equal */
61 typedef enum _lttv_expression_type
64 LTTV_SIMPLE_EXPRESSION
65 } lttv_expression_type
;
67 typedef struct _lttv_simple_expression
69 lttv_expression_op op
;
72 } lttv_simple_expression
;
74 typedef struct _lttv_expression
80 gboolean simple_expression
;
83 // struct lttv_expression *e;
84 // lttv_field_relation *se;
88 typedef struct _lttv_filter_tree
{
89 lttv_expression
* node
;
90 struct lttv_filter_tree
* r_child
;
91 struct lttv_filter_tree
* l_child
;
96 * ( will later contain a binary tree of filtering options )
98 typedef struct _lttv_filter
{
99 lttv_filter_tree
* tree
;
102 gboolean
parse_simple_expression(GString
* expression
);
104 /* Compile the filter expression into an efficient data structure */
106 lttv_filter
*lttv_filter_new(char *expression
, LttvTrace
*t
);
109 /* Check if the tracefile or event satisfies the filter. The arguments are
110 declared as void * to allow these functions to be used as hooks. */
112 gboolean
lttv_filter_tracefile(lttv_filter
*filter
, void *tracefile
);
114 gboolean
lttv_filter_event(lttv_filter
*filter
, void *event
);