forgot a BO wrap
[lttv.git] / ltt / branches / poly / lttv / lttv / filter.c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2005 Michel Dagenais and Simon Bouvier-Zappa
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
19 /*! \file lttv/lttv/filter.c
20 * \brief Defines the core filter of application
21 *
22 * consist in AND, OR and NOT nested expressions, forming a tree with
23 * simple relations as leaves. The simple relations test if a field
24 * in an event is equal, not equal, smaller, smaller or equal, larger, or
25 * larger or equal to a specified value.
26 *
27 * Fields specified in a simple expression can take following
28 * values
29 *
30 * \verbatim
31 * LttvTracefileContext{}
32 * |->event\
33 * | |->name (String, converted to GQuark)
34 * | |->facility (String, converted to GQuark)
35 * | |->category (String, not yet implemented)
36 * | |->time (LttTime)
37 * | |->tsc (LttCycleCount --> uint64)
38 * | |->fields
39 * | |->"event name"
40 * | |->"field name"
41 * | |->"sub-field name"
42 * | |->...
43 * | |->"leaf-field name" (field type)
44 * |->tracefile
45 * | |->name (String, converted to GQuark)
46 * |->trace
47 * | |->name (String, converted to GQuark)
48 * |->state
49 * |->pid (guint)
50 * |->ppid (guint)
51 * |->creation_time (LttTime)
52 * |->insertion_time (LttTime)
53 * |->process_name (String, converted to GQuark)
54 * |->execution_mode (LttvExecutionMode)
55 * |->execution_submode (LttvExecutionSubmode)
56 * |->process_status (LttvProcessStatus)
57 * |->cpu (guint)
58 * \endverbatim
59 */
60
61 /*
62 * \todo
63 * - refine switch of expression in multiple uses functions
64 * - remove the idle expressions in the tree
65 */
66
67 #ifdef HAVE_CONFIG_H
68 #include <config.h>
69 #endif
70
71 //#define TEST
72 #ifdef TEST
73 #include <time.h>
74 #include <sys/time.h>
75 #endif
76
77 #include <lttv/filter.h>
78 #include <ltt/trace.h>
79 #include <ltt/type.h>
80 #include <ltt/facility.h>
81 #include <stdlib.h>
82 #include <string.h>
83
84 /**
85 * @fn LttvSimpleExpression* lttv_simple_expression_new()
86 *
87 * Constructor for LttvSimpleExpression
88 * @return pointer to new LttvSimpleExpression
89 */
90 LttvSimpleExpression*
91 lttv_simple_expression_new() {
92
93 LttvSimpleExpression* se = g_new(LttvSimpleExpression,1);
94
95 se->field = LTTV_FILTER_UNDEFINED;
96 se->op = NULL;
97 se->offset = 0;
98
99 return se;
100 }
101
102 /**
103 * @fn gboolean lttv_simple_expression_assign_field(GPtrArray*,LttvSimpleExpression*)
104 *
105 * Parse through filtering field hierarchy as specified
106 * by user. This function compares each value to
107 * predetermined quarks
108 * @param fp The field path list
109 * @param se current simple expression
110 * @return success/failure of operation
111 */
112 gboolean
113 lttv_simple_expression_assign_field(GPtrArray* fp, LttvSimpleExpression* se) {
114
115 GString* f = NULL;
116
117 if(fp->len < 2) return FALSE;
118 g_assert((f=g_ptr_array_remove_index(fp,0)));
119
120 /*
121 * Parse through the specified
122 * hardcoded fields.
123 *
124 * Take note however that the
125 * 'event' subfields might change
126 * depending on values specified
127 * in core.xml file. Hence, if
128 * none of the subfields in the
129 * array match the hardcoded
130 * subfields, it will be considered
131 * as a dynamic field
132 */
133 if(!g_strcasecmp(f->str,"trace") ) {
134 /*
135 * Possible values:
136 * trace.name
137 */
138 g_string_free(f,TRUE);
139 f=g_ptr_array_remove_index(fp,0);
140 if(!g_strcasecmp(f->str,"name")) {
141 se->field = LTTV_FILTER_TRACE_NAME;
142 }
143 } else if(!g_strcasecmp(f->str,"traceset") ) {
144 /*
145 * FIXME: not yet implemented !
146 */
147 } else if(!g_strcasecmp(f->str,"tracefile") ) {
148 /*
149 * Possible values:
150 * tracefile.name
151 */
152 g_string_free(f,TRUE);
153 f=g_ptr_array_remove_index(fp,0);
154 if(!g_strcasecmp(f->str,"name")) {
155 se->field = LTTV_FILTER_TRACEFILE_NAME;
156 }
157 } else if(!g_strcasecmp(f->str,"state") ) {
158 /*
159 * Possible values:
160 * state.pid
161 * state.ppid
162 * state.creation_time
163 * state.insertion_time
164 * state.process_name
165 * state.execution_mode
166 * state.execution_submode
167 * state.process_status
168 * state.cpu
169 */
170 g_string_free(f,TRUE);
171 f=g_ptr_array_remove_index(fp,0);
172 if(!g_strcasecmp(f->str,"pid") ) {
173 se->field = LTTV_FILTER_STATE_PID;
174 }
175 else if(!g_strcasecmp(f->str,"ppid") ) {
176 se->field = LTTV_FILTER_STATE_PPID;
177 }
178 else if(!g_strcasecmp(f->str,"creation_time") ) {
179 se->field = LTTV_FILTER_STATE_CT;
180 }
181 else if(!g_strcasecmp(f->str,"insertion_time") ) {
182 se->field = LTTV_FILTER_STATE_IT;
183 }
184 else if(!g_strcasecmp(f->str,"process_name") ) {
185 se->field = LTTV_FILTER_STATE_P_NAME;
186 }
187 else if(!g_strcasecmp(f->str,"execution_mode") ) {
188 se->field = LTTV_FILTER_STATE_EX_MODE;
189 }
190 else if(!g_strcasecmp(f->str,"execution_submode") ) {
191 se->field = LTTV_FILTER_STATE_EX_SUBMODE;
192 }
193 else if(!g_strcasecmp(f->str,"process_status") ) {
194 se->field = LTTV_FILTER_STATE_P_STATUS;
195 }
196 else if(!g_strcasecmp(f->str,"cpu") ) {
197 se->field = LTTV_FILTER_STATE_CPU;
198 }
199 } else if(!g_strcasecmp(f->str,"event") ) {
200 /*
201 * Possible values:
202 * event.name
203 * event.category
204 * event.time
205 * event.tsc
206 */
207 g_string_free(f,TRUE);
208 f=g_ptr_array_remove_index(fp,0);
209 if(!g_strcasecmp(f->str,"name") ) {
210 se->field = LTTV_FILTER_EVENT_NAME;
211 }
212 else if(!g_strcasecmp(f->str,"facility") ) {
213 se->field = LTTV_FILTER_EVENT_FACILITY;
214 }
215 else if(!g_strcasecmp(f->str,"category") ) {
216 /*
217 * FIXME: Category not yet functional in lttv
218 */
219 se->field = LTTV_FILTER_EVENT_CATEGORY;
220 }
221 else if(!g_strcasecmp(f->str,"time") ) {
222 se->field = LTTV_FILTER_EVENT_TIME;
223 }
224 else if(!g_strcasecmp(f->str,"tsc") ) {
225 se->field = LTTV_FILTER_EVENT_TSC;
226 }
227 else { /* core.xml specified options */
228 se->field = LTTV_FILTER_EVENT_FIELD;
229 }
230 } else {
231 g_warning("Unrecognized field in filter string");
232 }
233
234 /* free memory for last string */
235 g_string_free(f,TRUE);
236
237 /* array should be empty */
238 g_assert(fp->len == 0);
239
240 if(se->field == LTTV_FILTER_UNDEFINED) {
241 g_warning("The specified field was not recognized !");
242 return FALSE;
243 }
244 return TRUE;
245 }
246
247 /**
248 * @fn gboolean lttv_simple_expression_assign_operator(LttvSimpleExpression*,LttvExpressionOp)
249 *
250 * Sets the function pointer for the current
251 * Simple Expression
252 * @param se current simple expression
253 * @param op current operator
254 * @return success/failure of operation
255 */
256 gboolean
257 lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionOp op) {
258
259 switch(se->field) {
260 /*
261 * string
262 */
263 case LTTV_FILTER_TRACE_NAME:
264 case LTTV_FILTER_TRACEFILE_NAME:
265 case LTTV_FILTER_STATE_P_NAME:
266 case LTTV_FILTER_EVENT_NAME:
267 case LTTV_FILTER_EVENT_FACILITY:
268 case LTTV_FILTER_STATE_EX_MODE:
269 case LTTV_FILTER_STATE_EX_SUBMODE:
270 case LTTV_FILTER_STATE_P_STATUS:
271 switch(op) {
272 case LTTV_FIELD_EQ:
273 se->op = lttv_apply_op_eq_quark;
274 break;
275 case LTTV_FIELD_NE:
276 se->op = lttv_apply_op_ne_quark;
277 break;
278 default:
279 g_warning("Error encountered in operator assignment = or != expected");
280 return FALSE;
281 }
282 break;
283 /*
284 * integer
285 */
286 case LTTV_FILTER_EVENT_TSC:
287 switch(op) {
288 case LTTV_FIELD_EQ:
289 se->op = lttv_apply_op_eq_uint64;
290 break;
291 case LTTV_FIELD_NE:
292 se->op = lttv_apply_op_ne_uint64;
293 break;
294 case LTTV_FIELD_LT:
295 se->op = lttv_apply_op_lt_uint64;
296 break;
297 case LTTV_FIELD_LE:
298 se->op = lttv_apply_op_le_uint64;
299 break;
300 case LTTV_FIELD_GT:
301 se->op = lttv_apply_op_gt_uint64;
302 break;
303 case LTTV_FIELD_GE:
304 se->op = lttv_apply_op_ge_uint64;
305 break;
306 default:
307 g_warning("Error encountered in operator assignment");
308 return FALSE;
309 }
310 break;
311 /*
312 * unsigned integers
313 */
314 case LTTV_FILTER_STATE_CPU:
315 case LTTV_FILTER_STATE_PID:
316 case LTTV_FILTER_STATE_PPID:
317 switch(op) {
318 case LTTV_FIELD_EQ:
319 se->op = lttv_apply_op_eq_uint;
320 break;
321 case LTTV_FIELD_NE:
322 se->op = lttv_apply_op_ne_uint;
323 break;
324 case LTTV_FIELD_LT:
325 se->op = lttv_apply_op_lt_uint;
326 break;
327 case LTTV_FIELD_LE:
328 se->op = lttv_apply_op_le_uint;
329 break;
330 case LTTV_FIELD_GT:
331 se->op = lttv_apply_op_gt_uint;
332 break;
333 case LTTV_FIELD_GE:
334 se->op = lttv_apply_op_ge_uint;
335 break;
336 default:
337 g_warning("Error encountered in operator assignment");
338 return FALSE;
339 }
340 break;
341
342 /*
343 * Enums
344 * Entered as string, converted to enum
345 *
346 * can only be compared with 'equal' or 'not equal' operators
347 *
348 * unsigned int of 16 bits are used here since enums
349 * should not go over 2^16-1 values
350 */
351 // case /*NOTHING*/:
352 // switch(op) {
353 // case LTTV_FIELD_EQ:
354 // se->op = lttv_apply_op_eq_uint16;
355 // break;
356 // case LTTV_FIELD_NE:
357 // se->op = lttv_apply_op_ne_uint16;
358 // break;
359 // default:
360 // g_warning("Error encountered in operator assignment = or != expected");
361 // return FALSE;
362 // }
363 // break;
364 /*
365 * Ltttime
366 */
367 case LTTV_FILTER_STATE_CT:
368 case LTTV_FILTER_STATE_IT:
369 case LTTV_FILTER_EVENT_TIME:
370 switch(op) {
371 case LTTV_FIELD_EQ:
372 se->op = lttv_apply_op_eq_ltttime;
373 break;
374 case LTTV_FIELD_NE:
375 se->op = lttv_apply_op_ne_ltttime;
376 break;
377 case LTTV_FIELD_LT:
378 se->op = lttv_apply_op_lt_ltttime;
379 break;
380 case LTTV_FIELD_LE:
381 se->op = lttv_apply_op_le_ltttime;
382 break;
383 case LTTV_FIELD_GT:
384 se->op = lttv_apply_op_gt_ltttime;
385 break;
386 case LTTV_FIELD_GE:
387 se->op = lttv_apply_op_ge_ltttime;
388 break;
389 default:
390 g_warning("Error encountered in operator assignment");
391 return FALSE;
392 }
393 break;
394 default:
395 g_warning("Error encountered in operator assignation ! Field type:%i",se->field);
396 return FALSE;
397 }
398
399 return TRUE;
400
401 }
402
403 /**
404 * @fn gboolean lttv_simple_expression_assign_value(LttvSimpleExpression*,char*)
405 *
406 * Assign the value field to the current LttvSimpleExpression
407 * @param se pointer to the current LttvSimpleExpression
408 * @param value string value for simple expression
409 */
410 gboolean
411 lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) {
412
413 unsigned i;
414 gboolean is_double = FALSE;
415 LttTime t = ltt_time_zero;
416 GString* v;
417
418 switch(se->field) {
419 /*
420 * Strings
421 * entered as strings, converted to Quarks
422 */
423 case LTTV_FILTER_TRACE_NAME:
424 case LTTV_FILTER_TRACEFILE_NAME:
425 case LTTV_FILTER_STATE_P_NAME:
426 case LTTV_FILTER_EVENT_NAME:
427 case LTTV_FILTER_EVENT_FACILITY:
428 case LTTV_FILTER_STATE_EX_MODE:
429 case LTTV_FILTER_STATE_EX_SUBMODE:
430 case LTTV_FILTER_STATE_P_STATUS:
431 // se->value.v_string = value;
432 se->value.v_uint32 = g_quark_from_string(value);
433 g_free(value);
434 break;
435 /*
436 * integer -- supposed to be uint64
437 */
438 case LTTV_FILTER_EVENT_TSC:
439 se->value.v_uint64 = atoi(value);
440 g_free(value);
441 break;
442 /*
443 * unsigned integers
444 */
445 case LTTV_FILTER_STATE_PID:
446 case LTTV_FILTER_STATE_PPID:
447 case LTTV_FILTER_STATE_CPU:
448 se->value.v_uint = atoi(value);
449 g_free(value);
450 break;
451 /*
452 * LttTime
453 */
454 case LTTV_FILTER_STATE_CT:
455 case LTTV_FILTER_STATE_IT:
456 case LTTV_FILTER_EVENT_TIME:
457 //se->value.v_double = atof(value);
458 /*
459 * parsing logic could be optimised,
460 * but as for now, simpler this way
461 */
462 v = g_string_new("");
463 for(i=0;i<strlen(value);i++) {
464 if(value[i] == '.') {
465 /* cannot specify number with more than one '.' */
466 if(is_double) return FALSE;
467 else is_double = TRUE;
468 t.tv_sec = atoi(v->str);
469 g_string_free(v,TRUE);
470 v = g_string_new("");
471 } else g_string_append_c(v,value[i]);
472 }
473 /* number can be integer or double */
474 if(is_double) t.tv_nsec = atoi(v->str);
475 else t.tv_sec = atoi(v->str);
476
477 g_string_free(v,TRUE);
478
479 se->value.v_ltttime = t;
480 g_free(value);
481 break;
482 default:
483 g_warning("Error encountered in value assignation ! Field type = %i",se->field);
484 g_free(value);
485 return FALSE;
486 }
487
488 return TRUE;
489
490 }
491
492 /**
493 * @fn void lttv_simple_expression_destroy(LttvSimpleExpression*)
494 *
495 * Disallocate memory for the current
496 * simple expression
497 * @param se pointer to the current LttvSimpleExpression
498 */
499 void
500 lttv_simple_expression_destroy(LttvSimpleExpression* se) {
501
502 // g_free(se->value);
503 // switch(se->field) {
504 // case LTTV_FILTER_TRACE_NAME:
505 // case LTTV_FILTER_TRACEFILE_NAME:
506 // case LTTV_FILTER_STATE_P_NAME:
507 // case LTTV_FILTER_EVENT_NAME:
508 // g_free(se->value.v_string);
509 // break;
510 // }
511 g_free(se);
512
513 }
514
515 /**
516 * @fn gint lttv_struct_type(gint)
517 *
518 * Finds the structure type depending
519 * on the fields in parameters
520 * @params ft Field of the current structure
521 * @return LttvStructType enum or -1 for error
522 */
523 gint
524 lttv_struct_type(gint ft) {
525
526 switch(ft) {
527 case LTTV_FILTER_TRACE_NAME:
528 return LTTV_FILTER_TRACE;
529 break;
530 case LTTV_FILTER_TRACEFILE_NAME:
531 return LTTV_FILTER_TRACEFILE;
532 break;
533 case LTTV_FILTER_STATE_PID:
534 case LTTV_FILTER_STATE_PPID:
535 case LTTV_FILTER_STATE_CT:
536 case LTTV_FILTER_STATE_IT:
537 case LTTV_FILTER_STATE_P_NAME:
538 case LTTV_FILTER_STATE_EX_MODE:
539 case LTTV_FILTER_STATE_EX_SUBMODE:
540 case LTTV_FILTER_STATE_P_STATUS:
541 case LTTV_FILTER_STATE_CPU:
542 return LTTV_FILTER_STATE;
543 break;
544 case LTTV_FILTER_EVENT_NAME:
545 case LTTV_FILTER_EVENT_FACILITY:
546 case LTTV_FILTER_EVENT_CATEGORY:
547 case LTTV_FILTER_EVENT_TIME:
548 case LTTV_FILTER_EVENT_TSC:
549 case LTTV_FILTER_EVENT_FIELD:
550 return LTTV_FILTER_EVENT;
551 break;
552 default:
553 return -1;
554 }
555 }
556
557 /**
558 * @fn gboolean lttv_apply_op_eq_uint(gpointer,LttvFieldValue)
559 *
560 * Applies the 'equal' operator to the
561 * specified structure and value
562 * @param v1 left member of comparison
563 * @param v2 right member of comparison
564 * @return success/failure of operation
565 */
566 gboolean lttv_apply_op_eq_uint(const gpointer v1, LttvFieldValue v2) {
567
568 guint* r = (guint*) v1;
569 return (*r == v2.v_uint);
570
571 }
572
573 /**
574 * @fn gboolean lttv_apply_op_eq_uint64(gpointer,LttvFieldValue)
575 *
576 * Applies the 'equal' operator to the
577 * specified structure and value
578 * @param v1 left member of comparison
579 * @param v2 right member of comparison
580 * @return success/failure of operation
581 */
582 gboolean lttv_apply_op_eq_uint64(const gpointer v1, LttvFieldValue v2) {
583
584 guint64* r = (guint64*) v1;
585 return (*r == v2.v_uint64);
586
587 }
588
589 /**
590 * @fn gboolean lttv_apply_op_eq_uint32(gpointer,LttvFieldValue)
591 *
592 * Applies the 'equal' operator to the
593 * specified structure and value
594 * @param v1 left member of comparison
595 * @param v2 right member of comparison
596 * @return success/failure of operation
597 */
598 gboolean lttv_apply_op_eq_uint32(const gpointer v1, LttvFieldValue v2) {
599 guint32* r = (guint32*) v1;
600 return (*r == v2.v_uint32);
601 }
602
603 /**
604 * @fn gboolean lttv_apply_op_eq_uint16(gpointer,LttvFieldValue)
605 *
606 * Applies the 'equal' operator to the
607 * specified structure and value
608 * @param v1 left member of comparison
609 * @param v2 right member of comparison
610 * @return success/failure of operation
611 */
612 gboolean lttv_apply_op_eq_uint16(const gpointer v1, LttvFieldValue v2) {
613 guint16* r = (guint16*) v1;
614 return (*r == v2.v_uint16);
615 }
616
617 /**
618 * @fn gboolean lttv_apply_op_eq_double(gpointer,LttvFieldValue)
619 *
620 * Applies the 'equal' operator to the
621 * specified structure and value
622 * @param v1 left member of comparison
623 * @param v2 right member of comparison
624 * @return success/failure of operation
625 */
626 gboolean lttv_apply_op_eq_double(const gpointer v1, LttvFieldValue v2) {
627 double* r = (double*) v1;
628 return (*r == v2.v_double);
629 }
630
631 /**
632 * @fn gboolean lttv_apply_op_eq_string(gpointer,LttvFieldValue)
633 *
634 * Applies the 'equal' operator to the
635 * specified structure and value
636 * @param v1 left member of comparison
637 * @param v2 right member of comparison
638 * @return success/failure of operation
639 */
640 gboolean lttv_apply_op_eq_string(const gpointer v1, LttvFieldValue v2) {
641 char* r = (char*) v1;
642 return (!g_strcasecmp(r,v2.v_string));
643 }
644
645 /**
646 * @fn gboolean lttv_apply_op_eq_quark(gpointer,LttvFieldValue)
647 *
648 * Applies the 'equal' operator to the
649 * specified structure and value
650 * @param v1 left member of comparison
651 * @param v2 right member of comparison
652 * @return success/failure of operation
653 */
654 gboolean lttv_apply_op_eq_quark(const gpointer v1, LttvFieldValue v2) {
655 GQuark* r = (GQuark*) v1;
656 // g_print("v1:%i v2:%i\n",*r,v2.v_uint32);
657 return (*r == v2.v_uint32);
658 }
659
660 /**
661 * @fn gboolean lttv_apply_op_eq_ltttime(gpointer,LttvFieldValue)
662 *
663 * Applies the 'equal' operator to the
664 * specified structure and value
665 * @param v1 left member of comparison
666 * @param v2 right member of comparison
667 * @return success/failure of operation
668 */
669 gboolean lttv_apply_op_eq_ltttime(const gpointer v1, LttvFieldValue v2) {
670 LttTime* r = (LttTime*) v1;
671 return ltt_time_compare(*r, v2.v_ltttime)==0?1:0;
672 }
673
674 /**
675 * @fn gboolean lttv_apply_op_ne_uint(gpointer,LttvFieldValue)
676 *
677 * Applies the 'not equal' operator to the
678 * specified structure and value
679 * @param v1 left member of comparison
680 * @param v2 right member of comparison
681 * @return success/failure of operation
682 */
683 gboolean lttv_apply_op_ne_uint(const gpointer v1, LttvFieldValue v2) {
684 guint* r = (guint*) v1;
685 return (*r != v2.v_uint);
686 }
687
688 /**
689 * @fn gboolean lttv_apply_op_ne_uint64(gpointer,LttvFieldValue)
690 *
691 * Applies the 'not equal' operator to the
692 * specified structure and value
693 * @param v1 left member of comparison
694 * @param v2 right member of comparison
695 * @return success/failure of operation
696 */
697 gboolean lttv_apply_op_ne_uint64(const gpointer v1, LttvFieldValue v2) {
698 guint64* r = (guint64*) v1;
699 return (*r != v2.v_uint64);
700 }
701
702 /**
703 * @fn gboolean lttv_apply_op_ne_uint32(gpointer,LttvFieldValue)
704 *
705 * Applies the 'not equal' operator to the
706 * specified structure and value
707 * @param v1 left member of comparison
708 * @param v2 right member of comparison
709 * @return success/failure of operation
710 */
711 gboolean lttv_apply_op_ne_uint32(const gpointer v1, LttvFieldValue v2) {
712 guint32* r = (guint32*) v1;
713 return (*r != v2.v_uint32);
714 }
715
716 /**
717 * @fn gboolean lttv_apply_op_ne_uint16(gpointer,LttvFieldValue)
718 *
719 * Applies the 'not equal' operator to the
720 * specified structure and value
721 * @param v1 left member of comparison
722 * @param v2 right member of comparison
723 * @return success/failure of operation
724 */
725 gboolean lttv_apply_op_ne_uint16(const gpointer v1, LttvFieldValue v2) {
726 guint16* r = (guint16*) v1;
727 return (*r != v2.v_uint16);
728 }
729
730 /**
731 * @fn gboolean lttv_apply_op_ne_double(gpointer,LttvFieldValue)
732 *
733 * Applies the 'not equal' operator to the
734 * specified structure and value
735 * @param v1 left member of comparison
736 * @param v2 right member of comparison
737 * @return success/failure of operation
738 */
739 gboolean lttv_apply_op_ne_double(const gpointer v1, LttvFieldValue v2) {
740 double* r = (double*) v1;
741 return (*r != v2.v_double);
742 }
743
744 /**
745 * @fn gboolean lttv_apply_op_ne_string(gpointer,LttvFieldValue)
746 *
747 * Applies the 'not equal' operator to the
748 * specified structure and value
749 * @param v1 left member of comparison
750 * @param v2 right member of comparison
751 * @return success/failure of operation
752 */
753 gboolean lttv_apply_op_ne_string(const gpointer v1, LttvFieldValue v2) {
754 char* r = (char*) v1;
755 return (g_strcasecmp(r,v2.v_string));
756 }
757
758 /**
759 * @fn gboolean lttv_apply_op_ne_quark(gpointer,LttvFieldValue)
760 *
761 * Applies the 'not equal' operator to the
762 * specified structure and value
763 * @param v1 left member of comparison
764 * @param v2 right member of comparison
765 * @return success/failure of operation
766 */
767 gboolean lttv_apply_op_ne_quark(const gpointer v1, LttvFieldValue v2) {
768 GQuark* r = (GQuark*) v1;
769 return (*r != v2.v_uint32);
770 }
771
772
773 /**
774 * @fn gboolean lttv_apply_op_ne_ltttime(gpointer,LttvFieldValue)
775 *
776 * Applies the 'not equal' operator to the
777 * specified structure and value
778 * @param v1 left member of comparison
779 * @param v2 right member of comparison
780 * @return success/failure of operation
781 */
782 gboolean lttv_apply_op_ne_ltttime(const gpointer v1, LttvFieldValue v2) {
783 LttTime* r = (LttTime*) v1;
784 return ltt_time_compare(*r, v2.v_ltttime)!=0?1:0;
785 }
786
787 /**
788 * @fn gboolean lttv_apply_op_lt_uint(gpointer,LttvFieldValue)
789 *
790 * Applies the 'lower than' operator to the
791 * specified structure and value
792 * @param v1 left member of comparison
793 * @param v2 right member of comparison
794 * @return success/failure of operation
795 */
796 gboolean lttv_apply_op_lt_uint(const gpointer v1, LttvFieldValue v2) {
797 guint* r = (guint*) v1;
798 return (*r < v2.v_uint);
799 }
800
801 /**
802 * @fn gboolean lttv_apply_op_lt_uint64(gpointer,LttvFieldValue)
803 *
804 * Applies the 'lower than' operator to the
805 * specified structure and value
806 * @param v1 left member of comparison
807 * @param v2 right member of comparison
808 * @return success/failure of operation
809 */
810 gboolean lttv_apply_op_lt_uint64(const gpointer v1, LttvFieldValue v2) {
811 guint64* r = (guint64*) v1;
812 return (*r < v2.v_uint64);
813 }
814
815 /**
816 * @fn gboolean lttv_apply_op_lt_uint32(gpointer,LttvFieldValue)
817 *
818 * Applies the 'lower than' operator to the
819 * specified structure and value
820 * @param v1 left member of comparison
821 * @param v2 right member of comparison
822 * @return success/failure of operation
823 */
824 gboolean lttv_apply_op_lt_uint32(const gpointer v1, LttvFieldValue v2) {
825 guint32* r = (guint32*) v1;
826 return (*r < v2.v_uint32);
827 }
828
829 /**
830 * @fn gboolean lttv_apply_op_lt_uint16(gpointer,LttvFieldValue)
831 *
832 * Applies the 'lower than' operator to the
833 * specified structure and value
834 * @param v1 left member of comparison
835 * @param v2 right member of comparison
836 * @return success/failure of operation
837 */
838 gboolean lttv_apply_op_lt_uint16(const gpointer v1, LttvFieldValue v2) {
839 guint16* r = (guint16*) v1;
840 return (*r < v2.v_uint16);
841 }
842
843 /**
844 * @fn gboolean lttv_apply_op_lt_double(gpointer,LttvFieldValue)
845 *
846 * Applies the 'lower than' operator to the
847 * specified structure and value
848 * @param v1 left member of comparison
849 * @param v2 right member of comparison
850 * @return success/failure of operation
851 */
852 gboolean lttv_apply_op_lt_double(const gpointer v1, LttvFieldValue v2) {
853 double* r = (double*) v1;
854 return (*r < v2.v_double);
855 }
856
857 /**
858 * @fn gboolean lttv_apply_op_lt_ltttime(gpointer,LttvFieldValue)
859 *
860 * Applies the 'lower than' operator to the
861 * specified structure and value
862 * @param v1 left member of comparison
863 * @param v2 right member of comparison
864 * @return success/failure of operation
865 */
866 gboolean lttv_apply_op_lt_ltttime(const gpointer v1, LttvFieldValue v2) {
867 LttTime* r = (LttTime*) v1;
868 // return ((r->tv_sec < v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec < v2.v_ltttime.tv_nsec)));
869 return ltt_time_compare(*r, v2.v_ltttime)==-1?1:0;
870 }
871
872 /**
873 * @fn gboolean lttv_apply_op_le_uint(gpointer,LttvFieldValue)
874 *
875 * Applies the 'lower or equal' operator to the
876 * specified structure and value
877 * @param v1 left member of comparison
878 * @param v2 right member of comparison
879 * @return success/failure of operation
880 */
881 gboolean lttv_apply_op_le_uint(const gpointer v1, LttvFieldValue v2) {
882 guint* r = (guint*) v1;
883 return (*r <= v2.v_uint);
884 }
885
886 /**
887 * @fn gboolean lttv_apply_op_le_uint64(gpointer,LttvFieldValue)
888 *
889 * Applies the 'lower or equal' operator to the
890 * specified structure and value
891 * @param v1 left member of comparison
892 * @param v2 right member of comparison
893 * @return success/failure of operation
894 */
895 gboolean lttv_apply_op_le_uint64(const gpointer v1, LttvFieldValue v2) {
896 guint64* r = (guint64*) v1;
897 return (*r <= v2.v_uint64);
898 }
899
900 /**
901 * @fn gboolean lttv_apply_op_le_uint32(gpointer,LttvFieldValue)
902 *
903 * Applies the 'lower or equal' operator to the
904 * specified structure and value
905 * @param v1 left member of comparison
906 * @param v2 right member of comparison
907 * @return success/failure of operation
908 */
909 gboolean lttv_apply_op_le_uint32(const gpointer v1, LttvFieldValue v2) {
910 guint32* r = (guint32*) v1;
911 return (*r <= v2.v_uint32);
912 }
913
914 /**
915 * @fn gboolean lttv_apply_op_le_uint16(gpointer,LttvFieldValue)
916 *
917 * Applies the 'lower or equal' operator to the
918 * specified structure and value
919 * @param v1 left member of comparison
920 * @param v2 right member of comparison
921 * @return success/failure of operation
922 */
923 gboolean lttv_apply_op_le_uint16(const gpointer v1, LttvFieldValue v2) {
924 guint16* r = (guint16*) v1;
925 return (*r <= v2.v_uint16);
926 }
927
928 /**
929 * @fn gboolean lttv_apply_op_le_double(gpointer,LttvFieldValue)
930 *
931 * Applies the 'lower or equal' operator to the
932 * specified structure and value
933 * @param v1 left member of comparison
934 * @param v2 right member of comparison
935 * @return success/failure of operation
936 */
937 gboolean lttv_apply_op_le_double(const gpointer v1, LttvFieldValue v2) {
938 double* r = (double*) v1;
939 return (*r <= v2.v_double);
940 }
941
942 /**
943 * @fn gboolean lttv_apply_op_le_ltttime(gpointer,LttvFieldValue)
944 *
945 * Applies the 'lower or equal' operator to the
946 * specified structure and value
947 * @param v1 left member of comparison
948 * @param v2 right member of comparison
949 * @return success/failure of operation
950 */
951 gboolean lttv_apply_op_le_ltttime(const gpointer v1, LttvFieldValue v2) {
952 LttTime* r = (LttTime*) v1;
953 // return ((r->tv_sec < v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec <= v2.v_ltttime.tv_nsec)));
954 return ltt_time_compare(*r, v2.v_ltttime)<1?1:0;
955 }
956
957
958 /**
959 * @fn gboolean lttv_apply_op_gt_uint(gpointer,LttvFieldValue)
960 *
961 * Applies the 'greater than' operator to the
962 * specified structure and value
963 * @param v1 left member of comparison
964 * @param v2 right member of comparison
965 * @return success/failure of operation
966 */
967 gboolean lttv_apply_op_gt_uint(const gpointer v1, LttvFieldValue v2) {
968 guint* r = (guint*) v1;
969 return (*r > v2.v_uint);
970 }
971
972 /**
973 * @fn gboolean lttv_apply_op_gt_uint64(gpointer,LttvFieldValue)
974 *
975 * Applies the 'greater than' operator to the
976 * specified structure and value
977 * @param v1 left member of comparison
978 * @param v2 right member of comparison
979 * @return success/failure of operation
980 */
981 gboolean lttv_apply_op_gt_uint64(const gpointer v1, LttvFieldValue v2) {
982 guint64* r = (guint64*) v1;
983 return (*r > v2.v_uint64);
984 }
985
986 /**
987 * @fn gboolean lttv_apply_op_gt_uint32(gpointer,LttvFieldValue)
988 *
989 * Applies the 'greater than' operator to the
990 * specified structure and value
991 * @param v1 left member of comparison
992 * @param v2 right member of comparison
993 * @return success/failure of operation
994 */
995 gboolean lttv_apply_op_gt_uint32(const gpointer v1, LttvFieldValue v2) {
996 guint32* r = (guint32*) v1;
997 return (*r > v2.v_uint32);
998 }
999
1000 /**
1001 * @fn gboolean lttv_apply_op_gt_uint16(gpointer,LttvFieldValue)
1002 *
1003 * Applies the 'greater than' operator to the
1004 * specified structure and value
1005 * @param v1 left member of comparison
1006 * @param v2 right member of comparison
1007 * @return success/failure of operation
1008 */
1009 gboolean lttv_apply_op_gt_uint16(const gpointer v1, LttvFieldValue v2) {
1010 guint16* r = (guint16*) v1;
1011 return (*r > v2.v_uint16);
1012 }
1013
1014 /**
1015 * @fn gboolean lttv_apply_op_gt_double(gpointer,LttvFieldValue)
1016 *
1017 * Applies the 'greater than' operator to the
1018 * specified structure and value
1019 * @param v1 left member of comparison
1020 * @param v2 right member of comparison
1021 * @return success/failure of operation
1022 */
1023 gboolean lttv_apply_op_gt_double(const gpointer v1, LttvFieldValue v2) {
1024 double* r = (double*) v1;
1025 return (*r > v2.v_double);
1026 }
1027
1028 /**
1029 * @fn gboolean lttv_apply_op_gt_ltttime(gpointer,LttvFieldValue)
1030 *
1031 * Applies the 'greater than' operator to the
1032 * specified structure and value
1033 * @param v1 left member of comparison
1034 * @param v2 right member of comparison
1035 * @return success/failure of operation
1036 */
1037 gboolean lttv_apply_op_gt_ltttime(const gpointer v1, LttvFieldValue v2) {
1038 LttTime* r = (LttTime*) v1;
1039 // return ((r->tv_sec > v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec > v2.v_ltttime.tv_nsec)));
1040 return ltt_time_compare(*r, v2.v_ltttime)==1?1:0;
1041 }
1042
1043 /**
1044 * @fn gboolean lttv_apply_op_ge_uint(gpointer,LttvFieldValue)
1045 *
1046 * Applies the 'greater or equal' operator to the
1047 * specified structure and value
1048 * @param v1 left member of comparison
1049 * @param v2 right member of comparison
1050 * @return success/failure of operation
1051 */
1052 gboolean lttv_apply_op_ge_uint(const gpointer v1, LttvFieldValue v2) {
1053 guint* r = (guint*) v1;
1054 return (*r >= v2.v_uint);
1055 }
1056
1057 /**
1058 * @fn gboolean lttv_apply_op_ge_uint64(gpointer,LttvFieldValue)
1059 *
1060 * Applies the 'greater or equal' operator to the
1061 * specified structure and value
1062 * @param v1 left member of comparison
1063 * @param v2 right member of comparison
1064 * @return success/failure of operation
1065 */
1066 gboolean lttv_apply_op_ge_uint64(const gpointer v1, LttvFieldValue v2) {
1067 guint64* r = (guint64*) v1;
1068 return (*r >= v2.v_uint64);
1069 }
1070
1071 /**
1072 * @fn gboolean lttv_apply_op_ge_uint32(gpointer,LttvFieldValue)
1073 *
1074 * Applies the 'greater or equal' operator to the
1075 * specified structure and value
1076 * @param v1 left member of comparison
1077 * @param v2 right member of comparison
1078 * @return success/failure of operation
1079 */
1080 gboolean lttv_apply_op_ge_uint32(const gpointer v1, LttvFieldValue v2) {
1081 guint32* r = (guint32*) v1;
1082 return (*r >= v2.v_uint32);
1083 }
1084
1085 /**
1086 * @fn gboolean lttv_apply_op_ge_uint16(gpointer,LttvFieldValue)
1087 *
1088 * Applies the 'greater or equal' operator to the
1089 * specified structure and value
1090 * @param v1 left member of comparison
1091 * @param v2 right member of comparison
1092 * @return success/failure of operation
1093 */
1094 gboolean lttv_apply_op_ge_uint16(const gpointer v1, LttvFieldValue v2) {
1095 guint16* r = (guint16*) v1;
1096 return (*r >= v2.v_uint16);
1097 }
1098
1099 /**
1100 * @fn gboolean lttv_apply_op_ge_double(gpointer,LttvFieldValue)
1101 *
1102 * Applies the 'greater or equal' operator to the
1103 * specified structure and value
1104 * @param v1 left member of comparison
1105 * @param v2 right member of comparison
1106 * @return success/failure of operation
1107 */
1108 gboolean lttv_apply_op_ge_double(const gpointer v1, LttvFieldValue v2) {
1109 double* r = (double*) v1;
1110 return (*r >= v2.v_double);
1111 }
1112
1113 /**
1114 * @fn gboolean lttv_apply_op_ge_ltttime(gpointer,LttvFieldValue)
1115 *
1116 * Applies the 'greater or equal' operator to the
1117 * specified structure and value
1118 * @param v1 left member of comparison
1119 * @param v2 right member of comparison
1120 * @return success/failure of operation
1121 */
1122 gboolean lttv_apply_op_ge_ltttime(const gpointer v1, LttvFieldValue v2) {
1123 LttTime* r = (LttTime*) v1;
1124 // return ((r->tv_sec > v2.v_ltttime.tv_sec) || ((r->tv_sec == v2.v_ltttime.tv_sec) && (r->tv_nsec >= v2.v_ltttime.tv_nsec)));
1125 return ltt_time_compare(*r, v2.v_ltttime)>-1?1:0;
1126 }
1127
1128
1129
1130 /**
1131 * Makes a copy of the current filter tree
1132 * @param tree pointer to the current tree
1133 * @return new copy of the filter tree
1134 */
1135 LttvFilterTree*
1136 lttv_filter_tree_clone(const LttvFilterTree* tree) {
1137
1138 LttvFilterTree* newtree = lttv_filter_tree_new();
1139
1140 newtree->node = tree->node;
1141
1142 newtree->left = tree->left;
1143 if(newtree->left == LTTV_TREE_NODE) {
1144 newtree->l_child.t = lttv_filter_tree_clone(tree->l_child.t);
1145 } else if(newtree->left == LTTV_TREE_LEAF) {
1146 newtree->l_child.leaf = lttv_simple_expression_new();
1147 newtree->l_child.leaf->field = tree->l_child.leaf->field;
1148 newtree->l_child.leaf->offset = tree->l_child.leaf->offset;
1149 newtree->l_child.leaf->op = tree->l_child.leaf->op;
1150 /* FIXME: special case for string copy ! */
1151 newtree->l_child.leaf->value = tree->l_child.leaf->value;
1152 }
1153
1154 newtree->right = tree->right;
1155 if(newtree->right == LTTV_TREE_NODE) {
1156 newtree->r_child.t = lttv_filter_tree_clone(tree->r_child.t);
1157 } else if(newtree->right == LTTV_TREE_LEAF) {
1158 newtree->r_child.leaf = lttv_simple_expression_new();
1159 newtree->r_child.leaf->field = tree->r_child.leaf->field;
1160 newtree->r_child.leaf->offset = tree->r_child.leaf->offset;
1161 newtree->r_child.leaf->op = tree->r_child.leaf->op;
1162 newtree->r_child.leaf->value = tree->r_child.leaf->value;
1163 }
1164
1165 return newtree;
1166
1167 }
1168
1169 /**
1170 * Makes a copy of the current filter
1171 * @param filter pointer to the current filter
1172 * @return new copy of the filter
1173 */
1174 LttvFilter*
1175 lttv_filter_clone(const LttvFilter* filter) {
1176
1177 if(!filter) return NULL;
1178
1179 LttvFilter* newfilter = g_new(LttvFilter,1);
1180
1181 strcpy(newfilter->expression,filter->expression);
1182
1183 newfilter->head = lttv_filter_tree_clone(filter->head);
1184
1185 return newfilter;
1186
1187 }
1188
1189
1190 /**
1191 * @fn LttvFilter* lttv_filter_new()
1192 *
1193 * Creates a new LttvFilter
1194 * @return the current LttvFilter or NULL if error
1195 */
1196 LttvFilter*
1197 lttv_filter_new() {
1198
1199 LttvFilter* filter = g_new(LttvFilter,1);
1200 filter->expression = NULL;
1201 filter->head = NULL;
1202
1203 return filter;
1204
1205 }
1206
1207 /**
1208 * @fn gboolean lttv_filter_update(LttvFilter*)
1209 *
1210 * Updates the current LttvFilter by building
1211 * its tree based upon the expression string
1212 * @param filter pointer to the current LttvFilter
1213 * @return Failure/Success of operation
1214 */
1215 gboolean
1216 lttv_filter_update(LttvFilter* filter) {
1217
1218 // g_print("filter::lttv_filter_new()\n"); /* debug */
1219
1220 if(filter->expression == NULL) return FALSE;
1221
1222 int
1223 i,
1224 p_nesting=0, /* parenthesis nesting value */
1225 not=0;
1226
1227 /* trees */
1228 LttvFilterTree
1229 *tree = lttv_filter_tree_new(), /* main tree */
1230 *subtree = NULL, /* buffer for subtrees */
1231 *t1, /* buffer #1 */
1232 *t2, /* buffer #2 */
1233 *t3; /* buffer #3 */
1234
1235 /*
1236 * the filter
1237 * If the tree already exists,
1238 * destroy it and build a new one
1239 */
1240 if(filter->head != NULL) lttv_filter_tree_destroy(filter->head);
1241 filter->head = NULL; /* will be assigned at the end */
1242
1243 /*
1244 * Tree Stack
1245 * each element of the list
1246 * is a sub tree created
1247 * by the use of parenthesis in the
1248 * global expression. The final tree
1249 * will be the one left at the root of
1250 * the list
1251 */
1252 GPtrArray *tree_stack = g_ptr_array_new();
1253 g_ptr_array_add( tree_stack,(gpointer) tree );
1254
1255 /* temporary values */
1256 GString *a_field_component = g_string_new("");
1257 GPtrArray *a_field_path = g_ptr_array_new();
1258
1259 /* simple expression buffer */
1260 LttvSimpleExpression* a_simple_expression = lttv_simple_expression_new();
1261
1262 /*
1263 * Parse entire expression and construct
1264 * the binary tree. There are two steps
1265 * in browsing that string
1266 * 1. finding boolean ops " &,|,^,! " and parenthesis " {,(,[,],),} "
1267 * 2. finding simple expressions
1268 * - field path ( separated by dots )
1269 * - op ( >, <, =, >=, <=, !=)
1270 * - value ( integer, string ... )
1271 * To spare computing time, the whole
1272 * string is parsed in this loop for a
1273 * O(n) complexity order.
1274 *
1275 * When encountering logical op &,|,^
1276 * 1. parse the last value if any
1277 * 2. create a new tree
1278 * 3. add the expression (simple exp, or exp (subtree)) to the tree
1279 * 4. concatenate this tree with the current tree on top of the stack
1280 * When encountering math ops >,>=,<,<=,=,!=
1281 * 1. add to op to the simple expression
1282 * 2. concatenate last field component to field path
1283 * When encountering concatening ops .
1284 * 1. concatenate last field component to field path
1285 * When encountering opening parenthesis (,{,[
1286 * 1. create a new subtree on top of tree stack
1287 * When encountering closing parenthesis ),},]
1288 * 1. add the expression on right child of the current tree
1289 * 2. the subtree is completed, allocate a new subtree
1290 * 3. pop the tree value from the tree stack
1291 */
1292
1293 #ifdef TEST
1294 struct timeval starttime;
1295 struct timeval endtime;
1296 gettimeofday(&starttime, NULL);
1297 #endif
1298
1299 for(i=0;i<strlen(filter->expression);i++) {
1300 // debug
1301 // g_print("%c\n ",filter->expression[i]);
1302
1303 switch(filter->expression[i]) {
1304 /*
1305 * logical operators
1306 */
1307 case '&': /* and */
1308
1309 /* get current tree in tree stack */
1310 t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
1311
1312 /* get current node at absolute right */
1313 while(t1->right != LTTV_TREE_IDLE) {
1314 g_assert(t1->right == LTTV_TREE_NODE);
1315 t1 = t1->r_child.t;
1316 }
1317 t2 = lttv_filter_tree_new();
1318 t2->node = LTTV_LOGICAL_AND;
1319 t1->right = LTTV_TREE_NODE;
1320 t1->r_child.t = t2;
1321 if(not) { /* add not operator to tree */
1322 t3 = lttv_filter_tree_new();
1323 t3->node = LTTV_LOGICAL_NOT;
1324 t2->left = LTTV_TREE_NODE;
1325 t2->l_child.t = t3;
1326 t2 = t3;
1327 not = 0;
1328 }
1329 if(subtree != NULL) { /* append subtree to current tree */
1330 t2->left = LTTV_TREE_NODE;
1331 t2->l_child.t = subtree;
1332 subtree = NULL;
1333 } else { /* append a simple expression */
1334 lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
1335 a_field_component = g_string_new("");
1336 t2->left = LTTV_TREE_LEAF;
1337 t2->l_child.leaf = a_simple_expression;
1338 a_simple_expression = lttv_simple_expression_new();
1339 }
1340 break;
1341
1342 case '|': /* or */
1343
1344 t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
1345 while(t1->right != LTTV_TREE_IDLE) {
1346 g_assert(t1->right == LTTV_TREE_NODE);
1347 t1 = t1->r_child.t;
1348 }
1349 t2 = lttv_filter_tree_new();
1350 t2->node = LTTV_LOGICAL_OR;
1351 t1->right = LTTV_TREE_NODE;
1352 t1->r_child.t = t2;
1353 if(not) { // add not operator to tree
1354 t3 = lttv_filter_tree_new();
1355 t3->node = LTTV_LOGICAL_NOT;
1356 t2->left = LTTV_TREE_NODE;
1357 t2->l_child.t = t3;
1358 t2 = t3;
1359 not = 0;
1360 }
1361 if(subtree != NULL) { /* append subtree to current tree */
1362 t2->left = LTTV_TREE_NODE;
1363 t2->l_child.t = subtree;
1364 subtree = NULL;
1365 } else { /* append a simple expression */
1366 lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
1367 a_field_component = g_string_new("");
1368 t2->left = LTTV_TREE_LEAF;
1369 t2->l_child.leaf = a_simple_expression;
1370 a_simple_expression = lttv_simple_expression_new();
1371 }
1372 break;
1373
1374 case '^': /* xor */
1375
1376 t1 = (LttvFilterTree*)g_ptr_array_index(tree_stack,tree_stack->len-1);
1377 while(t1->right != LTTV_TREE_IDLE) {
1378 g_assert(t1->right == LTTV_TREE_NODE);
1379 t1 = t1->r_child.t;
1380 }
1381 t2 = lttv_filter_tree_new();
1382 t2->node = LTTV_LOGICAL_XOR;
1383 t1->right = LTTV_TREE_NODE;
1384 t1->r_child.t = t2;
1385 if(not) { // add not operator to tree
1386 t3 = lttv_filter_tree_new();
1387 t3->node = LTTV_LOGICAL_NOT;
1388 t2->left = LTTV_TREE_NODE;
1389 t2->l_child.t = t3;
1390 t2 = t3;
1391 not = 0;
1392 }
1393 if(subtree != NULL) { /* append subtree to current tree */
1394 t2->left = LTTV_TREE_NODE;
1395 t2->l_child.t = subtree;
1396 subtree = NULL;
1397 } else { /* append a simple expression */
1398 lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
1399 a_field_component = g_string_new("");
1400 t2->left = LTTV_TREE_LEAF;
1401 t2->l_child.leaf = a_simple_expression;
1402 a_simple_expression = lttv_simple_expression_new();
1403 }
1404 break;
1405
1406 case '!': /* not, or not equal (math op) */
1407
1408 if(filter->expression[i+1] == '=') { /* != */
1409 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
1410 lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
1411 a_field_component = g_string_new("");
1412 lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_NE);
1413 i++;
1414 } else { /* ! */
1415 not=1;
1416 }
1417 break;
1418
1419 case '(': /* start of parenthesis */
1420 case '[':
1421 case '{':
1422
1423 p_nesting++; /* incrementing parenthesis nesting value */
1424 t1 = lttv_filter_tree_new();
1425 if(not) { /* add not operator to tree */
1426 t3 = lttv_filter_tree_new();
1427 t3->node = LTTV_LOGICAL_NOT;
1428 t1->right = LTTV_TREE_NODE;
1429 t1->r_child.t = t3;
1430 not = 0;
1431 }
1432 g_ptr_array_add( tree_stack,(gpointer) t1 );
1433 break;
1434
1435 case ')': /* end of parenthesis */
1436 case ']':
1437 case '}':
1438
1439 p_nesting--; /* decrementing parenthesis nesting value */
1440 if(p_nesting<0 || tree_stack->len<2) {
1441 g_warning("Wrong filtering options, the string\n\"%s\"\n\
1442 is not valid due to parenthesis incorrect use",filter->expression);
1443 return FALSE;
1444 }
1445
1446 /* there must at least be the root tree left in the array */
1447 g_assert(tree_stack->len>0);
1448
1449 t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
1450 while(t1->right != LTTV_TREE_IDLE) {
1451 t1 = t1->r_child.t;
1452 }
1453 if(not) { // add not operator to tree
1454 g_print("ici");
1455 t3 = lttv_filter_tree_new();
1456 t3->node = LTTV_LOGICAL_NOT;
1457 t1->right = LTTV_TREE_NODE;
1458 t1->r_child.t = t3;
1459 t1 = t3;
1460 not = 0;
1461 }
1462 if(subtree != NULL) { /* append subtree to current tree */
1463 t1->right = LTTV_TREE_NODE;
1464 t1->r_child.t = subtree;
1465 subtree = g_ptr_array_index(tree_stack,tree_stack->len-1);
1466 g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
1467 } else { /* assign subtree as current tree */
1468 lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
1469 a_field_component = g_string_new("");
1470 t1->right = LTTV_TREE_LEAF;
1471 t1->r_child.leaf = a_simple_expression;
1472 a_simple_expression = lttv_simple_expression_new();
1473 subtree = g_ptr_array_remove_index(tree_stack,tree_stack->len-1);
1474 }
1475 break;
1476
1477 /*
1478 * mathematic operators
1479 */
1480 case '<': /* lower, lower or equal */
1481
1482 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
1483 lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
1484 a_field_component = g_string_new("");
1485 if(filter->expression[i+1] == '=') { /* <= */
1486 i++;
1487 lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_LE);
1488 } else lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_LT);
1489 break;
1490
1491 case '>': /* higher, higher or equal */
1492
1493 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
1494 lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
1495 a_field_component = g_string_new("");
1496 if(filter->expression[i+1] == '=') { /* >= */
1497 i++;
1498 lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_GE);
1499 } else lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_GT);
1500 break;
1501
1502 case '=': /* equal */
1503
1504 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
1505 lttv_simple_expression_assign_field(a_field_path,a_simple_expression);
1506 a_field_component = g_string_new("");
1507 lttv_simple_expression_assign_operator(a_simple_expression,LTTV_FIELD_EQ);
1508 break;
1509
1510 /*
1511 * Field concatening caracter
1512 */
1513 case '.': /* dot */
1514
1515 /*
1516 * divide field expression into elements
1517 * in a_field_path array.
1518 *
1519 * A dot can also be present in double values
1520 */
1521 if(a_simple_expression->field == LTTV_FILTER_UNDEFINED) {
1522 g_ptr_array_add( a_field_path,(gpointer) a_field_component );
1523 a_field_component = g_string_new("");
1524 }
1525 break;
1526 case ' ': /* ignore */
1527 case '\n': /* ignore */
1528 break;
1529 default: /* concatening current string */
1530 g_string_append_c(a_field_component,filter->expression[i]);
1531 }
1532 }
1533
1534 /*
1535 * Preliminary check to see
1536 * if tree was constructed correctly
1537 */
1538 if( p_nesting>0 ) {
1539 g_warning("Wrong filtering options, the string\n\"%s\"\n\
1540 is not valid due to parenthesis incorrect use",filter->expression);
1541 return FALSE;
1542 }
1543
1544 if(tree_stack->len != 1) /* only root tree should remain */
1545 return FALSE;
1546
1547 /*
1548 * processing last element of expression
1549 */
1550 t1 = g_ptr_array_index(tree_stack,tree_stack->len-1);
1551 while(t1->right != LTTV_TREE_IDLE) {
1552 g_assert(t1->right == LTTV_TREE_NODE);
1553 t1 = t1->r_child.t;
1554 }
1555 if(not) { // add not operator to tree
1556 t3 = lttv_filter_tree_new();
1557 t3->node = LTTV_LOGICAL_NOT;
1558 t1->right = LTTV_TREE_NODE;
1559 t1->r_child.t = t3;
1560 t1 = t3;
1561 not = 0;
1562 }
1563 if(subtree != NULL) { /* add the subtree */
1564 t1->right = LTTV_TREE_NODE;
1565 t1->r_child.t = subtree;
1566 subtree = NULL;
1567 } else { /* add a leaf */
1568 lttv_simple_expression_assign_value(a_simple_expression,g_string_free(a_field_component,FALSE));
1569 a_field_component = NULL;
1570 t1->right = LTTV_TREE_LEAF;
1571 t1->r_child.leaf = a_simple_expression;
1572 a_simple_expression = NULL;
1573 }
1574
1575
1576 /* free the pointer array */
1577 g_assert(a_field_path->len == 0);
1578 g_ptr_array_free(a_field_path,TRUE);
1579
1580 /* free the tree stack -- but keep the root tree */
1581 filter->head = g_ptr_array_remove_index(tree_stack,0);
1582 g_ptr_array_free(tree_stack,TRUE);
1583
1584 /* free the field buffer if allocated */
1585 if(a_field_component != NULL) g_string_free(a_field_component,TRUE);
1586
1587 /* free the simple expression buffer if allocated */
1588 if(a_simple_expression != NULL) lttv_simple_expression_destroy(a_simple_expression);
1589
1590 g_assert(filter->head != NULL); /* tree should exist */
1591 g_assert(subtree == NULL); /* remaining subtree should be included in main tree */
1592
1593 #ifdef TEST
1594 gettimeofday(&endtime, NULL);
1595
1596 /* Calcul du temps de l'algorithme */
1597 double time1 = starttime.tv_sec + (starttime.tv_usec/1000000.0);
1598 double time2 = endtime.tv_sec + (endtime.tv_usec/1000000.0);
1599 // g_print("Tree build took %.10f ms for strlen of %i\n",(time2-time1)*1000,strlen(filter->expression));
1600 g_print("%.10f %i\n",(time2-time1)*1000,strlen(filter->expression));
1601 #endif
1602
1603 /* debug */
1604 g_debug("+++++++++++++++ BEGIN PRINT ++++++++++++++++\n");
1605 lttv_print_tree(filter->head,0) ;
1606 g_debug("+++++++++++++++ END PRINT ++++++++++++++++++\n");
1607
1608 /* success */
1609 return TRUE;
1610
1611 }
1612
1613 /**
1614 * @fn void lttv_filter_destroy(LttvFilter*)
1615 *
1616 * Destroy the current LttvFilter
1617 * @param filter pointer to the current LttvFilter
1618 */
1619 void
1620 lttv_filter_destroy(LttvFilter* filter) {
1621
1622 if(!filter) return;
1623
1624 if(filter->expression)
1625 g_free(filter->expression);
1626 if(filter->head)
1627 lttv_filter_tree_destroy(filter->head);
1628 g_free(filter);
1629
1630 }
1631
1632 /**
1633 * @fn LttvFilterTree* lttv_filter_tree_new()
1634 *
1635 * Assign a new tree for the current expression
1636 * or sub expression
1637 * @return pointer of LttvFilterTree
1638 */
1639 LttvFilterTree*
1640 lttv_filter_tree_new() {
1641 LttvFilterTree* tree;
1642
1643 tree = g_new(LttvFilterTree,1);
1644 tree->node = 0; //g_new(lttv_expression,1);
1645 tree->left = LTTV_TREE_IDLE;
1646 tree->right = LTTV_TREE_IDLE;
1647 tree->r_child.t = NULL;
1648 tree->l_child.t = NULL;
1649
1650 return tree;
1651 }
1652
1653 /**
1654 * @fn void lttv_filter_append_expression(LttvFilter*,char*)
1655 *
1656 * Append a new expression to the expression
1657 * defined in the current filter
1658 * @param filter pointer to the current LttvFilter
1659 * @param expression string that must be appended
1660 * @return Success/Failure of operation
1661 */
1662 gboolean
1663 lttv_filter_append_expression(LttvFilter* filter, const char *expression) {
1664
1665 if(expression == NULL) return FALSE;
1666 if(filter == NULL) return FALSE;
1667 if(expression[0] == '\0') return FALSE; /* Empty expression */
1668
1669 GString* s = g_string_new("");
1670 if(filter->expression != NULL) {
1671 g_string_append(s,filter->expression);
1672 g_string_append_c(s,'&');
1673 }
1674 g_string_append(s,expression);
1675
1676 g_free(filter->expression);
1677 filter->expression = g_string_free(s,FALSE);
1678
1679 /* TRUE if construction of tree proceeded without errors */
1680 return lttv_filter_update(filter);
1681
1682 }
1683
1684 /**
1685 * @fn void lttv_filter_clear_expression(LttvFilter*)
1686 *
1687 * Clear the filter expression from the
1688 * current filter and sets its pointer to NULL
1689 * @param filter pointer to the current LttvFilter
1690 */
1691 void
1692 lttv_filter_clear_expression(LttvFilter* filter) {
1693
1694 if(filter->expression != NULL) {
1695 g_free(filter->expression);
1696 filter->expression = NULL;
1697 }
1698
1699 }
1700
1701 /**
1702 * @fn void lttv_filter_tree_destroy(LttvFilterTree*)
1703 *
1704 * Destroys the tree and his sub-trees
1705 * @param tree Tree which must be destroyed
1706 */
1707 void
1708 lttv_filter_tree_destroy(LttvFilterTree* tree) {
1709
1710 if(tree == NULL) return;
1711
1712 if(tree->left == LTTV_TREE_LEAF) lttv_simple_expression_destroy(tree->l_child.leaf);
1713 else if(tree->left == LTTV_TREE_NODE) lttv_filter_tree_destroy(tree->l_child.t);
1714
1715 if(tree->right == LTTV_TREE_LEAF) lttv_simple_expression_destroy(tree->r_child.leaf);
1716 else if(tree->right == LTTV_TREE_NODE) lttv_filter_tree_destroy(tree->r_child.t);
1717
1718 // g_free(tree->node);
1719 g_free(tree);
1720 }
1721
1722 /**
1723 * Global parsing function for the current
1724 * LttvFilterTree
1725 * @param t pointer to the current LttvFilterTree
1726 * @param event current LttEvent, NULL if not used
1727 * @param tracefile current LttTracefile, NULL if not used
1728 * @param trace current LttTrace, NULL if not used
1729 * @param state current LttvProcessState, NULL if not used
1730 * @param context current LttvTracefileContext, NULL if not used
1731 * @return response of filter
1732 */
1733 gboolean
1734 lttv_filter_tree_parse(
1735 const LttvFilterTree* t,
1736 const LttEvent* event,
1737 const LttTracefile* tracefile,
1738 const LttTrace* trace,
1739 const LttvTracefileContext* context
1740 /*,...*/)
1741 {
1742
1743 /*
1744 * Each tree is parsed in inorder.
1745 * This way, it's possible to apply the left filter of the
1746 * tree, then decide whether or not the right branch should
1747 * be parsed depending on the linking logical operator
1748 *
1749 * Each node consists in a
1750 * 1. logical operator
1751 * 2. left child ( node or simple expression )
1752 * 3. right child ( node or simple expression )
1753 *
1754 * When the child is a simple expression, we must
1755 * before all determine if the expression refers to
1756 * a structure which is whithin observation ( not NULL ).
1757 * -If so, the expression is evaluated.
1758 * -If not, the result is set to TRUE since this particular
1759 * operation does not interfere with the lttv structure
1760 *
1761 * The result of each simple expression will directly
1762 * affect the next branch. This way, depending on
1763 * the linking logical operator, the parser will decide
1764 * to explore or not the next branch.
1765 * 1. AND OPERATOR
1766 * -If result of left branch is 0 / FALSE
1767 * then don't explore right branch and return 0;
1768 * -If result of left branch is 1 / TRUE then explore
1769 * 2. OR OPERATOR
1770 * -If result of left branch is 1 / TRUE
1771 * then don't explore right branch and return 1;
1772 * -If result of left branch is 0 / FALSE then explore
1773 * 3. XOR OPERATOR
1774 * -Result of left branch will not affect exploration of
1775 * right branch
1776 */
1777
1778 gboolean lresult = FALSE, rresult = FALSE;
1779
1780 LttvProcessState* state;
1781
1782 guint cpu = ltt_tracefile_num(context->tf);
1783 LttvTraceState *ts = (LttvTraceState*)context->t_context;
1784 state = ts->running_process[cpu];
1785
1786 /*
1787 * Parse left branch
1788 */
1789 if(t->left == LTTV_TREE_NODE) {
1790 lresult = lttv_filter_tree_parse(t->l_child.t,event,tracefile,trace,context);
1791 }
1792 else if(t->left == LTTV_TREE_LEAF) {
1793 lresult = lttv_filter_tree_parse_branch(t->l_child.leaf,event,tracefile,trace,state,context);
1794 }
1795
1796 /*
1797 * Parse linking operator
1798 * make a cutoff if possible
1799 */
1800 if((t->node & LTTV_LOGICAL_OR) && lresult == TRUE) return TRUE;
1801 if((t->node & LTTV_LOGICAL_AND) && lresult == FALSE) return FALSE;
1802
1803 /*
1804 * Parse right branch
1805 */
1806 if(t->right == LTTV_TREE_NODE) {
1807 rresult = lttv_filter_tree_parse(t->r_child.t,event,tracefile,trace,context);
1808 }
1809 else if(t->right == LTTV_TREE_LEAF) {
1810 rresult = lttv_filter_tree_parse_branch(t->r_child.leaf,event,tracefile,trace,state,context);
1811 }
1812
1813
1814 /*
1815 * Apply and return the
1816 * logical link between the
1817 * two operation
1818 */
1819 switch(t->node) {
1820 case LTTV_LOGICAL_OR: return (lresult | rresult);
1821 case LTTV_LOGICAL_AND: return (lresult & rresult);
1822 case LTTV_LOGICAL_NOT:
1823 return (t->left==LTTV_TREE_LEAF)?!lresult:((t->right==LTTV_TREE_LEAF)?!rresult:TRUE);
1824 case LTTV_LOGICAL_XOR: return (lresult ^ rresult);
1825 case 0: return (rresult);
1826 default:
1827 /*
1828 * This case should never be
1829 * parsed, if so, this subtree
1830 * is cancelled !
1831 */
1832 return TRUE;
1833 }
1834
1835 }
1836
1837 /**
1838 * This function parses a particular branch of the tree
1839 * @param se pointer to the current LttvSimpleExpression
1840 * @param event current LttEvent, NULL if not used
1841 * @param tracefile current LttTracefile, NULL if not used
1842 * @param trace current LttTrace, NULL if not used
1843 * @param state current LttvProcessState, NULL if not used
1844 * @param context current LttvTracefileContext, NULL if not used
1845 * @return response of filter
1846 */
1847 gboolean
1848 lttv_filter_tree_parse_branch(
1849 const LttvSimpleExpression* se,
1850 const LttEvent* event,
1851 const LttTracefile* tracefile,
1852 const LttTrace* trace,
1853 const LttvProcessState* state,
1854 const LttvTracefileContext* context) {
1855
1856 LttvFieldValue v;
1857 v = se->value;
1858 switch(se->field) {
1859 case LTTV_FILTER_TRACE_NAME:
1860 if(trace == NULL) return TRUE;
1861 else {
1862 GQuark quark = ltt_trace_name(trace);
1863 return se->op((gpointer)&quark,v);
1864 }
1865 break;
1866 case LTTV_FILTER_TRACEFILE_NAME:
1867 if(tracefile == NULL) return TRUE;
1868 else {
1869 GQuark quark = ltt_tracefile_name(tracefile);
1870 return se->op((gpointer)&quark,v);
1871 }
1872 break;
1873 case LTTV_FILTER_STATE_PID:
1874 if(state == NULL) return TRUE;
1875 else return se->op((gpointer)&state->pid,v);
1876 break;
1877 case LTTV_FILTER_STATE_PPID:
1878 if(state == NULL) return TRUE;
1879 else return se->op((gpointer)&state->ppid,v);
1880 break;
1881 case LTTV_FILTER_STATE_CT:
1882 if(state == NULL) return TRUE;
1883 else {
1884 return se->op((gpointer)&state->creation_time,v);
1885 }
1886 break;
1887 case LTTV_FILTER_STATE_IT:
1888 if(state == NULL) return TRUE;
1889 else {
1890 return se->op((gpointer)&state->insertion_time,v);
1891 }
1892 break;
1893 case LTTV_FILTER_STATE_P_NAME:
1894 /*
1895 * All 'unnamed' for the moment
1896 */
1897 if(state == NULL) return TRUE;
1898 else {
1899 GQuark quark = state->name;
1900 return se->op((gpointer)&quark,v);
1901 }
1902 break;
1903 case LTTV_FILTER_STATE_EX_MODE:
1904 if(state == NULL) return TRUE;
1905 else return se->op((gpointer)&state->state->t,v);
1906 break;
1907 case LTTV_FILTER_STATE_EX_SUBMODE:
1908 if(state == NULL) return TRUE;
1909 else return se->op((gpointer)&state->state->n,v);
1910 break;
1911 case LTTV_FILTER_STATE_P_STATUS:
1912 if(state == NULL) return TRUE;
1913 else return se->op((gpointer)&state->state->s,v);
1914 break;
1915 case LTTV_FILTER_STATE_CPU:
1916 if(context == NULL) return TRUE;
1917 else {
1918 /* FIXME: not sure of that one Mathieu : fixed.*/
1919 // GQuark quark = ((LttvTracefileState*)context)->cpu_name;
1920 // return se->op((gpointer)&quark,v);
1921 if(state == NULL) return TRUE;
1922 else return se->op((gpointer)&state->cpu,v);
1923 }
1924 break;
1925 case LTTV_FILTER_EVENT_NAME:
1926 if(event == NULL) return TRUE;
1927 else {
1928 LttEventType* et;
1929 et = ltt_event_eventtype(event);
1930 GQuark quark = ltt_eventtype_name(et);
1931 return se->op((gpointer)&quark,v);
1932 }
1933 break;
1934 case LTTV_FILTER_EVENT_FACILITY:
1935 if(event == NULL) return TRUE;
1936 else {
1937 LttFacility* fac;
1938 fac = ltt_event_facility(event);
1939 GQuark quark = ltt_facility_name(fac);
1940 return se->op((gpointer)&quark,v);
1941 }
1942 break;
1943 case LTTV_FILTER_EVENT_CATEGORY:
1944 /*
1945 * TODO: Not yet implemented
1946 */
1947 return TRUE;
1948 break;
1949 case LTTV_FILTER_EVENT_TIME:
1950 if(event == NULL) return TRUE;
1951 else {
1952 LttTime time = ltt_event_time(event);
1953 return se->op((gpointer)&time,v);
1954 }
1955 break;
1956 case LTTV_FILTER_EVENT_TSC:
1957 if(event == NULL) return TRUE;
1958 else {
1959 LttCycleCount count = ltt_event_cycle_count(event);
1960 return se->op((gpointer)&count,v);
1961 }
1962 break;
1963 case LTTV_FILTER_EVENT_FIELD:
1964 /*
1965 * TODO: Use the offset to
1966 * find the dynamic field
1967 * in the event struct
1968 */
1969 return TRUE;
1970 default:
1971 /*
1972 * This case should never be
1973 * parsed, if so, the whole
1974 * filtering is cancelled
1975 */
1976 g_warning("Error while parsing the filter tree");
1977 return TRUE;
1978 }
1979
1980 /* should never get here */
1981 return TRUE;
1982
1983 }
1984
1985
1986
1987 /**
1988 * Debug function. Prints tree memory allocation.
1989 * @param t the pointer to the current LttvFilterTree
1990 */
1991 void
1992 lttv_print_tree(const LttvFilterTree* t, const int count) {
1993
1994 g_debug("node:%p lchild:%p rchild:%p depth:%i\n",t, //t->l_child.t,t->r_child.t);
1995 (t->left==LTTV_TREE_NODE)?t->l_child.t:NULL,
1996 (t->right==LTTV_TREE_NODE)?t->r_child.t:NULL,
1997 count);
1998 g_debug("logic operator: %s\n",(t->node&1)?"OR":((t->node&2)?"AND":((t->node&4)?"NOT":((t->node&8)?"XOR":"IDLE"))));
1999 g_debug("|-> left branch %p is a %s\n",t->l_child.t,(t->left==LTTV_TREE_NODE)?"NODE":((t->left==LTTV_TREE_LEAF)?"LEAF":"IDLE"));
2000 if(t->left == LTTV_TREE_LEAF) {
2001 g_debug("| |-> field type number: %i\n",t->l_child.leaf->field);
2002 g_debug("| |-> offset is: %i\n",t->l_child.leaf->offset);
2003 g_debug("| |-> operator function is: %p\n",t->l_child.leaf->op);
2004 }
2005 g_debug("|-> right branch %p is a %s\n",t->r_child.t,(t->right==LTTV_TREE_NODE)?"NODE":((t->right==LTTV_TREE_LEAF)?"LEAF":"IDLE"));
2006 if(t->right == LTTV_TREE_LEAF) {
2007 g_debug("| |-> field type number: %i\n",t->r_child.leaf->field);
2008 g_debug("| |-> offset is: %i\n",t->r_child.leaf->offset);
2009 g_debug("| |-> operator function is: %p\n",t->r_child.leaf->op);
2010 }
2011
2012 if(t->left == LTTV_TREE_NODE) lttv_print_tree(t->l_child.t,count+1);
2013 if(t->right == LTTV_TREE_NODE) lttv_print_tree(t->r_child.t,count+1);
2014 }
2015
2016 /**
2017 * @fn static void module_init()
2018 *
2019 * Initializes the filter module and specific values
2020 */
2021 static void module_init()
2022 {
2023
2024 }
2025
2026 /**
2027 * Destroys the filter module and specific values
2028 */
2029 static void module_destroy()
2030 {
2031
2032 }
2033
2034
2035 LTTV_MODULE("filter", "Filters traceset and events", \
2036 "Filters traceset and events specifically to user input", \
2037 module_init, module_destroy)
2038
2039
2040
This page took 0.069784 seconds and 5 git commands to generate.