From: compudj Date: Mon, 24 Jul 2006 16:04:15 +0000 (+0000) Subject: update stop get_Events X-Git-Tag: v0.12.20~1475 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=04f2543ebde7de5ec5102e37dbcb4d280c3a87ed;p=lttv.git update stop get_Events git-svn-id: http://ltt.polymtl.ca/svn@2014 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/lttv/batchtest.c b/ltt/branches/poly/lttv/lttv/batchtest.c index b38a1469..ff4d6f19 100644 --- a/ltt/branches/poly/lttv/lttv/batchtest.c +++ b/ltt/branches/poly/lttv/lttv/batchtest.c @@ -661,17 +661,18 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, g_message("Running test 9 : seek_forward and seek_backward"); lttv_process_traceset_seek_time(tsc, ltt_time_zero); - count = lttv_process_traceset_seek_n_forward(tsc, 500, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 500, NULL, NULL, NULL); g_assert(count == 500); lttv_traceset_context_position_save(tsc, saved_pos); t0 = get_time(); - count = lttv_process_traceset_seek_n_forward(tsc, 150000, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 150000, NULL, NULL, NULL); t1 = get_time(); g_message("Seek forward 150000 events in %g seconds", t1 - t0); g_assert(count == 150000); t0 = get_time(); count = lttv_process_traceset_seek_n_backward(tsc, 150000, - seek_back_default_offset, lttv_process_traceset_seek_time, NULL); + seek_back_default_offset, lttv_process_traceset_seek_time, NULL, + NULL, NULL); t1 = get_time(); g_message("Seek backward 150000 events in %g seconds", t1 - t0); g_assert(count == 150000); @@ -679,19 +680,20 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, g_warning("Problem with seek_n ! Positions differ. (1)"); } - lttv_process_traceset_seek_n_forward(tsc, 500, NULL); + lttv_process_traceset_seek_n_forward(tsc, 500, NULL, NULL, NULL); lttv_traceset_context_position_save(tsc, saved_pos); - lttv_process_traceset_seek_n_forward(tsc, 15000, NULL); + lttv_process_traceset_seek_n_forward(tsc, 15000, NULL, NULL, NULL); lttv_process_traceset_seek_n_backward(tsc, 15005, - seek_back_default_offset, lttv_process_traceset_seek_time, NULL); - lttv_process_traceset_seek_n_forward(tsc, 5, NULL); + seek_back_default_offset, lttv_process_traceset_seek_time, NULL, + NULL, NULL); + lttv_process_traceset_seek_n_forward(tsc, 5, NULL, NULL, NULL); if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) { g_warning("Problem with seek_n ! Positions differ. (2)"); } lttv_process_traceset_seek_time(tsc, ltt_time_infinite); - count = lttv_process_traceset_seek_n_forward(tsc, 15000, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 15000, NULL, NULL, NULL); if(count > 0) g_warning("Problem with seek_n ! Forward at end of traceset."); @@ -700,11 +702,12 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, lttv_traceset_context_position_save(tsc, saved_pos); t0 = get_time(); lttv_process_traceset_seek_n_backward(tsc, 300, - seek_back_default_offset, lttv_process_traceset_seek_time, NULL); + seek_back_default_offset, lttv_process_traceset_seek_time, NULL, + NULL, NULL); t1 = get_time(); g_message("Seek backward 300 events in %g seconds", t1 - t0); - count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL); - count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL, NULL, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL, NULL, NULL); if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) { g_warning("Problem with seek_n ! Positions differ. (4)"); @@ -713,11 +716,12 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, lttv_traceset_context_position_save(tsc, saved_pos); t0 = get_time(); lttv_process_traceset_seek_n_backward(tsc, 10, - seek_back_default_offset, lttv_process_traceset_seek_time, NULL); + seek_back_default_offset, lttv_process_traceset_seek_time, NULL, + NULL, NULL); t1 = get_time(); g_message("Seek backward 10 events in %g seconds", t1 - t0); t0 = get_time(); - count = lttv_process_traceset_seek_n_forward(tsc, 10, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 10, NULL, NULL, NULL); t1 = get_time(); g_message("Seek forward 10 events in %g seconds", t1 - t0); @@ -727,9 +731,10 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, lttv_traceset_context_position_save(tsc, saved_pos); lttv_process_traceset_seek_n_backward(tsc, 301, - seek_back_default_offset, lttv_process_traceset_seek_time, NULL); - count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL); - count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL); + seek_back_default_offset, lttv_process_traceset_seek_time, NULL, + NULL, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 299, NULL, NULL, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 1, NULL, NULL, NULL); if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) == 0) { g_warning("Problem with seek_n ! Positions _should_ differ. (5)"); @@ -738,16 +743,17 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, /* Try a seek by closest time : Hint : try this one with and without states * computed. */ lttv_process_traceset_seek_time(tsc, ltt_time_zero); - count = lttv_process_traceset_seek_n_forward(tsc, 200000, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 200000, NULL, NULL, NULL); lttv_traceset_context_position_save(tsc, saved_pos); t0 = get_time(); lttv_process_traceset_seek_n_backward(tsc, 100301, seek_back_default_offset, - (seek_time_fct)lttv_state_traceset_seek_time_closest, NULL); + (seek_time_fct)lttv_state_traceset_seek_time_closest, NULL, + NULL, NULL); t1 = get_time(); g_message("Seek backward 100301 events (with seek closest) in %g seconds", t1 - t0); - count = lttv_process_traceset_seek_n_forward(tsc, 100301, NULL); + count = lttv_process_traceset_seek_n_forward(tsc, 100301, NULL, NULL, NULL); if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos)) { g_warning("Problem with seek_n with state seek time! Positions differ. (6)"); @@ -763,14 +769,15 @@ static gboolean process_traceset(void __UNUSED__ *hook_data, lttv_traceset_context_position_new(tsc); lttv_process_traceset_seek_time(tsc, ltt_time_zero); - lttv_process_traceset_seek_n_forward(tsc, 200000, NULL); + lttv_process_traceset_seek_n_forward(tsc, 200000, NULL, NULL, NULL); lttv_traceset_context_position_save(tsc, saved_pos); if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) != 0) g_critical("Error in seek position. (1)"); lttv_process_traceset_seek_time(tsc, ltt_time_infinite); lttv_process_traceset_seek_n_backward(tsc, 500, - seek_back_default_offset, lttv_process_traceset_seek_time, NULL); + seek_back_default_offset, lttv_process_traceset_seek_time, NULL, + NULL, NULL); lttv_traceset_context_position_save(tsc, saved_pos); if(lttv_traceset_context_ctx_pos_compare(tsc, saved_pos) != 0) diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.c b/ltt/branches/poly/lttv/lttv/tracecontext.c index ed7272a7..5d24e11b 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.c +++ b/ltt/branches/poly/lttv/lttv/tracecontext.c @@ -1338,6 +1338,9 @@ struct seek_back_data { guint n; /* number of events requested */ GPtrArray *array; /* array of LttvTracesetContextPositions pointers */ LttvFilter *filter; + check_handler *check; + gboolean *stop_flag; + guint raw_event_count; }; static gint seek_back_event_hook(void *hook_data, void* call_data) @@ -1347,6 +1350,9 @@ static gint seek_back_event_hook(void *hook_data, void* call_data) LttvTracesetContext *tsc = tfc->t_context->ts_context; LttvTracesetContextPosition *pos; + if(sd->check && sd->check(sd->raw_event_count, sd->stop_flag)) return TRUE; + sd->raw_event_count++; + if(sd->filter != NULL && sd->filter->head != NULL) { if(!lttv_filter_tree_parse(sd->filter->head, ltt_tracefile_get_event(tfc->tf), @@ -1398,7 +1404,9 @@ static gint seek_back_event_hook(void *hook_data, void* call_data) guint lttv_process_traceset_seek_n_backward(LttvTracesetContext *self, guint n, LttTime first_offset, seek_time_fct time_seeker, - LttvFilter *filter) + LttvFilter *filter, + check_handler *check, + gboolean *stop_flag) { if(lttv_traceset_number(self->ts) == 0) return 0; g_assert(ltt_time_compare(first_offset, ltt_time_zero) != 0); @@ -1421,6 +1429,9 @@ guint lttv_process_traceset_seek_n_backward(LttvTracesetContext *self, sd.array = g_ptr_array_sized_new(n); sd.filter = filter; sd.n = n; + sd.check = check; + sd.stop_flag = stop_flag; + sd.raw_event_count = 0; g_ptr_array_set_size(sd.array, n); for(i=0;icheck && sd->check(sd->raw_event_count, sd->stop_flag)) return TRUE; + sd->raw_event_count++; + if(sd->filter == NULL || lttv_filter_tree_parse(sd->filter->head, ltt_tracefile_get_event(tfc->tf), tfc->tf, @@ -1557,12 +1574,17 @@ static gint seek_forward_event_hook(void *hook_data, void* call_data) * returns : the number of events jumped over (may be less than requested if end * of traceset reached) */ guint lttv_process_traceset_seek_n_forward(LttvTracesetContext *self, - guint n, LttvFilter *filter) + guint n, LttvFilter *filter, + check_handler *check, + gboolean *stop_flag) { struct seek_forward_data sd; sd.event_count = 0; sd.n = n; sd.filter = filter; + sd.check = check; + sd.stop_flag = stop_flag; + sd.raw_event_count = 0; if(sd.event_count >= sd.n) return sd.event_count; diff --git a/ltt/branches/poly/lttv/lttv/tracecontext.h b/ltt/branches/poly/lttv/lttv/tracecontext.h index fcfef98b..61879a7f 100644 --- a/ltt/branches/poly/lttv/lttv/tracecontext.h +++ b/ltt/branches/poly/lttv/lttv/tracecontext.h @@ -352,9 +352,13 @@ void lttv_process_traceset_get_sync_data(LttvTracesetContext *tsc); static const LttTime seek_back_default_offset = { 1, 0 }; +typedef gboolean check_handler(guint count, gboolean *stop_flag); + guint lttv_process_traceset_seek_n_forward(LttvTracesetContext *self, guint n, - LttvFilter *filter); + LttvFilter *filter, + check_handler *check, + gboolean *stop_flag); typedef void (*seek_time_fct)(LttvTracesetContext *self, LttTime start); /* If first_offset is ltt_time_zero, it will choose a default value */ @@ -362,7 +366,9 @@ guint lttv_process_traceset_seek_n_backward(LttvTracesetContext *self, guint n, LttTime first_offset, seek_time_fct, - LttvFilter *filter); + LttvFilter *filter, + check_handler *check, + gboolean *stop_flag); #endif // PROCESSTRACE_H diff --git a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c index 351f4cd5..217e1abb 100644 --- a/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c +++ b/ltt/branches/poly/lttv/modules/gui/detailedevents/events.c @@ -77,6 +77,7 @@ #define abs(a) (((a)<0)?(-a):(a)) #define max(a,b) ((a)>(b)?(a):(b)) +#define min(a,b) ((a)<(b)?(a):(b)) /** Array containing instanced objects. Used when module is unloaded */ static GSList *g_event_viewer_data_list = NULL ; @@ -146,6 +147,8 @@ typedef struct _EventViewerData { guint num_events; /* Number of events processed */ + gboolean in_get_events; + } EventViewerData ; /** hook functions for update time interval, current time ... */ @@ -521,6 +524,8 @@ gui_events(LttvPluginTab *ptab) event_viewer_data, (GDestroyNotify)gui_events_free); + event_viewer_data->in_get_events = FALSE; + event_viewer_data->background_info_waiting = 0; request_background_data(event_viewer_data); @@ -1271,11 +1276,16 @@ gboolean show_event_detail(void * hook_data, void * call_data) } #endif //0 - - - - - +static gboolean events_check_handler(guint count, gboolean *stop_flag) +{ + if(count % CHECK_GDK_INTERVAL == 0) { + gtk_main_iteration_do(FALSE); + if(*stop_flag) + return TRUE; + else + return FALSE; + } +} static void get_events(double new_value, EventViewerData *event_viewer_data) { @@ -1286,9 +1296,12 @@ static void get_events(double new_value, EventViewerData *event_viewer_data) guint i; gboolean seek_by_time; + if(event_viewer_data->in_get_events) return; + double value = new_value - event_viewer_data->previous_value; /* Set stop button status for foreground processing */ + event_viewer_data->in_get_events = TRUE; event_viewer_data->tab->stop_foreground = FALSE; lttvwindow_events_request_disable(); @@ -1390,8 +1403,9 @@ static void get_events(double new_value, EventViewerData *event_viewer_data) */ if(relative_position > 0) { guint count; - count = lttv_process_traceset_seek_n_forward(tsc, relative_position, - event_viewer_data->main_win_filter); + count += lttv_process_traceset_seek_n_forward(tsc, relative_position, + event_viewer_data->main_win_filter, events_check_handler, + &event_viewer_data->tab->stop_foreground); } else if(relative_position < 0) { guint count; @@ -1403,10 +1417,14 @@ static void get_events(double new_value, EventViewerData *event_viewer_data) LttTime time_diff = ltt_time_sub(last_event_time, first_event_time); if(ltt_time_compare(time_diff, ltt_time_zero) == 0) time_diff = seek_back_default_offset; - count = lttv_process_traceset_seek_n_backward(tsc, abs(relative_position), + + count = lttv_process_traceset_seek_n_backward(tsc, + abs(relative_position), time_diff, (seek_time_fct)lttv_state_traceset_seek_time_closest, - event_viewer_data->main_win_filter); + event_viewer_data->main_win_filter, + events_check_handler, + &event_viewer_data->tab->stop_foreground); } /* else 0 : do nothing : we are already at the beginning position */ lttv_traceset_context_position_destroy(pos); @@ -1488,6 +1506,7 @@ static void get_events(double new_value, EventViewerData *event_viewer_data) gtk_widget_get_parent_window(event_viewer_data->tree_v)); lttvwindow_events_request_enable(); + event_viewer_data->in_get_events = FALSE; return; } @@ -1502,7 +1521,7 @@ int event_hook(void *hook_data, void *call_data) LttEvent *e = ltt_tracefile_get_event(tfc->tf); if(event_viewer_data->num_events % CHECK_GDK_INTERVAL == 0) { - gtk_main_iteration(); + gtk_main_iteration_do(FALSE); if(event_viewer_data->tab->stop_foreground) return TRUE; }