X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttv%2Fmain%2Fstate.c;h=e6b6a78a248bd3f4f2502968ac90a4e3df2b9ac9;hb=284675e3f10ed7885c04f505ce68aa3725bb00e8;hp=dbdb11ce8b7f51b39f972f423fbd626ba526e461;hpb=88a3e3d0ba9a2e56e5d3524bd9da05fe3a81f8e6;p=lttv.git diff --git a/ltt/branches/poly/lttv/main/state.c b/ltt/branches/poly/lttv/main/state.c index dbdb11ce..e6b6a78a 100644 --- a/ltt/branches/poly/lttv/main/state.c +++ b/ltt/branches/poly/lttv/main/state.c @@ -1,3 +1,21 @@ +/* This file is part of the Linux Trace Toolkit viewer + * Copyright (C) 2003-2004 Michel Dagenais + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License Version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + #include #include @@ -112,6 +130,8 @@ init(LttvTracesetState *self, LttvTraceset *ts) tc = self->parent.traces[i]; tcs = (LttvTraceState *)tc; tcs->save_interval = 100000; + tcs->recompute_state_in_seek = false; + tcs->saved_state_ready = false; fill_name_tables(tcs); nb_control = ltt_trace_control_tracefile_number(tc->t); @@ -965,7 +985,7 @@ void lttv_state_save_remove_event_hooks(LttvTracesetState *self) } -void lttv_state_restore_closest_state(LttvTracesetState *self, LttTime t) +void lttv_state_traceset_seek_time_closest(LttvTracesetState *self, LttTime t) { LttvTraceset *traceset = self->parent.ts; @@ -987,31 +1007,49 @@ void lttv_state_restore_closest_state(LttvTracesetState *self, LttTime t) for(i = 0 ; i < nb_trace ; i++) { tcs = (LttvTraceState *)self->parent.traces[i]; - saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a, - LTTV_STATE_SAVED_STATES); - min_pos = -1; - max_pos = lttv_attribute_get_number(saved_states_tree) - 1; - mid_pos = max_pos / 2; - while(min_pos < max_pos) { - type = lttv_attribute_get(saved_states_tree, mid_pos, &name, &value); - g_assert(type == LTTV_GOBJECT); - saved_state_tree = *((LttvAttribute **)(value.v_gobject)); - type = lttv_attribute_get_by_name(saved_state_tree, LTTV_STATE_TIME, - &value); - g_assert(type == LTTV_TIME); - if(ltt_time_compare(*(value.v_time), t) < 0) { - min_pos = mid_pos; - closest_tree = saved_state_tree; + if(tcs->recompute_state_in_seek) { + if(tcs->saved_state_available) { + saved_states_tree = lttv_attribute_find_subdir(tcs->parent.t_a, + LTTV_STATE_SAVED_STATES); + min_pos = -1; + max_pos = lttv_attribute_get_number(saved_states_tree) - 1; + mid_pos = max_pos / 2; + while(min_pos < max_pos) { + type = lttv_attribute_get(saved_states_tree, mid_pos, &name, &value); + g_assert(type == LTTV_GOBJECT); + saved_state_tree = *((LttvAttribute **)(value.v_gobject)); + type = lttv_attribute_get_by_name(saved_state_tree, LTTV_STATE_TIME, + &value); + g_assert(type == LTTV_TIME); + if(ltt_time_compare(*(value.v_time), t) < 0) { + min_pos = mid_pos; + closest_tree = saved_state_tree; + } + else max_pos = mid_pos - 1; + + mid_pos = (min_pos + max_pos + 1) / 2; + } + + /* restore the closest earlier saved state */ + if(min_pos != -1) lttv_state_restore(tcs, closest_tree); + + /* there is no earlier saved state, restart at T0 */ + else { + restore_init_state(tcs); + lttv_process_trace_seek_time(&(tcs->parent), ltt_time_zero); + } + + /* There is no saved state yet we want to have it. Restart at T0 */ + else { + restore_init_state(tcs); + lttv_process_trace_seek_time(&(tcs->parent), ltt_time_zero); } - else max_pos = mid_pos - 1; - mid_pos = (min_pos + max_pos + 1) / 2; - } - if(min_pos == -1) { + /* We want to seek quickly without restoring/updating the state */ + else { restore_init_state(tcs); - lttv_process_trace_seek_time(&(tcs->parent), ltt_time_zero); + lttv_process_trace_seek_time(&(tcs->parent), t); } - else lttv_state_restore(tcs, closest_tree); } }