From: pmf Date: Tue, 31 Jul 2007 19:46:14 +0000 (+0000) Subject: add state saving and restoring for cpu resource X-Git-Tag: v0.12.20~923 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fbfbd4dbe2e32419701b36cc4a1b266cc999c1f6;p=lttv.git add state saving and restoring for cpu resource no effect? git-svn-id: http://ltt.polymtl.ca/svn@2566 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 823bbe78..ff5e27b5 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -150,7 +150,8 @@ static GQuark LTTV_STATE_TIME, LTTV_STATE_HOOKS, LTTV_STATE_NAME_TABLES, - LTTV_STATE_TRACE_STATE_USE_COUNT; + LTTV_STATE_TRACE_STATE_USE_COUNT, + LTTV_STATE_RESOURCE_CPUS; static void create_max_time(LttvTraceState *tcs); @@ -1087,6 +1088,35 @@ static GHashTable *lttv_state_copy_process_table(GHashTable *processes) return new_processes; } +static LttvCPUState *lttv_state_copy_cpu_states(LttvCPUState *states, guint n) +{ + guint i,j; + LttvCPUState *retval; + + retval = g_malloc(n*sizeof(LttvCPUState)); + + for(i=0; ilen); + for(j=0; jlen; j++) { + g_array_index(retval[i].mode_stack, GQuark, j) = g_array_index(states[i].mode_stack, GQuark, j); + } + } + + return retval; +} + +static void lttv_state_free_cpu_states(LttvCPUState *states, guint n) +{ + guint i; + + for(i=0; iparent.timestamp.tv_sec, tfcs->parent.timestamp.tv_nsec); } } + + value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_CPUS, + LTTV_POINTER); + guint size = sizeof(LttvCPUState)*nb_cpus; + *(value.v_pointer) = lttv_state_copy_cpu_states(self->cpu_states, nb_cpus); } @@ -1214,11 +1249,18 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container) g_assert(self->running_process[i] != NULL); } - + printf("state restore\n"); + nb_tracefile = self->parent.tracefiles->len; //g_tree_destroy(tsc->pqueue); //tsc->pqueue = g_tree_new(compare_tracefile); + + /* restore cpu resource states */ + type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_CPUS, &value); + g_assert(type == LTTV_POINTER); + lttv_state_free_cpu_states(self->cpu_states, nb_cpus); + self->cpu_states = lttv_state_copy_cpu_states(*(value.v_pointer), nb_cpus); for(i = 0 ; i < nb_tracefile ; i++) { tfcs = @@ -1240,6 +1282,8 @@ 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); + + tfcs->cpu_state = &self->cpu_states[tfcs->cpu]; LttvTracefileContext *tfc = LTTV_TRACEFILE_CONTEXT(tfcs); g_tree_remove(tsc->pqueue, tfc); @@ -3563,6 +3607,7 @@ static void module_init() LTTV_STATE_NAME_TABLES = g_quark_from_string("name tables"); LTTV_STATE_TRACE_STATE_USE_COUNT = g_quark_from_string("trace_state_use_count"); + LTTV_STATE_RESOURCE_CPUS = g_quark_from_string("cpu resource states"); LTT_FACILITY_KERNEL = g_quark_from_string("kernel");