add target pid for filtering
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 23 Jun 2006 21:51:42 +0000 (21:51 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Fri, 23 Jun 2006 21:51:42 +0000 (21:51 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1964 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/filter.c
ltt/branches/poly/lttv/lttv/filter.h
ltt/branches/poly/lttv/lttv/state.c
ltt/branches/poly/lttv/lttv/state.h
ltt/branches/poly/lttv/lttv/tracecontext.c
ltt/branches/poly/lttv/lttv/tracecontext.h
ltt/branches/poly/lttv/modules/gui/filter/filter.c
ltt/branches/poly/lttv/modules/text/textFilter.c

index efe6bd64a0876939949f87e9a78a6108a58f86d9..50e9fceadf0809c707786f07162ffd8ccf9c979f 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;
@@ -2051,6 +2059,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 
index 067277981291d406b3d58bfeec567a246219d121..b809f5a0f705601aeebe65e6984a83affa0a515e 100644 (file)
@@ -114,6 +114,7 @@ enum _LttvFieldType {
   LTTV_FILTER_EVENT_CATEGORY,         /**< FIXME: not implemented */
   LTTV_FILTER_EVENT_TIME,             /**< event.time (double) */
   LTTV_FILTER_EVENT_TSC,              /**< event.tsc (double) */
+  LTTV_FILTER_EVENT_TARGET_PID,       /**< event.target_pid (guint) */
   LTTV_FILTER_EVENT_FIELD,            /**< dynamic field, specified in facility */
   LTTV_FILTER_UNDEFINED               /**< undefined field */
 };
index af0e89720aa4e2e12fe4275c15189a2c4e7b8ffd..b7c7556f7ff6ace72fee37bb3c2345978b7f62bb 100644 (file)
@@ -1623,6 +1623,7 @@ static gboolean process_fork(void *hook_data, void *call_data)
 
   /* Child PID */
   child_pid = ltt_event_get_unsigned(e, thf->f2);
+  s->parent.target_pid = child_pid;
 
   /* Child TGID */
   if(thf->f3) child_tgid = ltt_event_get_unsigned(e, thf->f3);
@@ -1690,6 +1691,7 @@ static gboolean process_kernel_thread(void *hook_data, void *call_data)
 
   /* PID */
   pid = ltt_event_get_unsigned(e, thf->f1);
+  s->parent.target_pid = pid;
 
   process = lttv_state_find_process(ts, ANY_CPU, pid);
   es = &g_array_index(process->execution_stack, LttvExecutionState, 0);
@@ -1711,6 +1713,7 @@ static gboolean process_exit(void *hook_data, void *call_data)
   LttvProcessState *process; // = ts->running_process[cpu];
 
   pid = ltt_event_get_unsigned(e, thf->f1);
+  s->parent.target_pid = pid;
 
   // FIXME : Add this test in the "known state" section
   // g_assert(process->pid == pid);
@@ -1733,6 +1736,7 @@ static gboolean process_free(void *hook_data, void *call_data)
 
   /* PID of the process to release */
   release_pid = ltt_event_get_unsigned(e, thf->f1);
+  s->parent.target_pid = release_pid;
   
   g_assert(release_pid != 0);
 
index f1e3f6d187ef0823dc2858b679b67ce93d45c630..c97c6c15d4297b5a6b6c3618bc22183cf1231ff3 100644 (file)
@@ -227,6 +227,7 @@ typedef struct _LttvProcessState {
   GArray *user_stack;          /* User space function call stack */
   guint64  current_function;
   LttvProcessType type;        /* kernel thread or user space ? */
+  guint target_pid; /* target PID of the current event. */
 } LttvProcessState;
 
 #define ANY_CPU 0 /* For clarity sake : a call to lttv_state_find_process for
@@ -337,5 +338,15 @@ struct _LttvTracefileStateClass {
 
 GType lttv_tracefile_state_get_type (void);
 
+static inline guint lttv_state_get_target_pid(LttvTracefileState *tfs)
+{
+  LttvTraceState *ts = (LttvTraceState*)tfs->parent.t_context;
+  guint cpu = tfs->cpu;
+  LttvProcessState *process = ts->running_process[cpu];
+
+  if(tfs->parent.target_pid) return tfs->parent.target_pid;
+  else return process->pid;
+}
+
 
 #endif // STATE_H
index 3d28927dcbb87ed6dac1d20d1b372b36e18b40aa..c800b924d1114c91be7fc564d7d29165a9d7a5f6 100644 (file)
@@ -171,6 +171,7 @@ static void init_tracefile_context(LttTracefile *tracefile,
   tfc->event = lttv_hooks_new();
   tfc->event_by_id = lttv_hooks_by_id_new();
   tfc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
+  tfc->target_pid = 0;
 }
 
 
@@ -767,6 +768,7 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self,
     fac_id = ltt_event_facility_id(e);
     ev_id = ltt_event_eventtype_id(e);
     id = GET_HOOK_ID(fac_id, ev_id);
+    tfc->target_pid = 0; /* unset target PID */
     /* Hooks : 
      * return values : 0 : continue read, 1 : go to next position and stop read,
      * 2 : stay at the current position and stop read */
index 37c4ba17884b6b615b1df3a4a0369b950a8d59d2..db4e5303d2a95f2048691717c26758145372ae86 100644 (file)
@@ -175,6 +175,8 @@ struct _LttvTracefileContext {
   LttvHooksById *event_by_id;
   LttTime timestamp;
   LttvAttribute *a;
+  guint target_pid;          /* Target PID of the event.
+                               Updated by state.c. 0 means unset. */
 };
 
 struct _LttvTracefileContextClass {
index 8420650957aabaa3cbbcc43550cbff070a71aa14..3b0489007de8cbd2a78c6e005d3d88df744e3cea 100644 (file)
@@ -189,6 +189,7 @@ gui_filter(LttvPlugin *plugin)
   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"));
+  g_ptr_array_add(fvd->f_field_options,(gpointer) g_string_new("event.target_pid"));
   /*
    * TODO: Add core.xml fields here !
    */
index 124daaf14782f5a780bdfebf2465ce77da658e37..a0823fbaa6a68fd3b97a77d1320e7ffe69e6fde8 100644 (file)
@@ -135,6 +135,7 @@ void filter_list_commands(void *hook_data) {
   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("trace.name (string)\n");
This page took 0.029023 seconds and 4 git commands to generate.