From 27304273a482c99620e992daf3826eb61208fd4b Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 20 Aug 2005 22:58:48 +0000 Subject: [PATCH] batchtest partially working git-svn-id: http://ltt.polymtl.ca/svn@1032 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/ltt/convert/convert.c | 2 +- ltt/branches/poly/ltt/event.c | 14 +- ltt/branches/poly/ltt/event.h | 2 + ltt/branches/poly/ltt/parser.c | 4 +- ltt/branches/poly/ltt/tracefile.c | 49 ++-- ltt/branches/poly/lttv/lttv/batchtest.c | 21 +- ltt/branches/poly/lttv/lttv/state.c | 16 +- ltt/branches/poly/lttv/lttv/tracecontext.c | 316 +++++++-------------- ltt/branches/poly/lttv/lttv/tracecontext.h | 10 +- 9 files changed, 169 insertions(+), 265 deletions(-) diff --git a/ltt/branches/poly/ltt/convert/convert.c b/ltt/branches/poly/ltt/convert/convert.c index b9812cc5..5f2de35f 100644 --- a/ltt/branches/poly/ltt/convert/convert.c +++ b/ltt/branches/poly/ltt/convert/convert.c @@ -302,7 +302,7 @@ int main(int argc, char ** argv){ cur_pos += sizeof(uint32_t); //skip time delta tStart = (trace_start_any*)cur_pos; if(tStart->MagicNumber != TRACER_MAGIC_NUMBER) - g_error("Trace magic number does not match : %lx, should be %lx", + g_error("Trace magic number does not match : %x, should be %x", tStart->MagicNumber, TRACER_MAGIC_NUMBER); if(tStart->MajorVersion != TRACER_SUP_VERSION_MAJOR) g_error("Trace Major number does match : %hu, should be %u", diff --git a/ltt/branches/poly/ltt/event.c b/ltt/branches/poly/ltt/event.c index 52344487..8b22b472 100644 --- a/ltt/branches/poly/ltt/event.c +++ b/ltt/branches/poly/ltt/event.c @@ -204,8 +204,12 @@ unsigned ltt_event_eventtype_id(const LttEvent *e) LttFacility *ltt_event_facility(const LttEvent *e) { LttTrace * trace = e->tracefile->trace; - unsigned id = e->event_id; - return ltt_trace_facility_by_id(trace,id); + unsigned id = e->facility_id; + LttFacility *facility = ltt_trace_facility_by_id(trace,id); + + g_assert(facility->exists); + + return facility; } /***************************************************************************** @@ -391,6 +395,12 @@ void ltt_event_position_copy(LttEventPosition *dest, } + +LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep) +{ + return ep->tracefile; +} + /***************************************************************************** *Function name * ltt_event_cpu_i: get the cpu id where the event happens diff --git a/ltt/branches/poly/ltt/event.h b/ltt/branches/poly/ltt/event.h index 1c8d40fb..a7408b4d 100644 --- a/ltt/branches/poly/ltt/event.h +++ b/ltt/branches/poly/ltt/event.h @@ -78,6 +78,8 @@ gint ltt_event_position_compare(const LttEventPosition *ep1, void ltt_event_position_copy(LttEventPosition *dest, const LttEventPosition *src); +LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep); + /* CPU id of the event */ unsigned ltt_event_cpu_id(LttEvent *e); diff --git a/ltt/branches/poly/ltt/parser.c b/ltt/branches/poly/ltt/parser.c index 24ffa521..aa87db95 100644 --- a/ltt/branches/poly/ltt/parser.c +++ b/ltt/branches/poly/ltt/parser.c @@ -1188,12 +1188,12 @@ unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor_t * type) flag = 1; break; case ARRAY: - sprintf(buf,"%d\0",type->size); + sprintf(buf,"%d",type->size); str = appendString("array ",buf); flag = 1; break; case SEQUENCE: - sprintf(buf,"%d\0",type->size); + sprintf(buf,"%d",type->size); str = appendString("sequence ",buf); flag = 1; break; diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index e6117b34..1b7e5ff7 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -1209,12 +1209,12 @@ guint ltt_tracefile_block_number(LttTracefile *tf) * the time passed in parameter. * * If the time parameter is outside the tracefile time span, seek to the first - * or the last event of the tracefile. + * event or if after, return ERANGE. * * If the time parameter is before the first event, we have to seek specially to * there. * - * If the time is after the end of the trace, get the last event. + * If the time is after the end of the trace, return ERANGE. * * Do a binary search to find the right block, then a sequential search in the * block to find the event. @@ -1229,6 +1229,7 @@ guint ltt_tracefile_block_number(LttTracefile *tf) * you will jump over an event if you do. * * Return value : 0 : no error, the tf->event can be used + * ERANGE : time if after the last event of the trace * otherwise : this is an error. * * */ @@ -1250,6 +1251,8 @@ int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time) * go to the first event. */ if(ltt_time_compare(time, tf->buffer.begin.timestamp) <= 0) { ret = ltt_tracefile_read(tf); + if(ret == ERANGE) goto range; + else if (ret) goto fail; goto found; /* There is either no event in the trace or the event points to the first event in the trace */ } @@ -1260,16 +1263,9 @@ int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time) goto fail; } - /* If the time is after the end of the trace, get the last event. */ - if(ltt_time_compare(time, tf->buffer.end.timestamp) >= 0) { - /* While the ltt_tracefile_read doesn't return ERANGE or EPERM, - * continue reading. - */ - while(1) { - ret = ltt_tracefile_read(tf); - if(ret == ERANGE) goto found; /* ERANGE or EPERM */ - else if(ret) goto fail; - } + /* If the time is after the end of the trace, return ERANGE. */ + if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) { + goto range; } /* Binary search the block */ @@ -1293,14 +1289,14 @@ int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time) * (or in the next buffer first event) */ while(1) { ret = ltt_tracefile_read(tf); - if(ret == ERANGE) goto found; /* ERANGE or EPERM */ + if(ret == ERANGE) goto range; /* ERANGE or EPERM */ else if(ret) goto fail; if(ltt_time_compare(time, tf->event.event_time) >= 0) break; } - } if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) { + } else if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) { /* go to lower part */ high = block_num; } else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) { @@ -1309,8 +1305,8 @@ int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time) } else {/* The event is right in the buffer! (or in the next buffer first event) */ while(1) { - ltt_tracefile_read(tf); - if(ret == ERANGE) goto found; /* ERANGE or EPERM */ + ret = ltt_tracefile_read(tf); + if(ret == ERANGE) goto range; /* ERANGE or EPERM */ else if(ret) goto fail; if(ltt_time_compare(time, tf->event.event_time) >= 0) @@ -1322,6 +1318,8 @@ int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time) found: return 0; +range: + return ERANGE; /* Error handling */ fail: @@ -1678,9 +1676,13 @@ void ltt_update_event_size(LttTracefile *tf) g_quark_to_string(tf->name)); goto event_type_error; } + + if(event_type->root_field) + size = get_field_type_size(tf, event_type, + 0, 0, event_type->root_field, tf->event.data); + else + size = 0; - size = get_field_type_size(tf, event_type, - 0, 0, event_type->root_field, tf->event.data); g_debug("Event root field : f.e %hhu.%hhu size %lu", tf->event.facility_id, tf->event.event_id, size); } @@ -1888,10 +1890,14 @@ void preset_field_type_size(LttTracefile *tf, LttEventType *event_type, field->child[0]); field->fixed_size = FIELD_VARIABLE; field->field_size = 0; + *fixed_root = FIELD_VARIABLE; + *fixed_parent = FIELD_VARIABLE; break; case LTT_STRING: field->fixed_size = FIELD_VARIABLE; field->field_size = 0; + *fixed_root = FIELD_VARIABLE; + *fixed_parent = FIELD_VARIABLE; break; case LTT_ARRAY: local_fixed_root = FIELD_VARIABLE; @@ -1901,10 +1907,13 @@ void preset_field_type_size(LttTracefile *tf, LttEventType *event_type, &local_fixed_root, &local_fixed_parent, field->child[0]); field->fixed_size = field->child[0]->fixed_size; - if(field->fixed_size == FIELD_FIXED) + if(field->fixed_size == FIELD_FIXED) { field->field_size = type->element_number * field->child[0]->field_size; - else + } else { field->field_size = 0; + *fixed_root = FIELD_VARIABLE; + *fixed_parent = FIELD_VARIABLE; + } break; case LTT_STRUCT: current_root_offset = field->offset_root; diff --git a/ltt/branches/poly/lttv/lttv/batchtest.c b/ltt/branches/poly/lttv/lttv/batchtest.c index 101cef50..181734db 100644 --- a/ltt/branches/poly/lttv/lttv/batchtest.c +++ b/ltt/branches/poly/lttv/lttv/batchtest.c @@ -249,14 +249,14 @@ gboolean save_state_event(void *hook_data, void *call_data) -static void compute_tracefile(LttTracefile *tracefile) +static void compute_tracefile(LttTracefile *tracefile, void *hook_data) { GString *filename; guint i, j, nb_equal, nb_block, offset; guint64 tsc; FILE *fp; LttTime time, previous_time; - LttEvent *event = ltt_event_new(); + LttEvent *event = ltt_tracefile_get_event(tracefile); LttFacility *facility; LttEventType *event_type; int err; @@ -285,11 +285,14 @@ static void compute_tracefile(LttTracefile *tracefile) time = ltt_event_time(event); ltt_event_position(event, a_event_position); ltt_event_position_get(a_event_position, &tf_pos, &nb_block, &offset, &tsc); - fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", - ltt_facility_name(facility), ltt_eventtype_name(event_type), + //fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", + fprintf(fp, "%s.%s: %llu %lu.%09lu position %u/%u, tracefile %s\n", + g_quark_to_string(ltt_facility_name(facility)), + g_quark_to_string(ltt_eventtype_name(event_type)), tsc, (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec, - nb_block, offset); + nb_block, offset, + g_quark_to_string(ltt_tracefile_name(tracefile))); if(ltt_time_compare(time, previous_time) < 0) { g_warning("Time decreasing trace %d tracefile %d position %u/%u", @@ -331,7 +334,6 @@ static void compute_tracefile(LttTracefile *tracefile) close: fclose(fp); - ltt_event_destroy(event); } static gboolean process_traceset(void __UNUSED__ *hook_data, @@ -368,6 +370,11 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, GData **tracefiles_groups; + struct compute_tracefile_group_args args; + + args.func = compute_tracefile; + args.func_args = NULL; + if(a_dump_tracefiles != NULL) { for(i = 0 ; i < lttv_traceset_number(traceset) ; i++) { trace = lttv_trace(lttv_traceset_get(traceset, i)); @@ -375,7 +382,7 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, g_datalist_foreach(tracefiles_groups, (GDataForeachFunc)compute_tracefile_group, - compute_tracefile); + &args); } } diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index ba822513..274d5f48 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -348,7 +348,7 @@ void lttv_state_write(LttvTraceState *self, LttTime t, FILE *fp) else { ltt_event_position(e, ep); ltt_event_position_get(ep, &tf, &nb_block, &offset, &tsc); - fprintf(fp, " BLOCK=%lu OFFSET=%lu TSC=%llu/>\n", nb_block, offset, + fprintf(fp, " BLOCK=%u OFFSET=%u TSC=%llu/>\n", nb_block, offset, tsc); } } @@ -447,7 +447,7 @@ static void state_save(LttvTraceState *self, LttvAttribute *container) guint64 tsc; LttTracefile *tf; ltt_event_position_get(ep, &tf, &nb_block, &offset, &tsc); - g_debug("Block %lu offset %lu tsc %llu time %lu.%lu", nb_block, offset, + g_debug("Block %u offset %u tsc %llu time %lu.%lu", nb_block, offset, tsc, tfcs->parent.timestamp.tv_sec, tfcs->parent.timestamp.tv_nsec); } @@ -471,6 +471,8 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container) LttEventPosition *ep; + LttvTracesetContext *tsc = self->parent.ts_context; + tracefiles_tree = lttv_attribute_find_subdir(container, LTTV_STATE_TRACEFILES); @@ -502,7 +504,15 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container) g_assert(*(value.v_pointer) != NULL); ep = *(value.v_pointer); g_assert(tfcs->parent.t_context != NULL); - lttv_process_tracefile_seek_position(LTTV_TRACEFILE_CONTEXT(tfcs), ep); + + g_tree_destroy(tsc->pqueue); + tsc->pqueue = g_tree_new(compare_tracefile); + + LttvTracefileContext *tfc = LTTV_TRACEFILE_CONTEXT(tfcs); + + g_assert(ltt_tracefile_seek_position(tfc->tf, ep) == 0); + tfc->timestamp = ltt_event_time(ltt_tracefile_get_event(tfc->tf)); + g_tree_insert(tsc->pqueue, tfc, tfc); } } diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index 3c8742f6..95462d96 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -26,11 +26,12 @@ #include #include #include +#include -static gint compare_tracefile(gconstpointer a, gconstpointer b) +gint compare_tracefile(gconstpointer a, gconstpointer b) { gint comparison = 0; @@ -51,14 +52,10 @@ static gint compare_tracefile(gconstpointer a, gconstpointer b) return comparison; } -struct _LttvTraceContextPosition { - LttEventPosition **tf_pos; /* Position in each tracefile */ - guint nb_tracefile; /* Number of tracefiles (check) */ -}; - struct _LttvTracesetContextPosition { - LttvTraceContextPosition *t_pos; /* Position in each trace */ - guint nb_trace; /* Number of traces (check) */ + GArray *ep; /* Array of LttEventPosition */ + GArray *tfc; /* Array of corresponding + TracefileContext* */ LttTime timestamp; /* Current time at the saved position */ }; @@ -620,44 +617,6 @@ static gboolean get_first(gpointer key, gpointer value, gpointer user_data) { } -/* Put all the tracefiles at the tracefile context position */ -void lttv_process_traceset_synchronize_tracefiles(LttvTracesetContext *self) -{ - guint iter_trace, nb_trace; - - LttvTraceContext *tc; - - nb_trace = lttv_traceset_number(self->ts); - - for(iter_trace = 0 ; iter_trace < nb_trace ; iter_trace++) { - tc = self->traces[iter_trace]; - { - /* each trace */ - guint iter_tf, nb_tracefile; - - LttvTracefileContext *tfc; - - nb_tracefile = tc->tracefiles->len; - - for(iter_tf = 0 ; iter_tf < nb_tracefile ; iter_tf++) { - tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, iter_tf); - { - /* each tracefile */ - //ltt_tracefile_copy(tfc->tf_sync_data, tfc->tf); - LttEventPosition *ep = ltt_event_position_new(); - - ltt_event_position(ltt_tracefile_get_event(tfc->tf), ep); - - ltt_tracefile_seek_position(tfc->tf, ep); - g_free(ep); - } - } - } - } -} - - - void lttv_process_traceset_begin(LttvTracesetContext *self, LttvHooks *before_traceset, LttvHooks *before_trace, @@ -763,6 +722,9 @@ void lttv_process_traceset_end(LttvTracesetContext *self, event_by_id); } +/* Subtile modification : + * if tracefile has no event at or after the time requested, it is not put in + * the queue, as the next read would fail. */ void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start) { guint i, nb_tracefile; @@ -778,10 +740,13 @@ void lttv_process_trace_seek_time(LttvTraceContext *self, LttTime start) for(i = 0 ; i < nb_tracefile ; i++) { tfc = g_array_index(self->tracefiles, LttvTracefileContext*, i); ret = ltt_tracefile_seek_time(tfc->tf, start); - if(ret) g_error("error in lttv_process_trace_seek_time seek"); + if(ret == EPERM) g_error("error in lttv_process_trace_seek_time seek"); g_tree_remove(pqueue, tfc); - tfc->timestamp = ltt_event_time(ltt_tracefile_get_event(tfc->tf)); - g_tree_insert(pqueue, tfc, tfc); + + if(ret == 0) { /* not ERANGE especially */ + tfc->timestamp = ltt_event_time(ltt_tracefile_get_event(tfc->tf)); + g_tree_insert(pqueue, tfc, tfc); + } } } @@ -800,62 +765,25 @@ void lttv_process_traceset_seek_time(LttvTracesetContext *self, LttTime start) } -gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self, - const LttEventPosition *pos) -{ - LttvTracefileContext *tfc = self; - - GTree *pqueue = self->t_context->ts_context->pqueue; - - ltt_tracefile_seek_position(tfc->tf, pos); - g_tree_remove(pqueue, tfc); - tfc->timestamp = ltt_event_time(ltt_tracefile_get_event(tfc->tf)); - g_tree_insert(pqueue, tfc, tfc); - - return TRUE; -} - -gboolean lttv_process_trace_seek_position(LttvTraceContext *self, - const LttvTraceContextPosition *pos) -{ - guint i, nb_tracefile; - - LttvTracefileContext *tfc; - - nb_tracefile = self->tracefiles->len; - - if(nb_tracefile != pos->nb_tracefile) - return FALSE; /* Error */ - - for(i = 0 ; i < nb_tracefile ; i++) { - tfc = g_array_index(self->tracefiles, LttvTracefileContext*, i); - lttv_process_tracefile_seek_position(tfc, pos->tf_pos[i]); - } - - return TRUE; -} - - - gboolean lttv_process_traceset_seek_position(LttvTracesetContext *self, const LttvTracesetContextPosition *pos) { - guint i, nb_trace; - gboolean sum_ret = TRUE; - + guint i; LttvTraceContext *tc; + LttvTracefileContext *tfc; - nb_trace = lttv_traceset_number(self->ts); + g_tree_destroy(self->pqueue); + self->pqueue = g_tree_new(compare_tracefile); - if(nb_trace != pos->nb_trace) - return FALSE; /* Error */ - - for(i = 0 ; i < nb_trace ; i++) { - tc = self->traces[i]; - sum_ret = sum_ret && lttv_process_trace_seek_position(tc, &pos->t_pos[i]); + for(i=0;iep->len; i++) { + LttEventPosition *ep = g_array_index(pos->ep, LttEventPosition*, i); + LttvTracefileContext *tfc = + g_array_index(pos->tfc, LttvTracefileContext*, i); + g_assert(ltt_tracefile_seek_position(tfc->tf, ep) == 0); + tfc->timestamp = ltt_event_time(ltt_tracefile_get_event(tfc->tf)); + g_tree_insert(self->pqueue, tfc, tfc); } - - return sum_ret; + return TRUE; } @@ -1006,139 +934,90 @@ void lttv_trace_hook_destroy(LttvTraceHook *th) LttvTracesetContextPosition *lttv_traceset_context_position_new() { - return g_new(LttvTracesetContextPosition,1); + LttvTracesetContextPosition *pos = g_new(LttvTracesetContextPosition,1); + pos->ep = g_array_sized_new(FALSE, TRUE, sizeof(LttEventPosition*), + 10); + pos->tfc = g_array_sized_new(FALSE, TRUE, sizeof(LttvTracefileContext*), + 10); + pos->timestamp = ltt_time_infinite; + return pos; } - -void lttv_traceset_context_position_save(const LttvTracesetContext *self, - LttvTracesetContextPosition *pos) +gboolean traverse_get_tfc(gpointer key, gpointer value, gpointer data) { - guint nb_trace, nb_tracefile; - guint iter_trace, iter_tracefile; - - LttvTraceContext *tc; - - LttvTracefileContext *tfc; + LttvTracefileContext *tfc = (LttvTracefileContext *)value; + LttvTracesetContextPosition *pos = (LttvTracesetContextPosition *)data; - LttEvent *event; + LttEvent *event = ltt_tracefile_get_event(tfc->tf); + LttEventPosition *ep = ltt_event_position_new(); + + ltt_event_position(event, ep); - LttTime timestamp = self->time_span.end_time; + g_array_append_val(pos->ep, ep); + g_array_append_val(pos->tfc, tfc); - pos->nb_trace = nb_trace = lttv_traceset_number(self->ts); - pos->t_pos = g_new(LttvTraceContextPosition, nb_trace); + if(ltt_time_compare(tfc->timestamp, pos->timestamp) < 0) + pos->timestamp = tfc->timestamp; - for(iter_trace = 0 ; iter_trace < nb_trace ; iter_trace++) { - tc = self->traces[iter_trace]; + return 0; +} - nb_tracefile = tc->tracefiles->len; - pos->t_pos[iter_trace].nb_tracefile = nb_tracefile; - - pos->t_pos[iter_trace].tf_pos = g_new(LttEventPosition*, nb_tracefile); - for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) { - tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, - iter_tracefile); - event = ltt_tracefile_get_event(tfc->tf); - if(event!=NULL) { - pos->t_pos[iter_trace].tf_pos[iter_tracefile] - = ltt_event_position_new(); - ltt_event_position(event, - pos->t_pos[iter_trace].tf_pos[iter_tracefile]); - } else { - pos->t_pos[iter_trace].tf_pos[iter_tracefile] = NULL; - } - if(ltt_time_compare(tfc->timestamp, timestamp) < 0) - timestamp = tfc->timestamp; - } - } - pos->timestamp = timestamp; +/* Subtile modification : + * only save the tracefiles that are loaded in the pqueue */ +void lttv_traceset_context_position_save(const LttvTracesetContext *self, + LttvTracesetContextPosition *pos) +{ + g_tree_foreach(self->pqueue, traverse_get_tfc, pos); } void lttv_traceset_context_position_destroy(LttvTracesetContextPosition *pos) { - guint nb_trace; - guint iter_trace, iter_tracefile; - - nb_trace = pos->nb_trace; - - for(iter_trace = 0 ; iter_trace < nb_trace ; iter_trace++) { - for(iter_tracefile = 0; iter_tracefile < - pos->t_pos[iter_trace].nb_tracefile; - iter_tracefile++) { - if(pos->t_pos[iter_trace].tf_pos[iter_tracefile] != NULL) - g_free(pos->t_pos[iter_trace].tf_pos[iter_tracefile]); - } - g_free(pos->t_pos[iter_trace].tf_pos); - } - g_free(pos->t_pos); - + int i; + for(i=0;iep->len;i++) + g_free(g_array_index(pos->ep, LttEventPosition*, i)); + g_array_free(pos->ep, TRUE); + g_array_free(pos->tfc, TRUE); + g_free(pos); } void lttv_traceset_context_position_copy(LttvTracesetContextPosition *dest, const LttvTracesetContextPosition *src) { - guint nb_trace, nb_tracefile; - guint iter_trace, iter_tracefile; + int i; - nb_trace = dest->nb_trace = src->nb_trace; - dest->t_pos = g_new(LttvTraceContextPosition, nb_trace); - - for(iter_trace = 0 ; iter_trace < nb_trace ; iter_trace++) { - - nb_tracefile = src->t_pos[iter_trace].nb_tracefile; - - dest->t_pos[iter_trace].nb_tracefile = nb_tracefile; - - dest->t_pos[iter_trace].tf_pos = g_new(LttEventPosition*, nb_tracefile); - - for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) { - dest->t_pos[iter_trace].tf_pos[iter_tracefile] = - ltt_event_position_new(); - if(src->t_pos[iter_trace].tf_pos[iter_tracefile] != NULL) - ltt_event_position_copy( - dest->t_pos[iter_trace].tf_pos[iter_tracefile], - src->t_pos[iter_trace].tf_pos[iter_tracefile]); - else - dest->t_pos[iter_trace].tf_pos[iter_tracefile] = NULL; - } + g_array_set_size(dest->ep, src->ep->len); + g_array_set_size(dest->tfc, src->tfc->len); + + for(i=0;iep->len;i++) { + g_array_index(dest->ep, LttEventPosition*, i) = ltt_event_position_new(); + ltt_event_position_copy( + g_array_index(dest->ep, LttEventPosition*, i), + g_array_index(src->ep, LttEventPosition*, i)); + } + for(i=0;itfc->len;i++) { + g_array_index(dest->tfc, LttvTracefileContext*, i) = + g_array_index(src->tfc, LttvTracefileContext*, i); } - dest->timestamp = src->timestamp; } gint lttv_traceset_context_ctx_pos_compare(const LttvTracesetContext *self, const LttvTracesetContextPosition *pos) { - guint nb_trace, nb_tracefile; - guint iter_trace, iter_tracefile; - gint ret; - - LttvTraceContext *tc; - - LttvTracefileContext *tfc; + int i; + int ret; - LttEvent *event; + for(i=0;iep->len;i++) { + LttEventPosition *ep = g_array_index(pos->ep, LttEventPosition*, i); + LttvTracefileContext *tfc = + g_array_index(pos->tfc, LttvTracefileContext*, i); - nb_trace = lttv_traceset_number(self->ts); + LttEvent *event = ltt_tracefile_get_event(tfc->tf); - if(unlikely(pos->nb_trace != nb_trace)) - g_error("lttv_traceset_context_ctx_pos_compare : nb_trace does not match."); - - for(iter_trace = 0 ; iter_trace < nb_trace ; iter_trace++) { - tc = self->traces[iter_trace]; - nb_tracefile = tc->tracefiles->len; + ret = ltt_event_position_compare((LttEventPosition*)event, + ep); + if(ret != 0) return ret; - if(unlikely(pos->t_pos[iter_trace].nb_tracefile != nb_tracefile)) - g_error("lttv_traceset_context_ctx_pos_compare : nb_tracefile does not match."); - - for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) { - tfc = g_array_index(tc->tracefiles, LttvTracefileContext*, - iter_tracefile); - event = ltt_tracefile_get_event(tfc->tf); - ret = ltt_event_position_compare((LttEventPosition*)event, - pos->t_pos[iter_trace].tf_pos[iter_tracefile]); - if(ret != 0) - return ret; - } } return 0; } @@ -1148,30 +1027,25 @@ gint lttv_traceset_context_pos_pos_compare( const LttvTracesetContextPosition *pos1, const LttvTracesetContextPosition *pos2) { - guint nb_trace, nb_tracefile; - guint iter_trace, iter_tracefile; + int i, j; + int ret; - gint ret; - - nb_trace = pos1->nb_trace; - if(unlikely(nb_trace != pos2->nb_trace)) - g_error("lttv_traceset_context_pos_pos_compare : nb_trace does not match."); - - for(iter_trace = 0 ; iter_trace < nb_trace ; iter_trace++) { - - nb_tracefile = pos1->t_pos[iter_trace].nb_tracefile; - if(unlikely(nb_tracefile != pos2->t_pos[iter_trace].nb_tracefile)) - g_error("lttv_traceset_context_ctx_pos_compare : nb_tracefile does not match."); + for(i=0;iep->len;i++) { + LttEventPosition *ep1 = g_array_index(pos1->ep, LttEventPosition*, i); + LttTracefile *tf1 = ltt_event_position_tracefile(ep1); + + for(j=0;jep->len;j++) { + LttEventPosition *ep2 = g_array_index(pos2->ep, LttEventPosition*, j); + LttTracefile *tf2 = ltt_event_position_tracefile(ep2); - for(iter_tracefile = 0; iter_tracefile < nb_tracefile; iter_tracefile++) { - ret = ltt_event_position_compare( - pos1->t_pos[iter_trace].tf_pos[iter_tracefile], - pos2->t_pos[iter_trace].tf_pos[iter_tracefile]); - if(ret != 0) - return ret; + if(tf1 == tf2) { + ret = ltt_event_position_compare(ep1, ep2); + if(ret != 0) return ret; + } } } return 0; + } diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.h b/ltt/branches/poly/lttv/lttv/tracecontext.h index 6df7e6fe..f6ea1322 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.h +++ b/ltt/branches/poly/lttv/lttv/tracecontext.h @@ -181,12 +181,6 @@ GType lttv_tracefile_context_get_type (void); void lttv_process_traceset(LttvTracesetContext *self, LttTime end, unsigned nb_events); -/* Save the complete tracefile information in the context */ -//void lttv_process_traceset_get_sync_data(LttvTracesetContext *self); - -/* Put all the tracefiles at the tracefile context position */ -void lttv_process_traceset_synchronize_tracefiles(LttvTracesetContext *self); - /* Process traceset can also be done in smaller pieces calling begin, * then seek and middle repeatedly, and end. The middle function return the * number of events processed. It will be smaller than nb_events if the end time @@ -327,8 +321,6 @@ gint lttv_traceset_context_ctx_pos_compare(const LttvTracesetContext *self, LttTime lttv_traceset_context_position_get_time( const LttvTracesetContextPosition *pos); -gboolean lttv_process_tracefile_seek_position(LttvTracefileContext *self, - const LttEventPosition *pos); - +gint compare_tracefile(gconstpointer a, gconstpointer b); #endif // PROCESSTRACE_H -- 2.34.1