From: compudj Date: Fri, 23 Jun 2006 21:51:42 +0000 (+0000) Subject: add target pid for filtering X-Git-Tag: v0.12.20~1525 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=33bdc8dd862c92f8b44f685304e6bf413932c244;p=lttv.git add target pid for filtering git-svn-id: http://ltt.polymtl.ca/svn@1964 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/lttv/filter.c b/ltt/branches/poly/lttv/lttv/filter.c index efe6bd64..50e9fcea 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" @@ -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 diff --git a/ltt/branches/poly/lttv/lttv/filter.h b/ltt/branches/poly/lttv/lttv/filter.h index 06727798..b809f5a0 100644 --- a/ltt/branches/poly/lttv/lttv/filter.h +++ b/ltt/branches/poly/lttv/lttv/filter.h @@ -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 */ }; diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index af0e8972..b7c7556f 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -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); diff --git a/ltt/branches/poly/lttv/lttv/state.h b/ltt/branches/poly/lttv/lttv/state.h index f1e3f6d1..c97c6c15 100644 --- a/ltt/branches/poly/lttv/lttv/state.h +++ b/ltt/branches/poly/lttv/lttv/state.h @@ -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 diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index 3d28927d..c800b924 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -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 */ diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.h b/ltt/branches/poly/lttv/lttv/tracecontext.h index 37c4ba17..db4e5303 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.h +++ b/ltt/branches/poly/lttv/lttv/tracecontext.h @@ -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 { diff --git a/ltt/branches/poly/lttv/modules/gui/filter/filter.c b/ltt/branches/poly/lttv/modules/gui/filter/filter.c index 84206509..3b048900 100644 --- a/ltt/branches/poly/lttv/modules/gui/filter/filter.c +++ b/ltt/branches/poly/lttv/modules/gui/filter/filter.c @@ -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 ! */ diff --git a/ltt/branches/poly/lttv/modules/text/textFilter.c b/ltt/branches/poly/lttv/modules/text/textFilter.c index 124daaf1..a0823fba 100644 --- a/ltt/branches/poly/lttv/modules/text/textFilter.c +++ b/ltt/branches/poly/lttv/modules/text/textFilter.c @@ -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");