update compat
[lttv.git] / ltt / branches / poly / lttv / lttv / state.c
index bcf6acd8019cbc8a80e11a5235a7d56c688b4cb5..952f6cde9bf866dfc8b349e17d533744b9183e65 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;
 
@@ -1154,7 +1155,7 @@ static void lttv_state_free_cpu_states(LttvCPUState *states, guint n)
   guint i;
 
   for(i=0; i<n; i++) {
-    g_array_free(states[i].mode_stack, FALSE);
+    g_array_free(states[i].mode_stack, TRUE);
   }
 
   g_free(states);
@@ -1183,7 +1184,7 @@ static void lttv_state_free_irq_states(LttvIRQState *states, guint n)
   guint i;
 
   for(i=0; i<n; i++) {
-    g_array_free(states[i].mode_stack, FALSE);
+    g_array_free(states[i].mode_stack, TRUE);
   }
 
   g_free(states);
@@ -1220,7 +1221,7 @@ static LttvBdevState *bdevstate_new(void)
 
 static void bdevstate_free(LttvBdevState *bds)
 {
-  g_array_free(bds->mode_stack, FALSE);
+  g_array_free(bds->mode_stack, TRUE);
   g_free(bds);
 }
 
@@ -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);
@@ -1479,7 +1484,7 @@ static void state_restore(LttvTraceState *self, LttvAttribute *container)
 
 static void state_saved_free(LttvTraceState *self, LttvAttribute *container)
 {
-  guint i, nb_tracefile, nb_cpus;
+  guint i, nb_tracefile, nb_cpus, nb_irqs;
 
   LttvTracefileState *tfcs;
 
@@ -1508,13 +1513,31 @@ 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);
   running_process = *(value.v_pointer);
   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(*(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(*(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(*(value.v_pointer));
+
   nb_tracefile = self->parent.tracefiles->len;
 
   for(i = 0 ; i < nb_tracefile ; i++) {
@@ -1656,6 +1679,7 @@ create_name_tables(LttvTraceState *tcs)
 //      }
 //    }
 
+    name_tables->nb_syscalls = 256;
     name_tables->syscall_names = g_new(GQuark, 256);
     for(i = 0 ; i < 256 ; i++) {
       g_string_printf(fe_name, "syscall %d", i);
@@ -2115,7 +2139,7 @@ lttv_state_find_process_or_create(LttvTraceState *ts, guint cpu, guint pid,
  * the parent waits for its child terminaison, but may also happen in special
  * cases in the child's exit : when the parent ignores its children SIGCCHLD or
  * has the flag SA_NOCLDWAIT. It can also happen when the child is part
- * of a killed thread ground, but isn't the leader.
+ * of a killed thread group, but isn't the leader.
  */
 static void exit_process(LttvTracefileState *tfs, LttvProcessState *process) 
 {
@@ -2541,9 +2565,18 @@ static gboolean schedchange(void *hook_data, void *call_data)
 
   /* update cpu status */
   if(pid_in == 0)
+    /* going to idle task */
     cpu_set_base_mode(s->cpu_state, LTTV_CPU_IDLE);
-  else
+  else {
+    /* scheduling a real task.
+     * we must be careful here:
+     * if we just schedule()'ed to a process that is
+     * in a trap, we must put the cpu in trap mode
+     */
     cpu_set_base_mode(s->cpu_state, LTTV_CPU_BUSY);
+    if(process->state->t == LTTV_STATE_TRAP)
+      cpu_push_mode(s->cpu_state, LTTV_CPU_TRAP);
+  }
 
   return FALSE;
 }
@@ -2872,6 +2905,8 @@ static gboolean enum_process_state(void *hook_data, void *call_data)
   f = lttv_trace_get_hook_field(th, 3);
   type = ltt_enum_string_get(f, ltt_event_get_unsigned(e, f));
 
+  //FIXME: type is rarely used, enum must match possible types.
+
   /* mode */
   f = lttv_trace_get_hook_field(th, 4);
   mode = ltt_enum_string_get(f,ltt_event_get_unsigned(e, f));
@@ -3791,7 +3826,7 @@ lttv_tracefile_state_get_type(void)
 
 static void module_init()
 {
-  LTTV_STATE_UNNAMED = g_quark_from_string("-unnamed-");
+  LTTV_STATE_UNNAMED = g_quark_from_string("");
   LTTV_STATE_UNBRANDED = g_quark_from_string("");
   LTTV_STATE_MODE_UNKNOWN = g_quark_from_string("MODE_UNKNOWN");
   LTTV_STATE_USER_MODE = g_quark_from_string("USER_MODE");
@@ -3823,6 +3858,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.025924 seconds and 4 git commands to generate.