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);
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.");
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)");
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);
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)");
/* 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)");
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)
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)
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),
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);
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;i<n;i++) {
g_ptr_array_index (sd.array, i) = lttv_traceset_context_position_new(self);
guint event_count; /* event counter */
guint n; /* requested number of events to jump over */
LttvFilter *filter;
+ check_handler *check;
+ gboolean *stop_flag;
+ guint raw_event_count; /* event counter */
};
static gint seek_forward_event_hook(void *hook_data, void* call_data)
struct seek_forward_data *sd = (struct seek_forward_data*)hook_data;
LttvTracefileContext *tfc = (LttvTracefileContext*)call_data;
+ if(sd->check && 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,
* 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;
#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 ;
guint num_events; /* Number of events processed */
+ gboolean in_get_events;
+
} EventViewerData ;
/** hook functions for update time interval, current time ... */
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);
}
#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)
{
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();
*/
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;
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);
gtk_widget_get_parent_window(event_viewer_data->tree_v));
lttvwindow_events_request_enable();
+ event_viewer_data->in_get_events = FALSE;
return;
}
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;
}