exec fix
[lttv.git] / ltt / branches / poly / lttv / lttv / filter.c
index efe6bd64a0876939949f87e9a78a6108a58f86d9..697779a60c30246a0443c9cc146b7d85dd626526 100644 (file)
@@ -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"
@@ -210,6 +211,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);
@@ -232,6 +234,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);
@@ -333,6 +338,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;
@@ -466,6 +472,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;
@@ -572,6 +579,7 @@ lttv_struct_type(gint ft) {
         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;
@@ -1825,7 +1833,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
         /*,...*/) 
 {
 
@@ -1866,18 +1876,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);
@@ -1894,7 +1910,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);
@@ -1987,7 +2003,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;
@@ -2007,10 +2023,9 @@ 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:
@@ -2051,6 +2066,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 
This page took 0.025984 seconds and 4 git commands to generate.