destroy the filter tree when the traceset is modified. FIXME : should be an update
[lttv.git] / ltt / branches / poly / lttv / lttv / filter.c
CommitLineData
9c312311 1/* This file is part of the Linux Trace Toolkit viewer
0769c82f 2 * Copyright (C) 2003-2005 Michel Dagenais
9c312311 3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
31452f49 19/*
48f6f3c2 20 consist in AND, OR and NOT nested expressions, forming a tree with
21 simple relations as leaves. The simple relations test is a field
22 in an event is equal, not equal, smaller, smaller or equal, larger, or
a4c292d4 23 larger or equal to a specified value.
24*/
48f6f3c2 25
0769c82f 26/*
27 * YET TO BE ANSWERED
f4e9dd16 28 * - the exists an other lttv_filter which conflicts with this one
0769c82f 29 */
30
410c83da 31/*
32 * TODO
33 * - refine switch of expression in multiple uses functions
0cdc2470 34 * - remove the idle expressions in the tree ****
410c83da 35 * - add the current simple expression to the tree
36 */
37
31452f49 38#include <lttv/filter.h>
39
31452f49 40/*
a4c292d4 41 read_token
48f6f3c2 42
a4c292d4 43 read_expression
44 ( read expr )
45 simple expr [ op expr ]
48f6f3c2 46
a4c292d4 47 read_simple_expression
48 read_field_path [ rel value ]
48f6f3c2 49
a4c292d4 50 read_field_path
51 read_field_component [. field path]
48f6f3c2 52
a4c292d4 53 read_field_component
54 name [ \[ value \] ]
48f6f3c2 55
a4c292d4 56 data struct:
57 and/or(left/right)
58 not(child)
59 op(left/right)
60 path(component...) -> field
31452f49 61*/
62
1a7fa682 63GQuark
64 LTTV_FILTER_TRACE,
65 LTTV_FILTER_TRACESET,
66 LTTV_FILTER_TRACEFILE,
67 LTTV_FILTER_STATE,
91ad3f0a 68 LTTV_FILTER_EVENT,
69 LTTV_FILTER_NAME,
70 LTTV_FILTER_CATEGORY,
71 LTTV_FILTER_TIME,
72 LTTV_FILTER_TSC,
73 LTTV_FILTER_PID,
74 LTTV_FILTER_PPID,
75 LTTV_FILTER_C_TIME,
76 LTTV_FILTER_I_TIME,
77 LTTV_FILTER_P_NAME,
78 LTTV_FILTER_EX_MODE,
79 LTTV_FILTER_EX_SUBMODE,
80 LTTV_FILTER_P_STATUS,
81 LTTV_FILTER_CPU;
0cdc2470 82
2ea36caf 83LttvSimpleExpression*
0cdc2470 84lttv_simple_expression_new() {
85
86}
87
f4e9dd16 88/**
89 * Assign a new tree for the current expression
90 * or sub expression
2ea36caf 91 * @return pointer of LttvFilter
f4e9dd16 92 */
2ea36caf 93LttvFilter* lttv_filter_tree_new() {
94 LttvFilter* tree;
f4e9dd16 95
2ea36caf 96 tree = g_new(LttvFilter,1);
0cdc2470 97 tree->node = 0; //g_new(lttv_expression,1);
98// tree->node->type = LTTV_UNDEFINED_EXPRESSION;
2a734d8e 99 tree->left = LTTV_TREE_IDLE;
100 tree->right = LTTV_TREE_IDLE;
f4e9dd16 101
102 return tree;
103}
104
105/**
106 * Destroys the tree and his sub-trees
107 * @param tree Tree which must be destroyed
108 */
2ea36caf 109void lttv_filter_tree_destroy(LttvFilter* tree) {
0e8fbe23 110
111 if(tree == NULL) return;
f4e9dd16 112
113 if(tree->left == LTTV_TREE_LEAF) g_free(tree->l_child.leaf);
114 else if(tree->left == LTTV_TREE_NODE) lttv_filter_tree_destroy(tree->l_child.t);
115
116 if(tree->right == LTTV_TREE_LEAF) g_free(tree->r_child.leaf);
117 else if(tree->right == LTTV_TREE_NODE) lttv_filter_tree_destroy(tree->r_child.t);
118
119 g_free(tree->node);
120 g_free(tree);
121}
bcacff8e 122
2ea36caf 123LttvFilter*
124lttv_filter_clone(LttvFilter* tree) {
bcacff8e 125
ef3818b1 126 if(tree == NULL) return NULL;
127
128 LttvFilter* newtree = lttv_filter_tree_new();
bcacff8e 129
ef3818b1 130 /*
131 * TODO : Copy tree into new tree
132 */
bcacff8e 133
ef3818b1 134 return newtree;
bcacff8e 135
136}
1a7fa682 137
0cdc2470 138void
2ea36caf 139lttv_filter_tree_add_node(GPtrArray* stack, LttvFilter* subtree, LttvLogicalOp op) {
0cdc2470 140
2ea36caf 141 LttvFilter* t1 = NULL;
142 LttvFilter* t2 = NULL;
0cdc2470 143
2ea36caf 144 t1 = (LttvFilter*)g_ptr_array_index(stack,stack->len-1);
0cdc2470 145 while(t1->right != LTTV_TREE_IDLE) t1 = t1->r_child.t;
146 t2 = lttv_filter_tree_new();
147 t2->node = op;
148 if(subtree != NULL) {
149 t2->left = LTTV_TREE_NODE;
150 t2->l_child.t = subtree;
151 subtree = NULL;
152 t1->right = LTTV_TREE_NODE;
153 t1->r_child.t = t2;
154 } else {
155// a_simple_expression->value = a_field_component->str;
156// a_field_component = g_string_new("");
157 t2->left = LTTV_TREE_LEAF;
158// t2->l_child.leaf = a_simple_expression;
159// a_simple_expression = g_new(lttv_simple_expression,1);
160 t1->right = LTTV_TREE_NODE;
161 t1->r_child.t = t2;
162 }
163
164}
165
0769c82f 166/**
167 * Parse through filtering field hierarchy as specified
168 * by user. This function compares each value to
169 * predetermined quarks
170 * @param fp The field path list
171 * @return success/failure of operation
172 */
173gboolean
f4e9dd16 174parse_field_path(GPtrArray* fp) {
0769c82f 175
f4e9dd16 176 GString* f = NULL;
2b99ec10 177 if(fp->len < 2) return FALSE;
f4e9dd16 178 g_assert(f=g_ptr_array_index(fp,0)); //list_first(fp)->data;
0769c82f 179
91ad3f0a 180 if(g_quark_try_string(f->str) == LTTV_FILTER_EVENT) {
2b99ec10 181 f=g_ptr_array_index(fp,1);
182 if(g_quark_try_string(f->str) == LTTV_FILTER_NAME) {}
183 else if(g_quark_try_string(f->str) == LTTV_FILTER_CATEGORY) {}
184 else if(g_quark_try_string(f->str) == LTTV_FILTER_TIME) {
185 // offset = &((LttEvent*)NULL)->event_time);
186 }
187 else if(g_quark_try_string(f->str) == LTTV_FILTER_TSC) {
188 // offset = &((LttEvent*)NULL)->event_cycle_count);
189 }
190 else { /* core.xml specified options */
191
192 }
91ad3f0a 193 } else if(g_quark_try_string(f->str) == LTTV_FILTER_TRACEFILE) {
2b99ec10 194 f=g_ptr_array_index(fp,1);
195 if(g_quark_try_string(f->str) == LTTV_FILTER_NAME) {}
196 else return FALSE;
91ad3f0a 197 } else if(g_quark_try_string(f->str) == LTTV_FILTER_TRACE) {
2b99ec10 198 f=g_ptr_array_index(fp,1);
199 if(g_quark_try_string(f->str) == LTTV_FILTER_NAME) {}
200 else return FALSE;
91ad3f0a 201
202 } else if(g_quark_try_string(f->str) == LTTV_FILTER_STATE) {
2b99ec10 203 f=g_ptr_array_index(fp,1);
204 if(g_quark_try_string(f->str) == LTTV_FILTER_PID) {}
205 else if(g_quark_try_string(f->str) == LTTV_FILTER_PPID) {}
206 else if(g_quark_try_string(f->str) == LTTV_FILTER_C_TIME) {}
207 else if(g_quark_try_string(f->str) == LTTV_FILTER_I_TIME) {}
208 else if(g_quark_try_string(f->str) == LTTV_FILTER_P_NAME) {}
209 else if(g_quark_try_string(f->str) == LTTV_FILTER_EX_MODE) {}
210 else if(g_quark_try_string(f->str) == LTTV_FILTER_EX_SUBMODE) {}
211 else if(g_quark_try_string(f->str) == LTTV_FILTER_P_STATUS) {}
212 else if(g_quark_try_string(f->str) == LTTV_FILTER_CPU) {}
213 else return FALSE;
91ad3f0a 214
215 } else {
216 g_warning("Unrecognized field in filter string");
217 return FALSE;
0769c82f 218 }
91ad3f0a 219 return TRUE;
0769c82f 220}
221
31452f49 222/**
84a333d6 223 * Add an filtering option to the current tree
224 * @param expression Current expression to parse
225 * @return success/failure of operation
226 */
227gboolean
228parse_simple_expression(GString* expression) {
229
230 unsigned i;
231
a4c292d4 232
0769c82f 233
a4c292d4 234
84a333d6 235}
236
237/**
238 * Creates a new lttv_filter
31452f49 239 * @param expression filtering options string
240 * @param t pointer to the current LttvTrace
84a333d6 241 * @return the current lttv_filter or NULL if error
31452f49 242 */
2ea36caf 243LttvFilter*
0769c82f 244lttv_filter_new(char *expression, LttvTraceState *tcs) {
a4c292d4 245
0769c82f 246 g_print("filter::lttv_filter_new()\n"); /* debug */
a4c292d4 247
a4c292d4 248 unsigned
249 i,
91ad3f0a 250 p_nesting=0, /* parenthesis nesting value */
a4c292d4 251 b=0; /* current breakpoint in expression string */
1601b365 252
253 /* trees */
2ea36caf 254 LttvFilter
1601b365 255 *tree = lttv_filter_tree_new(), /* main tree */
256 *subtree = NULL, /* buffer for subtrees */
257 *t1, /* buffer #1 */
258 *t2; /* buffer #2 */
259
260 /*
261 * Tree Stack
f4e9dd16 262 * each element of the list
263 * is a sub tree created
264 * by the use of parenthesis in the
265 * global expression. The final tree
1601b365 266 * will be the one left at the root of
f4e9dd16 267 * the list
268 */
18d1226f 269 GPtrArray *tree_stack = g_ptr_array_new();
270 g_ptr_array_add( tree_stack,(gpointer) tree );
f4e9dd16 271
a4c292d4 272 /* temporary values */
0769c82f 273 GString *a_field_component = g_string_new("");
f4e9dd16 274 GPtrArray *a_field_path = NULL;
275
2ea36caf 276 LttvSimpleExpression* a_simple_expression = g_new(LttvSimpleExpression,1);
0769c82f 277
a4c292d4 278 /*
279 * Parse entire expression and construct
280 * the binary tree. There are two steps
281 * in browsing that string
f4e9dd16 282 * 1. finding boolean ops " &,|,^,! " and parenthesis " {,(,[,],),} "
a4c292d4 283 * 2. finding simple expressions
0769c82f 284 * - field path ( separated by dots )
a4c292d4 285 * - op ( >, <, =, >=, <=, !=)
0769c82f 286 * - value ( integer, string ... )
287 * To spare computing time, the whole
288 * string is parsed in this loop for a
289 * O(n) complexity order.
1601b365 290 *
18d1226f 291 * When encountering logical op &,|,^
292 * 1. parse the last value if any
293 * 2. create a new tree
294 * 3. add the expression (simple exp, or exp (subtree)) to the tree
295 * 4. concatenate this tree with the current tree on top of the stack
296 * When encountering math ops >,>=,<,<=,=,!=
297 * 1. add to op to the simple expression
298 * 2. concatenate last field component to field path
299 * When encountering concatening ops .
300 * 1. concatenate last field component to field path
301 * When encountering opening parenthesis (,{,[
302 * 1. create a new subtree on top of tree stack
303 * When encountering closing parenthesis ),},]
304 * 1. add the expression on right child of the current tree
305 * 2. the subtree is completed, allocate a new subtree
306 * 3. pop the tree value from the tree stack
307 */
308
f4e9dd16 309 a_field_path = g_ptr_array_new();
310 g_ptr_array_set_size(a_field_path,2); /* by default, recording 2 field expressions */
311
18d1226f 312
a4c292d4 313 for(i=0;i<strlen(expression);i++) {
18d1226f 314// g_print("%s\n",a_field_component->str);
410c83da 315 g_print("%c ",expression[i]);
1601b365 316// g_print("switch:%c -->subtree:%p\n",expression[i],subtree);
a4c292d4 317 switch(expression[i]) {
318 /*
319 * logical operators
320 */
321 case '&': /* and */
2ea36caf 322 t1 = (LttvFilter*)g_ptr_array_index(tree_stack,tree_stack->len-1);
2a734d8e 323 while(t1->right != LTTV_TREE_IDLE) t1 = t1->r_child.t;
18d1226f 324 t2 = lttv_filter_tree_new();
0cdc2470 325 t2->node = LTTV_LOGICAL_AND;
1601b365 326 if(subtree != NULL) {
18d1226f 327 t2->left = LTTV_TREE_NODE;
328 t2->l_child.t = subtree;
f4e9dd16 329 subtree = NULL;
18d1226f 330 t1->right = LTTV_TREE_NODE;
410c83da 331 t1->r_child.t = t2;
f4e9dd16 332 } else {
0cdc2470 333 a_simple_expression->value = a_field_component->str;
18d1226f 334 a_field_component = g_string_new("");
335 t2->left = LTTV_TREE_LEAF;
0cdc2470 336 t2->l_child.leaf = a_simple_expression;
2ea36caf 337 a_simple_expression = g_new(LttvSimpleExpression,1);
18d1226f 338 t1->right = LTTV_TREE_NODE;
410c83da 339 t1->r_child.t = t2;
f4e9dd16 340 }
341
342 break;
a4c292d4 343 case '|': /* or */
2ea36caf 344 t1 = (LttvFilter*)g_ptr_array_index(tree_stack,tree_stack->len-1);
2a734d8e 345 while(t1->right != LTTV_TREE_IDLE) t1 = t1->r_child.t;
1601b365 346 t2 = lttv_filter_tree_new();
0cdc2470 347 t2->node = LTTV_LOGICAL_OR;
1601b365 348 if(subtree != NULL) {
349 t2->left = LTTV_TREE_NODE;
350 t2->l_child.t = subtree;
351 subtree = NULL;
352 t1->right = LTTV_TREE_NODE;
353 t1->r_child.t = t2;
354 } else {
0cdc2470 355 a_simple_expression->value = a_field_component->str;
1601b365 356 a_field_component = g_string_new("");
357 t2->left = LTTV_TREE_LEAF;
0cdc2470 358 t2->l_child.leaf = a_simple_expression;
2ea36caf 359 a_simple_expression = g_new(LttvSimpleExpression,1);
1601b365 360 t1->right = LTTV_TREE_NODE;
361 t1->r_child.t = t2;
362 }
f4e9dd16 363 break;
a4c292d4 364 case '^': /* xor */
2ea36caf 365 t1 = (LttvFilter*)g_ptr_array_index(tree_stack,tree_stack->len-1);
2a734d8e 366 while(t1->right != LTTV_TREE_IDLE) t1 = t1->r_child.t;
1601b365 367 t2 = lttv_filter_tree_new();
0cdc2470 368 t2->node = LTTV_LOGICAL_XOR;
1601b365 369 if(subtree != NULL) {
370 t2->left = LTTV_TREE_NODE;
371 t2->l_child.t = subtree;
372 subtree = NULL;
373 t1->right = LTTV_TREE_NODE;
374 t1->r_child.t = t2;
375 } else {
0cdc2470 376 a_simple_expression->value = a_field_component->str;
1601b365 377 a_field_component = g_string_new("");
378 t2->left = LTTV_TREE_LEAF;
0cdc2470 379 t2->l_child.leaf = a_simple_expression;
2ea36caf 380 a_simple_expression = g_new(LttvSimpleExpression,1);
1601b365 381 t1->right = LTTV_TREE_NODE;
382 t1->r_child.t = t2;
383 }
a4c292d4 384 break;
385 case '!': /* not, or not equal (math op) */
386 if(expression[i+1] == '=') { /* != */
0cdc2470 387 a_simple_expression->op = LTTV_FIELD_NE;
a4c292d4 388 i++;
0cdc2470 389 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
390 a_field_component = g_string_new("");
a4c292d4 391 } else { /* ! */
1601b365 392 // g_print("%s\n",a_field_component);
393 // a_field_component = g_string_new("");
2ea36caf 394 t1 = (LttvFilter*)g_ptr_array_index(tree_stack,tree_stack->len-1);
2a734d8e 395 while(t1->right != LTTV_TREE_IDLE) t1 = t1->r_child.t;
1601b365 396 t2 = lttv_filter_tree_new();
0cdc2470 397 t2->node = LTTV_LOGICAL_NOT;
1601b365 398 t1->right = LTTV_TREE_NODE;
399 t1->r_child.t = t2;
a4c292d4 400 }
401 break;
402 case '(': /* start of parenthesis */
91ad3f0a 403 case '[':
404 case '{':
405 p_nesting++; /* incrementing parenthesis nesting value */
1601b365 406 t1 = lttv_filter_tree_new();
407 g_ptr_array_add( tree_stack,(gpointer) t1 );
a4c292d4 408 break;
409 case ')': /* end of parenthesis */
91ad3f0a 410 case ']':
411 case '}':
412 p_nesting--; /* decrementing parenthesis nesting value */
18d1226f 413 if(p_nesting<0 || tree_stack->len<2) {
f4e9dd16 414 g_warning("Wrong filtering options, the string\n\"%s\"\n\
415 is not valid due to parenthesis incorrect use",expression);
416 return NULL;
417 }
18d1226f 418
419 g_assert(tree_stack->len>0);
420 if(subtree != NULL) {
421 t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
2a734d8e 422 while(t1->right != LTTV_TREE_IDLE && t1->right != LTTV_TREE_LEAF) {
18d1226f 423 g_assert(t1!=NULL && t1->r_child.t != NULL);
424 t1 = t1->r_child.t;
425 }
426 t1->right = LTTV_TREE_NODE;
427 t1->r_child.t = subtree;
428 subtree = g_ptr_array_index(tree_stack,tree_stack->len-1);
429 g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
430 } else {
0cdc2470 431 a_simple_expression->value = a_field_component->str;
18d1226f 432 a_field_component = g_string_new("");
433 t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
2a734d8e 434 while(t1->right != LTTV_TREE_IDLE) t1 = t1->r_child.t;
18d1226f 435 t1->right = LTTV_TREE_LEAF;
0cdc2470 436 t1->r_child.leaf = a_simple_expression;
2ea36caf 437 a_simple_expression = g_new(LttvSimpleExpression,1);
18d1226f 438 subtree = g_ptr_array_index(tree_stack,tree_stack->len-1);
1601b365 439 g_assert(subtree != NULL);
18d1226f 440 g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
441 }
a4c292d4 442 break;
443
444 /*
445 * mathematic operators
446 */
447 case '<': /* lower, lower or equal */
448 if(expression[i+1] == '=') { /* <= */
449 i++;
0cdc2470 450 a_simple_expression->op = LTTV_FIELD_LE;
451 } else a_simple_expression->op = LTTV_FIELD_LT;
f4e9dd16 452 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
453 a_field_component = g_string_new("");
a4c292d4 454 break;
455 case '>': /* higher, higher or equal */
456 if(expression[i+1] == '=') { /* >= */
457 i++;
0cdc2470 458 a_simple_expression->op = LTTV_FIELD_GE;
459 } else a_simple_expression->op = LTTV_FIELD_GT;
f4e9dd16 460 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
461 a_field_component = g_string_new("");
a4c292d4 462 break;
463 case '=': /* equal */
0cdc2470 464 a_simple_expression->op = LTTV_FIELD_EQ;
f4e9dd16 465 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
466 a_field_component = g_string_new("");
a4c292d4 467 break;
0769c82f 468 /*
469 * Field concatening caracter
470 */
471 case '.': /* dot */
f4e9dd16 472 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
0769c82f 473 a_field_component = g_string_new("");
474 break;
a4c292d4 475 default: /* concatening current string */
1a7fa682 476 g_string_append_c(a_field_component,expression[i]);
a4c292d4 477 }
478 }
1601b365 479
480 g_print("subtree:%p, tree:%p, t1:%p, t2:%p\n",subtree,tree,t1,t2);
0cdc2470 481 g_print("stack size: %i\n",tree_stack->len);
482
483 /*
484 * Preliminary check to see
485 * if tree was constructed correctly
486 */
487 if( p_nesting>0 ) {
488 g_warning("Wrong filtering options, the string\n\"%s\"\n\
489 is not valid due to parenthesis incorrect use",expression);
490 return NULL;
491 }
492
493 if(tree_stack->len != 1) /* only root tree should remain */
494 return NULL;
1601b365 495
410c83da 496 /* processing last element of expression */
410c83da 497 t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
2a734d8e 498 while(t1->right != LTTV_TREE_IDLE) t1 = t1->r_child.t;
410c83da 499 if(subtree != NULL) { /* add the subtree */
500 t1->right = LTTV_TREE_NODE;
0cdc2470 501 t1->r_child.t = subtree;
410c83da 502 subtree = NULL;
503 } else { /* add a leaf */
0cdc2470 504 a_simple_expression->value = a_field_component->str;
410c83da 505 a_field_component = g_string_new("");
506 t1->right = LTTV_TREE_LEAF;
0cdc2470 507 t1->r_child.leaf = a_simple_expression;
2ea36caf 508 /*
509 * FIXME: is it really necessary to reallocate
510 * LttvSimpleExpression at this point ??
511 */
512 a_simple_expression = g_new(LttvSimpleExpression,1);
410c83da 513 }
514
515 g_assert(tree != NULL);
516 g_assert(subtree == NULL);
a4c292d4 517
1601b365 518 lttv_filter_tracefile(tree,NULL);
519
410c83da 520 return tree;
521
31452f49 522}
523
1da1525d 524void
2ea36caf 525lttv_filter_destroy(LttvFilter* filter) {
1da1525d 526
527}
528
84a333d6 529/**
530 * Apply the filter to a specific trace
531 * @param filter the current filter applied
532 * @param tracefile the trace to apply the filter to
533 * @return success/failure of operation
534 */
31452f49 535gboolean
2ea36caf 536lttv_filter_tracefile(LttvFilter *filter, LttTracefile *tracefile) {
0769c82f 537
1601b365 538 /*
539 * Each tree is parsed in inorder.
540 * This way, it's possible to apply the left filter of the
541 * tree, then decide whether or not the right branch should
542 * be parsed depending on the linking logical operator
543 *
544 * As for the filtering structure, since we are trying
545 * to remove elements from the trace, it might be better
546 * managing an array of all items to be removed ..
547 */
0769c82f 548
1601b365 549 g_print("node:%p lchild:%p rchild:%p\n",filter,filter->l_child.t,filter->r_child.t);
0cdc2470 550 g_print("node type%i\n",filter->node);
1601b365 551 if(filter->left == LTTV_TREE_NODE) lttv_filter_tracefile(filter->l_child.t,NULL);
0cdc2470 552 else if(filter->left == LTTV_TREE_LEAF) {
553 g_assert(filter->l_child.leaf->value != NULL);
554 g_print("%p: left is qqch %i %s\n",filter,filter->l_child.leaf->op,filter->l_child.leaf->value);
555 }
1601b365 556 if(filter->right == LTTV_TREE_NODE) lttv_filter_tracefile(filter->r_child.t,NULL);
0cdc2470 557 else if(filter->right == LTTV_TREE_LEAF) {
558 g_assert(filter->r_child.leaf->value != NULL);
559 g_print("%p: right is qqch %i %s\n",filter,filter->r_child.leaf->op,filter->r_child.leaf->value);
560 }
0769c82f 561
562 /* test */
563/* int i, nb;
564 char *f_name, *e_name;
31452f49 565
0769c82f 566 char* field = "cpu";
567
568 LttvTraceHook h;
569
570 LttEventType *et;
571
572 LttType *t;
573
574 GString *fe_name = g_string_new("");
575
576 nb = ltt_trace_eventtype_number(tcs->parent.t);
577 g_print("NB:%i\n",nb);
578 for(i = 0 ; i < nb ; i++) {
579 et = ltt_trace_eventtype_get(tcs->parent.t, i);
580 e_name = ltt_eventtype_name(et);
581 f_name = ltt_facility_name(ltt_eventtype_facility(et));
582 g_string_printf(fe_name, "%s.%s", f_name, e_name);
583 g_print("facility:%s and event:%s\n",f_name,e_name);
584 }
585 */
31452f49 586}
587
1a7fa682 588gboolean
2ea36caf 589lttv_filter_tracestate(LttvFilter *filter, LttvTraceState *tracestate) {
341aa948 590
591}
1a7fa682 592
84a333d6 593/**
594 * Apply the filter to a specific event
595 * @param filter the current filter applied
596 * @param event the event to apply the filter to
597 * @return success/failure of operation
598 */
31452f49 599gboolean
2ea36caf 600lttv_filter_event(LttvFilter *filter, LttEvent *event) {
31452f49 601
602}
1a7fa682 603
91ad3f0a 604/**
605 * Initializes the filter module and specific values
606 */
1a7fa682 607static void module_init()
608{
91ad3f0a 609
610 /*
611 * Quarks initialization
612 * for hardcoded filtering options
613 *
614 * TODO: traceset has no yet been defined
615 */
616
617 /* top fields */
618 LTTV_FILTER_EVENT = g_quark_from_string("event");
619 LTTV_FILTER_TRACE = g_quark_from_string("trace");
620 LTTV_FILTER_TRACESET = g_quark_from_string("traceset");
621 LTTV_FILTER_STATE = g_quark_from_string("state");
622 LTTV_FILTER_TRACEFILE = g_quark_from_string("tracefile");
1a7fa682 623
91ad3f0a 624 /* event.name, tracefile.name, trace.name */
625 LTTV_FILTER_NAME = g_quark_from_string("name");
626
627 /* event sub fields */
628 LTTV_FILTER_CATEGORY = g_quark_from_string("category");
629 LTTV_FILTER_TIME = g_quark_from_string("time");
630 LTTV_FILTER_TSC = g_quark_from_string("tsc");
631
632 /* state sub fields */
633 LTTV_FILTER_PID = g_quark_from_string("pid");
634 LTTV_FILTER_PPID = g_quark_from_string("ppid");
635 LTTV_FILTER_C_TIME = g_quark_from_string("creation_time");
636 LTTV_FILTER_I_TIME = g_quark_from_string("insertion_time");
637 LTTV_FILTER_P_NAME = g_quark_from_string("process_name");
638 LTTV_FILTER_EX_MODE = g_quark_from_string("execution_mode");
639 LTTV_FILTER_EX_SUBMODE = g_quark_from_string("execution_submode");
640 LTTV_FILTER_P_STATUS = g_quark_from_string("process_status");
641 LTTV_FILTER_CPU = g_quark_from_string("cpu");
642
1a7fa682 643}
644
91ad3f0a 645/**
646 * Destroys the filter module and specific values
647 */
1a7fa682 648static void module_destroy()
649{
650}
651
652
91ad3f0a 653LTTV_MODULE("filter", "Filters traceset and events", \
654 "Filters traceset and events specifically to user input", \
1a7fa682 655 module_init, module_destroy)
656
657
658
This page took 0.063862 seconds and 4 git commands to generate.