From: compudj Date: Wed, 17 Dec 2008 20:54:10 +0000 (+0000) Subject: update filter X-Git-Tag: v0.12.20~304 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6471e71fc7e58d6108576f7a9a41966df02a4ccf;p=lttv.git update filter git-svn-id: http://ltt.polymtl.ca/svn@3185 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/trunk/lttv/configure.in b/trunk/lttv/configure.in index fed74635..d73e1f06 100644 --- a/trunk/lttv/configure.in +++ b/trunk/lttv/configure.in @@ -23,7 +23,7 @@ AC_PREREQ(2.57) AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS) #AC_WITH_LTDL # not needed ? -AM_INIT_AUTOMAKE(lttv,0.12.2-15122008) +AM_INIT_AUTOMAKE(lttv,0.12.3-17122008) AM_CONFIG_HEADER(config.h) AM_PROG_LIBTOOL diff --git a/trunk/lttv/lttv/lttv/filter.c b/trunk/lttv/lttv/lttv/filter.c index 71eb619c..28252b31 100644 --- a/trunk/lttv/lttv/lttv/filter.c +++ b/trunk/lttv/lttv/lttv/filter.c @@ -30,20 +30,20 @@ * \verbatim * LttvTracefileContext{} * |->event\ - * | |->name (String, converted to GQuark) - * | |->facility (String, converted to GQuark) + * | |->name (String, converted to GQuark) (channel.event) + * | |->subname (String, converted to GQuark) * | |->category (String, not yet implemented) * | |->time (LttTime) * | |->tsc (LttCycleCount --> uint64) * | |->target_pid (target PID of the event) * | |->fields - * | |->"facility_name + * | |->"channel name" * | |->"event name" * | |->"field name" * | |->"sub-field name" * | |->... * | |->"leaf-field name" (field type) - * |->tracefile + * |->channel (or tracefile) * | |->name (String, converted to GQuark) * |->trace * | |->name (String, converted to GQuark) @@ -168,10 +168,12 @@ lttv_simple_expression_assign_field(GPtrArray* fp, LttvSimpleExpression* se) { /* * FIXME: not yet implemented ! */ - } else if(!g_strcasecmp(f->str,"tracefile") ) { + } else if(!g_strcasecmp(f->str,"tracefile") + || !g_strcasecmp(f->str,"channel") ) { /* * Possible values: * tracefile.name + * channel.name */ g_string_free(f,TRUE); f=ltt_g_ptr_array_remove_index_slow(fp,0); @@ -228,6 +230,7 @@ lttv_simple_expression_assign_field(GPtrArray* fp, LttvSimpleExpression* se) { /* * Possible values: * event.name + * event.channel * event.category * event.time * event.tsc @@ -240,6 +243,9 @@ lttv_simple_expression_assign_field(GPtrArray* fp, LttvSimpleExpression* se) { if(!g_strcasecmp(f->str,"name") ) { se->field = LTTV_FILTER_EVENT_NAME; } + else if(!g_strcasecmp(f->str,"subname") ) { + se->field = LTTV_FILTER_EVENT_SUBNAME; + } else if(!g_strcasecmp(f->str,"category") ) { /* * FIXME: Category not yet functional in lttv @@ -305,7 +311,7 @@ lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionO case LTTV_FILTER_TRACEFILE_NAME: case LTTV_FILTER_STATE_P_NAME: case LTTV_FILTER_STATE_T_BRAND: - case LTTV_FILTER_EVENT_NAME: + case LTTV_FILTER_EVENT_SUBNAME: case LTTV_FILTER_STATE_EX_MODE: case LTTV_FILTER_STATE_EX_SUBMODE: case LTTV_FILTER_STATE_P_STATUS: @@ -321,6 +327,21 @@ lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionO return FALSE; } break; + /* + * two strings. + */ + case LTTV_FILTER_EVENT_NAME: + switch(op) { + case LTTV_FIELD_EQ: + se->op = lttv_apply_op_eq_quarks; + break; + case LTTV_FIELD_NE: + se->op = lttv_apply_op_ne_quarks; + break; + default: + g_warning("Error encountered in operator assignment = or != expected"); + return FALSE; + } /* * integer */ @@ -467,7 +488,7 @@ lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) { case LTTV_FILTER_TRACEFILE_NAME: case LTTV_FILTER_STATE_P_NAME: case LTTV_FILTER_STATE_T_BRAND: - case LTTV_FILTER_EVENT_NAME: + case LTTV_FILTER_EVENT_SUBNAME: case LTTV_FILTER_STATE_EX_MODE: case LTTV_FILTER_STATE_EX_SUBMODE: case LTTV_FILTER_STATE_P_STATUS: @@ -475,6 +496,25 @@ lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) { se->value.v_quark = g_quark_from_string(value); g_free(value); break; + /* + * Two strings. + */ + case LTTV_FILTER_EVENT_NAME: + { + /* channel.event */ + char *end = strchr(value, '.'); + if (end) { + *end = '\0'; + end++; + se->value.v_quarks.q[0] = g_quark_from_string(value); + se->value.v_quarks.q[1] = g_quark_from_string(end); + } else { + se->value.v_quarks.q[0] = (GQuark)0; + se->value.v_quarks.q[1] = g_quark_from_string(value); + } + g_free(value); + } + break; /* * integer -- supposed to be uint64 */ @@ -583,7 +623,7 @@ lttv_struct_type(gint ft) { case LTTV_FILTER_STATE_CT: case LTTV_FILTER_STATE_IT: case LTTV_FILTER_STATE_P_NAME: - case LTTV_FILTER_STATE_T_BRAND: + case LTTV_FILTER_STATE_T_BRAND: case LTTV_FILTER_STATE_EX_MODE: case LTTV_FILTER_STATE_EX_SUBMODE: case LTTV_FILTER_STATE_P_STATUS: @@ -591,6 +631,7 @@ lttv_struct_type(gint ft) { return LTTV_FILTER_STATE; break; case LTTV_FILTER_EVENT_NAME: + case LTTV_FILTER_EVENT_SUBNAME: case LTTV_FILTER_EVENT_CATEGORY: case LTTV_FILTER_EVENT_TIME: case LTTV_FILTER_EVENT_TSC: @@ -705,6 +746,25 @@ gboolean lttv_apply_op_eq_quark(const gpointer v1, LttvFieldValue v2) { return (*r == v2.v_quark); } +/** + * @fn gboolean lttv_apply_op_eq_quarks(gpointer,LttvFieldValue) + * + * Applies the 'equal' operator to the + * specified structure and value + * @param v1 left member of comparison + * @param v2 right member of comparison + * @return success/failure of operation + */ +gboolean lttv_apply_op_eq_quarks(const gpointer v1, LttvFieldValue v2) { + GQuark *r1 = (GQuark *) v1; + GQuark *r2 = r1 + 1; + if (likely(*r1 != (GQuark)0) && *r1 != v2.v_quarks.q[0]) + return 0; + if (*r2 != v2.v_quarks.q[1]) + return 0; + return 1; +} + /** * @fn gboolean lttv_apply_op_eq_ltttime(gpointer,LttvFieldValue) * @@ -817,6 +877,23 @@ gboolean lttv_apply_op_ne_quark(const gpointer v1, LttvFieldValue v2) { return (*r != v2.v_quark); } +/** + * @fn gboolean lttv_apply_op_ne_quarks(gpointer,LttvFieldValue) + * + * Applies the 'equal' operator to the + * specified structure and value + * @param v1 left member of comparison + * @param v2 right member of comparison + * @return success/failure of operation + */ +gboolean lttv_apply_op_ne_quarks(const gpointer v1, LttvFieldValue v2) { + GQuark *r1 = (GQuark *) v1; + GQuark *r2 = r1 + 1; + if ((*r1 == (GQuark)0 || *r1 == v2.v_quarks.q[0]) && *r2 == v2.v_quarks.q[1]) + return 0; + else + return 1; +} /** * @fn gboolean lttv_apply_op_ne_ltttime(gpointer,LttvFieldValue) @@ -2044,6 +2121,19 @@ lttv_filter_tree_parse_branch( } break; case LTTV_FILTER_EVENT_NAME: + if(event == NULL) return TRUE; + else { + struct marker_info *info; + GQuark qtuple[2]; + LttTracefile *tf = context->tf; + qtuple[0] = ltt_tracefile_name(tracefile); + info = marker_get_info_from_id(tf->mdata, event->event_id); + g_assert(info != NULL); + qtuple[1] = info->name; + return se->op((gpointer)qtuple,v); + } + break; + case LTTV_FILTER_EVENT_SUBNAME: if(event == NULL) return TRUE; else { struct marker_info *info; diff --git a/trunk/lttv/lttv/lttv/filter.h b/trunk/lttv/lttv/lttv/filter.h index 49d97981..d942752d 100644 --- a/trunk/lttv/lttv/lttv/filter.h +++ b/trunk/lttv/lttv/lttv/filter.h @@ -110,6 +110,7 @@ enum _LttvFieldType { LTTV_FILTER_STATE_P_STATUS, /**< state.process_status (LttvProcessStatus) */ LTTV_FILTER_STATE_CPU, /**< state.cpu (?last_cpu?) */ LTTV_FILTER_EVENT_NAME, /**< event.name (char*) */ + LTTV_FILTER_EVENT_SUBNAME, /**< event.subname (char*) */ LTTV_FILTER_EVENT_CATEGORY, /**< FIXME: not implemented */ LTTV_FILTER_EVENT_TIME, /**< event.time (double) */ LTTV_FILTER_EVENT_TSC, /**< event.tsc (double) */ @@ -156,6 +157,9 @@ union _LttvFieldValue { double v_double; /**< double */ char* v_string; /**< string */ LttTime v_ltttime; /**< LttTime */ + struct { + GQuark q[2]; + } v_quarks; }; /** @@ -268,6 +272,7 @@ gboolean lttv_apply_op_eq_uint16(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_eq_double(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_eq_string(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_eq_quark(const gpointer v1, LttvFieldValue v2); +gboolean lttv_apply_op_eq_quarks(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_eq_ltttime(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_ne_uint(const gpointer v1, LttvFieldValue v2); @@ -277,6 +282,7 @@ gboolean lttv_apply_op_ne_uint16(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_ne_double(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_ne_string(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_ne_quark(const gpointer v1, LttvFieldValue v2); +gboolean lttv_apply_op_ne_quarks(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_ne_ltttime(const gpointer v1, LttvFieldValue v2); gboolean lttv_apply_op_lt_uint(const gpointer v1, LttvFieldValue v2); diff --git a/trunk/lttv/lttv/lttv/print.c b/trunk/lttv/lttv/lttv/print.c index c9099064..b5f02a0c 100644 --- a/trunk/lttv/lttv/lttv/print.c +++ b/trunk/lttv/lttv/lttv/print.c @@ -264,7 +264,8 @@ void lttv_event_to_string(LttEvent *e, GString *s, if(mandatory_fields) { time = ltt_event_time(e); - g_string_append_printf(s,"%s: %ld.%09ld (%s/%s_%u)", + g_string_append_printf(s,"%s.%s: %ld.%09ld (%s/%s_%u)", + g_quark_to_string(ltt_tracefile_name(tfs->parent.tf)), g_quark_to_string(info->name), (long)time.tv_sec, time.tv_nsec, g_quark_to_string( diff --git a/trunk/lttv/lttv/modules/gui/filter/filter.c b/trunk/lttv/lttv/modules/gui/filter/filter.c index 66108652..60e17839 100644 --- a/trunk/lttv/lttv/modules/gui/filter/filter.c +++ b/trunk/lttv/lttv/modules/gui/filter/filter.c @@ -187,7 +187,7 @@ gui_filter(LttvPlugin *plugin) fvd->f_field_options = g_ptr_array_new(); //g_array_new(FALSE,FALSE,16); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.name")); - g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.facility")); + g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.subname")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.category")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.time")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.tsc")); @@ -195,7 +195,7 @@ gui_filter(LttvPlugin *plugin) /* * TODO: Add core.xml fields here ! */ - g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("tracefile.name")); + g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("channel.name")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("trace.name")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.process_name")); g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("state.thread_brand")); diff --git a/trunk/lttv/lttv/modules/text/textFilter.c b/trunk/lttv/lttv/modules/text/textFilter.c index 4590a76a..27425201 100644 --- a/trunk/lttv/lttv/modules/text/textFilter.c +++ b/trunk/lttv/lttv/modules/text/textFilter.c @@ -128,14 +128,14 @@ void filter_list_commands(void *hook_data) { g_print("[field] [op] [value]\n\n"); g_print("*** Possible fields ***\n"); - g_print("event.name (string)\n"); - g_print("event.facility (string)\n"); + g_print("event.name (string) (channel_name.event_name)\n"); + g_print("event.subname (string)\n"); g_print("event.category (string)\n"); g_print("event.time (double)\n"); g_print("event.tsc (integer)\n"); g_print("event.target_pid (integer)\n"); - g_print("event.field.facility_name.event_name.field_name.subfield_name (field_type)\n"); - g_print("tracefile.name (string)\n"); + g_print("event.field.channel_name.event_name.field_name.subfield_name (field_type)\n"); + g_print("channel.name (string)\n"); g_print("trace.name (string)\n"); g_print("state.pid (integer)\n"); g_print("state.ppid (integer)\n");