From: compudj Date: Thu, 29 Jul 2004 04:01:15 +0000 (+0000) Subject: init state timestamp is beginning of trace, not 0 X-Git-Tag: v0.12.20~2844 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d3e01c7a1f640d3b08fd896b29f4ad72e65033a9;p=lttv.git init state timestamp is beginning of trace, not 0 git-svn-id: http://ltt.polymtl.ca/svn@645 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/lttv/batchtest.c b/ltt/branches/poly/lttv/lttv/batchtest.c index f72733cb..08922fd7 100644 --- a/ltt/branches/poly/lttv/lttv/batchtest.c +++ b/ltt/branches/poly/lttv/lttv/batchtest.c @@ -253,7 +253,7 @@ static gboolean process_traceset(void *hook_data, void *call_data) LttTracefile *tracefile, *tf; - LttEvent *event; + LttEvent *event = ltt_event_new(); LttFacility *facility; @@ -300,7 +300,7 @@ static gboolean process_traceset(void *hook_data, void *call_data) ltt_tracefile_seek_time(tracefile, zero_time); previous_time = zero_time; nb_equal = 0; - while((event = ltt_tracefile_read(tracefile)) != NULL) { + while((ltt_tracefile_read(tracefile, event)) != NULL) { facility = ltt_event_facility(event); event_type = ltt_event_eventtype(event); time = ltt_event_time(event); @@ -539,6 +539,7 @@ static gboolean process_traceset(void *hook_data, void *call_data) g_free(a_event_position); lttv_context_fini(tc); g_object_unref(tscs); + ltt_event_destroy(event); if(lttv_profile_memory) { g_message("Memory summary at the end of batchtest"); diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index f7d34be1..f13bd8db 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -121,8 +121,6 @@ restore_init_state(LttvTraceState *self) LttvTracefileState *tfcs; - LttTime null_time = {0,0}; - if(self->processes != NULL) lttv_state_free_process_table(self->processes); self->processes = g_hash_table_new(process_hash, process_equal); self->nb_event = 0; @@ -132,7 +130,7 @@ restore_init_state(LttvTraceState *self) for(i = 0 ; i < nb_tracefile ; i++) { tfcs = LTTV_TRACEFILE_STATE(self->parent.tracefiles[i]); - tfcs->parent.timestamp = null_time; + ltt_trace_time_span_get(self->parent.t, &tfcs->parent.timestamp, NULL); tfcs->saved_position = 0; tfcs->process = lttv_state_create_process(tfcs, NULL,0); tfcs->process->state->s = LTTV_STATE_RUN; @@ -808,6 +806,7 @@ lttv_state_create_process(LttvTracefileState *tfs, LttvProcessState *parent, es->t = LTTV_STATE_USER_MODE; es->n = LTTV_STATE_SUBMODE_NONE; es->entry = tfs->parent.timestamp; + g_assert(tfs->parent.timestamp.tv_sec != 0); es->change = tfs->parent.timestamp; es->s = LTTV_STATE_WAIT_FORK; @@ -1254,6 +1253,8 @@ void lttv_state_save_add_event_hooks(LttvTracesetState *self) LttvTraceHook hook_start, hook_end; + lttv_state_add_event_hooks(self); + nb_trace = lttv_traceset_number(traceset); for(i = 0 ; i < nb_trace ; i++) { ts = (LttvTraceState *)self->parent.traces[i]; @@ -1317,6 +1318,8 @@ void lttv_state_save_remove_event_hooks(LttvTracesetState *self) tfs->parent.event_by_id, hook_end.id), hook_end.h, NULL); } } + + lttv_state_remove_event_hooks(self); } gint lttv_state_save_hook_remove_event_hooks(void *hook_data, void *call_data) diff --git a/ltt/branches/poly/lttv/lttv/state.h b/ltt/branches/poly/lttv/lttv/state.h index 54277f4f..988ee647 100644 --- a/ltt/branches/poly/lttv/lttv/state.h +++ b/ltt/branches/poly/lttv/lttv/state.h @@ -28,7 +28,7 @@ sufficient for the analysis, and possibly organized quite differently. The state information is added to LttvTracesetContext, LttvTraceContext - and LttvTracefileContext objects, used by processTrace, through + and LttvTracefileContext objects, used by process_traceset, through subtyping. The context objects already reflect the multiple tracefiles (one per cpu) per trace and multiple traces per trace set. The state objects defined here simply add fields to the relevant context objects. @@ -150,7 +150,6 @@ typedef struct _LttvProcessState { /* opened file descriptors, address map?... */ } LttvProcessState; - LttvProcessState * lttv_state_find_process(LttvTracefileState *tfs, guint pid); diff --git a/ltt/branches/poly/lttv/lttv/stats.c b/ltt/branches/poly/lttv/lttv/stats.c index fa697d0c..5bb91af6 100644 --- a/ltt/branches/poly/lttv/lttv/stats.c +++ b/ltt/branches/poly/lttv/lttv/stats.c @@ -80,9 +80,12 @@ init(LttvTracesetStats *self, LttvTraceset *ts) LTTV_TRACESET_CONTEXT_CLASS(g_type_class_peek(LTTV_TRACESET_STATE_TYPE))-> init((LttvTracesetContext *)self, ts); - self->stats =lttv_attribute_find_subdir(self->parent.parent.ts_a,LTTV_STATS); - lttv_attribute_find(self->parent.parent.ts_a, LTTV_STATS_USE_COUNT, - LTTV_UINT, &v); + self->stats = lttv_attribute_find_subdir( + lttv_traceset_attribute(self->parent.parent.ts), + LTTV_STATS); + lttv_attribute_find(lttv_traceset_attribute(self->parent.parent.ts), + LTTV_STATS_USE_COUNT, + LTTV_UINT, &v); *(v.v_uint)++; if(*(v.v_uint) == 1) { @@ -121,7 +124,6 @@ init(LttvTracesetStats *self, LttvTraceset *ts) } } - static void fini(LttvTracesetStats *self) { @@ -575,7 +577,7 @@ gboolean every_event(void *hook_data, void *call_data) void lttv_stats_sum_trace(LttvTraceStats *self) { - LttvTraceStats *tcs; + LttvAttribute *sum_container = self->stats; LttvAttributeType type; @@ -594,16 +596,18 @@ lttv_stats_sum_trace(LttvTraceStats *self) *cpu_events_tree, *process_modes_tree, *trace_cpu_tree, *trace_modes_tree; - main_tree = self->stats; + main_tree = sum_container; - lttv_attribute_find(self->parent.parent.t_a, LTTV_STATS_SUMMED, - LTTV_UINT, &value); + lttv_attribute_find(sum_container, + LTTV_STATS_SUMMED, + LTTV_UINT, &value); if(*(value.v_uint) != 0) return; *(value.v_uint) = 1; processes_tree = lttv_attribute_find_subdir(main_tree, - LTTV_STATS_PROCESSES); - trace_modes_tree = lttv_attribute_find_subdir(main_tree, LTTV_STATS_MODES); + LTTV_STATS_PROCESSES); + trace_modes_tree = lttv_attribute_find_subdir(main_tree, + LTTV_STATS_MODES); nb_process = lttv_attribute_get_number(processes_tree); for(i = 0 ; i < nb_process ; i++) { @@ -665,10 +669,17 @@ lttv_stats_sum_trace(LttvTraceStats *self) } +gboolean lttv_stats_sum_traceset_hook(void *hook_data, void *call_data) +{ + lttv_stats_sum_traceset((LttvTracesetStats *)call_data); + return 0; +} + void lttv_stats_sum_traceset(LttvTracesetStats *self) { LttvTraceset *traceset = self->parent.parent.ts; + LttvAttribute *sum_container = self->stats; LttvTraceStats *tcs; @@ -678,12 +689,12 @@ lttv_stats_sum_traceset(LttvTracesetStats *self) LttvAttributeValue value; - lttv_attribute_find(self->parent.parent.ts_a, LTTV_STATS_SUMMED, + lttv_attribute_find(sum_container, LTTV_STATS_SUMMED, LTTV_UINT, &value); if(*(value.v_uint) != 0) return; *(value.v_uint) = 1; - traceset_modes_tree = lttv_attribute_find_subdir(self->stats, + traceset_modes_tree = lttv_attribute_find_subdir(sum_container, LTTV_STATS_MODES); nb_trace = lttv_traceset_number(traceset); @@ -697,6 +708,16 @@ lttv_stats_sum_traceset(LttvTracesetStats *self) } +// Hook wrapper. call_data is a traceset context. +gint lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data) +{ + LttvTracesetStats *tss = (LttvTracesetStats*)call_data; + + lttv_stats_add_event_hooks(tss); + + return 0; +} + lttv_stats_add_event_hooks(LttvTracesetStats *self) { LttvTraceset *traceset = self->parent.parent.ts; @@ -719,6 +740,8 @@ lttv_stats_add_event_hooks(LttvTracesetStats *self) LttvAttributeValue val; + lttv_state_add_event_hooks(&self->parent); + nb_trace = lttv_traceset_number(traceset); for(i = 0 ; i < nb_trace ; i++) { ts = (LttvTraceStats *)self->parent.parent.traces[i]; @@ -822,6 +845,15 @@ lttv_stats_add_event_hooks(LttvTracesetStats *self) } } +// Hook wrapper. call_data is a traceset context. +gint lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data) +{ + LttvTracesetStats *tss = (LttvTracesetStats*)call_data; + + lttv_stats_remove_event_hooks(tss); + + return 0; +} lttv_stats_remove_event_hooks(LttvTracesetStats *self) { @@ -878,6 +910,7 @@ lttv_stats_remove_event_hooks(LttvTracesetStats *self) g_array_free(before_hooks, TRUE); g_array_free(after_hooks, TRUE); } + lttv_state_remove_event_hooks(&self->parent); } diff --git a/ltt/branches/poly/lttv/lttv/stats.h b/ltt/branches/poly/lttv/lttv/stats.h index af708f42..ef6f05cd 100644 --- a/ltt/branches/poly/lttv/lttv/stats.h +++ b/ltt/branches/poly/lttv/lttv/stats.h @@ -150,10 +150,17 @@ typedef struct _LttvTraceStatsClass LttvTraceStatsClass; typedef struct _LttvTracefileStats LttvTracefileStats; typedef struct _LttvTracefileStatsClass LttvTracefileStatsClass; + + +// Hook wrapper. call_data is a trace context. +gint lttv_stats_hook_add_event_hooks(void *hook_data, void *call_data); gboolean lttv_stats_add_event_hooks(LttvTracesetStats *self); +// Hook wrapper. call_data is a trace context. +gint lttv_stats_hook_remove_event_hooks(void *hook_data, void *call_data); gboolean lttv_stats_remove_event_hooks(LttvTracesetStats *self); +gboolean lttv_stats_sum_traceset_hook(void *hook_data, void *call_data); void lttv_stats_sum_traceset(LttvTracesetStats *self); void lttv_stats_sum_trace(LttvTraceStats *self); diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index bdd3bdc7..89d792c5 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -184,6 +184,7 @@ init(LttvTracesetContext *self, LttvTraceset *ts) tfc->tf = ltt_trace_per_cpu_tracefile_get(tc->t, j - nb_control); } tfc->t_context = tc; + tfc->e = ltt_event_new(); tfc->event = lttv_hooks_new(); tfc->event_by_id = lttv_hooks_by_id_new(); tfc->a = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL); @@ -223,6 +224,7 @@ void fini(LttvTracesetContext *self) for(j = 0 ; j < nb_tracefile ; j++) { tfc = tc->tracefiles[j]; + ltt_event_destroy(tfc->e); lttv_hooks_destroy(tfc->event); lttv_hooks_by_id_destroy(tfc->event_by_id); g_object_unref(tfc->a); @@ -646,8 +648,6 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, LttvTracefileContext *tfc; - LttEvent *event; - unsigned count = 0; gboolean last_ret = FALSE; /* return value of the last hook list called */ @@ -694,10 +694,8 @@ guint lttv_process_traceset_middle(LttvTracesetContext *self, last_ret = lttv_hooks_call_merge(tfc->event, tfc, lttv_hooks_by_id_get(tfc->event_by_id, id), tfc); - event = ltt_tracefile_read(tfc->tf); - if(event != NULL) { - tfc->e = event; - tfc->timestamp = ltt_event_time(event); + if(ltt_tracefile_read(tfc->tf, tfc->e) != NULL) { + tfc->timestamp = ltt_event_time(tfc->e); g_tree_insert(pqueue, tfc, tfc); } } @@ -727,8 +725,6 @@ void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start) LttvTracefileContext *tfc; - LttEvent *event; - GTree *pqueue = self->ts_context->pqueue; nb_tracefile = ltt_trace_control_tracefile_number(self->t) + @@ -738,10 +734,8 @@ void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start) tfc = self->tracefiles[i]; ltt_tracefile_seek_time(tfc->tf, start); g_tree_remove(pqueue, tfc); - event = ltt_tracefile_read(tfc->tf); - tfc->e = event; - if(event != NULL) { - tfc->timestamp = ltt_event_time(event); + if(ltt_tracefile_read(tfc->tf, tfc->e) != NULL) { + tfc->timestamp = ltt_event_time(tfc->e); g_tree_insert(pqueue, tfc, tfc); } } @@ -775,10 +769,8 @@ gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self, ltt_tracefile_seek_position(tfc->tf, pos); g_tree_remove(pqueue, tfc); - event = ltt_tracefile_read(tfc->tf); - tfc->e = event; - if(event != NULL) { - tfc->timestamp = ltt_event_time(event); + if(ltt_tracefile_read(tfc->tf, tfc->e) != NULL) { + tfc->timestamp = ltt_event_time(tfc->e); g_tree_insert(pqueue, tfc, tfc); }