From 18d1226ff771cccf7bc739f980b3412d5edb82b0 Mon Sep 17 00:00:00 2001 From: siboud Date: Fri, 25 Feb 2005 22:22:11 +0000 Subject: [PATCH] Continued implementation of lttv_filter_tree ! parsing of expression and construction of tree can now be done. However, more debugging and generalisation of parsing expression could be applied to the current tree. git-svn-id: http://ltt.polymtl.ca/svn@877 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/filter.c | 90 ++++++++++++++----- .../lttv/modules/gui/filter/.deps/filter.Plo | 32 ++++--- .../poly/lttv/modules/text/textFilter.c | 17 ++-- 3 files changed, 100 insertions(+), 39 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/filter.c b/ltt/branches/poly/lttv/lttv/filter.c index 7bfcc259..ec457eb8 100644 --- a/ltt/branches/poly/lttv/lttv/filter.c +++ b/ltt/branches/poly/lttv/lttv/filter.c @@ -175,11 +175,11 @@ lttv_filter_new(char *expression, LttvTraceState *tcs) { * will be the one created at the root of * the list */ - lttv_filter_tree* tree = NULL; + lttv_filter_tree* tree = lttv_filter_tree_new(); lttv_filter_tree* subtree = NULL; - lttv_filter_tree* current_tree = NULL; - GPtrArray *tree_list = g_ptr_array_new(); - g_ptr_array_add( tree_list,(gpointer) tree ); +// lttv_filter_tree* current_tree = NULL; + GPtrArray *tree_stack = g_ptr_array_new(); + g_ptr_array_add( tree_stack,(gpointer) tree ); /* temporary values */ GString *a_field_component = g_string_new(""); @@ -201,29 +201,56 @@ lttv_filter_new(char *expression, LttvTraceState *tcs) { * O(n) complexity order. */ + /* + * When encountering logical op &,|,^ + * 1. parse the last value if any + * 2. create a new tree + * 3. add the expression (simple exp, or exp (subtree)) to the tree + * 4. concatenate this tree with the current tree on top of the stack + * When encountering math ops >,>=,<,<=,=,!= + * 1. add to op to the simple expression + * 2. concatenate last field component to field path + * When encountering concatening ops . + * 1. concatenate last field component to field path + * When encountering opening parenthesis (,{,[ + * 1. create a new subtree on top of tree stack + * When encountering closing parenthesis ),},] + * 1. add the expression on right child of the current tree + * 2. the subtree is completed, allocate a new subtree + * 3. pop the tree value from the tree stack + */ + a_field_path = g_ptr_array_new(); g_ptr_array_set_size(a_field_path,2); /* by default, recording 2 field expressions */ + lttv_filter_tree *t1, *t2; + for(i=0;istr); +// g_print("%s\n",a_field_component->str); + g_print("%c\n",expression[i]); switch(expression[i]) { /* * logical operators */ case '&': /* and */ - a_simple_expression.value = a_field_component->str; - a_field_component = g_string_new(""); - lttv_filter_tree* t; - t = lttv_filter_tree_new(); - t->node->type = LTTV_EXPRESSION_OP; - t->node->e.op = LTTV_LOGICAL_AND; + t1 = g_ptr_array_index(tree_stack,tree_stack->len-1); + while(t1->right != LTTV_TREE_UNDEFINED) t1 = t1->r_child.t; + t2 = lttv_filter_tree_new(); + t2->node->type = LTTV_EXPRESSION_OP; + t2->node->e.op = LTTV_LOGICAL_AND; if(subtree != NULL) { - t->left = LTTV_TREE_NODE; - t->l_child.t = subtree; + t2->left = LTTV_TREE_NODE; + t2->l_child.t = subtree; subtree = NULL; + t1->right = LTTV_TREE_NODE; + t1->l_child.t = t2; } else { - t->left = LTTV_TREE_LEAF; - t->l_child.leaf = g_new(lttv_simple_expression,1); + a_simple_expression.value = a_field_component->str; + a_field_component = g_string_new(""); + t2->left = LTTV_TREE_LEAF; + t2->l_child.leaf = g_new(lttv_simple_expression,1); + t1->right = LTTV_TREE_NODE; + t1->l_child.t = t2; } break; @@ -245,19 +272,40 @@ lttv_filter_new(char *expression, LttvTraceState *tcs) { case '{': p_nesting++; /* incrementing parenthesis nesting value */ lttv_filter_tree* subtree = lttv_filter_tree_new(); - g_ptr_array_add( tree_list,(gpointer) subtree ); + g_ptr_array_add( tree_stack,(gpointer) subtree ); break; case ')': /* end of parenthesis */ case ']': case '}': p_nesting--; /* decrementing parenthesis nesting value */ - a_simple_expression.value = a_field_component->str; - a_field_component = g_string_new(""); - if(p_nesting<0 || tree_list->len<2) { + if(p_nesting<0 || tree_stack->len<2) { g_warning("Wrong filtering options, the string\n\"%s\"\n\ is not valid due to parenthesis incorrect use",expression); return NULL; } + + g_assert(tree_stack->len>0); + if(subtree != NULL) { + t1 = g_ptr_array_index(tree_stack,tree_stack->len-1); + /* FIXME ==> SEG FAULT */ + while(t1->right != LTTV_TREE_UNDEFINED && t1->right != LTTV_TREE_LEAF) { + g_assert(t1!=NULL && t1->r_child.t != NULL); + t1 = t1->r_child.t; + } + t1->right = LTTV_TREE_NODE; + t1->r_child.t = subtree; + subtree = g_ptr_array_index(tree_stack,tree_stack->len-1); + g_ptr_array_remove_index(tree_stack,tree_stack->len-1); + } else { + a_simple_expression.value = a_field_component->str; + a_field_component = g_string_new(""); + t1 = g_ptr_array_index(tree_stack,tree_stack->len-1); + while(t1->right != LTTV_TREE_UNDEFINED) t1 = t1->r_child.t; + t1->right = LTTV_TREE_LEAF; + t1->r_child.leaf = g_new(lttv_simple_expression,1); + subtree = g_ptr_array_index(tree_stack,tree_stack->len-1); + g_ptr_array_remove_index(tree_stack,tree_stack->len-1); + } /* lttv_filter_tree *sub1 = g_ptr_array_index(tree_list,tree_list->len-1); lttv_filter_tree *sub2 = g_ptr_array_index(tree_list,tree_list->len); if(sub1->left == LTTV_TREE_UNDEFINED){ @@ -270,8 +318,8 @@ lttv_filter_new(char *expression, LttvTraceState *tcs) { g_ptr_array_remove_index(tree_list,tree_list->len); break; */ - subtree = g_ptr_array_index(tree_list,tree_list->len); - g_ptr_array_remove_index(tree_list,tree_list->len); + // subtree = g_ptr_array_index(tree_stack,tree_stack->len); + // g_ptr_array_remove_index(tree_stack,tree_stack->len); break; /* diff --git a/ltt/branches/poly/lttv/modules/gui/filter/.deps/filter.Plo b/ltt/branches/poly/lttv/modules/gui/filter/.deps/filter.Plo index a78cdee5..e1957564 100644 --- a/ltt/branches/poly/lttv/modules/gui/filter/.deps/filter.Plo +++ b/ltt/branches/poly/lttv/modules/gui/filter/.deps/filter.Plo @@ -3,14 +3,14 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/glib-2.0/glib/gtypes.h \ /usr/lib/glib-2.0/include/glibconfig.h \ /usr/include/glib-2.0/glib/gmacros.h \ - /usr/lib/gcc-lib/i486-linux/3.3.5/include/stddef.h \ - /usr/lib/gcc-lib/i486-linux/3.3.5/include/limits.h \ - /usr/lib/gcc-lib/i486-linux/3.3.5/include/syslimits.h \ + /usr/lib/gcc/i386-redhat-linux/3.4.2/include/stddef.h \ + /usr/lib/gcc/i386-redhat-linux/3.4.2/include/limits.h \ + /usr/lib/gcc/i386-redhat-linux/3.4.2/include/syslimits.h \ /usr/include/limits.h /usr/include/features.h /usr/include/sys/cdefs.h \ /usr/include/gnu/stubs.h /usr/include/bits/posix1_lim.h \ /usr/include/bits/local_lim.h /usr/include/linux/limits.h \ /usr/include/bits/posix2_lim.h \ - /usr/lib/gcc-lib/i486-linux/3.3.5/include/float.h \ + /usr/lib/gcc/i386-redhat-linux/3.4.2/include/float.h \ /usr/include/glib-2.0/glib/garray.h \ /usr/include/glib-2.0/glib/gasyncqueue.h \ /usr/include/glib-2.0/glib/gthread.h \ @@ -30,7 +30,7 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/glib-2.0/glib/gstring.h \ /usr/include/glib-2.0/glib/gunicode.h \ /usr/include/glib-2.0/glib/gutils.h \ - /usr/lib/gcc-lib/i486-linux/3.3.5/include/stdarg.h \ + /usr/lib/gcc/i386-redhat-linux/3.4.2/include/stdarg.h \ /usr/include/glib-2.0/glib/gmarkup.h \ /usr/include/glib-2.0/glib/gmessages.h \ /usr/include/glib-2.0/glib/gnode.h \ @@ -143,6 +143,7 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/atk-1.0/atk/atknoopobjectfactory.h \ /usr/include/atk-1.0/atk/atkobjectfactory.h \ /usr/include/atk-1.0/atk/atkregistry.h \ + /usr/include/atk-1.0/atk/atkobjectfactory.h \ /usr/include/atk-1.0/atk/atkrelation.h \ /usr/include/atk-1.0/atk/atkrelationset.h \ /usr/include/atk-1.0/atk/atkselection.h \ @@ -269,7 +270,10 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/gtk-2.0/gtk/gtktextmark.h \ /usr/include/gtk-2.0/gtk/gtktextview.h \ /usr/include/gtk-2.0/gtk/gtktipsquery.h \ + /usr/include/gtk-2.0/gtk/gtktoggletoolbutton.h \ /usr/include/gtk-2.0/gtk/gtktoolbar.h \ + /usr/include/gtk-2.0/gtk/gtktoolbutton.h \ + /usr/include/gtk-2.0/gtk/gtktoolitem.h \ /usr/include/gtk-2.0/gtk/gtktree.h \ /usr/include/gtk-2.0/gtk/gtktreednd.h \ /usr/include/gtk-2.0/gtk/gtktreeitem.h \ @@ -312,11 +316,11 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/glib-2.0/glib/gmacros.h: -/usr/lib/gcc-lib/i486-linux/3.3.5/include/stddef.h: +/usr/lib/gcc/i386-redhat-linux/3.4.2/include/stddef.h: -/usr/lib/gcc-lib/i486-linux/3.3.5/include/limits.h: +/usr/lib/gcc/i386-redhat-linux/3.4.2/include/limits.h: -/usr/lib/gcc-lib/i486-linux/3.3.5/include/syslimits.h: +/usr/lib/gcc/i386-redhat-linux/3.4.2/include/syslimits.h: /usr/include/limits.h: @@ -334,7 +338,7 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/bits/posix2_lim.h: -/usr/lib/gcc-lib/i486-linux/3.3.5/include/float.h: +/usr/lib/gcc/i386-redhat-linux/3.4.2/include/float.h: /usr/include/glib-2.0/glib/garray.h: @@ -384,7 +388,7 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/glib-2.0/glib/gutils.h: -/usr/lib/gcc-lib/i486-linux/3.3.5/include/stdarg.h: +/usr/lib/gcc/i386-redhat-linux/3.4.2/include/stdarg.h: /usr/include/glib-2.0/glib/gmarkup.h: @@ -644,6 +648,8 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/atk-1.0/atk/atkregistry.h: +/usr/include/atk-1.0/atk/atkobjectfactory.h: + /usr/include/atk-1.0/atk/atkrelation.h: /usr/include/atk-1.0/atk/atkrelationset.h: @@ -914,8 +920,14 @@ filter.lo filter.o: filter.c /usr/include/glib-2.0/glib.h \ /usr/include/gtk-2.0/gtk/gtktipsquery.h: +/usr/include/gtk-2.0/gtk/gtktoggletoolbutton.h: + /usr/include/gtk-2.0/gtk/gtktoolbar.h: +/usr/include/gtk-2.0/gtk/gtktoolbutton.h: + +/usr/include/gtk-2.0/gtk/gtktoolitem.h: + /usr/include/gtk-2.0/gtk/gtktree.h: /usr/include/gtk-2.0/gtk/gtktreednd.h: diff --git a/ltt/branches/poly/lttv/modules/text/textFilter.c b/ltt/branches/poly/lttv/modules/text/textFilter.c index 17d73f60..5729634e 100644 --- a/ltt/branches/poly/lttv/modules/text/textFilter.c +++ b/ltt/branches/poly/lttv/modules/text/textFilter.c @@ -101,20 +101,21 @@ void filter_analyze_file(void *hook_data) { void filter_analyze_string(void *hook_data) { g_print("textFilter::filter_analyze_string\n"); - + + a_filter_string = g_string_new(""); /* * User may specify filtering options through static file * and/or command line string. From these sources, an * option string is rebuilded and sent to the filter core */ - if(!a_filter_string->len) { +// if(!a_filter_string->len) { g_string_append(a_filter_string,a_string); - lttv_filter_new(a_filter_string,NULL); - } - else { - g_string_append(a_filter_string,"&"); /*conjonction between expression*/ - g_string_append(a_filter_string,a_string); - } + lttv_filter_new(a_filter_string->str,NULL); +// } +// else { +// g_string_append(a_filter_string,"&"); /*conjonction between expression*/ +// g_string_append(a_filter_string,a_string); +// } } -- 2.34.1