1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2005 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,
24 simple expr [ op expr ]
26 read_simple_expression
27 read_field_path [ rel value ]
30 read_field_component [. field path]
39 path(component...) -> field
41 consist in AND, OR and NOT nested expressions, forming a tree with
42 simple relations as leaves. The simple relations test is a field
43 in an event is equal, not equal, smaller, smaller or equal, larger, or
44 larger or equal to a specified value.
54 * - refine switch of expression in multiple uses functions
55 * - remove the idle expressions in the tree ****
56 * - add the current simple expression to the tree
57 * * clear the field_path array after use
60 #include <lttv/filter.h>
66 LTTV_FILTER_TRACEFILE,
79 LTTV_FILTER_EX_SUBMODE,
85 * add a node to the current tree
86 * FIXME: Might be used to lower coding in lttv_filter_new switch expression
87 * @param stack the tree stack
88 * @param subtree the subtree if available (pointer or NULL)
89 * @param op the logical operator that will form the node
92 lttv_filter_tree_add_node(GPtrArray
* stack
, LttvFilterTree
* subtree
, LttvLogicalOp op
) {
94 LttvFilterTree
* t1
= NULL
;
95 LttvFilterTree
* t2
= NULL
;
97 t1
= (LttvFilterTree
*)g_ptr_array_index(stack
,stack
->len
-1);
98 while(t1
->right
!= LTTV_TREE_IDLE
) t1
= t1
->r_child
.t
;
99 t2
= lttv_filter_tree_new();
101 if(subtree
!= NULL
) {
102 t2
->left
= LTTV_TREE_NODE
;
103 t2
->l_child
.t
= subtree
;
105 t1
->right
= LTTV_TREE_NODE
;
108 // a_simple_expression->value = a_field_component->str;
109 // a_field_component = g_string_new("");
110 t2
->left
= LTTV_TREE_LEAF
;
111 // t2->l_child.leaf = a_simple_expression;
112 // a_simple_expression = g_new(lttv_simple_expression,1);
113 t1
->right
= LTTV_TREE_NODE
;
121 * Constructor for LttvSimpleExpression
122 * @return pointer to new LttvSimpleExpression
124 LttvSimpleExpression
*
125 lttv_simple_expression_new() {
127 LttvSimpleExpression
* se
= g_new(LttvSimpleExpression
,1);
129 se
->field
= LTTV_FILTER_UNDEFINED
;
138 * Parse through filtering field hierarchy as specified
139 * by user. This function compares each value to
140 * predetermined quarks
141 * @param fp The field path list
142 * @param se current simple expression
143 * @return success/failure of operation
146 parse_field_path(GPtrArray
* fp
, LttvSimpleExpression
* se
) {
149 // g_print("fp->len:%i\n",fp->len);
151 // for(i=0;i<fp->len;i++) {
152 // GString* f2 = g_ptr_array_index(fp,i);
153 // g_print("%i=%s",i,f2->str);
156 if(fp
->len
< 2) return FALSE
;
157 g_assert(f
=g_ptr_array_remove_index(fp
,0)); //list_first(fp)->data;
160 * Parse through the specified
163 * Take note however that the
164 * 'event' subfields might change
165 * depending on values specified
166 * in core.xml file. Hence, if
167 * none of the subfields in the
168 * array match the hardcoded
169 * subfields, it will be considered
172 if(!g_strcasecmp(f
->str
,"trace") ) {
177 g_string_free(f
,TRUE
);
178 f
=g_ptr_array_remove_index(fp
,0);
179 if(!g_strcasecmp(f
->str
,"name")) {
180 se
->field
= LTTV_FILTER_TRACE_NAME
;
182 // else return FALSE;
183 } else if(!g_strcasecmp(f
->str
,"traceset") ) {
185 * FIXME: not yet implemented !
187 } else if(!g_strcasecmp(f
->str
,"tracefile") ) {
192 g_string_free(f
,TRUE
);
193 f
=g_ptr_array_remove_index(fp
,0);
194 if(!g_strcasecmp(f
->str
,"name")) {
195 se
->field
= LTTV_FILTER_TRACEFILE_NAME
;
197 // else return FALSE;
198 } else if(!g_strcasecmp(f
->str
,"state") ) {
203 * state.creation_time
204 * state.insertion_time
206 * state.execution_mode
207 * state.execution_submode
208 * state.process_status
211 g_string_free(f
,TRUE
);
212 f
=g_ptr_array_remove_index(fp
,0);
213 if(!g_strcasecmp(f
->str
,"pid") ) {
214 se
->field
= LTTV_FILTER_STATE_PID
;
216 else if(!g_strcasecmp(f
->str
,"ppid") ) {
217 se
->field
= LTTV_FILTER_STATE_PPID
;
219 else if(!g_strcasecmp(f
->str
,"creation_time") ) {
220 se
->field
= LTTV_FILTER_STATE_CT
;
222 else if(!g_strcasecmp(f
->str
,"insertion_time") ) {
223 se
->field
= LTTV_FILTER_STATE_IT
;
225 else if(!g_strcasecmp(f
->str
,"process_name") ) {
226 se
->field
= LTTV_FILTER_STATE_P_NAME
;
228 else if(!g_strcasecmp(f
->str
,"execution_mode") ) {
229 se
->field
= LTTV_FILTER_STATE_EX_MODE
;
231 else if(!g_strcasecmp(f
->str
,"execution_submode") ) {
232 se
->field
= LTTV_FILTER_STATE_EX_SUBMODE
;
234 else if(!g_strcasecmp(f
->str
,"process_status") ) {
235 se
->field
= LTTV_FILTER_STATE_P_STATUS
;
237 else if(!g_strcasecmp(f
->str
,"cpu") ) {
238 se
->field
= LTTV_FILTER_STATE_CPU
;
240 // else return FALSE;
241 } else if(!g_strcasecmp(f
->str
,"event") ) {
249 g_string_free(f
,TRUE
);
250 f
=g_ptr_array_remove_index(fp
,0);
251 if(!g_strcasecmp(f
->str
,"name") ) {
252 se
->field
= LTTV_FILTER_EVENT_NAME
;
254 else if(!g_strcasecmp(f
->str
,"category") ) {
256 * FIXME: Category not yet functional in lttv
258 se
->field
= LTTV_FILTER_EVENT_CATEGORY
;
260 else if(!g_strcasecmp(f
->str
,"time") ) {
261 se
->field
= LTTV_FILTER_EVENT_TIME
;
262 // offset = &((LttEvent*)NULL)->event_time);
264 else if(!g_strcasecmp(f
->str
,"tsc") ) {
265 se
->field
= LTTV_FILTER_EVENT_TSC
;
266 // offset = &((LttEvent*)NULL)->event_cycle_count);
268 else { /* core.xml specified options */
269 se
->field
= LTTV_FILTER_EVENT_FIELD
;
270 //se->offset = (...);
273 g_warning("Unrecognized field in filter string");
277 g_string_free(f
,TRUE
);
278 g_assert(fp
->len
== 0);
280 if(se
->field
== LTTV_FILTER_UNDEFINED
) return FALSE
;
285 * Sets the function pointer for the current
287 * @param se current simple expression
288 * @return success/failure of operation
290 gboolean
assign_operator(LttvSimpleExpression
* se
, LttvExpressionOp op
) {
292 // g_print("se->field = %i\n",se->field);
293 // g_print("se->offset = %i\n",se->offset);
294 // g_print("se->op = %p\n",se->op);
295 // g_print("se->value = %s\n",se->value);
299 case LTTV_FILTER_TRACE_NAME
:
300 case LTTV_FILTER_TRACEFILE_NAME
:
301 case LTTV_FILTER_STATE_P_NAME
:
302 case LTTV_FILTER_EVENT_NAME
:
305 se
->op
= lttv_apply_op_eq_string
;
308 se
->op
= lttv_apply_op_eq_string
;
311 g_warning("Error encountered in operator assignment = or != expected");
315 case LTTV_FILTER_STATE_PID
:
316 case LTTV_FILTER_STATE_PPID
:
317 case LTTV_FILTER_STATE_EX_MODE
:
318 case LTTV_FILTER_STATE_EX_SUBMODE
:
319 case LTTV_FILTER_STATE_P_STATUS
:
322 se
->op
= lttv_apply_op_eq_uint64
;
325 se
->op
= lttv_apply_op_ne_uint64
;
328 se
->op
= lttv_apply_op_lt_uint64
;
331 se
->op
= lttv_apply_op_le_uint64
;
334 se
->op
= lttv_apply_op_gt_uint64
;
337 se
->op
= lttv_apply_op_ge_uint64
;
340 g_warning("Error encountered in operator assignment");
344 case LTTV_FILTER_STATE_CT
:
345 case LTTV_FILTER_STATE_IT
:
346 case LTTV_FILTER_EVENT_TIME
:
347 case LTTV_FILTER_EVENT_TSC
:
350 se
->op
= lttv_apply_op_eq_double
;
353 se
->op
= lttv_apply_op_ne_double
;
356 se
->op
= lttv_apply_op_lt_double
;
359 se
->op
= lttv_apply_op_le_double
;
362 se
->op
= lttv_apply_op_gt_double
;
365 se
->op
= lttv_apply_op_ge_double
;
368 g_warning("Error encountered in operator assignment");
373 g_warning("Error encountered in operator assignment ! Bad field type ...");
382 * Finds the structure type depending
383 * on the fields in parameters
384 * @params ft Field of the current structure
385 * @return LttvStructType enum or -1 for error
388 lttv_struct_type(gint ft
) {
391 case LTTV_FILTER_TRACE_NAME
:
392 return LTTV_FILTER_TRACE
;
394 case LTTV_FILTER_TRACEFILE_NAME
:
395 return LTTV_FILTER_TRACEFILE
;
397 case LTTV_FILTER_STATE_PID
:
398 case LTTV_FILTER_STATE_PPID
:
399 case LTTV_FILTER_STATE_CT
:
400 case LTTV_FILTER_STATE_IT
:
401 case LTTV_FILTER_STATE_P_NAME
:
402 case LTTV_FILTER_STATE_EX_MODE
:
403 case LTTV_FILTER_STATE_EX_SUBMODE
:
404 case LTTV_FILTER_STATE_P_STATUS
:
405 case LTTV_FILTER_STATE_CPU
:
406 return LTTV_FILTER_STATE
;
408 case LTTV_FILTER_EVENT_NAME
:
409 case LTTV_FILTER_EVENT_CATEGORY
:
410 case LTTV_FILTER_EVENT_TIME
:
411 case LTTV_FILTER_EVENT_TSC
:
412 case LTTV_FILTER_EVENT_FIELD
:
413 return LTTV_FILTER_EVENT
;
421 * Applies the 'equal' operator to the
422 * specified structure and value
423 * @param v1 left member of comparison
424 * @param v2 right member of comparison
425 * @return success/failure of operation
427 gboolean
lttv_apply_op_eq_uint64(gpointer v1
, char* v2
) {
429 guint64
* r
= (guint64
*) v1
;
430 guint64 l
= atoi(v2
);
436 * Applies the 'equal' operator to the
437 * specified structure and value
438 * @param v1 left member of comparison
439 * @param v2 right member of comparison
440 * @return success/failure of operation
442 gboolean
lttv_apply_op_eq_uint32(gpointer v1
, char* v2
) {
443 guint32
* r
= (guint32
*) v1
;
444 guint32 l
= atoi(v2
);
449 * Applies the 'equal' operator to the
450 * specified structure and value
451 * @param v1 left member of comparison
452 * @param v2 right member of comparison
453 * @return success/failure of operation
455 gboolean
lttv_apply_op_eq_uint16(gpointer v1
, char* v2
) {
456 guint16
* r
= (guint16
*) v1
;
457 guint16 l
= atoi(v2
);
462 * Applies the 'equal' operator to the
463 * specified structure and value
464 * @param v1 left member of comparison
465 * @param v2 right member of comparison
466 * @return success/failure of operation
468 gboolean
lttv_apply_op_eq_double(gpointer v1
, char* v2
) {
469 double* r
= (double*) v1
;
475 * Applies the 'equal' operator to the
476 * specified structure and value
477 * @param v1 left member of comparison
478 * @param v2 right member of comparison
479 * @return success/failure of operation
481 gboolean
lttv_apply_op_eq_string(gpointer v1
, char* v2
) {
482 char* r
= (char*) v1
;
483 return (!g_strcasecmp(r
,v2
));
487 * Applies the 'not equal' operator to the
488 * specified structure and value
489 * @param v1 left member of comparison
490 * @param v2 right member of comparison
491 * @return success/failure of operation
493 gboolean
lttv_apply_op_ne_uint64(gpointer v1
, char* v2
) {
494 guint64
* r
= (guint64
*) v1
;
495 guint64 l
= atoi(v2
);
500 * Applies the 'not equal' operator to the
501 * specified structure and value
502 * @param v1 left member of comparison
503 * @param v2 right member of comparison
504 * @return success/failure of operation
506 gboolean
lttv_apply_op_ne_uint32(gpointer v1
, char* v2
) {
507 guint32
* r
= (guint32
*) v1
;
508 guint32 l
= atoi(v2
);
513 * Applies the 'not equal' operator to the
514 * specified structure and value
515 * @param v1 left member of comparison
516 * @param v2 right member of comparison
517 * @return success/failure of operation
519 gboolean
lttv_apply_op_ne_uint16(gpointer v1
, char* v2
) {
520 guint16
* r
= (guint16
*) v1
;
521 guint16 l
= atoi(v2
);
526 * Applies the 'not equal' operator to the
527 * specified structure and value
528 * @param v1 left member of comparison
529 * @param v2 right member of comparison
530 * @return success/failure of operation
532 gboolean
lttv_apply_op_ne_double(gpointer v1
, char* v2
) {
533 double* r
= (double*) v1
;
539 * Applies the 'not equal' operator to the
540 * specified structure and value
541 * @param v1 left member of comparison
542 * @param v2 right member of comparison
543 * @return success/failure of operation
545 gboolean
lttv_apply_op_ne_string(gpointer v1
, char* v2
) {
546 char* r
= (char*) v1
;
547 return (g_strcasecmp(r
,v2
));
551 * Applies the 'lower than' operator to the
552 * specified structure and value
553 * @param v1 left member of comparison
554 * @param v2 right member of comparison
555 * @return success/failure of operation
557 gboolean
lttv_apply_op_lt_uint64(gpointer v1
, char* v2
) {
558 guint64
* r
= (guint64
*) v1
;
559 guint64 l
= atoi(v2
);
564 * Applies the 'lower than' operator to the
565 * specified structure and value
566 * @param v1 left member of comparison
567 * @param v2 right member of comparison
568 * @return success/failure of operation
570 gboolean
lttv_apply_op_lt_uint32(gpointer v1
, char* v2
) {
571 guint32
* r
= (guint32
*) v1
;
572 guint32 l
= atoi(v2
);
577 * Applies the 'lower than' operator to the
578 * specified structure and value
579 * @param v1 left member of comparison
580 * @param v2 right member of comparison
581 * @return success/failure of operation
583 gboolean
lttv_apply_op_lt_uint16(gpointer v1
, char* v2
) {
584 guint16
* r
= (guint16
*) v1
;
585 guint16 l
= atoi(v2
);
590 * Applies the 'lower than' operator to the
591 * specified structure and value
592 * @param v1 left member of comparison
593 * @param v2 right member of comparison
594 * @return success/failure of operation
596 gboolean
lttv_apply_op_lt_double(gpointer v1
, char* v2
) {
597 double* r
= (double*) v1
;
603 * Applies the 'lower than' operator to the
604 * specified structure and value
605 * @param v1 left member of comparison
606 * @param v2 right member of comparison
607 * @return success/failure of operation
609 gboolean
lttv_apply_op_le_uint64(gpointer v1
, char* v2
) {
610 guint64
* r
= (guint64
*) v1
;
611 guint64 l
= atoi(v2
);
616 * Applies the 'lower or equal' operator to the
617 * specified structure and value
618 * @param v1 left member of comparison
619 * @param v2 right member of comparison
620 * @return success/failure of operation
622 gboolean
lttv_apply_op_le_uint32(gpointer v1
, char* v2
) {
623 guint32
* r
= (guint32
*) v1
;
624 guint32 l
= atoi(v2
);
629 * Applies the 'lower or equal' operator to the
630 * specified structure and value
631 * @param v1 left member of comparison
632 * @param v2 right member of comparison
633 * @return success/failure of operation
635 gboolean
lttv_apply_op_le_uint16(gpointer v1
, char* v2
) {
636 guint16
* r
= (guint16
*) v1
;
637 guint16 l
= atoi(v2
);
642 * Applies the 'lower or equal' operator to the
643 * specified structure and value
644 * @param v1 left member of comparison
645 * @param v2 right member of comparison
646 * @return success/failure of operation
648 gboolean
lttv_apply_op_le_double(gpointer v1
, char* v2
) {
649 double* r
= (double*) v1
;
655 * Applies the 'greater than' operator to the
656 * specified structure and value
657 * @param v1 left member of comparison
658 * @param v2 right member of comparison
659 * @return success/failure of operation
661 gboolean
lttv_apply_op_gt_uint64(gpointer v1
, char* v2
) {
662 guint64
* r
= (guint64
*) v1
;
663 guint64 l
= atoi(v2
);
668 * Applies the 'greater than' operator to the
669 * specified structure and value
670 * @param v1 left member of comparison
671 * @param v2 right member of comparison
672 * @return success/failure of operation
674 gboolean
lttv_apply_op_gt_uint32(gpointer v1
, char* v2
) {
675 guint32
* r
= (guint32
*) v1
;
676 guint32 l
= atoi(v2
);
681 * Applies the 'greater than' operator to the
682 * specified structure and value
683 * @param v1 left member of comparison
684 * @param v2 right member of comparison
685 * @return success/failure of operation
687 gboolean
lttv_apply_op_gt_uint16(gpointer v1
, char* v2
) {
688 guint16
* r
= (guint16
*) v1
;
689 guint16 l
= atoi(v2
);
694 * Applies the 'greater than' operator to the
695 * specified structure and value
696 * @param v1 left member of comparison
697 * @param v2 right member of comparison
698 * @return success/failure of operation
700 gboolean
lttv_apply_op_gt_double(gpointer v1
, char* v2
) {
701 double* r
= (double*) v1
;
707 * Applies the 'greater or equal' operator to the
708 * specified structure and value
709 * @param v1 left member of comparison
710 * @param v2 right member of comparison
711 * @return success/failure of operation
713 gboolean
lttv_apply_op_ge_uint64(gpointer v1
, char* v2
) {
714 guint64
* r
= (guint64
*) v1
;
715 guint64 l
= atoi(v2
);
720 * Applies the 'greater or equal' operator to the
721 * specified structure and value
722 * @param v1 left member of comparison
723 * @param v2 right member of comparison
724 * @return success/failure of operation
726 gboolean
lttv_apply_op_ge_uint32(gpointer v1
, char* v2
) {
727 guint32
* r
= (guint32
*) v1
;
728 guint32 l
= atoi(v2
);
733 * Applies the 'greater or 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
739 gboolean
lttv_apply_op_ge_uint16(gpointer v1
, char* v2
) {
740 guint16
* r
= (guint16
*) v1
;
741 guint16 l
= atoi(v2
);
746 * Applies the 'greater or equal' operator to the
747 * specified structure and value
748 * @param v1 left member of comparison
749 * @param v2 right member of comparison
750 * @return success/failure of operation
752 gboolean
lttv_apply_op_ge_double(gpointer v1
, char* v2
) {
753 double* r
= (double*) v1
;
760 * Makes a copy of the current filter tree
761 * @param tree pointer to the current tree
762 * @return new copy of the filter tree
765 lttv_filter_tree_clone(LttvFilterTree
* tree
) {
767 LttvFilterTree
* newtree
= lttv_filter_tree_new();
769 newtree
->node
= tree
->node
;
771 newtree
->left
= tree
->left
;
772 if(newtree
->left
== LTTV_TREE_NODE
) {
773 newtree
->l_child
.t
= lttv_filter_tree_clone(tree
->l_child
.t
);
774 } else if(newtree
->left
== LTTV_TREE_LEAF
) {
775 newtree
->l_child
.leaf
= lttv_simple_expression_new();
776 newtree
->l_child
.leaf
->field
= tree
->l_child
.leaf
->field
;
777 newtree
->l_child
.leaf
->offset
= tree
->l_child
.leaf
->offset
;
778 newtree
->l_child
.leaf
->op
= tree
->l_child
.leaf
->op
;
779 newtree
->l_child
.leaf
->value
= g_strconcat(tree
->l_child
.leaf
->value
);
782 newtree
->right
= tree
->right
;
783 if(newtree
->right
== LTTV_TREE_NODE
) {
784 newtree
->r_child
.t
= lttv_filter_tree_clone(tree
->r_child
.t
);
785 } else if(newtree
->right
== LTTV_TREE_LEAF
) {
786 newtree
->r_child
.leaf
= lttv_simple_expression_new();
787 newtree
->r_child
.leaf
->field
= tree
->r_child
.leaf
->field
;
788 newtree
->r_child
.leaf
->offset
= tree
->r_child
.leaf
->offset
;
789 newtree
->r_child
.leaf
->op
= tree
->r_child
.leaf
->op
;
790 newtree
->r_child
.leaf
->value
= g_strconcat(tree
->r_child
.leaf
->value
);
798 * Makes a copy of the current filter
799 * @param filter pointer to the current filter
800 * @return new copy of the filter
803 lttv_filter_clone(LttvFilter
* filter
) {
806 LttvFilter
* newfilter
= g_new(LttvFilter
,1);
808 // newfilter->expression = g_new(char,1)
809 strcpy(newfilter
->expression
,filter
->expression
);
811 newfilter
->head
= lttv_filter_tree_clone(filter
->head
);
819 * Creates a new lttv_filter
820 * @param expression filtering options string
821 * @param t pointer to the current LttvTrace
822 * @return the current lttv_filter or NULL if error
827 LttvFilter
* filter
= g_new(LttvFilter
,1);
828 filter
->expression
= NULL
;
834 * Updates the current LttvFilter by building
835 * its tree based upon the expression string
836 * @param filter pointer to the current LttvFilter
837 * @return Failure/Success of operation
840 lttv_filter_update(LttvFilter
* filter
) {
842 g_print("filter::lttv_filter_new()\n"); /* debug */
844 if(filter
->expression
== NULL
) return FALSE
;
848 p_nesting
=0, /* parenthesis nesting value */
849 b
=0; /* current breakpoint in expression string */
853 *tree
= lttv_filter_tree_new(), /* main tree */
854 *subtree
= NULL
, /* buffer for subtrees */
860 * If the tree already exists,
861 * destroy it and build a new one
863 if(filter
->head
!= NULL
) lttv_filter_tree_destroy(filter
->head
);
868 * each element of the list
869 * is a sub tree created
870 * by the use of parenthesis in the
871 * global expression. The final tree
872 * will be the one left at the root of
875 GPtrArray
*tree_stack
= g_ptr_array_new();
876 g_ptr_array_add( tree_stack
,(gpointer
) tree
);
878 /* temporary values */
879 GString
*a_field_component
= g_string_new("");
880 GPtrArray
*a_field_path
= NULL
;
882 LttvSimpleExpression
* a_simple_expression
= lttv_simple_expression_new();
885 * Parse entire expression and construct
886 * the binary tree. There are two steps
887 * in browsing that string
888 * 1. finding boolean ops " &,|,^,! " and parenthesis " {,(,[,],),} "
889 * 2. finding simple expressions
890 * - field path ( separated by dots )
891 * - op ( >, <, =, >=, <=, !=)
892 * - value ( integer, string ... )
893 * To spare computing time, the whole
894 * string is parsed in this loop for a
895 * O(n) complexity order.
897 * When encountering logical op &,|,^
898 * 1. parse the last value if any
899 * 2. create a new tree
900 * 3. add the expression (simple exp, or exp (subtree)) to the tree
901 * 4. concatenate this tree with the current tree on top of the stack
902 * When encountering math ops >,>=,<,<=,=,!=
903 * 1. add to op to the simple expression
904 * 2. concatenate last field component to field path
905 * When encountering concatening ops .
906 * 1. concatenate last field component to field path
907 * When encountering opening parenthesis (,{,[
908 * 1. create a new subtree on top of tree stack
909 * When encountering closing parenthesis ),},]
910 * 1. add the expression on right child of the current tree
911 * 2. the subtree is completed, allocate a new subtree
912 * 3. pop the tree value from the tree stack
915 a_field_path
= g_ptr_array_new();
916 // g_ptr_array_set_size(a_field_path,2); /* by default, recording 2 field expressions */
919 g_print("expression: %s\n",filter
->expression
);
920 g_print("strlen(expression): %i\n",strlen(filter
->expression
));
921 for(i
=0;i
<strlen(filter
->expression
);i
++) {
923 g_print("%c ",filter
->expression
[i
]);
924 switch(filter
->expression
[i
]) {
930 t1
= (LttvFilterTree
*)g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
931 while(t1
->right
!= LTTV_TREE_IDLE
) t1
= t1
->r_child
.t
;
932 t2
= lttv_filter_tree_new();
933 t2
->node
= LTTV_LOGICAL_AND
;
934 if(subtree
!= NULL
) { /* append subtree to current tree */
935 t2
->left
= LTTV_TREE_NODE
;
936 t2
->l_child
.t
= subtree
;
938 t1
->right
= LTTV_TREE_NODE
;
940 } else { /* append a simple expression */
941 a_simple_expression
->value
= g_string_free(a_field_component
,FALSE
);
942 a_field_component
= g_string_new("");
943 t2
->left
= LTTV_TREE_LEAF
;
944 t2
->l_child
.leaf
= a_simple_expression
;
945 a_simple_expression
= lttv_simple_expression_new();
946 t1
->right
= LTTV_TREE_NODE
;
953 t1
= (LttvFilter
*)g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
954 while(t1
->right
!= LTTV_TREE_IDLE
) t1
= t1
->r_child
.t
;
955 t2
= lttv_filter_tree_new();
956 t2
->node
= LTTV_LOGICAL_OR
;
957 if(subtree
!= NULL
) { /* append subtree to current tree */
958 t2
->left
= LTTV_TREE_NODE
;
959 t2
->l_child
.t
= subtree
;
961 t1
->right
= LTTV_TREE_NODE
;
963 } else { /* append a simple expression */
964 a_simple_expression
->value
= g_string_free(a_field_component
,FALSE
);
965 a_field_component
= g_string_new("");
966 t2
->left
= LTTV_TREE_LEAF
;
967 t2
->l_child
.leaf
= a_simple_expression
;
968 a_simple_expression
= lttv_simple_expression_new();
969 t1
->right
= LTTV_TREE_NODE
;
976 t1
= (LttvFilter
*)g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
977 while(t1
->right
!= LTTV_TREE_IDLE
) t1
= t1
->r_child
.t
;
978 t2
= lttv_filter_tree_new();
979 t2
->node
= LTTV_LOGICAL_XOR
;
980 if(subtree
!= NULL
) { /* append subtree to current tree */
981 t2
->left
= LTTV_TREE_NODE
;
982 t2
->l_child
.t
= subtree
;
984 t1
->right
= LTTV_TREE_NODE
;
986 } else { /* append a simple expression */
987 a_simple_expression
->value
= g_string_free(a_field_component
,FALSE
);
988 a_field_component
= g_string_new("");
989 t2
->left
= LTTV_TREE_LEAF
;
990 t2
->l_child
.leaf
= a_simple_expression
;
991 a_simple_expression
= lttv_simple_expression_new();
992 t1
->right
= LTTV_TREE_NODE
;
997 case '!': /* not, or not equal (math op) */
999 if(filter
->expression
[i
+1] == '=') { /* != */
1000 g_ptr_array_add( a_field_path
,(gpointer
) a_field_component
);
1001 parse_field_path(a_field_path
,a_simple_expression
);
1002 a_field_component
= g_string_new("");
1003 assign_operator(a_simple_expression
,LTTV_FIELD_NE
);
1006 // g_print("%s\n",a_field_component);
1007 // a_field_component = g_string_new("");
1008 t1
= (LttvFilter
*)g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
1009 while(t1
->right
!= LTTV_TREE_IDLE
) t1
= t1
->r_child
.t
;
1010 t2
= lttv_filter_tree_new();
1011 t2
->node
= LTTV_LOGICAL_NOT
;
1012 t1
->right
= LTTV_TREE_NODE
;
1017 case '(': /* start of parenthesis */
1021 p_nesting
++; /* incrementing parenthesis nesting value */
1022 t1
= lttv_filter_tree_new();
1023 g_ptr_array_add( tree_stack
,(gpointer
) t1
);
1026 case ')': /* end of parenthesis */
1030 p_nesting
--; /* decrementing parenthesis nesting value */
1031 if(p_nesting
<0 || tree_stack
->len
<2) {
1032 g_warning("Wrong filtering options, the string\n\"%s\"\n\
1033 is not valid due to parenthesis incorrect use",filter
->expression
);
1037 g_assert(tree_stack
->len
>0);
1038 if(subtree
!= NULL
) { /* append subtree to current tree */
1039 t1
= g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
1040 while(t1
->right
!= LTTV_TREE_IDLE
&& t1
->right
!= LTTV_TREE_LEAF
) {
1041 g_assert(t1
!=NULL
&& t1
->r_child
.t
!= NULL
);
1044 t1
->right
= LTTV_TREE_NODE
;
1045 t1
->r_child
.t
= subtree
;
1046 subtree
= g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
1047 g_ptr_array_remove_index(tree_stack
,tree_stack
->len
-1);
1048 } else { /* assign subtree as current tree */
1049 a_simple_expression
->value
= g_string_free(a_field_component
,FALSE
);
1050 a_field_component
= g_string_new("");
1051 t1
= g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
1052 while(t1
->right
!= LTTV_TREE_IDLE
) t1
= t1
->r_child
.t
;
1053 t1
->right
= LTTV_TREE_LEAF
;
1054 t1
->r_child
.leaf
= a_simple_expression
;
1055 a_simple_expression
= lttv_simple_expression_new();
1056 subtree
= g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
1057 g_assert(subtree
!= NULL
);
1058 g_ptr_array_remove_index(tree_stack
,tree_stack
->len
-1);
1063 * mathematic operators
1065 case '<': /* lower, lower or equal */
1067 g_ptr_array_add( a_field_path
,(gpointer
) a_field_component
);
1068 parse_field_path(a_field_path
,a_simple_expression
);
1069 a_field_component
= g_string_new("");
1070 if(filter
->expression
[i
+1] == '=') { /* <= */
1072 assign_operator(a_simple_expression
,LTTV_FIELD_LE
);
1073 } else assign_operator(a_simple_expression
,LTTV_FIELD_LT
);
1076 case '>': /* higher, higher or equal */
1078 g_ptr_array_add( a_field_path
,(gpointer
) a_field_component
);
1079 parse_field_path(a_field_path
,a_simple_expression
);
1080 a_field_component
= g_string_new("");
1081 if(filter
->expression
[i
+1] == '=') { /* >= */
1083 assign_operator(a_simple_expression
,LTTV_FIELD_GE
);
1084 } else assign_operator(a_simple_expression
,LTTV_FIELD_GT
);
1087 case '=': /* equal */
1089 g_ptr_array_add( a_field_path
,(gpointer
) a_field_component
);
1090 parse_field_path(a_field_path
,a_simple_expression
);
1091 a_field_component
= g_string_new("");
1092 assign_operator(a_simple_expression
,LTTV_FIELD_EQ
);
1096 * Field concatening caracter
1101 * divide field expression into elements
1102 * in a_field_path array.
1104 // if(a_simple_expression->op == NULL) {
1105 g_ptr_array_add( a_field_path
,(gpointer
) a_field_component
);
1106 a_field_component
= g_string_new("");
1110 default: /* concatening current string */
1111 // fprintf(stderr,"%i>> %p:%s et %p\n",i,a_field_component,a_field_component->str,filter->expression[i]);
1112 g_string_append_c(a_field_component
,filter
->expression
[i
]);
1116 g_print("subtree:%p, tree:%p, t1:%p, t2:%p\n",subtree
,tree
,t1
,t2
);
1117 g_print("stack size: %i\n",tree_stack
->len
);
1120 * Preliminary check to see
1121 * if tree was constructed correctly
1124 g_warning("Wrong filtering options, the string\n\"%s\"\n\
1125 is not valid due to parenthesis incorrect use",filter
->expression
);
1129 if(tree_stack
->len
!= 1) /* only root tree should remain */
1132 /* processing last element of expression */
1133 t1
= g_ptr_array_index(tree_stack
,tree_stack
->len
-1);
1134 while(t1
->right
!= LTTV_TREE_IDLE
) t1
= t1
->r_child
.t
;
1135 if(subtree
!= NULL
) { /* add the subtree */
1136 t1
->right
= LTTV_TREE_NODE
;
1137 t1
->r_child
.t
= subtree
;
1139 } else { /* add a leaf */
1140 a_simple_expression
->value
= g_string_free(a_field_component
,FALSE
);
1141 // a_field_component = g_string_new("");
1142 t1
->right
= LTTV_TREE_LEAF
;
1143 t1
->r_child
.leaf
= a_simple_expression
;
1145 * FIXME: is it really necessary to reallocate
1146 * LttvSimpleExpression at this point ??
1148 // a_simple_expression = lttv_simple_expression_new();
1151 /* free the pointer array */
1152 g_assert(a_field_path
->len
== 0);
1153 g_ptr_array_free(a_field_path
,TRUE
);
1155 g_assert(tree
!= NULL
);
1156 g_assert(subtree
== NULL
);
1158 // lttv_print_tree(filter->head) ;
1160 g_print("ended update tree!\n");
1168 * Destroy the current LttvFilter
1169 * @param filter pointer to the current LttvFilter
1172 lttv_filter_destroy(LttvFilter
* filter
) {
1174 g_free(filter
->expression
);
1175 lttv_filter_tree_destroy(filter
->head
);
1181 * Assign a new tree for the current expression
1183 * @return pointer of LttvFilterTree
1186 lttv_filter_tree_new() {
1187 LttvFilterTree
* tree
;
1189 tree
= g_new(LttvFilter
,1);
1190 tree
->node
= 0; //g_new(lttv_expression,1);
1191 tree
->left
= LTTV_TREE_IDLE
;
1192 tree
->right
= LTTV_TREE_IDLE
;
1198 * Append a new expression to the expression
1199 * defined in the current filter
1200 * @param filter pointer to the current LttvFilter
1201 * @param expression string that must be appended
1203 void lttv_filter_append_expression(LttvFilter
* filter
, char *expression
) {
1205 if(expression
== NULL
) return;
1206 if(filter
== NULL
) {
1207 filter
= lttv_filter_new();
1208 filter
->expression
= expression
;
1209 } else if(filter
->expression
== NULL
) {
1210 filter
->expression
= expression
;
1212 filter
->expression
= g_strconcat(filter
->expression
,"&",expression
);
1215 lttv_filter_update(filter
);
1220 * Clear the filter expression from the
1221 * current filter and sets its pointer to NULL
1222 * @param filter pointer to the current LttvFilter
1224 void lttv_filter_clear_expression(LttvFilter
* filter
) {
1226 if(filter
->expression
!= NULL
) {
1227 g_free(filter
->expression
);
1228 filter
->expression
= NULL
;
1234 * Destroys the tree and his sub-trees
1235 * @param tree Tree which must be destroyed
1238 lttv_filter_tree_destroy(LttvFilterTree
* tree
) {
1240 if(tree
== NULL
) return;
1242 if(tree
->left
== LTTV_TREE_LEAF
) g_free(tree
->l_child
.leaf
);
1243 else if(tree
->left
== LTTV_TREE_NODE
) lttv_filter_tree_destroy(tree
->l_child
.t
);
1245 if(tree
->right
== LTTV_TREE_LEAF
) g_free(tree
->r_child
.leaf
);
1246 else if(tree
->right
== LTTV_TREE_NODE
) lttv_filter_tree_destroy(tree
->r_child
.t
);
1253 * Global parsing function for the current
1255 * @param tree pointer to the current LttvFilterTree
1256 * @param event current LttEvent, NULL if not used
1257 * @param tracefile current LttTracefile, NULL if not used
1258 * @param trace current LttTrace, NULL if not used
1259 * @param state current LttvProcessState, NULL if not used
1262 lttv_filter_tree_parse(
1265 LttTracefile
* tracefile
,
1267 LttvProcessState
* state
1272 * Each tree is parsed in inorder.
1273 * This way, it's possible to apply the left filter of the
1274 * tree, then decide whether or not the right branch should
1275 * be parsed depending on the linking logical operator
1277 * Each node consists in a
1278 * 1. logical operator
1279 * 2. left child ( node or simple expression )
1280 * 3. right child ( node or simple expression )
1282 * When the child is a simple expression, we must
1283 * before all determine if the expression refers to
1284 * a structure which is whithin observation ( not NULL ).
1285 * -If so, the expression is evaluated.
1286 * -If not, the result is set to TRUE since this particular
1287 * operation does not interfere with the lttv structure
1289 * The result of each simple expression will directly
1290 * affect the next branch. This way, depending on
1291 * the linking logical operator, the parser will decide
1292 * to explore or not the next branch.
1294 * -If result of left branch is 0 / FALSE
1295 * then don't explore right branch and return 0;
1296 * -If result of left branch is 1 / TRUE then explore
1298 * -If result of left branch is 1 / TRUE
1299 * then don't explore right branch and return 1;
1300 * -If result of left branch is 0 / FALSE then explore
1302 * -Result of left branchwill not affect exploration of
1305 g_print("filter::lttv_parse_tree(...)\n");
1307 gboolean lresult
= FALSE
, rresult
= FALSE
;
1312 if(t
->left
== LTTV_TREE_NODE
) lresult
= lttv_filter_tree_parse(t
->l_child
.t
,event
,tracefile
,trace
,state
);
1313 else if(t
->left
== LTTV_TREE_LEAF
) {
1314 //g_print("%p: left is %i %p %s\n",t,t->l_child.leaf->field,t->l_child.leaf->op,t->l_child.leaf->value);
1316 g_assert(v
= t
->l_child
.leaf
->value
);
1317 switch(t
->l_child
.leaf
->field
) {
1319 case LTTV_FILTER_TRACE_NAME
:
1320 if(trace
== NULL
) lresult
= TRUE
;
1321 else lresult
= t
->l_child
.leaf
->op((gpointer
)ltt_trace_name(trace
),v
);
1323 case LTTV_FILTER_TRACEFILE_NAME
:
1324 if(tracefile
== NULL
) lresult
= TRUE
;
1325 else lresult
= t
->l_child
.leaf
->op((gpointer
)ltt_tracefile_name(tracefile
),v
);
1327 case LTTV_FILTER_STATE_PID
:
1328 if(state
== NULL
) lresult
= TRUE
;
1329 else lresult
= t
->l_child
.leaf
->op((gpointer
)&state
->pid
,v
);
1331 case LTTV_FILTER_STATE_PPID
:
1332 if(state
== NULL
) lresult
= TRUE
;
1333 else lresult
= t
->l_child
.leaf
->op((gpointer
)&state
->ppid
,v
);
1335 case LTTV_FILTER_STATE_CT
:
1336 if(state
== NULL
) lresult
= TRUE
;
1338 double val
= ltt_time_to_double(state
->creation_time
);
1339 lresult
= t
->l_child
.leaf
->op((gpointer
)&val
,v
);
1342 case LTTV_FILTER_STATE_IT
:
1343 if(state
== NULL
) lresult
= TRUE
;
1345 double val
= ltt_time_to_double(state
->insertion_time
);
1346 lresult
= t
->l_child
.leaf
->op((gpointer
)&val
,v
);
1349 case LTTV_FILTER_STATE_P_NAME
:
1351 * FIXME: Yet to be done ( I think ? )
1355 case LTTV_FILTER_STATE_EX_MODE
:
1356 if(state
== NULL
) lresult
= TRUE
;
1357 else lresult
= t
->l_child
.leaf
->op((gpointer
)&state
->state
->t
,v
);
1359 case LTTV_FILTER_STATE_EX_SUBMODE
:
1360 if(state
== NULL
) lresult
= TRUE
;
1361 else lresult
= t
->l_child
.leaf
->op((gpointer
)&state
->state
->n
,v
);
1363 case LTTV_FILTER_STATE_P_STATUS
:
1364 if(state
== NULL
) lresult
= TRUE
;
1365 else lresult
= t
->l_child
.leaf
->op((gpointer
)&state
->state
->s
,v
);
1367 case LTTV_FILTER_STATE_CPU
:
1369 * FIXME: What is the comparison value ?
1373 case LTTV_FILTER_EVENT_NAME
:
1374 if(event
== NULL
) lresult
= TRUE
;
1375 else lresult
= t
->l_child
.leaf
->op((gpointer
)ltt_event_eventtype(event
),v
);
1378 case LTTV_FILTER_EVENT_CATEGORY
:
1380 * FIXME: Not yet implemented
1384 case LTTV_FILTER_EVENT_TIME
:
1385 // if(event == NULL) lresult = TRUE;
1387 // double val = ltt_time_to_double(event->event_time);
1388 // lresult = t->l_child.leaf->op((gpointer)&val,v);
1392 case LTTV_FILTER_EVENT_TSC
:
1393 // if(event == NULL) lresult = TRUE;
1395 // double val = ltt_time_to_double(event->event_time);
1396 // lresult = t->l_child.leaf->op((gpointer)&val,v);
1399 * FIXME: Where is event.tsc
1403 case LTTV_FILTER_EVENT_FIELD
:
1405 * TODO: Use the offset to
1406 * find the dynamic field
1407 * in the event struct
1412 * This case should never be
1413 * parsed, if so, the whole
1414 * filtering is cancelled
1416 g_warning("Error while parsing the filter tree");
1422 * Parse linking operator
1423 * make a cutoff if possible
1425 if((t
->node
& LTTV_LOGICAL_OR
) && lresult
== TRUE
) return TRUE
;
1426 if((t
->node
& LTTV_LOGICAL_AND
) && lresult
== FALSE
) return FALSE
;
1429 * Parse right branch
1431 if(t
->right
== LTTV_TREE_NODE
) rresult
= lttv_filter_tree_parse(t
->r_child
.t
,event
,tracefile
,trace
,state
);
1432 else if(t
->right
== LTTV_TREE_LEAF
) {
1433 //g_print("%p: right is %i %p %s\n",t,t->r_child.leaf->field,t->r_child.leaf->op,t->r_child.leaf->value);
1435 g_assert(v
= t
->r_child
.leaf
->value
);
1436 switch(t
->r_child
.leaf
->field
) {
1438 case LTTV_FILTER_TRACE_NAME
:
1439 if(trace
== NULL
) rresult
= TRUE
;
1440 else rresult
= t
->r_child
.leaf
->op((gpointer
)ltt_trace_name(trace
),v
);
1442 case LTTV_FILTER_TRACEFILE_NAME
:
1443 if(tracefile
== NULL
) rresult
= TRUE
;
1444 else rresult
= t
->r_child
.leaf
->op((gpointer
)ltt_tracefile_name(tracefile
),v
);
1446 case LTTV_FILTER_STATE_PID
:
1447 if(state
== NULL
) rresult
= TRUE
;
1448 else rresult
= t
->r_child
.leaf
->op((gpointer
)&state
->pid
,v
);
1450 case LTTV_FILTER_STATE_PPID
:
1451 if(state
== NULL
) rresult
= TRUE
;
1452 else rresult
= t
->r_child
.leaf
->op((gpointer
)&state
->ppid
,v
);
1454 case LTTV_FILTER_STATE_CT
:
1455 if(state
== NULL
) rresult
= TRUE
;
1457 double val
= ltt_time_to_double(state
->creation_time
);
1458 rresult
= t
->r_child
.leaf
->op((gpointer
)&val
,v
);
1461 case LTTV_FILTER_STATE_IT
:
1462 if(state
== NULL
) rresult
= TRUE
;
1464 double val
= ltt_time_to_double(state
->insertion_time
);
1465 rresult
= t
->r_child
.leaf
->op((gpointer
)&val
,v
);
1468 case LTTV_FILTER_STATE_P_NAME
:
1470 * FIXME: Yet to be done ( I think ? )
1474 case LTTV_FILTER_STATE_EX_MODE
:
1475 if(state
== NULL
) rresult
= TRUE
;
1476 else rresult
= t
->r_child
.leaf
->op((gpointer
)&state
->state
->t
,v
);
1478 case LTTV_FILTER_STATE_EX_SUBMODE
:
1479 if(state
== NULL
) rresult
= TRUE
;
1480 else rresult
= t
->r_child
.leaf
->op((gpointer
)&state
->state
->n
,v
);
1482 case LTTV_FILTER_STATE_P_STATUS
:
1483 if(state
== NULL
) rresult
= TRUE
;
1484 else rresult
= t
->r_child
.leaf
->op((gpointer
)&state
->state
->s
,v
);
1486 case LTTV_FILTER_STATE_CPU
:
1488 * FIXME: What is the comparison value ?
1492 case LTTV_FILTER_EVENT_NAME
:
1493 if(event
== NULL
) rresult
= TRUE
;
1494 else rresult
= t
->r_child
.leaf
->op((gpointer
)ltt_event_eventtype(event
),v
);
1497 case LTTV_FILTER_EVENT_CATEGORY
:
1499 * FIXME: Not yet implemented
1503 case LTTV_FILTER_EVENT_TIME
:
1504 // if(event == NULL) rresult = TRUE;
1506 // double val = ltt_time_to_double(event->event_time);
1507 // rresult = t->r_child.leaf->op((gpointer)&val,v);
1511 case LTTV_FILTER_EVENT_TSC
:
1512 // if(event == NULL) rresult = TRUE;
1514 // double val = ltt_time_to_double(event->event_time);
1515 // rresult = t->r_child.leaf->op((gpointer)&val,v);
1518 * FIXME: Where is event.tsc
1522 case LTTV_FILTER_EVENT_FIELD
:
1524 * TODO: Use the offset to
1525 * find the dynamic field
1526 * in the event struct
1531 * This case should never be
1532 * parsed, if so, this subtree
1535 g_warning("Error while parsing the filter tree");
1541 * Apply and return the
1542 * logical link between the
1546 case LTTV_LOGICAL_OR
: return (lresult
| rresult
);
1547 case LTTV_LOGICAL_AND
: return (lresult
& rresult
);
1548 case LTTV_LOGICAL_NOT
: return (!rresult
);
1549 case LTTV_LOGICAL_XOR
: return (lresult
^ rresult
);
1552 * This case should never be
1553 * parsed, if so, this subtree
1565 lttv_print_tree(LttvFilterTree
* t
) {
1567 g_print("node:%p lchild:%p rchild:%p\n",t
, //t->l_child.t,t->r_child.t);
1568 (t
->left
==LTTV_TREE_NODE
)?t
->l_child
.t
:NULL
,
1569 (t
->right
==LTTV_TREE_NODE
)?t
->r_child
.t
:NULL
);
1570 g_print("node type: %i / [left] %i / [right] %i\n",t
->node
,t
->left
,t
->right
);
1571 if(t
->left
== LTTV_TREE_NODE
) lttv_print_tree(t
->l_child
.t
);
1572 else if(t
->left
== LTTV_TREE_LEAF
) {
1573 // g_assert(t->l_child.leaf->value != NULL);
1574 g_print("%p: left is %i %p %s\n",t
,t
->l_child
.leaf
->field
,t
->l_child
.leaf
->op
,t
->l_child
.leaf
->value
);
1577 if(t
->right
== LTTV_TREE_NODE
) lttv_print_tree(t
->r_child
.t
);
1578 else if(t
->right
== LTTV_TREE_LEAF
) {
1579 fprintf(stderr
,"leaf!\n");
1580 // g_assert(t->r_child.leaf->value != NULL);
1581 fprintf(stderr
,"%p: right is %i %p %s\n",t
,t
->r_child
.leaf
->field
,t
->r_child
.leaf
->op
,t
->r_child
.leaf
->value
);
1588 * Apply the filter to a specific trace
1589 * @param filter the current filter applied
1590 * @param tracefile the trace to apply the filter to
1591 * @return success/failure of operation
1594 lttv_filter_tracefile(LttvFilter
*filter
, LttTracefile
*tracefile
) {
1596 return lttv_filter_tree_parse(filter
->head
,NULL
,tracefile
,NULL
,NULL
);
1601 lttv_filter_tracestate(LttvFilter
*filter
, LttvTraceState
*tracestate
) {
1606 * Apply the filter to a specific event
1607 * @param filter the current filter applied
1608 * @param event the event to apply the filter to
1609 * @return success/failure of operation
1612 lttv_filter_event(LttvFilter
*filter
, LttEvent
*event
) {
1617 * Initializes the filter module and specific values
1619 static void module_init()
1623 * Quarks initialization
1624 * for hardcoded filtering options
1626 * TODO: traceset has no yet been defined
1630 // LTTV_FILTER_EVENT = g_quark_from_string("event");
1631 // LTTV_FILTER_TRACE = g_quark_from_string("trace");
1632 // LTTV_FILTER_TRACESET = g_quark_from_string("traceset");
1633 // LTTV_FILTER_STATE = g_quark_from_string("state");
1634 // LTTV_FILTER_TRACEFILE = g_quark_from_string("tracefile");
1636 /* event.name, tracefile.name, trace.name */
1637 // LTTV_FILTER_NAME = g_quark_from_string("name");
1639 /* event sub fields */
1640 // LTTV_FILTER_CATEGORY = g_quark_from_string("category");
1641 // LTTV_FILTER_TIME = g_quark_from_string("time");
1642 // LTTV_FILTER_TSC = g_quark_from_string("tsc");
1644 /* state sub fields */
1645 // LTTV_FILTER_PID = g_quark_from_string("pid");
1646 // LTTV_FILTER_PPID = g_quark_from_string("ppid");
1647 // LTTV_FILTER_C_TIME = g_quark_from_string("creation_time");
1648 // LTTV_FILTER_I_TIME = g_quark_from_string("insertion_time");
1649 // LTTV_FILTER_P_NAME = g_quark_from_string("process_name");
1650 // LTTV_FILTER_EX_MODE = g_quark_from_string("execution_mode");
1651 // LTTV_FILTER_EX_SUBMODE = g_quark_from_string("execution_submode");
1652 // LTTV_FILTER_P_STATUS = g_quark_from_string("process_status");
1653 // LTTV_FILTER_CPU = g_quark_from_string("cpu");
1658 * Destroys the filter module and specific values
1660 static void module_destroy()
1665 LTTV_MODULE("filter", "Filters traceset and events", \
1666 "Filters traceset and events specifically to user input", \
1667 module_init
, module_destroy
)