From 1a7fa6824f9bd614ff78181c96d239b322411d7f Mon Sep 17 00:00:00 2001 From: siboud Date: Wed, 16 Feb 2005 18:55:26 +0000 Subject: [PATCH] compilation of work done on tuesday on the filter core/text module. git-svn-id: http://ltt.polymtl.ca/svn@873 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/filter.c | 64 +++++++++++++------ ltt/branches/poly/lttv/lttv/filter.h | 37 +++++++---- .../poly/lttv/modules/text/textFilter.c | 5 +- 3 files changed, 72 insertions(+), 34 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/filter.c b/ltt/branches/poly/lttv/lttv/filter.c index d2f62d81..aa29b2c5 100644 --- a/ltt/branches/poly/lttv/lttv/filter.c +++ b/ltt/branches/poly/lttv/lttv/filter.c @@ -25,7 +25,6 @@ /* * YET TO BE ANSWERED - * - should the filter be implemented as a module * - should all the structures and field types be associated with GQuarks */ @@ -54,6 +53,13 @@ path(component...) -> field */ +GQuark + LTTV_FILTER_TRACE, + LTTV_FILTER_TRACESET, + LTTV_FILTER_TRACEFILE, + LTTV_FILTER_STATE, + LTTV_FILTER_EVENT; + /** * Parse through filtering field hierarchy as specified * by user. This function compares each value to @@ -67,21 +73,21 @@ parse_field_path(GList* fp) { GString* f = g_list_first(fp)->data; switch(g_quark_try_string(f->str)) { -// case LTTV_FILTER_TRACE: + case LTTV_FILTER_TRACE: -// break; -// case LTTV_FILTER_TRACEFILE: + break; + case LTTV_FILTER_TRACEFILE: -// break; -// case LTTV_FILTER_TRACESET: + break; + case LTTV_FILTER_TRACESET: -// break; -// case LTTV_FILTER_STATE: + break; + case LTTV_FILTER_STATE: -// break; -// case LTTV_FILTER_EVENT: + break; + case LTTV_FILTER_EVENT: -// break; + break; default: /* Quark value unrecognized or equal to 0 */ g_warning("Unrecognized field in filter string"); return FALSE; @@ -120,12 +126,7 @@ lttv_filter_new(char *expression, LttvTraceState *tcs) { p=0, /* parenthesis nesting value */ b=0; /* current breakpoint in expression string */ - LTTV_FILTER_EVENT = g_quark_from_string("event"); - LTTV_FILTER_TRACE = g_quark_from_string("trace"); - LTTV_FILTER_TRACESET = g_quark_from_string("traceset"); - LTTV_FILTER_STATE = g_quark_from_string("state"); - LTTV_FILTER_TRACEFILE = g_quark_from_string("tracefile"); - + gpointer tree = NULL; /* temporary values */ @@ -177,7 +178,7 @@ lttv_filter_new(char *expression, LttvTraceState *tcs) { i++; } else { /* ! */ g_print("%s\n",a_field_component); - current_option = g_string_new(""); + a_field_component = g_string_new(""); } break; case '(': /* start of parenthesis */ @@ -213,7 +214,7 @@ lttv_filter_new(char *expression, LttvTraceState *tcs) { a_field_component = g_string_new(""); break; default: /* concatening current string */ - g_string_append_c(current_option,expression[i]); + g_string_append_c(a_field_component,expression[i]); } } @@ -263,6 +264,9 @@ lttv_filter_tracefile(lttv_filter *filter, LttTracefile *tracefile) { */ } +gboolean +lttv_filter_tracestate(lttv_filter *filter, LttvTraceState *tracestate) {} + /** * Apply the filter to a specific event * @param filter the current filter applied @@ -273,3 +277,25 @@ gboolean lttv_filter_event(lttv_filter *filter, LttEvent *event) { } + +static void module_init() +{ + LTTV_FILTER_EVENT = g_quark_from_string("event"); + LTTV_FILTER_TRACE = g_quark_from_string("trace"); + LTTV_FILTER_TRACESET = g_quark_from_string("traceset"); + LTTV_FILTER_STATE = g_quark_from_string("state"); + LTTV_FILTER_TRACEFILE = g_quark_from_string("tracefile"); + +} + +static void module_destroy() +{ +} + + +LTTV_MODULE("filter", "Filter state & event", \ + "Filters the current tracestate and events from user expression", \ + module_init, module_destroy) + + + diff --git a/ltt/branches/poly/lttv/lttv/filter.h b/ltt/branches/poly/lttv/lttv/filter.h index 99f3c403..d405a09a 100644 --- a/ltt/branches/poly/lttv/lttv/filter.h +++ b/ltt/branches/poly/lttv/lttv/filter.h @@ -52,7 +52,7 @@ */ -static GQuark +extern GQuark LTTV_FILTER_TRACE, LTTV_FILTER_TRACESET, LTTV_FILTER_TRACEFILE, @@ -85,22 +85,31 @@ typedef struct _lttv_simple_expression char *value; } lttv_simple_expression; - -//typedef union _tmp { -// struct lttv_expression *e; -// lttv_field_relation *se; -//} tmp; +typedef enum _lttv_logical_op { + OR = 1, + AND = 1<<1, + NOT = 1<<2, + XOR = 1<<3 +} lttv_logical_op; + /* + * Ah .. that's my tree + */ typedef struct _lttv_expression { - gboolean or; - gboolean not; - gboolean and; - gboolean xor; - gboolean simple_expression; -// tmp e; +// gboolean or; +// gboolean not; +// gboolean and; +// gboolean xor; +// gboolean simple_expression; + lttv_logical_op op; + lttv_expression_type type; + union { + struct lttv_expression *e; + lttv_field_relation *se; /* --> simple expression */ + } e; } lttv_expression; -*/ + typedef union _lttv_expression { lttv_simple_expression se; @@ -134,6 +143,8 @@ lttv_filter *lttv_filter_new(char *expression, LttvTraceState *tfs); gboolean lttv_filter_tracefile(lttv_filter *filter, LttTracefile *tracefile); +gboolean lttv_filter_tracestate(lttv_filter *filter, LttvTraceState *tracestate); + gboolean lttv_filter_event(lttv_filter *filter, LttEvent *event); #endif // FILTER_H diff --git a/ltt/branches/poly/lttv/modules/text/textFilter.c b/ltt/branches/poly/lttv/modules/text/textFilter.c index c0e56ee1..bcca8751 100644 --- a/ltt/branches/poly/lttv/modules/text/textFilter.c +++ b/ltt/branches/poly/lttv/modules/text/textFilter.c @@ -125,7 +125,8 @@ static void init() { "filters a string issued by the user on the command line", "string", LTTV_OPT_STRING, &a_filter_string, NULL, NULL); - + // add function to call for option + a_file_name = NULL; lttv_option_add("filename", 'f', "browse the filter options contained in specified file", @@ -169,5 +170,5 @@ static void destroy() { LTTV_MODULE("textFilter", "Filters traces", \ "Filter the trace following commands issued by user input", \ - init, destroy, "batchAnalysis", "option") + init, destroy, "option") -- 2.34.1