add thread branding
[lttv.git] / ltt / branches / poly / lttv / lttv / state.c
index 1369be5e68576d37a91e266814d2bfcfb80f03a7..9b3c0822586e1c6029b4e3f6a8fb54da583f20e8 100644 (file)
@@ -203,6 +203,8 @@ restore_init_state(LttvTraceState *self)
   guint i, nb_cpus;
 
   LttvTracefileState *tfcs;
+
+  LttTime start_time, end_time;
   
   /* Free the process tables */
   if(self->processes != NULL) lttv_state_free_process_table(self->processes);
@@ -218,6 +220,7 @@ restore_init_state(LttvTraceState *self)
   //g_tree_destroy(self->parent.ts_context->pqueue);
   //self->parent.ts_context->pqueue = g_tree_new(compare_tracefile);
   
+  ltt_trace_time_span_get(self->parent.t, &start_time, &end_time);
   
   //lttv_process_trace_seek_time(&self->parent, ltt_time_zero);
 
@@ -226,7 +229,7 @@ restore_init_state(LttvTraceState *self)
   /* Put the per cpu running_process to beginning state : process 0. */
   for(i=0; i< nb_cpus; i++) {
     self->running_process[i] = lttv_state_create_process(self, NULL, i, 0,
-        LTTV_STATE_UNNAMED, &ltt_time_zero);
+        LTTV_STATE_UNNAMED, &start_time);
     self->running_process[i]->state->s = LTTV_STATE_RUN;
     self->running_process[i]->cpu = i;
   }
@@ -826,8 +829,9 @@ free_max_time(LttvTraceState *tcs)
 typedef struct _LttvNameTables {
  // FIXME  GQuark *eventtype_names;
   GQuark *syscall_names;
-       guint nb_syscalls;
+  guint nb_syscalls;
   GQuark *trap_names;
+  guint nb_traps;
   GQuark *irq_names;
   GQuark *soft_irq_names;
 } LttvNameTables;
@@ -918,7 +922,7 @@ create_name_tables(LttvTraceState *tcs)
                                        ltt_enum_string_get(t, i));
                }
                */
-
+               name_tables->nb_traps = 256;
                name_tables->trap_names = g_new(GQuark, 256);
                for(i = 0 ; i < 256 ; i++) {
                        g_string_printf(fe_name, "trap %d", i);
@@ -926,6 +930,7 @@ create_name_tables(LttvTraceState *tcs)
                }
        } else {
                name_tables->trap_names = NULL;
+               name_tables->nb_traps = 0;
        }
 
   if(!lttv_trace_find_hook(tcs->parent.t,
@@ -988,6 +993,7 @@ get_name_tables(LttvTraceState *tcs)
   tcs->syscall_names = name_tables->syscall_names;
   tcs->nb_syscalls = name_tables->nb_syscalls;
   tcs->trap_names = name_tables->trap_names;
+  tcs->nb_traps = name_tables->nb_traps;
   tcs->irq_names = name_tables->irq_names;
   tcs->soft_irq_names = name_tables->soft_irq_names;
 }
@@ -1359,8 +1365,19 @@ static gboolean trap_entry(void *hook_data, void *call_data)
 
   LttvExecutionSubmode submode;
 
-  submode = ((LttvTraceState *)(s->parent.t_context))->trap_names[
-      ltt_event_get_unsigned(e, f)];
+  guint64 nb_traps = ((LttvTraceState *)(s->parent.t_context))->nb_traps;
+  guint64 trap = ltt_event_get_long_unsigned(e, f);
+
+  if(trap < nb_traps) {
+    submode = ((LttvTraceState *)(s->parent.t_context))->trap_names[trap];
+  } else {
+    /* Fixup an incomplete trap table */
+    GString *string = g_string_new("");
+    g_string_printf(string, "trap %u", trap);
+    submode = g_quark_from_string(string->str);
+    g_string_free(string, TRUE);
+  }
+
   push_state(s, LTTV_STATE_TRAP, submode);
   return FALSE;
 }
@@ -1430,7 +1447,7 @@ static gboolean soft_irq_entry(void *hook_data, void *call_data)
   LttvExecutionSubmode submode;
 
   submode = ((LttvTraceState *)(s->parent.t_context))->soft_irq_names[
-      ltt_event_get_unsigned(e, f)];
+      ltt_event_get_long_unsigned(e, f)];
 
   /* Do something with the info about being in user or system mode when int? */
   push_state(s, LTTV_STATE_SOFT_IRQ, submode);
@@ -1675,13 +1692,14 @@ static gboolean process_exit(void *hook_data, void *call_data)
   guint pid;
   guint cpu = s->cpu;
   LttvTraceState *ts = (LttvTraceState*)s->parent.t_context;
-  LttvProcessState *process = ts->running_process[cpu];
+  LttvProcessState *process; // = ts->running_process[cpu];
 
   pid = ltt_event_get_unsigned(e, thf->f1);
 
   // FIXME : Add this test in the "known state" section
   // g_assert(process->pid == pid);
 
+  process = lttv_state_find_process(ts, ANY_CPU, pid);
   if(likely(process != NULL)) {
     process->state->s = LTTV_STATE_EXIT;
   }
@@ -1726,9 +1744,8 @@ static gboolean process_free(void *hook_data, void *call_data)
         break;
       }
     }
-    //if(i == num_cpus) /* process is not scheduled */
-      //exit_process(s, process);      // do nothing : wait for the schedchange to
-                       //delete the process.
+    if(i == num_cpus) /* process is not scheduled */
+      exit_process(s, process);
   }
 
   return FALSE;
@@ -2640,7 +2657,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("UNNAMED");
   LTTV_STATE_MODE_UNKNOWN = g_quark_from_string("MODE_UNKNOWN");
   LTTV_STATE_USER_MODE = g_quark_from_string("USER_MODE");
   LTTV_STATE_SYSCALL = g_quark_from_string("SYSCALL");
This page took 0.02916 seconds and 4 git commands to generate.