X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2FprocessTrace.c;h=c4f650c4be5b0b86b5a9dddb4e5ad50c515bd9be;hb=b445142a71748192520cfd645b4963e23070a486;hp=94b5e2d90f37685abb688f70784f7e3ddcb3389b;hpb=d83f67398f1bf3c1f1372570c009071622626e4e;p=lttv.git diff --git a/ltt/branches/poly/lttv/processTrace.c b/ltt/branches/poly/lttv/processTrace.c index 94b5e2d9..c4f650c4 100644 --- a/ltt/branches/poly/lttv/processTrace.c +++ b/ltt/branches/poly/lttv/processTrace.c @@ -1,6 +1,7 @@ #include #include +#include void lttv_context_init(LttvTracesetContext *self, LttvTraceset *ts) { @@ -33,7 +34,7 @@ lttv_context_new_trace_context(LttvTracesetContext *self) LttvTracefileContext * lttv_context_new_tracefile_context(LttvTracesetContext *self) { - LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_tracefile_context(self); + return LTTV_TRACESET_CONTEXT_GET_CLASS(self)->new_tracefile_context(self); } @@ -288,7 +289,8 @@ traceset_context_instance_init (GTypeInstance *instance, gpointer g_class) static void traceset_context_finalize (LttvTracesetContext *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACESET_CONTEXT_GET_CLASS(self)))->finalize(G_OBJECT(self)); + G_OBJECT_CLASS(g_type_class_peek(g_type_parent(LTTV_TRACESET_CONTEXT_TYPE))) + ->finalize(G_OBJECT(self)); } @@ -340,7 +342,8 @@ trace_context_instance_init (GTypeInstance *instance, gpointer g_class) static void trace_context_finalize (LttvTraceContext *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACE_CONTEXT_GET_CLASS(self)))->finalize(G_OBJECT(self)); + G_OBJECT_CLASS(g_type_class_peek(g_type_parent(LTTV_TRACE_CONTEXT_TYPE)))-> + finalize(G_OBJECT(self)); } @@ -365,7 +368,7 @@ lttv_trace_context_get_type(void) (GClassInitFunc) trace_context_class_init, /* class_init */ NULL, /* class_finalize */ NULL, /* class_data */ - sizeof (LttvTracesetContext), + sizeof (LttvTraceContext), 0, /* n_preallocs */ (GInstanceInitFunc) trace_context_instance_init /* instance_init */ }; @@ -387,7 +390,8 @@ tracefile_context_instance_init (GTypeInstance *instance, gpointer g_class) static void tracefile_context_finalize (LttvTracefileContext *self) { - G_OBJECT_CLASS(g_type_class_peek_parent(LTTV_TRACEFILE_CONTEXT_GET_CLASS(self)))->finalize(G_OBJECT(self)); + G_OBJECT_CLASS(g_type_class_peek(g_type_parent(LTTV_TRACEFILE_CONTEXT_TYPE))) + ->finalize(G_OBJECT(self)); } @@ -441,7 +445,7 @@ gboolean get_first(gpointer key, gpointer value, gpointer user_data) { void lttv_process_trace(LttTime start, LttTime end, LttvTraceset *traceset, - LttvTracesetContext *context) + LttvTracesetContext *context, unsigned maxNumEvents) { GPtrArray *traces = g_ptr_array_new(); @@ -460,6 +464,8 @@ void lttv_process_trace(LttTime start, LttTime end, LttvTraceset *traceset, LttvTracefileContext *tfc; LttEvent *event; + unsigned count = 0; + LttTime preTimestamp; /* Call all before_traceset, before_trace, and before_tracefile hooks. For all qualifying tracefiles, seek to the start time, create a context, @@ -521,14 +527,31 @@ void lttv_process_trace(LttTime start, LttTime end, LttvTraceset *traceset, or more tracefiles have events for the same time, hope that lookup and remove are consistent. */ + count++; + if(count > maxNumEvents){ + if(tfc->timestamp.tv_sec == preTimestamp.tv_sec && + tfc->timestamp.tv_nsec == preTimestamp.tv_nsec) { + count--; + }else{ + while(TRUE){ + tfc = NULL; + g_tree_foreach(pqueue, get_first, &tfc); + if(tfc == NULL) break; + g_tree_remove(pqueue, &(tfc->timestamp)); + } + break; + } + } + preTimestamp = tfc->timestamp; + tfc = g_tree_lookup(pqueue, &(tfc->timestamp)); g_tree_remove(pqueue, &(tfc->timestamp)); - if(!lttv_hooks_call(tfc->check_event, context)) { + if(!lttv_hooks_call(tfc->check_event, tfc)) { id = ltt_event_eventtype_id(tfc->e); lttv_hooks_call(tfc->before_event, tfc); lttv_hooks_call(lttv_hooks_by_id_get(tfc->before_event_by_id, id), tfc); - lttv_hooks_call(tfc->after_event, context); + lttv_hooks_call(tfc->after_event, tfc); lttv_hooks_call(lttv_hooks_by_id_get(tfc->after_event_by_id, id), tfc); } @@ -536,7 +559,9 @@ void lttv_process_trace(LttTime start, LttTime end, LttvTraceset *traceset, if(event != NULL) { tfc->e = event; tfc->timestamp = ltt_event_time(event); - g_tree_insert(pqueue, &(tfc->timestamp), tfc); + if(tfc->timestamp.tv_sec < end.tv_sec || + (tfc->timestamp.tv_sec == end.tv_sec && tfc->timestamp.tv_nsec <= end.tv_nsec)) + g_tree_insert(pqueue, &(tfc->timestamp), tfc); } } @@ -565,3 +590,56 @@ void lttv_process_trace(LttTime start, LttTime end, LttvTraceset *traceset, g_ptr_array_free(traces, TRUE); g_tree_destroy(pqueue); } + +static LttField * +find_field(LttEventType *et, const char *field) +{ + LttType *t; + + LttField *f; + + guint i, nb; + + char *name; + + if(field == NULL) return NULL; + + f = ltt_eventtype_field(et); + t = ltt_eventtype_type(et); + g_assert(ltt_type_class(t) == LTT_STRUCT); + nb = ltt_type_member_number(t); + for(i = 0 ; i < nb ; i++) { + ltt_type_member_type(t, i, &name); + if(strcmp(name, field) == 0) break; + } + g_assert(i < nb); + return ltt_field_member(f, i); +} + + +void +lttv_trace_find_hook(LttTrace *t, char *facility, char *event_type, + char *field1, char *field2, char *field3, LttvHook h, LttvTraceHook *th) +{ + LttFacility *f; + + LttEventType *et; + + guint nb, pos, i; + + char *name; + + nb = ltt_trace_facility_find(t, facility, &pos); + if(nb < 1) g_error("No %s facility", facility); + f = ltt_trace_facility_get(t, pos); + et = ltt_facility_eventtype_get_by_name(f, event_type); + if(et == NULL) g_error("Event %s does not exist", event_type); + + th->h = h; + th->id = ltt_eventtype_id(et); + th->f1 = find_field(et, field1); + th->f2 = find_field(et, field2); + th->f3 = find_field(et, field3); +} + +