X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Flttv%2Ffilter.c;h=f62755868f27f8958e4b13989556d2ef6effd5d1;hb=0305fe774206ec12a98378be3cf891446b1b901c;hp=360cb3aa859fb357b32ee1a714f1f2157158c48c;hpb=571ef1ede7dd64ec88d31115069a4fb3c407764d;p=lttv.git diff --git a/ltt/branches/poly/lttv/lttv/filter.c b/ltt/branches/poly/lttv/lttv/filter.c index 360cb3aa..f6275586 100644 --- a/ltt/branches/poly/lttv/lttv/filter.c +++ b/ltt/branches/poly/lttv/lttv/filter.c @@ -35,6 +35,7 @@ * | |->category (String, not yet implemented) * | |->time (LttTime) * | |->tsc (LttCycleCount --> uint64) + * | |->target_pid (target PID of the event) * | |->fields * | |->"facility_name * | |->"event name" @@ -79,8 +80,6 @@ #include #include #include -#include -#include #include #include @@ -210,6 +209,7 @@ lttv_simple_expression_assign_field(GPtrArray* fp, LttvSimpleExpression* se) { * event.category * event.time * event.tsc + * event.target_pid * event.field */ g_string_free(f,TRUE); @@ -217,9 +217,6 @@ 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,"facility") ) { - se->field = LTTV_FILTER_EVENT_FACILITY; - } else if(!g_strcasecmp(f->str,"category") ) { /* * FIXME: Category not yet functional in lttv @@ -232,6 +229,9 @@ lttv_simple_expression_assign_field(GPtrArray* fp, LttvSimpleExpression* se) { else if(!g_strcasecmp(f->str,"tsc") ) { se->field = LTTV_FILTER_EVENT_TSC; } + else if(!g_strcasecmp(f->str,"target_pid") ) { + se->field = LTTV_FILTER_EVENT_TARGET_PID; + } else if(!g_strcasecmp(f->str,"field") ) { se->field = LTTV_FILTER_EVENT_FIELD; g_string_free(f,TRUE); @@ -283,7 +283,6 @@ lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionO case LTTV_FILTER_STATE_P_NAME: case LTTV_FILTER_STATE_T_BRAND: case LTTV_FILTER_EVENT_NAME: - case LTTV_FILTER_EVENT_FACILITY: case LTTV_FILTER_STATE_EX_MODE: case LTTV_FILTER_STATE_EX_SUBMODE: case LTTV_FILTER_STATE_P_STATUS: @@ -333,6 +332,7 @@ lttv_simple_expression_assign_operator(LttvSimpleExpression* se, LttvExpressionO case LTTV_FILTER_STATE_CPU: case LTTV_FILTER_STATE_PID: case LTTV_FILTER_STATE_PPID: + case LTTV_FILTER_EVENT_TARGET_PID: switch(op) { case LTTV_FIELD_EQ: se->op = lttv_apply_op_eq_uint; @@ -445,7 +445,6 @@ lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) { case LTTV_FILTER_STATE_P_NAME: case LTTV_FILTER_STATE_T_BRAND: case LTTV_FILTER_EVENT_NAME: - case LTTV_FILTER_EVENT_FACILITY: case LTTV_FILTER_STATE_EX_MODE: case LTTV_FILTER_STATE_EX_SUBMODE: case LTTV_FILTER_STATE_P_STATUS: @@ -466,6 +465,7 @@ lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) { case LTTV_FILTER_STATE_PID: case LTTV_FILTER_STATE_PPID: case LTTV_FILTER_STATE_CPU: + case LTTV_FILTER_EVENT_TARGET_PID: se->value.v_uint = atoi(value); g_free(value); break; @@ -502,7 +502,6 @@ lttv_simple_expression_assign_value(LttvSimpleExpression* se, char* value) { g_string_free(v,TRUE); se->value.v_ltttime = t; - //g_error("Filter TEST ltttime : %u, %u.", t.tv_sec, t.tv_nsec); g_free(value); break; default: @@ -569,10 +568,10 @@ lttv_struct_type(gint ft) { return LTTV_FILTER_STATE; break; case LTTV_FILTER_EVENT_NAME: - case LTTV_FILTER_EVENT_FACILITY: case LTTV_FILTER_EVENT_CATEGORY: case LTTV_FILTER_EVENT_TIME: case LTTV_FILTER_EVENT_TSC: + case LTTV_FILTER_EVENT_TARGET_PID: case LTTV_FILTER_EVENT_FIELD: return LTTV_FILTER_EVENT; break; @@ -1337,15 +1336,15 @@ lttv_filter_update(LttvFilter* filter) { i++; } break; - case '\"': + case '\"': nest_quotes = 0; - i++; + i++; break; } if(a_string_spaces->len != 0) { a_field_component = g_string_append( a_field_component, a_string_spaces->str); - a_string_spaces = g_string_set_size(a_string_spaces, 0); + a_string_spaces = g_string_set_size(a_string_spaces, 0); } a_field_component = g_string_append_c(a_field_component, filter->expression[i]); @@ -1591,10 +1590,13 @@ lttv_filter_update(LttvFilter* filter) { a_field_component = g_string_new(""); g_string_free(a_string_spaces, TRUE); a_string_spaces = g_string_new(""); + } else { + /* Operator found, we are in the value field */ + g_string_append_c(a_field_component, filter->expression[i]); } break; case ' ': /* keep spaces that are within a field component */ - if(a_field_component->len == 0) break; /* ignore */ + if(a_field_component->len == 0) break; /* ignore */ else a_string_spaces = g_string_append_c(a_string_spaces, filter->expression[i]); @@ -1606,9 +1608,9 @@ lttv_filter_update(LttvFilter* filter) { break; default: /* concatening current string */ if(a_string_spaces->len != 0) { - a_field_component = g_string_append( + a_field_component = g_string_append( a_field_component, a_string_spaces->str); - a_string_spaces = g_string_set_size(a_string_spaces, 0); + a_string_spaces = g_string_set_size(a_string_spaces, 0); } a_field_component = g_string_append_c(a_field_component, filter->expression[i]); @@ -1823,7 +1825,9 @@ lttv_filter_tree_parse( const LttEvent* event, const LttTracefile* tracefile, const LttTrace* trace, - const LttvTracefileContext* context + const LttvTracefileContext* context, + const LttvProcessState* state, + const LttvTraceContext* tc /*,...*/) { @@ -1864,18 +1868,24 @@ lttv_filter_tree_parse( gboolean lresult = FALSE, rresult = FALSE; - LttvProcessState* state; - - LttvTraceState *ts = (LttvTraceState*)context->t_context; + LttvTraceState *ts; LttvTracefileState *tfs = (LttvTracefileState*)context; - guint cpu = tfs->cpu; - state = ts->running_process[cpu]; + if(tc) + ts = (LttvTraceState*)tc; + else if(context) + ts = (LttvTraceState*)context->t_context; + + if(tfs) { + guint cpu = tfs->cpu; + if(ts) + state = ts->running_process[cpu]; + } /* * Parse left branch */ if(t->left == LTTV_TREE_NODE) { - lresult = lttv_filter_tree_parse(t->l_child.t,event,tracefile,trace,context); + lresult = lttv_filter_tree_parse(t->l_child.t,event,tracefile,trace,context,NULL,NULL); } else if(t->left == LTTV_TREE_LEAF) { lresult = lttv_filter_tree_parse_branch(t->l_child.leaf,event,tracefile,trace,state,context); @@ -1892,7 +1902,7 @@ lttv_filter_tree_parse( * Parse right branch */ if(t->right == LTTV_TREE_NODE) { - rresult = lttv_filter_tree_parse(t->r_child.t,event,tracefile,trace,context); + rresult = lttv_filter_tree_parse(t->r_child.t,event,tracefile,trace,context,NULL,NULL); } else if(t->right == LTTV_TREE_LEAF) { rresult = lttv_filter_tree_parse_branch(t->r_child.leaf,event,tracefile,trace,state,context); @@ -1985,7 +1995,7 @@ lttv_filter_tree_parse_branch( return se->op((gpointer)&quark,v); } break; - case LTTV_FILTER_STATE_T_BRAND: + case LTTV_FILTER_STATE_T_BRAND: if(state == NULL) return TRUE; else { GQuark quark = state->brand; @@ -2005,27 +2015,18 @@ lttv_filter_tree_parse_branch( else return se->op((gpointer)&state->state->s,v); break; case LTTV_FILTER_STATE_CPU: - if(context == NULL) return TRUE; + if(state == NULL) return TRUE; else { - if(state == NULL) return TRUE; - else return se->op((gpointer)&state->cpu,v); + return se->op((gpointer)&state->cpu,v); } break; case LTTV_FILTER_EVENT_NAME: if(event == NULL) return TRUE; else { - LttEventType* et; - et = ltt_event_eventtype(event); - GQuark quark = ltt_eventtype_name(et); - return se->op((gpointer)&quark,v); - } - break; - case LTTV_FILTER_EVENT_FACILITY: - if(event == NULL) return TRUE; - else { - LttFacility* fac; - fac = ltt_event_facility(event); - GQuark quark = ltt_facility_name(fac); + struct marker_info *info; + info = marker_get_info_from_id((LttTrace *)trace, event->event_id); + g_assert(info != NULL); + GQuark quark = info->name; return se->op((gpointer)&quark,v); } break; @@ -2049,6 +2050,14 @@ lttv_filter_tree_parse_branch( return se->op((gpointer)&count,v); } break; + case LTTV_FILTER_EVENT_TARGET_PID: + if(context == NULL) return TRUE; + else { + guint target_pid = + lttv_state_get_target_pid((LttvTracefileState*)context); + return se->op((gpointer)&target_pid,v); + } + break; case LTTV_FILTER_EVENT_FIELD: /* * TODO: Use the offset to