move kernel_arch to kernel
[lttv.git] / trunk / lttv / lttv / lttv / state.c
index 6fb3b2afd2d6450a9b8019e65e2ea5506f1737b8..ffbca79d610b72a89734126a5e3a3c47d9b5e362 100644 (file)
@@ -49,7 +49,6 @@
 
 GQuark
     LTT_FACILITY_KERNEL,
-    LTT_FACILITY_KERNEL_ARCH,
     LTT_FACILITY_LIST,
     LTT_FACILITY_FS,
     LTT_FACILITY_USER_GENERIC,
@@ -419,8 +418,12 @@ restore_init_state(LttvTraceState *self)
     self->running_process[i]->cpu = i;
 
     /* reset cpu states */
-    if(self->cpu_states[i].mode_stack->len > 0)
+    if(self->cpu_states[i].mode_stack->len > 0) {
       g_array_remove_range(self->cpu_states[i].mode_stack, 0, self->cpu_states[i].mode_stack->len);
+      self->cpu_states[i].last_irq = -1;
+      self->cpu_states[i].last_soft_irq = -1;
+      self->cpu_states[i].last_trap = -1;
+    }
   }
 
   /* reset irq states */
@@ -599,6 +602,9 @@ init(LttvTracesetState *self, LttvTraceset *ts)
     tcs->cpu_states = g_new(LttvCPUState, nb_cpu);
     for(j = 0; j<nb_cpu; j++) {
       tcs->cpu_states[j].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
+      tcs->cpu_states[j].last_irq = -1;
+      tcs->cpu_states[j].last_soft_irq = -1;
+      tcs->cpu_states[j].last_trap = -1;
       g_assert(tcs->cpu_states[j].mode_stack != NULL);
     } 
 
