state_saved_free(): fix freeing of resource data structures
authorpmf <pmf@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Oct 2007 18:54:29 +0000 (18:54 +0000)
committerpmf <pmf@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 15 Oct 2007 18:54:29 +0000 (18:54 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2694 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttv/lttv/state.c

index 0398bb9c074189c8e43c4d3fa029df045bc037d4..b15c616847d77276471919f5f1808a1eab055ac7 100644 (file)
@@ -168,6 +168,7 @@ static GQuark
   LTTV_STATE_NAME_TABLES,
   LTTV_STATE_TRACE_STATE_USE_COUNT,
   LTTV_STATE_RESOURCE_CPUS,
+  LTTV_STATE_RESOURCE_CPUS_COUNT,
   LTTV_STATE_RESOURCE_IRQS,
   LTTV_STATE_RESOURCE_BLKDEVS;
 
@@ -1351,6 +1352,10 @@ static void state_save(LttvTraceState *self, LttvAttribute *container)
 
   /* save the cpu state */
   {
+    value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_CPUS_COUNT,
+        LTTV_UINT);
+    *(value.v_uint) = nb_cpus;
+
     value = lttv_attribute_add(container, LTTV_STATE_RESOURCE_CPUS,
         LTTV_POINTER);
     *(value.v_pointer) = lttv_state_copy_cpu_states(self->cpu_states, nb_cpus);
@@ -1508,7 +1513,6 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
   lttv_attribute_remove_by_name(container, LTTV_STATE_PROCESSES);
 
   /* Free running processes array */
-  nb_cpus = ltt_trace_get_num_cpu(self->parent.t);
   type = lttv_attribute_get_by_name(container, LTTV_STATE_RUNNING_PROCESS, 
         &value);
   g_assert(type == LTTV_POINTER);
@@ -1516,20 +1520,23 @@ static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
   g_free(running_process);
 
   /* free cpu resource states */
+  type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_CPUS_COUNT, &value);
+  g_assert(type == LTTV_UINT);
+  nb_cpus = *value.v_uint;
   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);
+  lttv_state_free_cpu_states(*(value.v_pointer), nb_cpus);
 
   /* free irq resource states */
   nb_irqs = self->nb_irqs;
   type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_IRQS, &value);
   g_assert(type == LTTV_POINTER);
-  lttv_state_free_irq_states(self->irq_states, nb_irqs);
+  lttv_state_free_irq_states(*(value.v_pointer), nb_irqs);
 
   /* free the blkdev states */
   type = lttv_attribute_get_by_name(container, LTTV_STATE_RESOURCE_BLKDEVS, &value);
   g_assert(type == LTTV_POINTER);
-  lttv_state_free_blkdev_hashtable(self->bdev_states);
+  lttv_state_free_blkdev_hashtable(*(value.v_pointer));
 
   nb_tracefile = self->parent.tracefiles->len;
 
@@ -3842,6 +3849,7 @@ static void module_init()
   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");
+  LTTV_STATE_RESOURCE_CPUS = g_quark_from_string("cpu count");
   LTTV_STATE_RESOURCE_IRQS = g_quark_from_string("irq resource states");
   LTTV_STATE_RESOURCE_BLKDEVS = g_quark_from_string("blkdevs resource states");
 
This page took 0.025793 seconds and 4 git commands to generate.