@@ -1277,6 +1283,8 @@ static LttvCPUState *lttv_state_copy_cpu_states(LttvCPUState *states, guint n)
   for(i=0; i<n; i++) {
     retval[i].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
     retval[i].last_irq = states[i].last_irq;
+    retval[i].last_soft_irq = states[i].last_soft_irq;
+    retval[i].last_trap = states[i].last_trap;
     g_array_set_size(retval[i].mode_stack, states[i].mode_stack->len);
     for(j=0; j<states[i].mode_stack->len; j++) {
       g_array_index(retval[i].mode_stack, GQuark, j) = g_array_index(states[i].mode_stack, GQuark, j);
@@ -1867,7 +1875,7 @@ create_name_tables(LttvTraceState *tcs)
   hooks = g_array_sized_new(FALSE, FALSE, sizeof(LttvTraceHook), 1);
 
   if(!lttv_trace_find_hook(tcs->parent.t,
-      LTT_FACILITY_KERNEL_ARCH,
+      LTT_FACILITY_KERNEL,
       LTT_EVENT_SYSCALL_ENTRY,
       FIELD_ARRAY(LTT_FIELD_SYSCALL_ID),
       NULL, NULL, &hooks)) {
@@ -1903,7 +1911,7 @@ create_name_tables(LttvTraceState *tcs)
   lttv_trace_hook_remove_all(&hooks);
 
   if(!lttv_trace_find_hook(tcs->parent.t,
-        LTT_FACILITY_KERNEL_ARCH,
+        LTT_FACILITY_KERNEL,
         LTT_EVENT_TRAP_ENTRY,
         FIELD_ARRAY(LTT_FIELD_TRAP_ID),
         NULL, NULL, &hooks)) {
@@ -2456,7 +2464,7 @@ static gboolean trap_exit(void *hook_data, void *call_data)
 {
   LttvTracefileState *s = (LttvTracefileState *)call_data;
   LttvTraceState *ts = (LttvTraceState *)s->parent.t_context;
-  guint trap = s->cpu_state->last_trap;
+  gint trap = s->cpu_state->last_trap;
 
   pop_state(s, LTTV_STATE_TRAP);
 
@@ -2464,8 +2472,9 @@ static gboolean trap_exit(void *hook_data, void *call_data)
   cpu_pop_mode(s->cpu_state);
 
   /* update trap status */
-  if(ts->trap_states[trap].running)
-    ts->trap_states[trap].running--;
+  if (trap != -1)
+    if(ts->trap_states[trap].running)
+      ts->trap_states[trap].running--;
 
   return FALSE;
 }
@@ -2503,13 +2512,14 @@ static gboolean soft_irq_exit(void *hook_data, void *call_data)
 {
   LttvTracefileState *s = (LttvTracefileState *)call_data;
   LttvTraceState *ts = (LttvTraceState *)s->parent.t_context;
-  guint softirq = s->cpu_state->last_soft_irq;
+  gint softirq = s->cpu_state->last_soft_irq;
 
   pop_state(s, LTTV_STATE_SOFT_IRQ);
 
   /* update softirq status */
-  if(ts->soft_irq_states[softirq].running)
-    ts->soft_irq_states[softirq].running--;
+  if (softirq != -1)
+    if(ts->soft_irq_states[softirq].running)
+      ts->soft_irq_states[softirq].running--;
 
   /* update cpu status */
   cpu_pop_mode(s->cpu_state);
@@ -2528,7 +2538,8 @@ static gboolean irq_exit(void *hook_data, void *call_data)
   cpu_pop_mode(s->cpu_state);
 
   /* update irq status */
-  irq_pop_mode(&ts->irq_states[s->cpu_state->last_irq]);
+  if (s->cpu_state->last_irq != -1)
+    irq_pop_mode(&ts->irq_states[s->cpu_state->last_irq]);
 
   return FALSE;
 }
@@ -3367,25 +3378,25 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
     //hn = 0;
 
     lttv_trace_find_hook(ts->parent.t,
-        LTT_FACILITY_KERNEL_ARCH,
+        LTT_FACILITY_KERNEL,
         LTT_EVENT_SYSCALL_ENTRY,
         FIELD_ARRAY(LTT_FIELD_SYSCALL_ID),
        syscall_entry, NULL, &hooks);
 
     lttv_trace_find_hook(ts->parent.t,
-        LTT_FACILITY_KERNEL_ARCH,
+        LTT_FACILITY_KERNEL,
         LTT_EVENT_SYSCALL_EXIT,
         NULL,
         syscall_exit, NULL, &hooks);
 
     lttv_trace_find_hook(ts->parent.t,
-        LTT_FACILITY_KERNEL_ARCH,
+        LTT_FACILITY_KERNEL,
         LTT_EVENT_TRAP_ENTRY,
         FIELD_ARRAY(LTT_FIELD_TRAP_ID),
         trap_entry, NULL, &hooks);
 
     lttv_trace_find_hook(ts->parent.t,
-        LTT_FACILITY_KERNEL_ARCH,
+        LTT_FACILITY_KERNEL,
         LTT_EVENT_TRAP_EXIT,
         NULL,
         trap_exit, NULL, &hooks);
@@ -3435,7 +3446,7 @@ void lttv_state_add_event_hooks(LttvTracesetState *self)
         process_fork, NULL, &hooks);
 
     lttv_trace_find_hook(ts->parent.t,
-        LTT_FACILITY_KERNEL_ARCH,
+        LTT_FACILITY_KERNEL,
         LTT_EVENT_KTHREAD_CREATE,
         FIELD_ARRAY(LTT_FIELD_PID),
         process_kernel_thread, NULL, &hooks);
@@ -4179,7 +4190,6 @@ static void module_init()
 
   
   LTT_FACILITY_KERNEL     = g_quark_from_string("kernel");
-  LTT_FACILITY_KERNEL_ARCH = g_quark_from_string("kernel_arch");
   LTT_FACILITY_FS    = g_quark_from_string("fs");
   LTT_FACILITY_LIST = g_quark_from_string("list");
   LTT_FACILITY_USER_GENERIC    = g_quark_from_string("user_generic");
This page took 0.0268 seconds and 4 git commands to generate.